Versions Compared

Key

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

...

MacroPythonNotes
numbernumber
stringstring
listlistCan also pass a tuple to Macro, and it will be converted to a Macro list
fieldsetFieldsetLightweight wrapper class in Meview-Python
geopointsGeopointsLightweight wrapper class in Meview-Python
observationsBufrLightweight wrapper class in Meview-Python
netcdfNetCDFLightweight wrapper class in Meview-Python
odbOdbLightweight wrapper class in Meview-Python
tableTableLightweight wrapper class in Meview-Python
vectornumPy array
datedatetimeCan also pass a date or a datetime64 to Macro
definitiondictionary
nilNone

Working with Fieldsets

Fieldsets work much the same as they do in the Macro language, but watch out for these things:

  • indexing starts at 0: first_field = my_fieldset[0]
  • comparison operators work the same, i.e. they return a fieldset of 1s and 0s: smaller = fs1 < fs2
  • equality and non-equality operators are == and !=
  • Fieldsets can be directly constructed either as empty, or with a path to a GRIB file:
    • f = mv.Fieldset()
    • f = mv.Fieldset(path='test.grib')
  • concatenation can be done like this:  my_fieldset.append(my_other_fieldset)
  • length of a fieldset can be found with the len function: num_fields = len(my_fieldset)
  • slicing works: my_fields = fs[0:6:2]
  • iteration works: for f in my_fieldset:  #do something

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.

...