Versions Compared

Key

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

...

Each value returned (representing the mean at longitude Lon ) is a mean of non-missing values in those grid points whose longitude coordinate is between Lon-2.5 and Lon+2.5 (2.5 is 5/2), in the belt between 30N and 30S.

 

date or list base_date ( fieldset )

Returns the base dates (including the time components) of the given fields. If the fieldset has only one field, a date is returned; otherwise a list of dates is returned.

 

fieldset bitmap (fieldset,number)
fieldset bitmap (fieldset,fieldset)

Returns a copy of the input fieldset (first argument) with zero or more of its values replaced with grib missing value indicators. If the second argument is a number, then any value equal to that number in the input fieldset is replaced with the missing value indicator. If the second argument is another fieldset with the same number of fields as the first fieldset, then the result takes the arrangement of missing values from the second fieldset. If the second argument is another fieldset with one field, the arrangement of missing values from that field are copied into all fields of the output fieldset. See also nobitmap .

 

number or list corr_a ( fieldset,fieldset )
number or list corr_a ( fieldset,fieldset,list )

Computes the correlation between two fieldsets over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

Note that the following lines are equivalent, although the first is more efficient:

z = corr_a (x, y)
z = covar_a (x, y) / (sqrt(var_a(x)) * sqrt(var_a(y)))

 

fieldset coslat ( fieldset )

For each field in the input fieldset, this function creates a field where each grid point has the value of the cosine of its latitude.

 

fieldset covar ( fieldset,fieldset )

Computes the covariance of two fieldsets. With n fields in the input fieldsets, if xik and yik are the ith values of the kth field of each input field respectively and zi is the ith value of the resulting field, the formula can be written :

Image Removed

Note that the following lines are equivalent:

z = covar(x,y)
z = mean(x*y)-mean(x)*mean(y)

A missing value in either input fieldset will result in a missing value in the corresponding place in the output fieldset.

 

number or list covar_a ( fieldset,fieldset )
number or list covar_a ( fieldset,fieldset,list )


fieldset bearing (f: fieldset, reflat: number, reflon: number )
fieldset bearing (f: fieldset, ref: list )

Computes the bearing for each grid point with reference to the given location. The location (in degrees) may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order.

The bearing is the angle between the Northward meridian going through the reference point and the great circle connecting the reference point and the given gridpoint.  It is measured in degrees clockwise from North. If a gridpoint is located on the same latitude as the reference point the bearing is regarded constant: it is either 90° (East) or 270° (West). If the gridpoint is co-located with the reference point the bearing is set to a missing value.


date or list base_date ( fieldset )

Returns the base dates (including the time components) of the given fields. If the fieldset has only one field, a date is returned; otherwise a list of dates is returned.

 

fieldset bitmap (fieldset,number)
fieldset bitmap (fieldset,fieldset)

Returns a copy of the input fieldset (first argument) with zero or more of its values replaced with grib missing value indicators. If the second argument is a number, then any value equal to that number in the input fieldset is replaced with the missing value indicator. If the second argument is another fieldset with the same number of fields as the first fieldset, then the result takes the arrangement of missing values from the second fieldset. If the second argument is another fieldset with one field, the arrangement of missing values from that field are copied into all fields of the output fieldset. See also nobitmap .

 

number or list corr_a ( fieldset,fieldset )
number or list corr_a ( fieldset,fieldset,list )

Computes the correlation between Computes the covariance of two fieldsets over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

list datainfo ( fieldset )

Returns a list of definitions - one for each field in the fieldset. Each definition provides the following members: the index of the field in the fieldset, the number of missing values, the number of values that are present and the proportion of each. The following example illustrates how to use the function.

fs = read (strGribFile)
listdefInfo = datainfo (fs)
loop defInfo in listdefInfo
     print ("Field index : ", defInfo.index)
     print ("Number of values present : ", defInfo.number_present)
     print ("Number of values missing : ", defInfo.number_missing)
     print ("Proportion values present : ", defInfo.proportion_present)
     print ("Proportion values missing : ", defInfo.proportion_missing)
end loop

 

fieldset direction ( fieldset,fieldset )

Returns a fieldset with the value in each grid point being the direction computed from the given U and V fieldsets; the first input fieldset is assumed to be the East-West (U) component and the second the North-South (V) component. The resulting numbers are directions, in degrees clockwise from North, where a value of 0 represents a wind from the North and a value of 90 represents a wind from the East.

 

fieldset distance ( fieldset,number,number )
fieldset distance ( fieldset,list )

Returns a fieldset with the value in each grid point being the distance in meters from the given geographical location. The location may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order. The location should be specified in degrees.

 

Note that the following lines are equivalent, although the first is more efficient:

z = corr_a (x, y)
z = covar_a (x, y) / (sqrt(var_a(x)) * sqrt(var_a(y)))

 

fieldset coslat ( fieldset )

For each field in the input fieldset, this function creates a field where each grid point has the value of the cosine of its latitude.

 

fieldset covar ( fieldset,fieldset )

Computes the covariance of two fieldsets. With n fields in the input fieldsets, if xik and yik are the ith values of the kth field of each input field respectively and zi is the ith value of the resulting field, the formula can be written :

Image Added

Note that the following lines are equivalent:

z = covar(x,y)
z = mean(x*y)-mean(x)*mean(y)

A missing value in either input fieldset will result in a missing value in the corresponding place in the output fieldset.

 

number or list covar_a ( fieldset,fieldset )
number or list covar_a ( fieldset,fieldset,list )

Computes the covariance of two fieldsets over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

list datainfo ( fieldset )

Returns a list of definitions - one for each field in the fieldset. Each definition provides the following members: the index of the field in the fieldset, the number of missing values, the number of values that are present and the proportion of each. The following example illustrates how to use the function.

fs = read (strGribFile)
listdefInfo = datainfo (fs)
loop defInfo in listdefInfo
     print ("Field index : ", defInfo.index)
     print ("Number of values present : ", defInfo.number_present)
     print ("Number of values missing : ", defInfo.number_missing)
     print ("Proportion values present : ", defInfo.proportion_present)
     print ("Proportion values missing : ", defInfo.proportion_missing)
end loop


fieldset direction fieldset div ( fieldset,fieldset )

Returns a fieldset with as many fields as the input fieldsets; the grid points of the output fieldset are the integer part of the division of the first fieldset by the second fieldset (the function operating field by field).

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:

Image Removed

A missing value in either input fieldset will result in a missing value in the corresponding place in the output fieldset.

 

fieldset duplicate ( fieldset,number )

Returns a fieldset with the specified number of copies of the field in the input fieldset. The input fieldset must contain only one field.

 

list find ( fieldset,number )
list find ( fieldset,number,list )
list find ( fieldset,number,field )

A filtering function that returns a list of locations (lat/long pairs), where the values of the input fieldset given as the first argument equal the value specified as the second argument. Missing values in the input field are not returned.

    • if there is a third argument, and it is a list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East] , the function returns a list of locations within that area where the fieldset values equal the input value
    • if there is a third argument, and it is a mask field, the function returns a list of locations within the area defined by the mask (ie, where the mask gridpoints are non-zero) where the fieldset values equal the input value.

 

list find ( fieldset,list )
list find ( fieldset,list,list )
list find ( fieldset,list,field )

A filtering function that returns a list of locations (lat/long pairs), where the values of the input fieldset given as the first argument are within the interval [a, b] specified as the second argument (a two value list). Missing values in the input field are not returned.

    • if there is a third argument, and it is a list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East] , returns a list of locations within that area where the field values are within the interval [a, b]
    • if there is a third argument, and it is a mask field, returns a list of locations within the area defined by the mask (ie, where the mask gridpoints are non-zero) where the fieldset values are within the interval [a, b]

 

list frequencies ( fieldset,list )
list frequencies ( fieldset,list,list )

...

the value in each grid point being the direction computed from the given U and V fieldsets; the first input fieldset is assumed to be the East-West (U) component and the second the North-South (V) component. The resulting numbers are directions, in degrees clockwise from North, where a value of 0 represents a wind from the North and a value of 90 represents a wind from the East.

 

fieldset distance ( fieldset,number,number )
fieldset distance ( fieldset,list )

Returns a fieldset with the value in each grid point being the distance in meters from the given geographical location. The location may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order. The location should be specified in degrees.

 

fieldset div ( fieldset,fieldset )

Returns a fieldset with as many fields as the input fieldsets; the grid points of the output fieldset are the integer part of the division of the first fieldset by the second fieldset (the function operating field by field).

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:

Image Added

A missing value in either input fieldset will result in a missing value in the corresponding place in the output fieldset.

 

fieldset divergence (fx: fieldset, fy: fieldset)

Computes the horizontal divergence of 2-dimensional vector fields. The computations for a vector field f=(fx ,fy ) are based on the following formula:

Mathdisplay
 div(f) = \frac{1}{R \ cos\phi}\frac{\partial f_x}{\partial \lambda} + \frac{1}{R}\frac{\partial f_y}{\partial \phi} - \frac{f_y}{R}tan\phi

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. If the input fields are horizontal wind components the GRIB paramId of the resulting field is set to 155 (=divergence). Please note that this function is only implemented for regular latitude-longitude grids.


fieldset duplicate ( fieldset,number )

Returns a fieldset with the specified number of copies of the field in the input fieldset. The input fieldset must contain only one field.

 

list find ( fieldset,number )
list find ( fieldset,number,list )
list find ( fieldset,number,field )

A filtering function that returns a list of locations (lat/long pairs), where the values of the input fieldset given as the first argument equal the value specified as the second argument. Missing values in the input field are not returned.

    • if there is a third argument, and it is a list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East]

...

    • , the function returns a list of locations within that area where the fieldset values equal the input value
    • if there is a third argument, and it is a mask field, the function returns a list of locations within the area defined by the mask (ie, where the mask gridpoints are non-zero) where the fieldset values equal the input value.

 

list find ( fieldset,list )
list find ( fieldset,list,list )
list find ( fieldset,list,field

If the input fieldset has just one field, then the result is a list of n+1 elements where n is the number of elements in the interval list. Using the above example, the output list could be described as follows:

    • the first element is the number of values below 0
    • the second element is the number of values in the range [0, 10)
    • the third element is the number of values in the range [10, 20)
    • the fourth element is the number of values above 20

If the input fieldset has more than one field, the result is a list of lists, one for each field. Note that this function accumulates its results between fields in a fieldset.

 

geopoints gfind ( fieldset,number )
geopoints gfind ( fieldset,number,number )

A filtering function that returns a geopoints holding the grid points whose value is equal to the value of the first numberlist of locations (lat/long pairs), where the values of the input fieldset given as the first argument are within the interval [a, b] specified as the second argument (a two value list). Missing values in the input field are not returned. If a second number is given as the

    • if there is a third argument, and it is a

...

abs(data-value) <= threshold

list grib_get (fieldset, list)
list grib_get (fieldset, list, string)

For the efficient retrieval of multiple GRIB keys from a fieldset. A single call to grib_get can replace multiple calls to the other grib_get_* functions and is hence more efficient. The keys are provided as a list for the second argument; by default they will be retrieved as strings, but their type can be specified by adding a modifier to their names, following the convention used by grib_ls where the key name is followed by a colon and then one or two characters which specify the type (s=string, l=long, d=double, la=long array, da=double array). For example, the key 'centre' can be retrieved as a string with 'centre' or 'centre:s', or as a number with 'centre:l'. The result is always a list of lists; by default, or if the optional third argument is 'field', the result will be grouped by field, containing one list per field, each of these lists containing one element per key; if the optional third parameter is 'key', the result will be grouped by key, containing one list per key, each of these lists containing one element per field. Example - the following lines of Macro code on a particular 6-field fieldset:

print(grib_get(data, ['editionNumber', 'centre',   'level', 'step'], 'field'))
print(grib_get(data, ['editionNumber', 'centre:l', 'level', 'step'], 'key'))

produces this output:

[[1,ecmf,1000,0],[1,ecmf,500,0],[1,ecmf,100,0],[1,ecmf,1000,48],[1,ecmf,500,48],[1,ecmf,100,48]]
[[1,1,1,1,1,1],[98,98,98,98,98,98],[1000,500,100,1000,500,100],[0,0,0,48,48,48]]

...

number or list grib_get_long ( fieldset, string )
number or list grib_get_double ( fieldset, string )
number or list grib_get_string ( fieldset, string )
vector or list grib_get_long_array ( fieldset, string )
vector or list grib_get_double_array ( fieldset, string )

These functions return information from the given fieldset's GRIB header. Available keys (to be passed as the second parameter) can be inspected by Examining the GRIB file (right-click, Examine). Alternatively, use the GRIB API command grib_dump to see the available key names. See https://software.ecmwf.int/wiki/display/GRIB/Grib+API+keys for more details on key names.

The first three functions return a number if the input fieldset has a single field, otherwise they return a list of numbers. The `array' functions return a vector of numbers if the input fieldset has a single field, otherwise they return a list of vectors.

The following example shows the retrieval of GRIB header information, including the derived key 'max', using the different functions:

print (grib_get_long   (data, "editionNumber"))
print (grib_get_long   (data, "max"))
print (grib_get_double (data, "max"))
print (grib_get_string (data, "max"))
print (grib_get_string (data, "typeOfGrid"))

The output from this on an example single-field GRIB file was:

1
317
317.278808594
317.279
regular_ll

The following example shows how to obtain the list of parallels from a reduced Gaussian grid fieldset:

a = read('/x/y/z/data_in_gg.grb')
pl = grib_get_long_array (a, 'pl')
print (count(pl))
print (pl)

fieldset grib_set ( fieldset, list )

This function sets information in the given fieldset's GRIB header, automatically deducing the type from the value passed (not from the key name). The list provided as the second argument should be a set of key/value pairs, for example:

f = grib_set(f, ["date", 20150601,       # integer
                 "time", 0600,           # integer
                 "stepType", "avg",      # string
                 "startStep", 0 ,        # integer
                 "endStep", 31,          # integer

                 "unitOfTimeRange", "D", # string
                 "
longitudeOfLastGridPointInDegrees"])  100.5  #  double

fieldset grib_set_long ( fieldset, list )
fieldset grib_set_double ( fieldset, list )
fieldset grib_set_string ( fieldset, list )

These functions set information in the given fieldset's GRIB header, and are type-specific. The list provided as the second argument should be a set of key/value pairs, for example:

data = grib_set_long (data,
  ["centre", 99,
   "level", 200])

This function does not modify the input fieldset, but returns a new fieldset with the modifications applied.

Available keys can be inspected by Examining the GRIB file (right-click, Examine). Alternatively, use the GRIB API command grib_dump to see the available key names. See https://software.ecmwf.int/wiki/display/GRIB/Grib+API+keys for more details on key names.

If applied to a multi-field fieldset, then all fields are modified.

 

number gribsetbits ( number )

This function sets the number of GRIB packing bits to the value given (eg 8, 10, 16), and returns the previously used internal value. This function is particularly useful when dealing with 10-bit satellite images as these require GRIB packing to be set to 10 bits.

 

fieldset indexes ( fieldset, vector )

Given a fieldset and a vector of target values, this function finds for each gridpoint the indexes of the nearest values in the target. Indexes are zero-based and will always have a minimum value of zero and a maximum value equal to the index of the last element of the target vector. A value lying between two values in the vector will use the index of the nearest value; if equidistant, then the higher value is used. The input vector MUST be sorted in ascending order. Example: if these are our inputs:

GRIB: 10,20,30,40
      15,25,35,45
       8, 4,20,11

VECTOR: | 5,10,15,20,25,30 |

then our output would be a new GRIB, with values equal to the input values' positions in the input vector:

GRIB: 1,3,5,5
      2,4,5,5
      1,0,3,1

 

number or list integrate ( fieldset )
number or list integrate ( fieldset,list )
number or list integrate ( fieldset,fieldset )

This function computes the average value of field. Each grid point value is weighted by the cosine of its latitude :

Image Removed

Where ϕi is the latitude and xi is the grid point value. If the input fieldset contains only one field, a number is returned. If there is more than one field, a list of numbers is returned. Missing values in the input fieldset are bypassed in this calculation. For each field for which there are no valid values, nil is returned.

    • If the fieldset is the only argument, the integration is done on all grid points.
    • If a list is the second argument, it must contain four numbers which are respectively the north, west, south and east boundaries of an area. The integration is done on the grid points contained inside this area :

europe = [75,-12.5,35,42.5]
x = integrate(field,europe)

    • If a fieldset is the second argument it is used as a mask. It should contain either one or as many fields as the first fieldset. If it has a single field then this mask is applied to all fields of the input fieldset. If it has the same number of fields as the input fieldset, then a different mask is applied to each input field. The integration is performed only on the grid points where the mask values are non zero. The following code shows a simple example :

...

    • list of four numbers (lat/long coordinates) defining a geographical area - [North,West,South,East] , returns a list of locations within that area where the field values are within the interval [a, b]
    • if there is a third argument, and it is a mask field, returns a list of locations within the area defined by the mask (ie, where the mask gridpoints are non-zero) where the fieldset values are within the interval [a, b]

 

fieldset first_derivative_x (f: fieldset)

Computes the zonal (from West to East) partial derivative of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
\frac {\partial f}{\partial x} = \frac{1}{R \ cos\phi}\frac{\partial f}{\partial \lambda} 

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. Please note that this function is only implemented for regular latitude-longitude grids.


fieldset first_derivative_y (f: fieldset)

Computes the meridional (from South to North) partial derivative of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
\frac {\partial f}{\partial y} = \frac{1}{R}\frac{\partial f}{\partial \phi} 

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. Please note that this function is only implemented for regular latitude-longitude grids.


list frequencies ( fieldset,list )
list frequencies ( fieldset,list,list )

Counts the number of grid points whose values fall within a set of specified intervals. These intervals are given as the second argument - a list of values in ascending order, starting with the upper bound of the first interval, eg [0, 10, 20] . A third argument, if given, specifies a geographical area over which to consider values - [North,West,South,East] . Missing values in the input field are not included in the results.

If the input fieldset has just one field, then the result is a list of n+1 elements where n is the number of elements in the interval list. Using the above example, the output list could be described as follows:

    • the first element is the number of values below 0
    • the second element is the number of values in the range [0, 10)
    • the third element is the number of values in the range [10, 20)
    • the fourth element is the number of values above 20

If the input fieldset has more than one field, the result is a list of lists, one for each field. Note that this function accumulates its results between fields in a fieldset.

 

fieldset geostropic_wind_pl (z: fieldset)

Computes the geostrophic wind from geopotential fields defined on pressure levels.  For a given z geopotential field the computation of the geostrophic wind components is based on the following formulas:

Mathdisplay
 u_g = -\frac{1}{f} \frac{1}{R}\frac{\partial z}{\partial \phi}


Mathdisplay
 v_g = \frac{1}{f} \frac{1}{R \ cos\phi}\frac{\partial z}{\partial \lambda}

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude
    • f=2Ωsinφ is the Coriolis parameter, where Ω is the Earth's angular velocity.

The derivatives are computed with a second order finite-difference approximation. The resulting fieldset contains two fields for each input field: the u and v geostrophic wind components. In each output field the points close to the poles and the Equator, are bitmapped (they contain missing values). Please note that this function is only implemented for regular latitude-longitude grids.


geopoints gfind ( fieldset,number )
geopoints gfind ( fieldset,number,number )

A filtering function that returns a geopoints holding the grid points whose value is equal to the value of the first number. Missing values in the input field are not returned. If a second number is given as the third argument it is a tolerance threshold and the geopoints will hold the grid points for which :

abs(data-value) <= threshold


fieldset gradient (f: fieldset)

Computes the horizontal gradient of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
\nabla f = (\frac {\partial f}{\partial x}, \frac {\partial f}{\partial y}) = (\frac{1}{R \ cos\phi}\frac{\partial f}{\partial \lambda}, \frac{1}{R}\frac{\partial f}{\partial \phi} )

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fieldset contains two fields for each input field: the zonal derivative followed by the meridional derivative. The output fields are bitmapped on the poles (they contain missing values there). Please note that this function is only implemented for regular latitude-longitude grids.


list grib_get (fieldset, list)
list grib_get (fieldset, list, string)

For the efficient retrieval of multiple GRIB keys from a fieldset. A single call to grib_get can replace multiple calls to the other grib_get_* functions and is hence more efficient. The keys are provided as a list for the second argument; by default they will be retrieved as strings, but their type can be specified by adding a modifier to their names, following the convention used by grib_ls where the key name is followed by a colon and then one or two characters which specify the type (s=string, l=long, d=double, la=long array, da=double array). For example, the key 'centre' can be retrieved as a string with 'centre' or 'centre:s', or as a number with 'centre:l'. The result is always a list of lists; by default, or if the optional third argument is 'field', the result will be grouped by field, containing one list per field, each of these lists containing one element per key; if the optional third parameter is 'key', the result will be grouped by key, containing one list per key, each of these lists containing one element per field. Example - the following lines of Macro code on a particular 6-field fieldset:

print(grib_get(data, ['editionNumber', 'centre',   'level', 'step'], 'field'))
print(grib_get(data, ['editionNumber', 'centre:l', 'level', 'step'], 'key'))

produces this output:

[[1,ecmf,1000,0],[1,ecmf,500,0],[1,ecmf,100,0],[1,ecmf,1000,48],[1,ecmf,500,48],[1,ecmf,100,48]]
[[1,1,1,1,1,1],[98,98,98,98,98,98],[1000,500,100,1000,500,100],[0,0,0,48,48,48]]


 

number or list grib_get_long ( fieldset, string )
number or list grib_get_double ( fieldset, string )
number or list grib_get_string ( fieldset, string )
vector or list grib_get_long_array ( fieldset, string )
vector or list grib_get_double_array ( fieldset, string )

These functions return information from the given fieldset's GRIB header. Available keys (to be passed as the second parameter) can be inspected by Examining the GRIB file (right-click, Examine). Alternatively, use the GRIB API command grib_dump to see the available key names. See https://software.ecmwf.int/wiki/display/GRIB/Grib+API+keys for more details on key names.

The first three functions return a number if the input fieldset has a single field, otherwise they return a list of numbers. The `array' functions return a vector of numbers if the input fieldset has a single field, otherwise they return a list of vectors.

The following example shows the retrieval of GRIB header information, including the derived key 'max', using the different functions:

print (grib_get_long   (data, "editionNumber"))
print (grib_get_long   (data, "max"))
print (grib_get_double (data, "max"))
print (grib_get_string (data, "max"))
print (grib_get_string (data, "typeOfGrid"))

The output from this on an example single-field GRIB file was:

1
317
317.278808594
317.279
regular_ll

The following example shows how to obtain the list of parallels from a reduced Gaussian grid fieldset:

a = read('/x/y/z/data_in_gg.grb')
pl = grib_get_long_array (a, 'pl')
print (count(pl))
print (pl)


fieldset grib_set ( fieldset, list )

This function sets information in the given fieldset's GRIB header, automatically deducing the type from the value passed (not from the key name). The list provided as the second argument should be a set of key/value pairs, for example:

f = grib_set(f, ["date", 20150601,       # integer
                 "time", 0600,           # integer
                 "stepType", "avg",      # string
                 "startStep", 0 ,        # integer
                 "endStep", 31,          # integer

                 "unitOfTimeRange", "D", # string
                 "
longitudeOfLastGridPointInDegrees"])  100.5  #  double


fieldset grib_set_long ( fieldset, list )
fieldset grib_set_double ( fieldset, list )
fieldset grib_set_string ( fieldset, list )

These functions set information in the given fieldset's GRIB header, and are type-specific. The list provided as the second argument should be a set of key/value pairs, for example:

data = grib_set_long (data,
  ["centre", 99,
   "level", 200])

This function does not modify the input fieldset, but returns a new fieldset with the modifications applied.

Available keys can be inspected by Examining the GRIB file (right-click, Examine). Alternatively, use the GRIB API command grib_dump to see the available key names. See https://software.ecmwf.int/wiki/display/GRIB/Grib+API+keys for more details on key names.

If applied to a multi-field fieldset, then all fields are modified.

 

number gribsetbits ( number )

This function sets the number of GRIB packing bits to the value given (eg 8, 10, 16), and returns the previously used internal value. This function is particularly useful when dealing with 10-bit satellite images as these require GRIB packing to be set to 10 bits.

 

fieldset indexes ( fieldset, vector )

Given a fieldset and a vector of target values, this function finds for each gridpoint the indexes of the nearest values in the target. Indexes are zero-based and will always have a minimum value of zero and a maximum value equal to the index of the last element of the target vector. A value lying between two values in the vector will use the index of the nearest value; if equidistant, then the higher value is used. The input vector MUST be sorted in ascending order. Example: if these are our inputs:

GRIB: 10,20,30,40
      15,25,35,45
       8, 4,20,11

VECTOR: | 5,10,15,20,25,30 |

then our output would be a new GRIB, with values equal to the input values' positions in the input vector:

GRIB: 1,3,5,5
      2,4,5,5
      1,0,3,1

 


number or list integrate ( fieldset )
number or list integrate ( fieldset,list )
number or list integrate ( fieldset,fieldset )

This function computes the average value of field. Each grid point value is weighted by the cosine of its latitude :

Image Added

Where ϕi is the latitude and xi is the grid point value. If the input fieldset contains only one field, a number is returned. If there is more than one field, a list of numbers is returned. Missing values in the input fieldset are bypassed in this calculation. For each field for which there are no valid values, nil is returned.

    • If the fieldset is the only argument, the integration is done on all grid points.
    • If a list is the second argument, it must contain four numbers which are respectively the north, west, south and east boundaries of an area. The integration is done on the grid points contained inside this area :

europe = [75,-12.5,35,42.5]
x = integrate(field,europe)


    • If a fieldset is the second argument it is used as a mask. It should contain either one or as many fields as the first fieldset. If it has a single field then this mask is applied to all fields of the input fieldset. If it has the same number of fields as the input fieldset, then a different mask is applied to each input field. The integration is performed only on the grid points where the mask values are non zero. The following code shows a simple example :

# Retrieve land-sea mask and interpolate to LL grid
lsm = retrieve(
   type : "an",
   date : -1,
   param : "lsm",
   grid : [1.5,1.5],
   levtype : "sfc"
)

# The following line forces the values to 0 or 1.
lsm = lsm > 0.5

# Now compute the average value on land and on sea
land = integrate(field, lsm)
sea = integrate(field, not lsm)

 

Anchor
interpolate
interpolate
number or list interpolate ( fieldset,list )
number or list interpolate ( fieldset,number,number )

Interpolate a fieldset at a given point. The method used is bilinear interpolation. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a gridded field. If the fieldset has only one field, a number is returned; otherwise a list is returned. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned. Note that a similar function, nearest_gridpoint() , also exists.

 

geopoints interpolate ( fieldset,geopoints )

Generates a set of geopoints from a field. The first field of the input fieldset is used. The field is interpolated for each position of the geopoints given as a second parameter. The method used is bilinear interpolation. The output geopoints take their date, time and level from the fieldset. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the function remove_missing_values). Note that a similar function, nearest_gridpoint() , also exists.

 

fieldset laplacian (f: fieldset)

Computes the Laplacian of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
 \triangle f =\frac{1}{R^2 \ cos^2\phi}\frac{\partial^2 f}{\partial \lambda^2} + \frac{1}{R^2}\frac{\partial^2 f}{\partial \phi^2} - \frac{1}{R^2}tan\phi\frac{\partial f}{\partial \lambda}

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. Please note that this function is only implemented for regular latitude-longitude grids.


...

 

...

Interpolate a fieldset at a given point. The method used is bilinear interpolation. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a gridded field. If the fieldset has only one field, a number is returned; otherwise a list is returned. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned. Note that a similar function, nearest_gridpoint() , also exists.

 

geopoints interpolate ( fieldset,geopoints )

Generates a set of geopoints from a field. The first field of the input fieldset is used. The field is interpolated for each position of the geopoints given as a second parameter. The method used is bilinear interpolation. The output geopoints take their date, time and level from the fieldset. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the function remove_missing_values). Note that a similar function, nearest_gridpoint() , also exists.

 

vector or list latitudes ( fieldset )

...

Returns the value of the nearest point to a given location (or locations) in each field of a fieldset. The field must be a gridded field. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. For batch processing of multiple locations, two vectors can be given, the first is a vector of latitudes, the second the longitudes; this can be much more efficient than multiple calls with a single location each. If the fieldset has only one field, a number (or vector) is returned; otherwise a list of numbers (or a list of vectors) is returnedwith a single location each. If the fieldset has only one field, a number (or vector) is returned; otherwise a list of numbers (or a list of vectors) is returned. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the a nil is returned in the case of a single coordinate, or vector_missing_value in the case of a vector. Note that a similar function, interpolate() , also exists.


geopoints nearest_gridpoint ( fieldset,geopoints )

Generates a set of geopoints from a field. The first field of the input fieldset is used. The result is a set of geopoints whose values are those of the nearest gridpoints in the field to the geopoints given as a second parameter. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the

...

internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value

...

or removed with the function remove_missing_values). Note that a similar function, interpolate() , also exists.

...

 

list nearest_gridpoint_info ( fieldset,list )
list geopoints nearest_gridpoint_info ( fieldset,number,geopoints number )

Generates a set of geopoints from a field. The first field of the input fieldset is used. The result is a set of geopoints whose values are those of the nearest gridpoints in the field to the geopoints given as a second parameterReturns the value and location of the nearest point to a given location in each field of a fieldset. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a lat-long field. The return value is a list of definitions, one for each field, and each containing the following members: value , latitude , longitude . Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the function remove_missing_values). Note that a similar function, interpolate() , also exists.

 

list nearest_gridpoint_info ( fieldset,list )
list nearest_gridpoint_info ( fieldset,number,number )

Returns the value and location of the nearest point to a given location in each field of a fieldset. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a lat-long field. The return value is a list of definitions, one for each field, and each containing the following members: value , latitude , longitude . Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned.

The following example illustrates how to use the function.

fs = read (strGribFile)
listdef = nearest_gridpoint_info(fs, 51.46, -1.33)
loop ngp in listdef
     print ("Value : ", ngp.value)
     print ("Latitude : ", ngp.latitude)
     print ("Longitude : ", ngp.longitude)
end loop

 

fieldset nobitmap ( fieldset,number )

Returns a copy of the input fieldset (first argument) with all of its missing values replaced with the number specified by the second argument. See also bitmap .

 

fieldset pressure ( fieldset )
fieldset pressure ( fieldset,number )
fieldset pressure ( fieldset,list )
fieldset pressure ( fieldset,fieldset )

This function creates fields of pressure from the logarithm of the surface pressure (lnsp) and a list of model levels. Note that this function only works with gridded fields and assumes that the parameter for lnsp is 152. A newer, more flexible version of this function exists - see unipressure () .

    • The first argument is always a fieldset containing an lnsp field. If no other parameter is given, the list of levels will range from 1 to (number of vertical coordinates/2)-1 as coded in the GRIB header of the lnsp parameter.
    • The second argument specifies the levels at which the output fields must be generated. To generate a single level, pass a number. For more than one level, either pass a list of levels or a fieldset. If a fieldset is passed as the second parameter, the level information is extracted from each field of the fieldset.

Missing values in the lnsp field are retained in the output fieldset.

 

fieldset rmask ( fieldset,number,number,number )
fieldset rmask ( fieldset,list )

Similar to mask , except that a round mask is computed with a given radius around a geographical centre point. These can be given by either:

    • three numbers : latitude, longitude (in degrees), radius (in meters)
    • a list containing the above three numbers

The name of this function is derived from the fact that it creates a "round mask" or a "radius mask".

 

fieldset rms ( fieldset )

Computes the root mean square of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xi k is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :

Image Removed

Note that the following lines are equivalent :

y = rms(x)
y = sqrt(mean(x*x))

nil is returned.

The following example illustrates how to use the function.

fs = read (strGribFile)
listdef = nearest_gridpoint_info(fs, 51.46, -1.33)
loop ngp in listdef
     print ("Value : ", ngp.value)
     print ("Latitude : ", ngp.latitude)
     print ("Longitude : ", ngp.longitude)
end loop

 

fieldset nobitmap ( fieldset,number )

Returns a copy of the input fieldset (first argument) with all of its missing values replaced with the number specified by the second argument. See also bitmap .

 

fieldset pressure ( fieldset )
fieldset pressure ( fieldset,number )
fieldset pressure ( fieldset,list )
fieldset pressure ( fieldset,fieldset )

This function creates fields of pressure from the logarithm of the surface pressure (lnsp) and a list of model levels. Note that this function only works with gridded fields and assumes that the parameter for lnsp is 152. A newer, more flexible version of this function exists - see unipressure () .

    • The first argument is always a fieldset containing an lnsp field. If no other parameter is given, the list of levels will range from 1 to (number of vertical coordinates/2)-1 as coded in the GRIB header of the lnsp parameter.
    • The second argument specifies the levels at which the output fields must be generated. To generate a single level, pass a number. For more than one level, either pass a list of levels or a fieldset. If a fieldset is passed as the second parameter, the level information is extracted from each field of the fieldset.

Missing values in the lnsp field are retained in the output fieldset.


 

fieldset rmask ( fieldset,number,number,number )
fieldset rmask ( fieldset,list )

Similar to mask , except that a round mask is computed with a given radius around a geographical centre point. These can be given by either:

    • three numbers : latitude, longitude (in degrees), radius (in meters)
    • a list containing the above three numbers

The name of this function is derived from the fact that it creates a "round mask" or a "radius mask".

 

fieldset rms ( fieldset )

Computes the root mean square of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xi k is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :

Image Added

Note that the following lines are equivalent :

y = rms(x)
y = sqrt(mean(x*x))

 

fieldset second_derivative_x (f: fieldset)

Computes the second zonal (from West to East) partial derivative of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
\frac {\partial^2 f}{\partial x^2} = \frac{1}{R^2 \ cos^2\phi}\frac{\partial^2 f}{\partial \lambda^2} 

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. Please note that this function is only implemented for regular latitude-longitude grids.


fieldset second_derivative_y (f: fieldset)

Computes the second meridional (from South to North) partial derivative of each field in the fieldset. The computations for a field f are based on the following formula:

Mathdisplay
\frac {\partial^2 f}{\partial y^2} = \frac{1}{R^2}\frac{\partial^2 f}{\partial \phi^2} 

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. Please note that this function is only implemented for regular latitude-longitude grids.

...


fieldset set_values ( fieldset,vector )
fieldset set_values ( fieldset,list )
fieldset set_values ( fieldset,vector,string )
fieldset set_values ( fieldset,list,string )

...

fieldset sort ( fieldset )
fieldset sort ( fieldset,string )
fieldset sort ( fieldset,list )
fieldset sort ( fieldset,string,string )
fieldset sort ( fieldset,list,string )
fieldset sort ( fieldset,list,string )
fieldset sort ( fieldset,list,string )
fieldset sort ( fieldset,list,list )

This function accepts a fieldset as input and returns it sorted according to keys and rules specified in the other input arguments.

Specified with only the fieldset as its single argument, sort() sorts in descending order the fieldset according to date, time, step, (ensemble) number, level and parameter.

The second argument allows you to modify the precedence of the sorting keys - e.g. if the second argument is a string "parameter", then the sorting is done according to the parameter first. If the second argument is a list you specify a list of sorting keys - e.g. ["parameter", "date"] sorts on parameter and then date.

The third argument specifies a sorting direction. This can be a string (">" or "<") or a list ([">", "<", ">",...]). If it is a string, the sorting direction it specifies applies to all sorting keys specified in the second argument. If it is a list, then the second argument must also be a list with the same number of elements - the sorting directions apply to each sorting key specified.

 

fieldset stdev ( fieldset )

list )

This function accepts a fieldset as input and returns it sorted according to keys and rules specified in the other input arguments.

Specified with only the fieldset as its single argument, sort() sorts in descending order the fieldset according to date, time, step, (ensemble) number, level and parameter.

The second argument allows you to modify the precedence of the sorting keys - e.g. if the second argument is a string "parameter", then the sorting is done according to the parameter first. If the second argument is a list you specify a list of sorting keys - e.g. ["parameter", "date"] sorts on parameter and then date.

The third argument specifies a sorting direction. This can be a string (">" or "<") or a list ([">", "<", ">",...]). If it is a string, the sorting direction it specifies applies to all sorting keys specified in the second argument. If it is a list, then the second argument must also be a list with the same number of elements - the sorting directions apply to each sorting key specified.

 

fieldset stdev ( fieldset )

Computes the standard deviation of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xik is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :

Image Added

Note that the following lines are equivalent :

y = stdev(x)
y = sqrt(mean(x*x)-mean(x)*mean(x))
y = sqrt(var(x))

 

number or list stdev_a ( fieldset )
number or list stdev_a ( fieldset,list )

Computes the standard deviation over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

fieldset sum ( fieldset )

Computes the sum of a fieldset. The result is a single-field Computes the standard deviation of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xik is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :

Image Removed

Note that the following lines are equivalent :

...

value of the resulting field, the formula can be written :

Image Added

 

number or list stdevsurrounding_points_aindexes ( fieldset,list )
number or list stdevsurrounding_points_aindexes ( fieldset,number,list number )

Computes the standard deviation over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

fieldset sum ( fieldset )

Computes the sum of a fieldset. The result is a single-field fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xik is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :

Image Removed

 

number or list surrounding_points_indexes ( fieldset,list )
number or list surrounding_points_indexes ( fieldset,number,number )

Returns the indexes of the four gridpoints surrounding the given location, ordered by increasing distance from the target point. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a gridded field. If the fieldset has only one field, a number is returned; otherwise a list is returned. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned.

fieldset thickness ( fieldset )
fieldset thickness ( fieldset,number )
fieldset thickness ( fieldset,list )
fieldset thickness ( fieldset,fieldset )

Returns the indexes of the four gridpoints surrounding the given location, ordered by increasing distance from the target point. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a gridded field. If the fieldset has only one field, a number is returned; otherwise a list is returned. Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned.


fieldset thickness ( fieldset )
fieldset thickness ( fieldset,number )
fieldset thickness ( fieldset,list )
fieldset thickness ( fieldset,fieldset )

This function creates fields of thickness from the logarithm of the surface pressure (lnsp ) and a list of model levels. Note that this function only works with lat/long grids and assumes that the parameter for lnsp is 152. A newer, more flexible version of this function exists - see unithickness () .

    • The first argument is always a fieldset containing an lnsp field. If no other parameter is given, the list of levels will range from 1 to (number of vertical coordinates/2)-1 as coded in the GRIB header of the lnsp .
    • The second argument specifies the levels at which the output fields must be generated. To generate a single level, pass a number. For more than one level, either pass a list of levels or a fieldset. If a fieldset is passed as the second parameter, the level information is extracted from each field of the fieldset.

Missing values in the lnsp field are retained in the output fieldset.

 

fieldset unipressure ( fieldset )
fieldset unipressure ( fieldset,fieldset )
fieldset unipressure ( fieldset,list )
fieldset unipressure ( fieldset,number )
fieldset unipressure ( fieldset,fieldset,number )
fieldset unipressure ( fieldset,list,number )

This function creates fields of pressure This function creates fields of thickness from the logarithm of the surface pressure (lnsp) and a list of model levels. Note that Unlike pressure() , this function only works with all grid types known to Metview (not just lat/long grids and assumes that ); it also allows the user to override the parameter number for lnsp is 152. A newer, more flexible version of this function exists - see unithickness ((default 152).

    • The first argument is always a fieldset containing an lnsp field. If no other parameter is given, the list of levels will range from 1 to (number of vertical coordinates/2)-1 as coded then pressure is computed for all model levels that are described in the GRIB header of fieldset .
    • If number is given (always the last parameter) it is the lnsp .parameter code (default is 152).
    • list should contain model levels for which pressure is to be computed. Note that also for a single model level one has to use a list (this is a signature difference compared to the old function pressure() ).
    • If fieldset is given as the second parameter then pressure is computed for those model levels found in the second The second argument specifies the levels at which the output fields must be generated. To generate a single level, pass a number. For more than one level, either pass a list of levels or a fieldset. If a fieldset is passed as the second parameter, the level information is extracted from each field of the fieldset.

Missing values in the lnsp field are retained in the output fieldset.

 

fieldset unipressure unithickness ( fieldset )
fieldset unipressure unithickness ( fieldset,fieldset )
fieldset unipressure unithickness ( fieldset,list )
fieldset unipressure unithickness ( fieldset,number )
fieldset unipressure unithickness ( fieldset,fieldset,number )
fieldset unipressure unithickness ( fieldset,list,number )

This function creates fields of pressure thickness from the logarithm of the surface pressure (lnsp) and a list of model levels. Unlike pressurethickness() , this function works with all grid types known to Metview (not just lat/long); it also allows the user to override the parameter number for lnsp (default 152).

    • The first argument is always a fieldset containing an lnsp field. If no other parameter is given, then pressure thickness is computed for all model levels that are described in the GRIB header of fieldset .
    • If number is given (always the last parameter) it is the lnsp parameter code (default is 152).
    • list should contain model levels for which pressure thickness is to be computed. Note that also for a single model level one has to use a list (this is a signature difference compared to the old function pressurethickness() ).
    • If fieldset is given as the second parameter then pressure thickness is computed for those model levels found in the second fieldset.

Missing values in the lnsp field are retained in the output fieldset.

 

...

fieldset unithickness univertint ( fieldset, fieldset)
fieldset unithickness univertint ( fieldset, list fieldset )
fieldset unithickness univertint ( fieldset, number )
fieldset unithickness univertint ( fieldset, fieldset, number )
fieldset unithickness univertint ( fieldset, fieldset, list,number )

This function creates fields of thickness from the logarithm of the surface pressure (lnsp) and a list of model levels. Unlike thickness() , this function works with all grid types known to Metview (not just lat/long); it also allows the user to override the parameter number for lnsp (default 152).

...

Universal vertical integration. This function is similar to vertint() , except that univertint() also works with sparse levels whereas vertint() is restricted to continuous levels.

This function performs a vertical integration of the input fieldset. If just one fieldset is given, it must also contain the logarithm of the surface pressure (lnsp). If the function is called with two fieldsets, the first one is a fieldset containing an lnsp field

...

, the second one is the multi-level fieldset. A number may optionally be given as the last parameter in order to specify the lnsp code used in the fieldset that contains the lnsp data; its default value is 152. If a list with two elements [top, bottom] is given as the third parameter, then the integration is performed between (and including) these layers.

A missing value in any field will result in a missing value in the corresponding place Missing values in the lnsp field are retained in the output fieldset.

 

fieldset univertint ( fieldset)
fieldset univertint ( fieldset, fieldset )
fieldset univertint ( fieldset, number )
fieldset univertint ( fieldset, fieldset, number )
fieldset univertint ( fieldset, fieldset, list)

Universal vertical integration. This function is similar to vertint() , except that univertint() also works with sparse levels whereas vertint() is restricted to continuous levels.

This function performs a vertical integration of the input fieldset. If just one fieldset is given, it must also contain the logarithm of the surface pressure (lnsp). If the function is called with two fieldsets, the first one is a fieldset containing an lnsp field, the second one is the multi-level fieldset. A number may optionally be given as the last parameter in order to specify the lnsp code used in the fieldset that contains the lnsp data; its default value is 152. If a list with two elements [top, bottom] is given as the third parameter, then the integration is performed between (and including) these layers.

The function computes :

Image Added

Where f is the fieldset, p is the pressure and g the acceleration of gravity.

 


date or list valid_date ( fieldset )

Returns the valid dates (including the time components) of the given fields. If the fieldset has only one field, a date is returned; otherwise a list of dates is returned.

 

vector or list values ( fieldset )

This function returns the grid point values as a vector. If the fieldset contains more than one field it returns a list of vectors. Each of these vectors contains as many elements as grid points in each field. Missing values are included in the results as vector_missing_value.

# x is a fieldset of n fields
xgrid = values(x)
field1_values = xgrid[1]
gridpoint1 = field1_values[1]

# or equivalently
gridpoint1 = xgrid[1][1]


fieldset var ( fieldset )

Computes the variance of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset.

The function computes :

Image Removed

Where f is the fieldset, p is the pressure and g the acceleration of gravity.

 

date or list valid_date ( fieldset )

Returns the valid dates (including the time components) of the given fields. If the fieldset has only one field, a date is returned; otherwise a list of dates is returned.

 

vector or list values ( fieldset )

This function returns the grid point values as a vector. If the fieldset contains more than one field it returns a list of vectors. Each of these vectors contains as many elements as grid points in each field. Missing values are included in the results as vector_missing_value.

...

With n fields in the input fieldset, if xik is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :
Image Added
Note that the following lines are equivalent :

y = var(x)
y = mean(x*x)-mean(x)*mean(x)

 

number or list var_a ( fieldset )
number or list var_a ( fieldset,list )

Computes the variance over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

fieldset vertint ( fieldset )

fieldset vertint ( fieldset,fieldset )

This function performs a vertical integration of the input fieldset, which must contain a range of model levels for the same parameter

...

fieldset var ( fieldset )

Computes the variance of a fieldset. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. With n fields in the input fieldset, if xik is the ith value of the kth input field and yi is the ith value of the resulting field, the formula can be written :
Image Removed
Note that the following lines are equivalent :

y = var(x)
y = mean(x*x)-mean(x)*mean(x)

 

number or list var_a ( fieldset )
number or list var_a ( fieldset,list )

Computes the variance over a weighted area. The area, if specified, is a list of numbers representing North, West, South, East. If the area is not specified, the whole field will be used in the calculation. The result is a number for a single field, or a list for a multi-field fieldset.

 

fieldset vertint ( fieldset )

fieldset vertint ( fieldset,fieldset )

This function performs a vertical integration of the input fieldset, which must contain a range of model levels for the same parameter. A missing value in any field will result in a missing value in the corresponding place in the output fieldset. If the function is called with the fieldset as its single argument, it must also contain the logarithm of the surface pressure (lnsp ). If the function is called with two parameters, the first one is a fieldset containing an lnsp field, the second one is the multi-level fieldset.

The function computes :

Image Removed

Where f is the fieldset, p is the pressure and g the acceleration of gravity.

The following example computes the total amount of liquid water in the atmosphere by integrating the cloud liquid water content (clwc ) over all levels of the model :

   

...

If the function is called with the fieldset as its single argument, it must also contain the logarithm of the surface pressure (lnsp ). If the function is called with two parameters, the first one is a fieldset containing an lnsp field, the second one is the multi-level fieldset.

The function computes :

Image Added

Where f is the fieldset, p is the pressure and g the acceleration of gravity.

The following example computes the total amount of liquid water in the atmosphere by integrating the cloud liquid water content (clwc ) over all levels of the model :

   

# Retrieve clwc
clwc = retrieve(
   levtype : "ml",
   levelist : [1,"to",31],
   param : "clwc",
   date : -1,
   grid : [2.5,2.5]
)

# Retrieve lnsp
lnsp = retrieve(
   levtype : "ml",
   levelist : 1,
   param : "lnsp",
   date : -1,
   grid : [2.5,2.5]
)

# Integrate the field
x = vertint(lnsp,clwc)

plot(x)

   
 

fieldset vorticity (fx fieldset, fy: fieldset)

Computes the vertical component of the curl differential operator for 2-dimensional vector fields. For wind fields (i.e. when the input fieldsets are u and v wind components) this computes the relative vorticity (ζ). The computations for a vector field f=(fx ,fy ) are based on the following formula :

Mathdisplay
 \zeta =\frac{1}{R \ cos\phi}\frac{\partial f_y}{\partial \lambda} - \frac{1}{R}\frac{\partial f_x}{\partial \phi} + \frac{f_x}{R}tan\phi

where

    • R is the radius of the Earth
    • φ is the latitude
    • λ is the longitude.

The derivatives are computed with a second order finite-difference approximation. The resulting fields contain missing values on the poles. If the input fields are horizontal wind components the GRIB paramId of the resulting field is set to 138 (relative vorticity). Please note that this function is only implemented for regular latitude-longitude grids.

...