definition lifted_condensation_level(number t, number td, number p)

Computes the Lifted Condensation Level (LCL) of a parcel ascending from a given temperature, dewpoint and pressure, where

The LCL is the level where the parcel becomes saturated and it is computed with an iterative method along the dry adiabat of the ascending parcel.

The result is a definition with two members: t and p, containing the temperature and pressure of the LCL, in K and Pa units, respectively. On error or if the LCL does not exist nil is returned.


number mixing_ratio(number q)

Computes the mixing ratio from the given specific humidity, where

The result is the mixing ratio in kg/kg units. On error nil is returned. The computation is based on the following well known formula:

w = \frac{q}{1 - q}


number mixing_ratio_from_vapour_pressure(number p, number e)

Computes the mixing ratio from the given (total) pressure and vapour pressure, where

The result is the mixing ratio in kg/kg units. On error  nil is returned. The computation is based on the following formula:

w = \epsilon \frac{e}{p - e}

with

\epsilon = \frac{R_{dry}}{R_{vapour}} = 0.621981



number potential_temperature(number t, number p)

Computes the potential temperature for a given temperature and pressure, where

The result is the potential temperature in K units. On error  nil is returned.


number relative_humidity(number t, number q, number p)

Computes the relative humidity for a given temperature, specific humidity and pressure, where

The result is the relative humidity in the range of [0, 1]. On error nil is returned. The computation is based on the following formula:

r = \frac{e(q, p)}{e_{sat}(t)}

where e is the vapour pressure and esat is the saturation vapour pressure.


fieldset relhum(...)

Extract vertical profiles from BUFR data in a suitable format suitable for thermodynamic diagrams (defined by Thermo View). This is a Metview icon function, for detailed documentation please see Thermo Data.


number saturation_mixing_ratio(number t, number p)

Computes the saturation mixing ratio for a given temperature and pressure, where

The result is the saturation mixing ratio in kg/kg units. On error nil is returned. The computation is implemented via the following function calls:

ws = mixing_ratio(p, saturation_vapour_pressure(t))


number saturation_vapour_pressure(number t)

Computes the saturation vapour pressure for a given temperature, where

The result is the saturation vapour pressure in Pa units. On error nil is returned. The computations are based on a mixed-phase Tetens formula used by IFS for diagnostic purposes (see here on p116 for details from the latest model cycle (CY45R1, at the time of the writing of this documentation).


number temperature_from_potential_temperature(number th, number p)

Computes the temperature for a given potential temperature and pressure, where

The result is the temperature in K units. On error nil is returned.


netcdf thermo_bufr(...)

Extract vertical profiles from BUFR data in a suitable format suitable for thermodynamic diagrams (defined by Thermo View). This is a Metview icon function, for detailed documentation please see Thermo Data.


netcdf thermo_grib(...)

Extract vertical profiles from GRIB data in a suitable format for thermodynamic diagrams (defined by Thermo View). This is a Metview icon function, for detailed documentation please see Thermo Data.


definition thermo_parcel_path(vector t, vector td, vector p, definition options)

definition thermo_parcel_path(netcdf profile, definition options)

Computes the path of an ascending thermodynamic parcel with the given start condition for the given vertical profile. It returns a definition containing all the data to plot parcel path, buoyancy areas and related data into a thermodynamic diagram. The vertical profile is either specified as a set of vectors where:

or as a vertical profile where:

The function can take an optional options argument (it is a definition) to specify the various settings for the parcel computations. The members of this definition are as follows (temperature values are in °C and pressure values are in hPa:

There are four different modes available for the parcel start conditions:

Surface

The parcel ascends from the surface, i.e. the lowest point of the profile. The format is as follows:

(mode: 'surface')

Custom

The parcel ascends from a given temperature, dewpoint and pressure. The format is as follows:

(mode: 'custom', start_t: start_temperature, start_td: start_dewpoint, start_p: start_pressure)

Mean layer

The parcel ascends from the mean temperature, dew point and pressure of a given pressure layer. The format is as follows:

(mode: 'mean_layer', top_p: layer_top, bottom_p: layer_bottom )

Please note that when bottom_p is omitted the layer starts at the surface.

Most unstable

The parcel ascends from the most unstable condition. To determine this, a parcel is started from all the points along the profile in the specified pressure layer. The start level of the parcel that results in the highest CAPE value will define the most unstable start condition. The format is as follows:

(mode: 'most_unstable', top_p: layer_top, bottom_p: layer_bottom )

Please note that when bottom_p is omitted the pressure layer starts at the surface.


The function returns a definition to describe all the parameters related to the parcel's ascend. The members of this definition are as follows (temperature values are in °C and pressure values are in hPa) :


number vapour_pressure(number q, number p)

Computes the vapour pressure for a given specific humidity and pressure, where

The result is the vapour pressure in Pa units. On error  nil is returned. The computation is based on the following formula:

\frac{p\;q}{\epsilon\; (1 + q(\frac{1}{\epsilon} -1 )}

with

\epsilon = \frac{R_{dry}}{R_{vapour}} = 0.621981