Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confirmed.
Scroll pdf ignore
Panel
titleDownload
Expand
titleClick here for files to download...
Excerpt Include
A Quick Tour of Metview
A Quick Tour of Metview
nopaneltrue

Attachments
uploadfalse
oldfalse
patterns*.tar.gz,*.grib,*.grb
sortByname

Time

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

Overlaying Time Steps

Image Added

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 together with its corresponding Contouring icon (cont_fc) into the Display Window, and then drop the analysis GRIB icon together with its corresponding Contouring icon (cont_an) too.

Time

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

Overlaying Time Steps

Image Removed

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

Edit the Geographical View icon and set this:

Map Overlay ControlBy Date

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.

...

Visualise the macro. If you drop the precip_shade visdef icon into the plot, it may become blank! 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:

Grib Scaling of Derived FieldsOn

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.

...

Code Block
languagepy
dates = nil
for i = 1 to n do
   print(i) # we will put proper code here in the next step!
end for

Extract the date and time from each field

You can get the date and time of a field as numbers like this, inside the loop, where i is the field index:

Code Block
languagepy
d = grib_get_long(precip[i], 'validityDate')
t = grib_get_long(precip[i], 'validityTime')

Print the results of these to understand the numbers that are being returned.

Info
The grib_get() functions are general-purpose functions to get pieces of meta-data from a GRIB field, specified by keys such as 'validityDate'. The Grib Examiner can help you find the available keys. These are handled by the GRIB_API library.

Convert these numbers into a date variable

date and time from each field

You can get the valid date (including its time) of a field like this, inside the loop, where i is the field indexThe date (d) can be converted with the date() function into a proper date variable. You will need to divide the time variable (t) to convert it into a fraction of a day before adding it to the date variable (d). A time of 12:00 is returned as 1200, so we need to divide by 100 to get it into hours. The hour() function then converts it into a fraction of a day.  Add the two together to create a full date variable:

Code Block
languagepy
dt = valid_date(d) + hour(t/100)precip[i])

Print the result to see what's being returned.

Add the date to the list

We add it to the list like this (inside the loop):

Code Block
languagepy
dates = dates & [dt]

Compute the differences between consecutive dates

This is very similar to computing the precipitation data earlier (ok, we know it's 3 hours, but in theory it could be anything). We do this after the previous loop:

...

Often, these climatological averages are computed individually for each time step. So in our case, we want to now produce two means: one for all the fields at 00:00 and one for all the fields at 12:00. Hint: use the GRIB Filter icon (and its equivalent Macro code) to extract all the fields where Time = 0, and compute their mean. Do the same with all the 12:00 fields. Concatenate the two mean fields into a 2-field fieldset and plot it.

...

The easiest way to extract dates from a BUFR file is to convert it to geopoints using the Observation Filter and then extract the dates from the resulting geopoints.

Other formats

then extract the dates from the resulting geopoints.

GRIB

For GRIB, we also have the base_date() function, which returns the model run time for each field.

NetCDF

The values() function will return a list of dates when the current variable is a time variable - see Data Part 2Extracting dates from other formats can be more tricky and will not be covered here.

Extra Work

If you have time, try the following.

...