...
Macro | Python | Notes |
---|---|---|
number | number | |
string | string | |
list | list | Can also pass a tuple to Macro, and it will be converted to a Macro list |
fieldset | Fieldset | Lightweight wrapper class in Meview-Python |
geopoints | Geopoints | Lightweight wrapper class in Meview-Python |
observations | Bufr | Lightweight wrapper class in Meview-Python |
netcdf | NetCDF | Lightweight wrapper class in Meview-Python |
odb | Odb | Lightweight wrapper class in Meview-Python |
table | Table | Lightweight wrapper class in Meview-Python |
vector | numPy array | |
date | datetime | Can also pass a date or a datetime64 to Macro |
definition | dictionary | |
nil | None |
Additional data export features
NumPy arrays
Any Metview function that normally returns a vector will return a numPy array when called from Python. For example:
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 |
Pandas Dataframes
The Geopoints data type as an additional function, to_dataframe()
, which can be used as shown:
Code Block | ||
---|---|---|
| ||
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()) |
Output:
Code Block |
---|
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 |
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:
...