This tutorial explains how to use the FLEXTRA trajectory model within Metview 4.
Note | ||
---|---|---|
| ||
Please note that this tutorial requires Metview version 45.3.0 or later. | ||
Warning | ||
This tutorial can only work at ECMWF it uses large local data files. |
Table of Contents |
---|
Preparations
...
You will create some icons yourself, but some are supplied for you - please download the following file:
Panel | ||
---|---|---|
| ||
and save it in your Alternatively, if at ECMWF then you can copy it like this from the command line: |
and save it in your $HOME/metview
directory. You should see it appear on your main Metview desktop, from where you can right-click on it, then choose execute to extract the files. You should now (after a few seconds) see a flexta_tutorial folder which contains the solutions and also some additional icons required by these exercises. You will work in the flextra_tutorial folder so open it up. You should see the following contents:
About FLEXTRA
What is FLEXTRA?
...
FLEXTRA can compute both forward and background backward trajectories using various trajectory types such as: three-dimensional, model level, mixing layer, isobaric and isentropic trajectories. Trajectory computations can be carried out in the three different modes. These are as follows:
...
Warning |
---|
Please note that FLEXTRA is not an ECMWF development. FLEXTRA is not distributed with Metview, but it has to be downloaded from the web site specified above and installed separately. It is installed at ECMWF though (see details here). |
About the Metview interface
...
The input data needed to run the examples of this tutorial is already prepared for you and located in the directory as follows:
Code Block |
---|
/scratch/graphics/cgr/flextra_data |
This directory contains folder Data. Here you find a set of GRIB files starting with the string "EN". These files are valid for the period of 2012-01-11 00 UTC to 2012-01-15 00 UTC. There is the AVAILABLE file here as well. It is a parameter file telling FLEXTRA the names and dates of the input GRIB files.
This dataset was generated through the Metview FLEXTRA interface.The chapter on data preparation explains how it works and helps prepare your own dataset if it is needed.
...
To compute trajectories with FLEXTRA we need to use the FLEXTRA Run icon (right-click in the desktop when no icons are selected and use the New icon ... menu).
Rename it 'run_normal' and open up its editor.
First, set the input data parameters:
Flextra Input Mode | Path |
Flextra Input Data Path |
../data | |
Flextra Available File Path | SAME_AS_INPUT_PATH |
The selected option ('Path') for parameter Flextra Input Mode indicates that we want to specify the input data and the AVAILABLE file by their paths. Because the AVAILABLE file is also located in the same directory as the input data we simply set parameter Flextra Available File Path to SAME_AS_INPUT_PATH (it is the default value). Otherwise the full path to the AVAILABLE file should have been typed in.
In the next step we will specify the starting dates of the group of trajectories we want to generate:
Flextra Run Mode | Normal |
Flextra Trajectory Direction | Forward |
Flextra Trajectory Length | 72 |
Flextra First Starting Date | 20120111 |
Flextra First Starting Time | 3 |
Flextra Last Starting Date | 20120111 |
Flextra Last Starting Time | 15 |
Flextra Starting Time Interval | 3 |
Flextra Output Interval Mode | Interval |
Flextra Output Interval Value | 3 |
Here we set the run mode to 'NORMAL' and defined a set of forward trajectories starting on 11 January 2012 at 3, 9,12 and 15 UTC. We set the length of the trajectories to 72 h and specified that the output data (i.e. trajectory waypoints) will be written out every three hours.
...
The last step is to define the starting point parameters:
Flextra Normal Types | 1 |
Flextra Normal Names | Katla |
Flextra Normal Latitudes | 63.63 |
Flextra Normal Longitudes | -19.05 |
Flextra Normal Levels | 1512 |
Flextra Normal Level Units | 1 |
With these settings we specified the trajectory type to be three-dimensional (see below for the list of IDs for trajectory types) and set the starting point to volcano Katla (on Iceland) with the height of 1512m.
...
Info | ||
---|---|---|
| ||
We set the trajectory type by its ID. The possible values are as follows:
The level units were also given by an ID. The possible values are as follows:
|
Parameter Flextra Output Interval Mode controls how the trajectory points are written out into the output file. It can have three values:
...
We only specified one starting point but in the chapter on multiple_outputs we will see how to work with multiple starting points for a NORMAL run.
Note | ||
---|---|---|
| ||
If global GRIB2 input fields generated by Metview are used in FLEXTRA 5 it incorrectly detects the domain and treats it as a limited area. As a consequence trajectories cannot cross the domain boundaries because the computation stops at the border. | ||
Note | ||
| ||
Another problem with global GRIB2 input fields is that FLEXTRA interprets the longitude span of the domain either as 0-360 or 180-540 (!!!) degrees depending on the geometry settings in the GRIB headers. The actual range can be figured out from the header of the FLEXTRA output files. In both cases we need to guarantee that the starting point we specify is in the given coordinate range. Otherwise FLEXTRA fails with the following message:
In the first case it is trivial to ensure we have the right coordinate values, while in the second case we need to add 360 to the longitude to make FLEXTRA accept the starting pointcross the domain boundaries because the computation stops at the border. |
Running FLEXTRA
Save your FLEXTRA Run icon (Apply) then right-click and execute to start the trajectory computations. Within a minute (it might take longer on your machine) the icon should turn green indicating that the run was successful and the results have been cached.
...
Our FLEXTRA run generated an ASCII file on output which is now represented by our FLEXTRA Run icon. Right-click and examine the icon to look to see its content. This action will start up a window showing the output generated by FLEXTRA. What you are looking at is a custom ASCII format describing the resulting trajectories and some metadata.
Info | ||
---|---|---|
| ||
Flextra assigns an exit code called stop index for each trajectory. Its value can be seen in the FLEXTRA output (the examiner highlights it in blue in the trajectory header). The possible values are as follows:
|
Now close the FLEXTRA examiner. Right-click and save the icon to get a local copy of the FLEXTRA output file. A File Save dialog will appear with a Selection box at the bottom where you can specify the output file name. Type here 'res_normal.txt' and click Ok. After a few seconds a FLEXTRA File icon with the selected name will appear in your folder.
This icon now stores your FLEXTRA output data. You can check its content by right-click and examine or edit.
...
To visualise your FLEXTRA output you need to use a FLEXTRA Visualiser icon.
Create a new FLEXTRA Visualiser icon and rename it 'plot_normal'. Edit it and drop your 'run_normal' FLEXTRA Run icon into the Flextra Data field. This specifies the FLEXTRA output to be visualised. (Please note that you could also have dropped your 'res_normal.txt' FLEXTRA File icon into the FLEXTRA Data field to specify the data to be plotted).
At this point we do not need to set any other parameters the default values will work for us. After these modifications your icon editor should look like this.
Visualising the Icon
...
telling us that we visualised a set of 3D forward trajectories starting from the point called 'Katla'. The legend contains the starting date, time and elevation for each trajectory.
Now click on the 'plot_normal' layer in the Layers tab (on the right hand side of the plot window). If you change the view by clicking on the View metadata toggle button
you will see the meta-data associated with the visualised trajectories.
Customising the Plot
...
To start with, we have to be aware that Metview assigns an integer ID to each trajectory before it gets visualised. The numbering starts at 1 and the original trajectory order is kept. In this way we assign thevalue the value of 1 to all the points in the first trajectory. We assign the value of 2 to the points if the second trajectory and so on for the rest of the trajectories. Then in the visualisation Metview uses symbol plotting to assign different graphical attributes to different values i.e. for different trajectories.
To see how it is working in detail let's create a Symbol Plotting icon. Rename it 'symbol' then edit it.
First, we need to set the symbol plotting type:
Legend | On |
Symbol Type | Marker |
Symbol Table Mode | Advanced |
With these settings we will plot markers (symbols) in the plot. We also set Symbol Table Mode to 'Advanced' so that we can define value intervals to which a separate maker type, colour and size can be assigned. We will construct these intervals by using the trajectory IDs. In this way the points of a given trajectory will all belong to the same interval.
The next step is to set the line properties:
Symbol Connect Line | On |
Symbol Connect Automatic Line Colour | On |
This means that we will connect the points of a given trajectory and use the same colour for the lines as for the symbols they connect.
The intervals should be set carefully so that each trajectory ID (we have five trajectories with IDs ranging from one to five) should have a separate interval:
Symbol Advanced Table Selection Type | Interval |
Symbol Advanced Table Min Value | 1 |
Symbol Advanced Table Max Value | 6 |
Symbol Advanced Table Interval | 1 |
The settings above define the following intervals:
...
The last step is to specify the graphical properties we want to assign to the intervals:
Symbol Advanced Table Max Level Colour | Cyan |
Symbol Advanced Table Min Level Colour | Blue |
Symbol Advanced Table Colour Direction | Clockwise |
Symbol Advanced Table Marker List | 15/18/12/14/15 |
Symbol Advanced Table Height List | 0.4 |
With these settings we will automatically generate our colour palette from a colour wheel by interpolating in clockwise direction between Symbol Advanced Table Min Level Colour and Symbol Advanced Table Max Level Colour.
The markers used to denote the trajectory points are defined by parameter Symbol Advanced Table Marker List (see below for the list of available markers).
Now save your changes and drop this icon into the plot to see the effect of the settings.
The identifiers of the available symbol markers are summarised in the table below:
Visualisation on XY Plots
...
After these modifications your icon editor should look like this.
Visualising the Icon
Save your FLEXTRA Visualiser icon (Apply) then right-click and visualise to plot the trajectories.
The Metview Display Window is popping up using a custom visualisation assigned to FLEXTRA files. The title and a legend have been built exactly in the same way as in the map-based visualisation (see Part 4 ).
...
Our plot was generated by using hard-coded symbol plotting settings for trajectory rendering. We can change these settings exactly in the same way as we did for our map-based plot (see Part 4 for details). Now we will not create a new icon but simply reuse the Symbol Plotting icon called 'symbol' we created in Part 4 . Drop this icon into the plot to see the effect of the settings.
Changing the View
We will further customise the plot by changing the axis value ranges and adding axis labels and grid-lines to it. To change these properties we need a Cartesian View icon. This time you do not need to create a new icon since there is one called 'xy_view' already prepared for you. Edit his icon to see how the view is constructed (please note that the axis properties are defined via the embedded Horizontal Axis and Vertical Axis icons). Then simply drag it into the Display Window and see how you plot has been changed.
Backward Trajectories
...
Copy your 'run_normal' FLEXTRA Run icon (either right-click + duplicate, or drag with the middle mouse button), and rename the duplicate 'run_normal_back' by clicking on its title. Open its editor and start editing the date and time related parameters (the input data parameters are already set correctly for us so we do not need to change them):
Flextra Run Mode | Normal |
Flextra Trajectory Direction | Backward |
Flextra Trajectory Length | 72 |
Flextra First Starting Date | 20120114 |
Flextra First Starting Time | 3 |
Flextra Last Starting Date | 20120114 |
Flextra Last Starting Time | 15 |
Flextra Starting Time Interval | 3 |
Flextra Output Interval Mode | Interval |
Flextra Output Interval Value | 3 |
Here we set the run mode to 'NORMAL' and defined a set of backward trajectories ending on 14 January 2012 at 3, 9,12 and 15 UTC. The trajectory length will be 72 h and the output data (i.e. trajectory waypoints) will be written out every three hours.
We finish the editing by setting the end point parameters:
Flextra Normal Types | 1 |
Flextra Normal Names | Reading |
Flextra Normal Latitudes | 51.45 |
Flextra Normal Longitudes | -0.97 |
Flextra Normal Levels | 1500 |
Flextra Normal Level Units | 1 |
We selected Reading as the end point and set the height to 1500 metres. We defined the trajectory type to be three-dimensional.
...
Save your FLEXTRA Run icon (Apply) then right-click and execute to start the trajectory computations. Within a minute (it might take longer on your machines) the icon should turn green indicating that the run was successful and the results have been cached. Right-click and examine the icon to look at its content. Please note that the first data column contains negative values indicating that we computed backward trajectories.
Visualising the Results
...
Create a new FLEXTRA Visualiser icon. Edit it and drop your 'normal_run_back' FLEXTRA Run icon into the Flextra Data field. Now save your settings (Apply) then right-click and visualise to plot the trajectories. After zooming into the proper area (or dropping the map_Reading icon into the plot) you should see something like this.
CET Run Mode
...
First, we need to set the input data parameters (in the same way as we did it in Part 3 ):
Flextra Input Mode | Path |
Flextra Input Data Path |
../data | |
Flextra Available File Path | SAME_AS_INPUT_PATH |
In the next step we will specify the run mode and some global parameters valid for all the trajectories:
Flextra Run Mode | Cet |
Flextra Trajectory Direction | Forward |
Flextra Trajectory Length | 72 |
Flextra First Starting Date | 20120111 |
Flextra First Starting Time | 3 |
Flextra Last Starting Date | 20120111 |
Flextra Last Starting Time | 3 |
Flextra Output Interval Mode | Interval |
Flextra Output Interval Value | 3 |
Here we set the run mode to 'CET' and defined a set of forward trajectories starting on 11 January 2012 at 3 UTC. The trajectory length will be 72 h and the output data (i.e. trajectory waypoints) will be written out every three hours. Please note that for simplicity we defined only one starting time (of course we could have defined multiple ones just like in the previous chapters).
We finish the editing by setting the starting point grid:
Flextra Cet Type | 3d |
Flextra Cet Name | Katla |
Flextra Cet Area | 63.63/-19.05/63.63/-19.05 |
Flextra Cet Dx | 1 |
Flextra Cet Dy | 1 |
Flextra Cet Top Level | 3000 |
Flextra Cet Bottom Level | 1500 |
Flextra Cet Dz | 500 |
Flextra Cet Level Units | Metres ASL |
With these settings we defined a horizontal grid with only one point (exactly at the position of volcano Katla) and specified four vertical layers from 1500 to 3000 m above seal level.
...
Create a new FLEXTRA Visualiser icon. Edit it and drop your 'run_cet' FLEXTRA Run icon into the Flextra Data field. Now save your settings (Apply) then right-click and visualise to plot the trajectories. After zooming into the proper area (or dropping the map_Katla Map View icon into the plot) you should see something like this.
FLIGHT Run Mode
...
Create a new FLEXTRA Run icon and rename it 'run_flight' then open its editor.
First, we need to set the input data parameters (in the same way as we did it in Part 3 ):
Flextra Input Mode | Path |
Flextra Input Data Path |
../data | |
Flextra Available File Path | SAME_AS_INPUT_PATH |
In the next step we will specify the run mode and some global parameters valid for all the trajectories:
Flextra Run Mode | Flight |
Flextra Trajectory Direction | Forward |
Flextra Trajectory Length | 72 |
Flextra Output Interval Mode | Interval |
Flextra Output Interval Value | 3 |
Here we set the run mode to 'FLIGHT' and defined a set of forward trajectories with the length of 72 h. The output data (i.e. trajectory waypoints) will be written out every three hours. Please note that this time we did not define any starting dates because in FLIGHT mode each starting point has its own starting date (see below). So parameters like Flextra First Starting Date etc. are disabled.
We finish the editing by setting the starting points, dates and times:
Flextra Flight Type | 3d |
Flextra Flight Name | track |
Flextra Flight Latitudes | 60/50/40 |
Flextra Flight Longitudes | -15/0/15 |
Flextra Flight Levels | 5000/12000/5000 |
Flextra Flight Level Units | Metres ASL |
Flextra Flight Starting Dates | 20120111/20120111/20120111 |
Flextra Flight Starting Times | 3/6/9 |
Here we set the trajectory mode to 'FLIGHT' and defined an imaginary flight track called 'track' with 3 points each being valid at a different time.
...
Create a new FLEXTRA Visualiser icon. Edit it and drop your 'run_flight' FLEXTRA Run icon into the Flextra Data field. Now save your settings (Apply) then right-click and visualise to plot the trajectories. After zooming into the proper area (or dropping the map_Eu icon Map View into the plot) you should see something like this.
Using Macro
...
There is also a macro equivalent command for icon FLEXTRA Prepare, which is used to prepare input data for FLEXTRA. Please see the chapter on data preparation for details on it.
Automatic macro generation
The quickest way to generate a macro is to simply save a visualisation on screen as a Macro icon. Visualise your 'plot_normal' FLEXTRA Visualiser icon again and click on the macro icon in the tool bar of the Display Window.
Now a new Macro icon called 'MacroFrameworkN' is generated in your folder. Right-click visualise this icon. Now you should see your original plot reproduced.
...
Please find below the list of the metadata keys used by flextra_group_get():
Key | Description | Might get a nil value |
---|---|---|
cflSpace | Spatial CFL criterion. |
cflTime | Temporal CFL criterion. |
direction | Trajectory direction. |
dx | West-east resolution of the input grid. |
dy | North-south resolution of the input grid. |
east | Eastern border of the input grid. |
integration | Integration scheme. |
interpolation | Interpolation type. |
maxInterval | The maximum interval between input fields. |
name | The name of group (= 'startComment'). |
normalInterval | The normal interval between input fields. |
north | Northern border of the input grid. |
runComment | Label for the FLEXTRA run. |
south | Southern border of the input grid. |
startComment | The name of the trajectory group (= 'name'). |
startDate | Date of starting points. | |
startEta | Model level of starting points. | |
startLat | Latitude of starting points. | |
startLon | Longitude of starting points. | |
startPres | Pressure of starting points. | |
startPv | Potential vorticity of starting points. | |
startTheta | Potential temperature of starting points. | |
startTime | Time of starting points. | |
startZ | Height (above sea ) of starting points. | |
startZAboveGround | Height (above ground) of starting points. | |
trNum | Number of trajectories in the group. |
type | Trajectory type. |
west | Western border of the input grid. |
Step 2 - Accessing Individual Trajectory Data
...
Please find below the list of the metadata keys used by flextra_tr_get()
:
Key | Description | Return value |
---|---|---|
date | Date. | list of dates |
eta | Model level. | vector |
lat | Latitude. | vector |
lon | Longitude. | vector |
pres | Pressure. | vector |
pv | Potential vorticity. | vector |
startDate | Date of starting point. | string |
startEta | Model level of starting point. | string |
startLat | Latitude of starting point. | string |
startLon | Longitude of starting point. | string |
startPres | Pressure of starting point. | string |
startPv | Potential vorticity of starting point. | string |
startTheta | Potential temperature of starting point. | string |
startTime | Time of starting point. | string |
startZ | Height (above sea) of starting point | string |
startZAboveGround | Height (above ground) of starting point | string |
stopIndex | Stop index of computations. | string |
theta | Potential temperature. | vector |
z | Height above sea level. | vector |
zAboveGroundLevel | Height above ground level. | vector |
Anchor | ||||
---|---|---|---|---|
|
...
Open the editor of 'run_multi' and start editing the starting point parameters (now we will use the same input data and starting date settings as in the original icon so we do not need to change these settings):
Flextra Normal Types | 1/1 |
Flextra Normal Names | Katla/Stromboli |
Flextra Normal Latitudes | 63.63/38.79 |
Flextra Normal Longitudes | -19.05/15.21 |
Flextra Normal Levels | 1512/926 |
Flextra Normal Level Units | 1/1 |
Here we defined two starting points: volcano Katla (as in Part 3 ) and volcano Stromboli. We set the starting heights to the real heights of these volcanoes and again we defined the trajectory types to be three-dimensional.
...
In NORMAL run mode FLEXTRA generates a separate output file for each starting point: i.e. in our case two output files were created. However, to have only one access point for all the outputs, Metview concatenates these files into one single file and the Flextra Run icon represents this concatenated file. Now right-click and examine the Flextra Run icon to look at its content.
You can see that the examiner has a different structure than we had in Part 3 when only one starting point was specified. On the left hand side there is a list showing the different starting points. In Metview we call the data represented by such an item a trajectory group (i.e. one trajectory group represents one output file). By selecting an item from this list its corresponding ASCII data will be displayed in the text browser in the right hand side.
...
Save your settings (Apply) then drop the icon into the plot. After zooming into the proper area (or dropping icon 'map_Eu' into the plot) you should see something like this.
Plotting in Macro
...
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:
Mathinline |
---|
\dot \eta \frac{\partial \eta}{\partial 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.
...
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.
Create a new FLEXTRA Prepare and rename it 'prepare'.
First, open its editor and set the following parameters:
Flextra Prepare Mode | Forecast |
Flextra Date | -1 |
Flextra Time | 0 |
Flextra Step | 0/3/6 |
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:
Flextra Area | 60/-25/70/-15 |
Flextra Grid | 1/1 |
We also indicate that we want to reuse the already existing input data (the meaning of this parameter will be explained later in detail):
Flextra Reuse Input | On |
Last, we need to define the output directory:
Flextra Output Path | your_path_to_flextra_data |
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.
...
Code Block |
---|
res=flextra_prepare( flextra_output_path: "/scratch/graphics/cgr/flextra_data", ... ) flextra_run( flextra_input_mode : "path", flextra_input_path : "/scratch/graphics/cgr/flextra_data", ... ) |
With this code we want to generate the input data for FLEXTRA with flextra_prepare() but we do not use the variable it returns in flextra_run().
Instead we simply use the path where the generated input data should be located. Now, because flextra_prepare() is executed asynchronously the macro starts to execute it and does not wait until it finishes but jumps immediately to flextra_run(). Then flextra_run() fails because the input data is not yet in place so the macro fails as well.
...