CheckIfReasonablyMonotonic
Test whether a gridded density profile is monotonic enough for stretched coordinates.
Developer documentation: this item describes internal implementation details.
Declaration
[flag,dTotalVariation,rho_zCheb,rho_zLobatto,rhoz_zCheb,rhoz_zLobatto] = CheckIfReasonablyMonotonic(zLobatto,rho_zCheb,rho_zLobatto,rhoz_zCheb,rhoz_zLobatto)
Parameters
zLobattoLobatto depth gridrho_zChebChebyshev coefficients of densityrho_zLobattodensity sampled onzLobattorhoz_zChebChebyshev coefficients of \(\partial_z \rho\)rhoz_zLobatto\(\partial_z \rho\) sampled onzLobatto
Returns
flagmonotonicity status flagdTotalVariationfractional change in total variation after coercionrho_zChebpossibly corrected Chebyshev coefficients of densityrho_zLobattopossibly corrected density onzLobattorhoz_zChebpossibly corrected Chebyshev coefficients of \(\partial_z \rho\)rhoz_zLobattopossibly corrected \(\partial_z \rho\) onzLobatto
Discussion
We want to know if the density function is decreasing as z increases. If it's not, are the discrepencies small enough that we can just force them?
flag is 0 if the function is not reasonably monotonic, 1 if it is, and 2 if we were able to to coerce it to be, without too much change