Versions Compared

Key

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

...

Info
titleRule 2
Multiple data provided in several data icons are overlaid according to the overlay setting in the current view.

 

Hovmoeller?

Precipitation

Precipitation data provides an interesting challenge. Precipitation fields in MARS are stored as accumulated fields. Visualise the supplied precip.grib icon with the precip_shade visdef. The first field is empty (check using the Cursor Data). The first field has a step of 0, meaning that it contains the total precipitation accumulated between the run time and the run time plus step. Since these are the same, there is no accumulated precipitation! Subsequent steps show more and more precipitation (the amount accumulated over 3, 6, 9, etc hours).

What if we want to plot just the rain that accumulated between 06:00 and 09:00? That would be the accumulated precip at 09:00 minus the accumulated precip at 06:00. We can compute this in a macro.

Create a new Macro icon and rename it compute_precip.

We can see from examining the file that the 6 and 9 o-clock steps are fields 3 and 4 respectively (using 1-based indexing). So the following macro code will compute the difference and return it:

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

precip_6_to_9 = precip[4] - precip[3]
return precip_6_to_9

Visualise the macro to plot it.

Now we want to go further and compute the precipitation for each 3-hour period. We can do this with more complex field indexing.

To extract fields 1 to 4, for example, we can use the following syntax:

Code Block
languagepy
fields = precip[1,4]