...
Any Metview function that normally returns a vector will return a numPy array when called from Python. For example, the follownig fieldset functions return numPy arrays:
Code Block | ||
---|---|---|
| ||
a = mv.read('my_data.grib') # returns a Fieldset lats = mv.latitudes(a) # returns a numPy array lons = mv.longitudes(a) # returns a numPy array vals = mv.values(a) # returns a numPy array |
...
The Fieldset object has an additional method, to_dataset()
, which produces an xarray Dataset object from the given fieldset. This is an N-dimensional data array based on the Common Data Model used in netCDF. For example:
Code Block | ||
---|---|---|
| ||
import metview as mv t2m_fc = mv.retrieve( type = 'fc', levtype = 'sfc', param = ['2t', '2d'], date = -5, step = list(range(0, 48+1, 6)), grid = [1,1] ) xa = t2m_fc.to_dataset() print(xa) |
will produce the following output:
Code Block | ||
---|---|---|
| ||
<xarray.Dataset> Dimensions: (latitude: 181, longitude: 360, step: 9, time: 1) Coordinates: * time (time) datetime64[ns] 2018-05-10T12:00:00 * step (step) timedelta64[ns] 0 days 00:00:00 0 days 06:00:00 ... * latitude (latitude) float64 90.0 89.0 88.0 87.0 86.0 85.0 84.0 83.0 ... * longitude (longitude) float64 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 ... Data variables: 2t (time, step, latitude, longitude) float32 ... 2d (time, step, latitude, longitude) float32 ... Attributes: Conventions: CF-1.7 comment: GRIB to CF translation performed by xarray-grib |
...