values
- values(fs)
Returns the grid point values in
fs
as an ndarray.- Parameters
fs (
Fieldset
) – input fieldset- Return type
ndarray
If
fs
contains more than one field a 2D-ndarrays is returned. Missing values are included in the results as nan.- Example
import metview as mv # fs is a fieldset of n fields vals = mv.values(fs) # values in the first field first_vals = vals[0] # first value in the first field first_gridpoint = first_vals[0] # or equivalently first_gridpoint = vals[0][0]
- values(gpt[, index_or_name])
Returns the values in the specified values column of
gpt
.- Parameters
gpt (
Geopoints
) – input geopointsindex_or_name (number or str) – index or name of the values column to be returned from
gpt
- Return type
list or ndarray
If
index_or_name
is specified and is a number it refers to the index of the column within the value columns (and not within all the columns ingpt
). E.g. 0 means the first value column.index_or_name
has to be used forGeopoints
of ‘ncols’ type. In all the other types the values column is uniquely identified.If the values column contains str the return will be a list, otherwise an ndarray is returned.
- Example
import metview as mv gpt = mv.read("my_data.gpt") # get values from the 4th column a = mv.values(gpt, 3) # get values from column named "geopotential" a = mv.values(gpt, "geopotential") # direct indexing can also be used a = gpt["geopotential"]
- values(nc[, index])
Returns all the values of the current NetCDF variable in
nc
.- Parameters
nc (
NetCDF
) – input NetCDFindex (list) – value index (zero-based)
- Return type
ndarray or list of str or list of datetime.datetime
To define a hypercube for the value extraction
index
has to be specified as a list with the same number of elements as the number of dimensions of the current NetCDF variable. The elements (except one) should be numbers, specifying the indexes (0-based) into the respective dimensions from where the value(s) are to be taken. If all the elements are numbers, then they simply specify the coordinates for a single value (returned as a single-value array). Optionally, one of the elements can be set to the string ‘all’; in this case, all the values from that dimension are returned.- Example
If the current NetCDF variable is defined with 3 dimensions: Q(time, region, exp) then we can obtain the values for all times, for the second region and the fifth exp with this syntax:
v = mv.values(nc, ['all', 1, 4])