Versions Compared

Key

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

...

#Metview Macro
flx=read("res_multi.txt")
Now variable flx holds all the data in our FLEXTRA output. First, we will find out the number of trajectory groups we have by using the count() function.
num=count(flx)
Now we will create a for loop to go though all the trajectory groups and extract and print some data out of them:
for i=1 to num do
vals=flextra_group_get(flx[i],["name","type"])
print("tr: ",i," name: ",vals[1]," type: ",vals[2])
end for
Here we used the flextra_group_get() function to read the value for a list of metadata keys from the i-th trajectory group. Please note that just as in the previous step we specified the trajectory group by the [] operator.
In the next step we will read some data from the first trajectory of the second trajectory group (volcano Stromboli). It goes like this:
vals=flextra_tr_get(flx[2],1,["date","lat","lon"]
In the last step we print the data:
print(" ")
print("date: ",vals[1])
print("lat: ",vals[2])
print("lon: ",vals[3])
Now, if you run this macro you will see the data values appearing in the standard output.

...

Input Data Preparation

In this exercise we will see how to generate input data for FLEXTRA runs from ECMWF's MARS archive. Please note that to run the examples you need to have a Metview version being able to connect to MARS. Please open folder 'prepare' in folder 'flextra_tutorial' to start the work.

...

FLEXTRA expects input data on a regular latitude-longitude grid in GRIB format. The input data must contain four three-dimensional fields: the two horizontal wind components, vertical velocity and temperature. Two additional two-dimensional fields are needed as well: topography and surface pressure.

The three-dimensional input data has to be available on ECMWF model (i.e. h) levels defined by a hybrid vertical coordinate system. An important restriction is that all the data fields used within a FLEXTRA run must have the same domain size, resolution, number of levels, etc.

All the required fields, with one exception, can be retrieved from ECMWF's MARS archive. The only exception is the vertical velocity because FLEXTRA needs the following field for its computations:
∂p∂η

The problem with this product is that only is archived in MARS and the full product needs to be computed during the data preparation process.

All the input GRIB files for a FLEXTRA run have to be located in the same folder and the following naming convention has to be used: ENyymmddhh.

In addition to the GRIB files a FLEXTRA run requires several parameter files as well. Most of these files are automatically generated by Metview in the background, so users do not need to create them. The only exception is the file called AVAILABLE describing the input dates, times and GRIB files. This file can be optionally provided by the users (as we saw it in Part 3 ).

...

The FLEXTRA Prepare icon is used to generate all the input data needed for a FLEXTRA run including the MARS retrievals, the computations and the generation of the AVAILABLE file as well. You can find this icon in the Modules (Data) icon drawer.

Image Modified

Create a new FLEXTRA Prepare icon by dragging it into your folder and rename it 'prepare'.

First, open its editor and set the following parameters:

...

The selected option ('Forecast') for parameter Flextra Prepare Mode indicates that we want to generate the input data from a given forecast. We specified the run date (-1 means yesterday) and run time of the forecast and defined the forecast steps as well. We used a relative date here because MARS retrievals are much faster for current dates.

In the next step we define the area and grid:

...

Here you need to define the output directory where the GRIB files and the AVAILABLE file will be generated. Please note that the resulting files are rather small (around 1.5 Mb in total) so probably you do not need to worry about your quota.

Warning

Please be aware that the preparation process is currently only working for operational forecasts having 91 or 137 model levels and requires parameter etadot from MARS. Because parameter etadot has only been archived in MARS since 4 June 2008, earlier dates cannot be used.


Remarks

...

  • Parameter Flextra Prepare Mode can be set to 'Period' to retrieve input data between a specified starting and ending date.

...

Now open a terminal window and check the content of your output directory. When this tutorial was written our FLEXTRA Prepare icon generated the following results (remember we used relative dates in the icon so your current dates will be different). :

Code Block
244 	2012-02-02 16:08 AVAILABLE

...


547200 	2012-02-02 16:07 EN12020100

...


547200 	2012-02-02 16:08 EN12020103

...


547200 	2012-02-02 16:08 EN12020106

 If we check the AVAIALBLE file itself we will see the following content (again, you will see different dates in your file):

Code Block
DATE TIME FILNAME SPECIFICATIONS

...


YYYYMMDD HHMMSS

...


_____________________________________________

...


20120131 000000 EN12013100 ON DISC

...


20120131 030000 EN12013103 ON DISC

...


20120131 060000 EN12013106 ON DISC

Input Data Caching

Edit and save your FLEXTRA Prepare icon (Apply) again. You should see that the title of the icon turned black. For other icons it would mean that the data cached by the icon got deleted. Do not worry, you did not lose your precious data with this action because caching works differently for the FLEXTRA Prepare icon. Even if you delete the icon you will not lose your data and it will remain untouched in the output directory. You need to delete it manually if you want to remove it from the file system. Naturally if you generate a new dataset for the same date, time and steps but with a different grid the original data will be overwritten. Now right

Right-click and execute to start the data preparations again. This time your icon turnes green almost immediately indicating that actually no data retrieval and processing happened. The reason for it is that we set parameter Flextra Reuse Input to 'On'. In this case Metview checks the existence of the data to be generated and if the data is already in place no new data is retrieved. The same happens with the AVAILABLE file.
Remarks:  

Info

If parameter Flextra Reuse Input is set to 'On' Metview confirms the existence of a GRIB file by using the file name and a set of GRIB API keys from the first message in the file. This is the list of the keys that are checked:

  • date, time, stepRange
  • gridType
  • iDirectionIncrement, jDirectionIncrement
  • latitudeOfFirstGridPoint, latitudeOfLastGridPoint
  • longitudeOfFirstGridPoint, longitudeOfLastGridPoint

...

Running FLEXTRA with the FLEXTRA Prepare Icon

...