Reading in Pre-existing ERA5Variable Information
In order to familiarize ourselves with using ERA5Variables, we load some of the pre-existing variables that are prepackaged with ERA5Reanalysis.jl.
Loading Single-Level Variable Information
The easiest example is to load a single-level variable using the SingleVariable() function, for example the u-component of wind 100m above the surface:
ERA5Reanalysis.SingleVariable — Type
SingleVariable(
ID :: AbstractString,
ST = String,
) -> evar :: SingleLevelRetrieve the basic properties of the Single-Level variable defined by ID and put them in the evar SingleLevel type structure.
Arguments
ID: variable ID (in string format) used in the NetCDF file
As of v0.3 and above, all Single-Level variables available in the CDS are available by default in ERA5Reanalysis.jl.
julia> using ERA5Reanalysisjulia> SingleVariable("u100")The Single-Level Variable "u100" has the following properties: Variable ID (ID) : u100 Long Name (long) : 100m_u_component_of_wind Variable Name (name) : 100 metre U wind component Variable Units (units) : m s**-1 Is Analysis (analysis) : true Is Forecast (forecast) : true Invariant? (invariant) : false NetCDF ID (ncID) : u100 MARS ID (mars) : 228246 DRKZ ID (dkrz) : 502
Loading Pressure-Level Variable Information
Loading pressure-level variables using the PressureVariable() function is similar overall. However, an additional argument hPa is needed to specify the pressure-levels in question. By default hPa = 0 refers to all available pressure-levels. However, if the input for hPa is not a valid ERA5 pressure-level in CDS, then throw determines if an error is thrown, or if the nearest pressure level will be used instead.
ERA5Reanalysis.PressureVariable — Type
PressureVariable(
ID :: AbstractString,
ST = String;
hPa :: Int = 0
throw :: Bool = true
) -> evar :: SingleLevelRetrieve the basic properties of the Pressure-Level variable defined by ID at pressure-height indicated by hPa and put them in the evar SingleLevel type structure.
Arguments
ID: variable ID (in string format) used in the NetCDF file
Keyword Arguments
hPa: Integer specifying pressure-level height in hPathrow: ifhPalevel does not exist andthrowis true, throw error, otherwise find nearest pressure level
julia> using ERA5Reanalysisjulia> PressureVariable("cc",hPa=1000)The Pressure-Level Variable "cc" has the following properties: Variable ID (ID) : cc Long Name (long) : fraction_of_cloud_cover Variable Name (name) : Cloud Cover Fraction (1000 hPa) Variable Units (units) : % Pressure Level (hPa) : 1000 Is Analysis (analysis) : true Is Forecast (forecast) : true Invariant? (invariant) : false NetCDF ID (ncID) : cc MARS ID (mars) : 248 DRKZ ID (dkrz) : 248julia> PressureVariable("cc",hPa=890)ERROR: 2025-11-29T00:49:38.243 - ERA5Reanalysis.jl - Pressure level specified in "hPa" argument is invalid, please check and see if you requested correctlyjulia> PressureVariable("cc",hPa=890,throw=false)┌ Warning: 2025-11-29T00:49:38.254 - ERA5Reanalysis.jl - Pressure level specified in "hPa" argument does not exist, snapping to nearest pressure level └ @ ERA5Reanalysis ~/work/ERA5Reanalysis.jl/ERA5Reanalysis.jl/src/variable/pressure.jl:242 The Pressure-Level Variable "cc" has the following properties: Variable ID (ID) : cc Long Name (long) : fraction_of_cloud_cover Variable Name (name) : Cloud Cover Fraction (900 hPa) Variable Units (units) : % Pressure Level (hPa) : 900 Is Analysis (analysis) : true Is Forecast (forecast) : true Invariant? (invariant) : false NetCDF ID (ncID) : cc MARS ID (mars) : 248 DRKZ ID (dkrz) : 248
Valid ERA5 Pressure-Levels in CDS
A list of valid ERA5 pressure-levels available directly from CDS can be retrieved using the function era5Pressures
ERA5Reanalysis.era5Pressures — Method
era5Pressures() -> parray :: Vector{Int}Returns the a vector containing the 37 pressure levels available in ERA5 in hPa units.
Returns
parray: vector containing list of pressures in Int format and hPa units
julia> using ERA5Reanalysisjulia> era5Pressures()37-element Vector{Int64}: 1 2 3 5 7 10 20 30 50 70 ⋮ 800 825 850 875 900 925 950 975 1000
Does the ERA5Variable exist?
If we want to check if the ERA5Variable exists, we use either the isSingle() or isPressure functions.
There is no generic isERA5Variable function, because some pressure-level variables and single-level variables on the CDS have the same identifier (e.g. Total Cloud Cover, and Cloud Cover Fraction, both of which use the identifer cc).
julia> using ERA5Reanalysisjulia> isSingle("tcwv")ERROR: UndefVarError: `isSingle` not defined in `Main` Suggestion: check for spelling errors or missing imports.