...
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 |
|
Working with dates
There are several differences between the usage of the date object in Macro and the datetime object in Python. You will find a few examples below to compare the various date manipulation techniques used in Macro and Python, respectively.
Macro | Python |
---|
Code Block |
---|
| # Metview Macro
# creating
d = 2000-01-04 09:50:24
today = date(0)
yesterday = date(-1)
# arithmetic
d = d + hour(9) + minute(50) + second(24)
# using an increment of 2 days
for d = 2018-11-01 to 2018-11-10 by 2 do
(...)
end for
# using an increment of 6 hours
for d = 2018-11-01 to 2018-11-10 by hour(6) do
x = retrieve(
date : yymmdd(d),
time : hhmm(d),
...)
(...)
end for
|
|
Code Block |
---|
| import metview as mv
import numpy as np
from datetime import datetime, timedelta
# creating
d = datetime(2000, 1, 4, 9, 50, 24)
today = datetime.today()
yesterday = datetime.today() - timedelta(1)
# arithmetic
d = d + timedelta(hours=9, minutes=50, seconds=24)
# using an increment of 2 days
d0 = datetime(2018,11,1)
d1 = datetime(2018,11,10)
dt = timedelta(days = 2)
for d in np.arange(d0, d1, dt):
(...)
# using an increment of 6 hours
d0 = datetime(2018, 11, 1)
d1 = datetime(2018, 11, 10)
dt = timedelta(hours = 6)
for d = np.arange(d0, d1, dt):
x = mv.retrieve(date =d,
time = d.hour,
...)
(...)
|
|
Additional data export features
...