Metview's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This tutorial demonstrates how to generate plume trajectories with FLEXPART and how to visualise the results in various ways.

Using FLEXPART with Metview

Requirements

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

Preparations

First start Metview; at ECMWF, the command to use is metview (see Metview at ECMWF for details of Metview versions). You should see the main Metview desktop popping up.

The icons you will work with are already prepared for you - please download the following file:

Download

flexpart_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/flexpart_tutorial ~/metview

You should now (after a few seconds) see a flexpart_tutorial folder. Please open it up.

The input data

The input data is already prepared for you and is located in folder 'Data'. You will find a FLEXPART Prepare -old icon that was used to generate the data in folder 'Prepare'. The corresponding macro code can also be found there.

You do not need to run the data preparation. However, if you wish to do so please note that it requires MARS access and you must set the Output Path parameter accordingly.


Please enter folder 'plume_tr' to start working.

In this example we will generate forward trajectories by releasing atmospheric tracers from Newcastle.

The simulation itself is defined by the 'tr_run' FLEXPART Run icon and the 'rel_ncastle' FLEXPART Release icon, respectively. Both these are encompassed in a single macro called 'tr_run.mv'. For simplicity will use this macro to examine the settings in detail. 

The macro starts with defining the release like this:

rel_ncastle = flexpart_release(
	name	:	"NEWCASTLE",
	starting_date	:	0,
	starting_time	:	15,
	ending_date	:	0,
	ending_time	:	18,
	level_units	:	"agl",
	top_level	:	500,
	bottom_level	:	0,
	particle_count	:	10000,
	masses	:	1000,
	area	:	[54.96,-1.6,54.96,-1.6]
	)

This says that the release will happen over a 3 h period between heights in the lower 500 m at Newcastle and we will release 1000 kg of material in total.

Please note that

  • the species is not defined here (will be defined in flexpart_run())
  • we used dates relative to the starting date of the simulation (see also in flexpart_run())

The actual simulation is carried out by calling flexpart_run():

#Run flexpart (asynchronous call!)
r = flexpart_run(
	output_path	:	"result_tr",
	input_path	:	"../data",
	starting_date	:	20120517,
	starting_time	:	12,
	ending_date	:	20120519,
	ending_time	:	12,
	output_field_type	:	"none",
	output_trajectory	:	"on",
	output_area	:	[40,-25,66,10],
	output_grid	:	[0.25,0.25],
	output_levels	:	500,
	release_species	:	1,
	releases	:	rel_ncastle
 
print(r)

Here we defined both the input and output path and specified the simulation period, the output grid as well. We also told FLEXPART to only generate plume trajectories on output..

The actual species that will be released is defined as an integer number (for details about using the species see here). With the default species settings number 1 stands for tracer.

If we run this macro (or alternatively right-click execute the FLEXPART Run icon) the results (after a minute or so) will be available in folder 'result_tr'. The computations actually took place in a temporary folder then Metview copied the results to the output folder. If we open folder 'result_tr' we will see the 'tr_r1.csv' CSV file containing the plume trajectories. For details about the FLEXPART outputs click here.

Step 1 - Plotting the mean track

The macro to plot the mean trajectories is 'plot_tr_step1.mv'. We will see how this macro works.

First, we read the CSV file.

#The input file
dIn="result_tr_single"
inFile=dIn  & "/tr_r1.csv"

#Read table (CSV) data
tbl=read_table(table_filename: inFile,
    table_header_row: "2",
    table_meta_data_rows: "1")

Next, we determine the trajectory start date and time from the table header:

#Read runDate from table header
runDate=date(metadata_value(tbl,"runDate"))
runTime=number(metadata_value(tbl,"runTime"))
runDate=runDate + hour(runTime/10000)

#Read release start  date from table header
startSec=number(metadata_value(tbl,"start"))
releaseDate=runDate + second(startSec)

Next we read the coordinates of the mean track and define an Input Visualiser to plot it:

#Read columns from table
mLat=tolist(values(tbl,"meanLat"))
mLon=tolist(values(tbl,"meanLon"))

#visualiser
iv_curve = input_visualiser(
	   input_plot_type	:	"geo_points",
	   input_longitude_variable	:	mLon,
	   input_latitude_variable	:	mLat	  	  
	)

#line attributes
graph_curve=mgraph(graph_line_colour: "red",
         graph_line_thickness: "3",
         graph_symbol: "on",
         graph_symbol_marker_index: 15,
         graph_symbol_height: 0.5,
         graph_symbol_colour: "white",
         graph_symbol_outline: "on"
        ) 

Then we define the title:

txt="Mean trajectory starting at: " & 
             string(releaseDate,"yyyymmdd") & " " &
             string(releaseDate,"HH") & " UTC"

title=mtext(text_line_1: txt,
            text_font_size: 0.4)

the mapview:

Define map view
#Define coastlines
coast_grey = mcoast(
	map_coastline_thickness	:	2,
	map_coastline_land_shade	:	"on",
	map_coastline_land_shade_colour	:	"grey",
	map_coastline_sea_shade	:	"on",
	map_coastline_sea_shade_colour	:	"RGB(0.89,0.89,0.89)",
	map_boundaries	:	"on",
	map_boundaries_colour	:	"black",
	map_grid_latitude_increment	:	5,
	map_grid_longitude_increment	:	5
	)

#Define geo view
view = geoview(
	map_area_definition	:	"corners",
    area	:	[47,-16,57,0],
	coastlines: coast_grey
	)

and finally generate the plot:

plot(view,iv_curve,graph_curve,title)

Having run the macro we will get a plot like this:

Step 2 - Plotting the dates along the mean track

We will improve the trajectory plot by showing the waypoint dates along the track. 

The macro to use is 'plot_tr_step2.mv'. This macro is basically the same as the one in Step 1, but we have to modify and extend it a bit.

The first difference is that we need to determine the middle of the release interval since the trajectory waypoint times are given in seconds elapsed since this date. The release date reading part needs to be modified like this:

#Read release dates from table header
startSec=number(metadata_value(tbl,"start"))
endSec=number(metadata_value(tbl,"end"))
releaseDate=runDate + second(startSec)
releaseMidDate=runDate + second((endSec+startSec)/2)

Then we need to add a new plotting layer for the date labels. Using the information above we can build the list of strings we want to show along the track and use the Input Visualiser and Symbol Plotting to define the plot:

#Read waypoint times from table
#These are seconds elapsed since the middle of the release interval
tt=values(tbl,"time")

#Build the list of date strings to be plotted 
ttLst=nil
for i=1 to count(tt) do
    d=releaseMidDate + second(tt[i])
    ttLst = ttLst & [ "  " & string(d,"dd") & "/" & string(d,"HH")]
end for    

#visualiser
iv_date = input_visualiser(
	   input_plot_type	:	"geo_points",
	   input_longitude_variable	:	mLon,
	   input_latitude_variable	:	mLat	  	  
	)

#line attributes
sym_date=msymb(symbol_type: "text",
         symbol_text_list: ttLst,
         symbol_text_font_size: 0.3,
         symbol_text_font_colour: "navy"
        ) 

Finally the plot command has to be extended like this:

plot(view,iv_curve,graph_curve,iv_date,sym_date,title)

Having run the macro we will get a plot like this:

Step 3 - Plotting the cluster centres

The trajectory output file also contains the coordinates of the cluster centres. In this step we will show a possible way to plot this extra bit of information together with the mean trajectory. Our approach is as follow:

we plot the track as a curve

we plot the mean trajectory points using different shaped and coloured symbols at different times

we use use the same symbols and colour-coding for the cluster centres


The challenge here is to produce an informative but still readplot kepping thWe will improve the trajectory plot by showing the waypoint dates along the track. 

The macro to use is 'plot_tr_step3.mv'.

First, we read the CSV file.

#The input file
dIn="result_tr_single"
inFile=dIn  & "/tr_r1.csv"

#Read table (CSV) data
tbl=read_table(table_filename: inFile,
    table_header_row: "2",
    table_meta_data_rows: "1")



The first difference is that we need to determine the middle of the release interval since the trajectory waypoint times are given in seconds elapsed since this date. The release date reading part needs to be modified like this:


  • No labels