Versions Compared

Key

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

...

The first argument is the name of the function, the subsequent arguments will be passed to the function.

Things to watch out for

Although it's easy to convert an existing macro into a Python script, there are some 'gotchas' to be aware of.

  • Macro indexing starts at 1, but Python indexing starts at 0. Aside from the standard Python structures such as lists, this is also true for Metview classes such as Fieldset. Given a fieldset fs, the first field is obtained in Macro by fs[1], but in Python it is obtained by fs[0].
  • In order to support the more interactive coding environments provided by Python, any call to the plot() command will immediately produce a plot. This is different from Macro, where plots are delayed until the end. The result of this is that multiple plot() commands in Python will result in multiple plot windows. Fortunately, a single plot() command can be given any number of items, including multiple pages. To see how to produce a multi-plot layout, please see the  Layoutx3 In Python gallery example.