Versions Compared

Key

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

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.

MacroPython


Code Block
languagepy
# 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)
print(
mean
integrate(diff
_vals
))



Code Block
languagepy
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)

print(mv.
mean
integrate(diff
_vals
))