Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confirmed.

This tutorial explains how to use the FLEXTRA trajectory model within Metview 4.

Note
titleRequirements

Please note that this tutorial requires Metview version 5.0 or later.

...


Table of Contents

Preparations

...

You will create some icons yourself, but some are supplied for you - please download the following file:

Panel
titleDownload

flextra_tutorial.tar.gz

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.

Alternatively, if at ECMWF then you can copy it like this from the command line:
    cp -R /home/graphics/cgx/tutorials/flextra_tutorial ~/metview

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:

Image RemovedImage Added

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

Image RemovedImage Added

Rename it 'run_normal' and open up its editor.

...

Flextra Input Mode

Path

Flextra Input Data Path

/scratch/graphics/cgr/flextra_../data

Flextra Available File Path

SAME_AS_INPUT_PATH

...

Info
titleTrajectory types and levels

We set the trajectory type by its ID. The possible values are as follows:

  1. Three-dimensional
  2. Model layer
  3. Mixing layer
  4. Isobaric
  5. Isentropic

The level units were also given by an ID. The possible values are as follows:

  1. Metres above sea level
  2. Metres above ground levelevel
  3. Hectopascals

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
titleGRIB2 input fields

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
titleGRIB2 input fields

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:

"NOTICE: STARTING POINT OUT OF DOMAIN HAS BEEN DETECTED"

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.


Image Modified

Info
titleFLEXTRA stop index

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:

  1. Normal exit.
  2. The trajectory left the computation domain.
  3. The time difference between two wind fields was too large.
  4. No wind fields were available.

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.

Image RemovedImage Added

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.

Image RemovedImage Added

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.
Image Modified

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

Image RemovedImage Added

you will see the meta-data associated with the visualised trajectories.
Image Modified

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.

Image RemovedImage Added

First, we need to set the symbol plotting type:

...

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.

Image RemovedImage Added

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.


Image Modified

 The identifiers of the available symbol markers are summarised in the table below:

Image Modified

Visualisation on XY Plots

...

After these modifications your icon editor should look like this.


Image Modified

Visualising the Icon

Save your FLEXTRA Visualiser icon (Apply) then right-click and visualise to plot the trajectories.


Image Modified

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.


Image Modified

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.


Image Modified

Backward Trajectories

...

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.


Image Modified

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.


Image Modified

CET Run Mode

...

Flextra Input Mode

Path

Flextra Input Data Path

/scratch/graphics/cgr/flextra_../data

Flextra Available File Path

SAME_AS_INPUT_PATH

...

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.


Image Modified

FLIGHT Run Mode

...

Flextra Input Mode

Path

Flextra Input Data Path

/scratch/graphics/cgr/flextra_../data

Flextra Available File Path

SAME_AS_INPUT_PATH

...

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.


Image Modified

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.
Image Removed Image Added

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.

...

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.

(tick)

startEta

Model level of starting points.

(tick)

startLat

Latitude of starting points.

(tick)

startLon

Longitude of starting points.

(tick)

startPres

Pressure of starting points.

(tick)

startPv

Potential vorticity of starting points.

(tick)

startTheta

Potential temperature of starting points.

(tick)

startTime

Time of starting points.

(tick)

startZ

Height (above sea ) of starting points.

(tick)

startZAboveGround

Height (above ground) of starting points.

(tick)

trNum

Number of trajectories in the group. 


type

Trajectory type.

 


west

Western border of the input grid. 


Step 2 - Accessing Individual Trajectory Data

...

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.


Image Modified

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.


Image Modified

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.

Image RemovedImage Added

Create a new FLEXTRA Prepare and rename it 'prepare'.

...

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.

...