Custom PressureLevel
variables
In ERA5Reanalysis.jl, we have predefined all the pressure-level variables that are available directly from the CDS. As such, all custom PressureLevel
variables are defined under the PressureCustom
type.
Defining Custom PressureLevel
Variables
PressureCustom
variables are defined using the PressureVariable()
function, as follows:
ERA5Reanalysis.PressureVariable
— TypePressureVariable(
ST = String;
varID :: AbstractString,
lname :: AbstractString = "",
vname :: AbstractString,
units :: AbstractString,
hPa :: Int = 0,
throw :: Bool = true
) -> evar :: PressureCustom
Create a custom Pressure-Level variable that is not in the default list exported by ERA5Reanalysis.jl. These variables are not available in the CDS store, and so they must be separately calculated from other variables and analyzed.
Keyword Arguments
varID
: variable ID (in string format) used in the NetCDF filelname
: long-name for variable (used in specifying variable for CDS downloads)vname
: user-defined variable nameunits
: user-defined units of the variablehPa
: Pressure level specified in hPa. Default is 0, which indicates all levels.throw
: ifhPa
level does not exist andthrow
is true, throw error, otherwise find nearest pressure level
Removing Custom PressureLevel
Variables
To remove a PressureCustom
variable, we can use the rmPressure()
function:
ERA5Reanalysis.rmPressure
— MethodrmPressure( varID :: AbstractString ) -> nothing
Remove the Pressure-Level Variable with the ID varID
from the lists.
Arguments
RegID
: The keyword ID that will be used to identify the Pressure-Level Variable that is to be removed
An Example!
Let us define the custom variable "vt" for Virtual Temperature, which is a proxy to buoyancy in the atmosphere. Virtual Temperature is calculated from both the water vapour mixing ratio and atmospheric temperature and is given by the formula:
\[T_v = T(1+0.61q)\]
Virtual Temperature has the units "K", and for this example let us define the pressure level height we are interested in to be at 1000 hPa. The resultant PressureCustom
variable is given by:
julia> using ERA5Reanalysis
julia> PressureVariable( varID = "vt", units = "K", hPa = 1000, lname = "virtual_temperature", vname = "Virtual Temperature" )
ERROR: 2023-04-03T03:55:12.682 - ERA5Reanalysis.jl - The PressureVariable "vt" has already been defined, please use another identifier.
julia> tablePressures()
ERROR: MethodError: no method matching pretty_table(::Matrix{Any}, ::Vector{String}; alignment=[:c, :c, :l, :c, :l], crop=:none, tf=PrettyTables.TextFormat(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', [:begin, :header, :end], :all)) Closest candidates are: pretty_table(!Matched::IO, ::Any; kwargs...) at ~/.julia/packages/PrettyTables/pZvTh/src/print.jl:705 pretty_table(!Matched::Type{String}, ::Any; color, kwargs...) at ~/.julia/packages/PrettyTables/pZvTh/src/print.jl:707 pretty_table(!Matched::Type{HTML}, ::Any; kwargs...) at ~/.julia/packages/PrettyTables/pZvTh/src/print.jl:713 ...
julia> rmPressure("vt")
ERROR: UndefKeywordError: keyword argument hPa not assigned
julia> isPressure("vt",throw=false) # don't throw error, just show warning
true