Versions Compared

Key

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

...

Inspect the supplied GRIB files: z500_fc.grib contains geopotential forecasts made in one run, but for six different forecast steps; z500_an.grib contains analysis fields for two times. Visualise the supplied Geographical View icon and drop the forecast GRIB icon along together with its corresponding Contouring icon (cont_fc)into the Display Window, and then drop the analysis GRIB icon along together with its corresponding Contouring icon (cont_an) too. Go through the frames of animation. The fields have been overlaid, but if you look at the times and dates in the title, you will see that they do not match. Metview has simply plotted the first field of each data file together, then the second, and so on. We can make it more intelligent.

...

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).

...

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:

...

Visualise the macro. Your plot may be blank! (Why?) There is one more trick: we have created a derived field, and this changes the automatic scaling algorithm used when plotting. Precipitation is stored in metres, but we want to display it in mm. Modify the precip_shade icon and set:

...

Compute and print the difference between your two dates, d2 and d1. 

Looping through dates

Three examples (no need to type these in, but the code is in a macro called dates in the solutions folder), to get a feel for it:

...