Versions Compared

Key

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

Overview

Time is a very important dimension in meteorology, and there are many things to keep in mind. Here we will explore how Metview handles the fourth dimension.

XXX download

Overlaying Time Steps

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 with its corresponding Contouring icon into the Display Window, and then drop the analysis GRIB icon along with its corresponding Contouring icon 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.

...

Save the icon, visualise it and drop the data with their visdefs in again. Go through the animation steps and look at the Frames tab in the Display Window to see what has happened. Now the fields will be overlaid only if their valid date and time match.

Metview's overlay rules

To summarise, Metview's overlay rules can be described like this:

...

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

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

...

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.

Dates in Macro

Macro has specific date-handling abilities. Dates are a built-in data type which in fact describe both a date and a time.

Defining dates

You can create date variables in a number of ways:

...

Code Block
d1 = 2015-03-11 12:00

Converting numbers into dates

The date() function converts numbers into dates using the same syntax that MARS understands. For example:

...

Note that when passing numeric dates such as 20150105 to other modules, such as the MARS Retrieval module, these do not need to be converted into date variables. However, MARS treats Date and Time as separate parameters, so a date variable would need to be split into these components.

Date arithmetic

When dealing with dates, the number 1 represents one day. So the expression d1 + 1 gives a date one day later than day 1. To compute the difference, in days, between two dates, it's simply:

...

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

Looping through dates

Three examples (no need to type these in), to get a feel for it:

Code Block
languagepy
for d = 2015-01-01 to 2015-03-01 do
    print(d)  # each step is 1 day
end for

for d = 2015-01-01 to 2015-03-01 by 2 do
    print(d)  # each step is 2 days
end for

for d = 2015-01-01 to 2015-03-01 by hour(6) do
    print(d)  # each step is 6 hours
end for

Computing mean precipitation rate at a point

As an exercise to put all of this together, we will write a new macro to compute the precipitation rate in mm per hour at a  particular location for each time step. The steps will be:

...