Miscellaneous functions
Functions here are usually general "helper" or "utility" type functions that a likely used throughout different parts of RetrievalToolbox.
RetrievalToolbox.EQV โ Method
EQV(T::Unitful.Temperature) -> Unitful.PressureCalculates equilibrium vapor pressure from temperature T, which can by any Unitful temperature quantity, as it is internally converted to Kelvin. Returns the value in units of Pa.
For details see Murphy & Koop (2005): doi:10.1256/qj.04.94.
RetrievalToolbox.FWHM_to_sigma โ Method
FWHM_to_sigma(FWHM::Real) -> Any
Calculates the standard deviation of a Gaussian for a given full width at half the maximum value.
RetrievalToolbox.H2O_VMR_to_relative_humidity โ Method
H2O_VMR_to_relative_humidity(
H2O_VMR::Real,
p::Unitful.Pressure,
T::Unitful.Temperature
) -> NumberCalculates relative humidity given a HโO volume mixing ratio H2O_VMR, pressure p, and temperature T. Converts the result to Unitful.NoUnits, thus returning a number.
julia> H2O_VMR_to_relative_humidity(0.025, 1013e2u"Pa", 300u"K") โ 0.71604995533615401
trueRetrievalToolbox.H2O_VMR_to_specific_humidity โ Method
H2O_VMR_to_specific_humidity(h2o::Number) -> Any
Calculates specific humidity from H2O VMR
RetrievalToolbox.W_to_ph โ Method
W_to_ph(
L_in::Unitful.Quantity,
ฮฝ::Unitful.Wavenumber
) -> Unitful quantity with units ph sโปยน mโปยฒ srโปยน (cmโปยน)โปยนConverts a spetral radiance in units of power per area, per steradian per wavelength into spectral radiance in units of ph sโปยน mโปยฒ srโปยน (cmโปยน)โปยน. Users can then cast this into a quantity of other wavelength units. The function interface allows L_in to be any Unitful quantity, however the function checks whether L_in is dimensionally compatible with spectral radiance type units of power per wavenumber.
Example
RetrievalToolbox.W_to_ph โ Method
W_to_ph(
L_in::Unitful.Quantity,
ฮป::Unitful.Length
) -> Unitful quantity with units ph ฮผm^-1 m^-2 s^-1 sr^-1Converts a spetral radiance L_in in units of power per area, per steradian per wavelength into spectral radiance in units of ph ฮผm^-1 m^-2 s^-1 sr^-1. Users can then cast this into a quantity of other wavelength units. The function interface allows L_in to be any Unitful quantity, however the function checks whether L_in is dimensionally compatible with spectral radiance type units of power per wavelength.
Example
RetrievalToolbox.avx_add_along_columns! โ Method
avx_add_along_columns!(
y::AbstractVector,
x::AbstractMatrix
)Adds the along-column sum of matrix x to the vector y. This function makes use of the @turbo macro of the LoopVectorization package for high performance. The contents of y are zeroed out prior to the computation. Equivalent to y[:] .+= sum(x, dims=2), but roughly 3x faster.
RetrievalToolbox.avx_sum_along_columns_between! โ Method
avx_sum_along_columns_between!(
y::AbstractVector,
x::AbstractMatrix,
idx1::Integer,
idx2::Integer
)Calculates the along-column sum of matrix x between indices idx1 and idx2, to store it in the vector y. It is assumed that idx1 < idx2. This function makes use of the @turbo macro of the LoopVectorization package for high performance. The contents of y are zeroed out prior to the computation. Equivalent to y[:] .= sum(x[:,idx1:idx2], dims=2), but roughly 2x faster.
Example
Below example shows a matrix with two rows and three columns. avx_sum_along_columns_between! computes the sums for each of the two rows, between column indices 2 and 3, meaning 2+3 and 5+6, and stores the results in the two-element vector y.
x = [1 2 3; 4 5 6]
y = zeros(Int, 2)
avx_sum_along_columns_between!(y, x, 2, 3)
yRetrievalToolbox.check_for_not_finite โ Method
check_for_not_finite(x::AbstractArray) -> Bool
For an array x, returns true if any element is not finite (as per isfinite), or false if all elements are finite.
RetrievalToolbox.findany โ Method
findany(x::AbstractVector, a) -> Bool
Returns true if a is found within x, does not allocate.
Examples
julia> findany(["a", "b", "c", "d"], "b")
truejulia> findany([1,2,3,4,5], 10)
falseRetrievalToolbox.findanytype โ Method
findanytype(x::AbstractVector, T) -> Bool
Returns true if any element within x is of type T, does not allocate.
RetrievalToolbox.ingest! โ Method
ingest!(obj, field::Symbol, val::AbstractArray)
Sets a RetrievalToolbox type field and applies the correct unit conversion. This is the specialized function to deal with array-type values. This should be mostlya allocation-free.
Details
RetrievalToolbox.ingest! โ Method
ingest!(obj, field::Symbol, val::Number)
Sets a RetrievalToolbox type field and applies the correct unit conversion
Details
RetrievalToolbox.levels_to_layers! โ Method
levels_to_layers!(
layers::AbstractVector,
levels::AbstractVector;
logspace
)
For a given level vector, calculate the mid-layer values and store into layers. This function assumes that the layer-value is evaluated at the center point between the two adjacent levels.
RetrievalToolbox.levels_to_layers โ Method
levels_to_layers(levels::AbstractVector; logspace) -> Any
For a given level object, create a new vector that contains the mid-layer vector. This function assumes that the layer-value is evaluated at the center point between the two adjacent levels.
RetrievalToolbox.maxmin โ Method
maxmin(x::AbstractArray) -> Any
For an array x, returns the difference between the largest and smallest element maximum(x) - minimum(x).
RetrievalToolbox.pwl_value_1d_axb! โ Method
a * b
RetrievalToolbox.specific_humidity_to_H2O_VMR โ Method
specific_humidity_to_H2O_VMR(sh::Number) -> Any
Calculates H2O VMR from specific humidity