Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Merge several fieldsets. The same as the operator &. The output is a fieldset with as many fields as the total number of fields in all merged fieldsets. Merging with the value nil does nothing, and is used to initialise when building a fieldset from nothing.

...


...

fieldset   ml_to_hl (mfld: fieldset, z: fieldset, zs: fieldset, hlist: list, reflev: string, method: string, [fs_surf: fieldset])

Interpolates a fieldset on on model levels   (i.e. on hybrid or eta levels used by the IFS) onto onto height levels (in m) above sea or ground level.   At gridpoints where interpolation is not possible missing value is returned. This function has the following positional arguments:

    • mfld: the fieldset to be interpolated
    • z: the geopotential fieldset on model

...

    • levels (it must contain the same levels as

...

    • mfld

...

    • but the order of the levels can be different)
    • zs: the surface geopotential field (if the

...

    • reflev

...

    • argument is set to

...

    • "sea"

...

    • it should be set to

...

    • nil).
    • hlist: the list of target height levels (they can came in any given order)
    • reflev: specifies the reference level for the target heights. The possible values are

...

    • "sea"

...

    • and

...

    • "ground"

...

    • * method: specifies the interpolation method. The possible values are

...

    • "linear"

...

    • and

...

    • "log".

Please note that geopotential is not archived operationally on model levels in MARS at ECMWF.  To compute geopotential on model levels use Metview's mvl_geopotential_on_ml() function. The following example shows how to use function ml_to_hl() together with mvl_geopotential_on_ml() :

    • fs_surf: (optional) specifies the field values on the surface. With this it is possible to interpolate to target heights between the surface and the bottom-most model level. If fs_surf is a number it defines a constant fieldset. Only available when ref_level is "ground". New in Metview version 5.14.0.

At gridpoints where the interpolation is not possible a missing value is returned. It can happen when the target height level is below the bottom-most model level or the surface (when fs_surf is used) or above the top-most level. Please note that model levels we are dealing with in ml_to_hl are "full-levels" and the bottom-most model level does match the surface but it is above it. If you need to interpolate to height levels close to the surface use fs_surf.

Info

The actual ECMWF model level definition is stored in the "pv" array in the GRIB message metadata. You can figure out the total number of model levels in the given vertical coordinate system by using the len(pv)/2-1 formula. The typical values are 137 and 91. This can be then used to look up details about actual the model level definitions (e.g. approximate pressure and height values) on this page.


Info

Geopotential is not archived operationally on model levels in MARS at ECMWF. To compute it use mvl_geopotential_on_ml().

The following example shows how to use function ml_to_hl() together with mvl_geopotential_on_ml():

Code Block
languagepy
# retrieve the data on model levels - 
# surface geopotential (zs) is only available in the first forecast step!
common_retrieve_
Code Block
languagepy
# retrieve the data on model levels - surface geopotential (zs) is only available in the first forecast step!

common_retrieve_params = ( type : "fc", levtype : "ml", step : 12, grid : [1.5,1.5] )
t = retrieve retrieve paramparam : "t", levelist levelist : [1, 'to', 137], common common_retrieve_params)
q = retrieve retrieve paramparam : "q", levelist levelist : [1, 'to', 137], common common_retrieve_params)
lnsp = retrieve( param param : "lnsp", levelist levelist : 1, common common_retrieve_params)
zs = retrieve( param : "z", levelist : 1, type : "fc", levtype : "ml", step : 0, grid : [1.5,1.5])
   
# compute geopotential on model levels
z = mvl_geopotential_on_ml(t, q, lnsp, zs)
   

# interpolate the t field onto a list of height levels above sea level
hlevs = [1000, 2000, 3000, 4000, 5000]
th = ml_to_hl (t, z, nil, hlevs, "sea", "linear")

...

With n fields in the input fieldsets, if xik, yik are the ith value of the kth input fieldsets and zi is the ith value of the resulting field:


Anchor
mvl_geopotential_on_mlmvl_geopotential_on_ml

fieldset mvl_geopotential_on_ml(t:fieldset, q:fieldset, lnsp:fieldset, zs:fieldset)

Computes geopotential on model levels.

...

mvl_geopotential_on_ml
mvl_geopotential_on_ml
fieldset mvl_geopotential_on_ml(t:fieldset, q:fieldset, lnsp:fieldset, zs:fieldset)

Computes geopotential on model levels.

All fields must be gridpoint data - no spherical harmonics, and they must all be on the same grid, with the same number of points. mvl_geopotential_on_ml() assumes that there are no other dimensions contained in the data, e.g. all fields should have the same date and time.

The return value is a fieldset of geopotential defined on the model levels present in the input data sorted by ascending numeric level order.

The required levels and their ordering in t and q depend on the Metview version used:

    • from Metview version 5.14.0: t and q must contain the same levels in the same order but there is no restriction on the actual level ordering. The model level range must be contiguous and must include the bottom-most level. E.g. if the current vertical coordinate system has 137 model levels using only a subset of levels between e.g. 137-96 is allowed.
    • in previous Metview versions: t and q must contain the full model level range in ascending numeric order. E.g. if the current vertical coordinate system has 137 model levels t and q must contain all the levels ordered as 1,..., 137.


Info

The actual ECMWF model level definition is stored in the "pv" array in the GRIB message metadata. You can figure out the total number of model levels in the given vertical coordinate system by using the len(pv)/2-1 formula. The typical values are 137 and 91. This can be then used to look up details about actual the model level definitions (e.g. approximate pressure and height values) on this page.


Info

Surface geopotential is defined on model level 1 in MARS at ECMWF. For most recent dates it is available for the 0 forecast step. However, generally it is only available as an analysis field.

The code below illustrates how to use this function:

# retrieves analysis data on model levels

...