Versions Compared

Key

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

...

The Geopoints data type as an additional function, to_dataframe(), which can be used to produce a Pandas Dataframe object as shown:

Code Block
languagepy
import metview as mv
import pandas as pd

gpt = mv.read("gpts.gpt") # returns a Geopoints
df = gpt.to_dataframe()   # returns a Pandas Dataframe
print(df.head())

...

Code Block
languagetext
                 date  latitude   level  longitude    value
0 2018-01-14 12:00:00      30.0  1000.0      -24.0  288.736
1 2018-01-14 12:00:00      30.0  1000.0      -18.0  288.736
2 2018-01-14 12:00:00      30.0  1000.0      -12.0  286.736
3 2018-01-14 12:00:00      30.0  1000.0       -6.0      NaN
4 2018-01-14 12:00:00      30.0  1000.0        0.0      NaN

Xarray Datasets

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

This is based on the xarray GRIB driver, which is not yet available outside of Metview, but is planned to be released and ultimately integrated into xarray.

Icon functions

Macro functions which correspond to icons, such as retrieve(), which corresponds to the Mars Retrieval icon, can take their arguments in a number of ways:

...