Custom SingleLevel
variables
The Climate Data Store provides a very large number of SingleLevel
variables. As such, we only predefine a small subset of the variables available on CDS in ERA5Reanalysis.jl. However, only SingleVariable
type variables can be downloaded from the Climate Data Store - SingleCustom
type variables are not defined on CDS. Therefore, we allow the user the option to define if the custom SingleLevel
variable they are defining exists on the Climate Data Store, and store it as a SingleVariable
type.
Defining a new SingleVariable
or SingleCustom
To define both SingleVariable
and SingleCustom
variables, we use the funciton SingleVariable()
. To create a SingleCustom
variable, the keyword argument inCDS
must be set to false.
ERA5Reanalysis.SingleVariable
— TypeSingleVariable(
ST = String;
varID :: AbstractString,
lname :: AbstractString = "",
vname :: AbstractString,
units :: AbstractString,
inCDS :: Bool = true
) -> evar :: SingleLevel
Create a custom Single-Level variable that is not in the default list exported by ERA5Reanalysis.jl. These variables are either available in the CDS store (whereby they can be both downloaded analyzed), or not (in which case means that they were 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 variableinCDS
: Boolean that indicates if this variable is available on the CDS store. True if available.
Removing Custom PressureLevel
Variables
To remove a SingleLevel
variable, we can use the rmSingle()
function:
ERA5Reanalysis.rmSingle
— MethodrmSingle( varID :: AbstractString ) -> nothing
Remove the Single-Level Variable with the ID varID
from the lists.
Arguments
RegID
: The keyword ID that will be used to identify the Single-Level Variable that is to be removed
An Example!
In this example, we add two SingleLevel
variables to the list:
hvc
, for High Vegetation Cover, which is a downloadable variable in the CDSeke
, for Eddy Kinetic Energy, which is not downloadable and must be calculated using other variables
The Eddy Kinetic Energy is calculated by the following:
\[E = \frac{1}{2g} \int_0^{p_s} \overline{u'^2} + \overline{v'^2} \>dp\]
And it is often used as a measure of storm-track intensity.
julia> using ERA5Reanalysis
julia> SingleVariable( varID = "cvh", units = "0-1", vname = "High Vegetation Cover", lname = "high_vegetation_cover", )
ERROR: 2023-04-03T03:55:13.205 - ERA5Reanalysis.jl - The SingleVariable "cvh" has already been defined,please use another identifier.
julia> SingleVariable( varID = "eke", units = "J m**-2", vname = "Eddy Kinetic Energy", lname = "eddy_kinetic_energy", inCDS = false )
The Single-Level Variable "eke" has the following properties: Variable ID (varID) : eke Long Name (lname) : eddy_kinetic_energy Variable Name (vname) : Eddy Kinetic Energy Variable Units (units) : J m**-2
julia> tableSingles()
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> rmSingle.(["eke","hvc"])
[ Info: 2023-04-03T03:55:13.319 - ERA5Reanalysis.jl - Successfully removed the Single-Level variable defined by "eke" ┌ Warning: 2023-04-03T03:55:13.321 - ERA5Reanalysis.jl - "hvc" is not a valid SingleVariable identifier, use the function SingleVariable() or SingleCustom() to add this ERA5Variable to the list. └ @ ERA5Reanalysis ~/.julia/packages/ERA5Reanalysis/o6ANm/src/variable/single.jl:200 ┌ Warning: 2023-04-03T03:55:13.321 - ERA5Reanalysis.jl - No Single-Level variable defined by "hvc" exists, please make sure you specified the correct variable ID └ @ ERA5Reanalysis ~/.julia/packages/ERA5Reanalysis/o6ANm/src/variable/single.jl:230 2-element Vector{Nothing}: nothing nothing
julia> isSingle("eke",throw=false) # don't throw error, just show warning
┌ Warning: 2023-04-03T03:55:13.395 - ERA5Reanalysis.jl - "eke" is not a valid SingleVariable identifier, use the function SingleVariable() or SingleCustom() to add this ERA5Variable to the list. └ @ ERA5Reanalysis ~/.julia/packages/ERA5Reanalysis/o6ANm/src/variable/single.jl:200 false