Versions Compared

Key

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

...

Code Block
languagepy
precip = read("precip.grib")

n = count(precip) # the number of fields in the fieldset
precip_3h = precip[2, n] - precip[1, n-1]
return precip_3h

...

Visualise your macro result again and confirm that you now have precipitation only for the 3-hour periods, which does not accumulate with each frame.

Note that the meta-data for each field is taken from the first field in each subtraction; "step9 minus step6" returns a field with meta-data from step9, so be aware of this. Macro has functions for setting GRIB meta-data if you need to change it in order to correctly describe the new data.