Metview's Python interface provides access to all of Metview's Macro language functions, with automatic translations between data types. Here's an example that shows how to retrieve model and observation data and compute their difference, and the weighted mean value of that difference, both in Macro and in Python.
Macro | Python |
---|
Code Block |
---|
| # Metview Macro
t2m_fc48 = retrieve(
type : "fc",
levtype : "sfc",
param : "2t",
date : -5,
step : 48,
grid : "o1280")
synop = retrieve(
type : "ob",
repres : "bu",
date : -3)
synop_t2m = obsfilter(
output : "geopoints",
parameter : 012004,
data : synop)
|
|
diff = t2m_fc48 - synop_t2m
|
|
diff_vals = values(diff)
mean_vals |
Code Block |
---|
| import metview as mv
t2m_fc48 = mv.retrieve(
type = "fc",
levtype = "sfc",
param = "2t",
date = -5,
step = 48,
grid = "o1280")
synop = mv.retrieve(
type = "ob",
repres = "bu",
date = -3)
synop_t2m = mv.obsfilter(
output = "geopoints",
parameter = "012004",
data = synop)
|
|
diff = t2m_fc48 - synop_t2m |
|
diff_vals = mv.values(diff)mean_vals