...
Code Block | ||
---|---|---|
| ||
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
...
the 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:
...
The final calculation requires converting the time intervals into hours (because if the time difference between two steps is 7 hours, then the rate of precip per hour is the mean precip value divided by 7).
Computing a climatology
The supplied GRIB file era_t2m_jan_2010_2014.grib contains 2 metre temperature fields from the ERA Interim data set, interpolated onto a low-resolution 5x5 degree grid. The data are from years 2010 to 2014 and only include the month of January. The data are also from two times: 00:00 and 12:00. Check that all of this is true!
We will compute a small climatology dataset, which will simply be the mean of all these fields. Write a small macro to do this - it should be just 2 lines long: one to read the GRIB file, and one to compute the mean (simply the mean()
function). Return or plot the result to confirm that it looks sensible.
Info |
---|
Remember that the result is a derived field, and so the default temperature scaling from Kelvin to Celcius will not be applied unless Grib Scaling of Derived Fields is set to On in the Contouring icon. |
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.
Extracting dates from other data types
...