This tutorial demonstrates how to generate a single plume trajectories trajectory with FLEXPART and how to visualise the results in various ways.
...
Note |
---|
Please enter folder 'plume_trtrajectory' to start working. |
Info |
---|
In this tutorial example we will release generate a forward trajectory by releasing atmospheric tracers from Newcastle and visualise the resulting plume trajectories. |
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.
...
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.
...
Code Block | ||
---|---|---|
| ||
#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 paths and specified the simulation period , and the output grid as well. We also told FLEXPART to only generate plume trajectories on output..
Info |
---|
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 atmospheric tracer. |
If we run this macro (or alternatively right-click execute
the FLEXPART Run icon) the results resulting CSV file, 'tr_r001.csv', will appear (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 trajectory outputs click here.
Step 1 - Plotting the mean track
...
First, we read the CSV file .using a Table Reader:
Code Block | ||
---|---|---|
| ||
#The input file dIn="result_tr_single" inFile=dIn & "/tr_r1r001.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 (i.e. the release) start date and time from the table header (we will use them to construct the title):
Code Block | ||
---|---|---|
| ||
#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 use Input Visualiser and Graph Plotting to plot it:
Code Block | ||
---|---|---|
| ||
#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" ) |
...
Having run the macro we will get a plot like this:
Step 2 - Plotting the dates along the mean 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.
We start with loading the CSV file and determining the start date and time as before:
Code Block | ||
---|---|---|
| ||
#The input file
dIn="result_tr"
inFile=dIn & "/tr_r001.csv"
#Read table (CSV) data
tbl=read_table(table_filename: inFile,
table_header_row: "2",
table_meta_data_rows: "1")
#Read runDate from table header
runDate=date(metadata_value(tbl,"runDate"))
runTime=number(metadata_value(tbl,"runTime"))
runDate=runDate + hour(runTime/10000) |
Next 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:
Code Block | ||
---|---|---|
| ||
#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) |
The plotting of the track is the same as in Step1:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#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 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 Here we use a loop to construct and plot the date labels one by one with Input Visualiser and Symbol Plotting to define the plot:
Code Block | ||
---|---|---|
| ||
#Read waypoint times from table #These are seconds elapsed since the middle of the release interval tt=values(tbl,"time") #Build and define the visualiser listfor ofthe date strings to be plotted ttLst #The plot definitions are collected into a list pltDateLst=nil for i=1 to count(tt) do d=releaseMidDate + second(tt[i]) ttLst = ttLst & [ label=" " & string(d,"dd") & "/" & string(d,"HH")] end for #visualiser iv_date = input_visualiser( input_plot_type : "geo_points", input_longitude_variable : mLon[i], input_latitude_variable : mLat[i] ) #line #text attributes sym_date=msymb(symbol_type: "text", symbol_text_list: ttLstlabel, symbol_text_font_size: 0.3, symbol_text_font_colour: "navy" ) #collect the plot definitions into a list pltDateLst= pltDateLst & [iv_date,sym_date] end for |
Note |
---|
We had to define the plot for each date label individually (instead of defining just one plot object with a list of values), due to a current limitation for string plotting in Metview' plotting library. Until this issue is resolved this is the recommended way to plot strings onto a map. |
Finally we define the title and mapview in the same way as in Step 1 and generate the plotFinally the plot command has to be extended like this:
Code Block | ||
---|---|---|
| ||
plot(view,iv_curve,graph_curve,iv_date,sym_date,pltDateLst,title) |
Having run the macro we will get a plot like this:
Step 3 - Plotting the cluster centres
The macro to use is 'plot_tr_step3.mv' .
...
and is basically the same as the one in Step 2 but contains an additional plot layer. In this plot layer we draw circles around the mean trajectory waypoints using the RMS (root mean square) of the horizontal distances of the particles to this waypoint. The code goes like this:
Code Block | ||
---|---|---|
| ||
#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#Get rms of the horizontal distances (in km) to the mean particle positions (i.e. waypoints) mRms=values(tbl,"rmsHBefore") #Draw an rms circle around every second waypoint iStart=1 if mod(count(mRms),2)= 0 then iStart=2 end if pltRmsLst=nil for i=iStart to count(mRms) by 2 do if mRms[i] > 0 then #input visualiser defining the circle iv_rms=mvl_geocircle(mLat[i],mLon[i],mRms[i],100) #circle line attributes graph_rms=mgraph( graph_line_colour: "magenta", graph_line_thickness: "2", table graph_meta_data_rowsline_style: "dot", graph_symbol: "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:
off"
)
#collect the plot definitions into a list
pltRmsLst=pltRmsLst & [iv_rms,graph_rms]
end if
end for |
Please note that we use mvl_geocircle() to construct the circle and plotted the circle around every second waypoint to avoid cluttering. The only other change with respect to Step 2 is that we need to extend the plot command with the new data layer (pltRmsLst
):
Code Block |
---|
plot(view,iv_track,graph_track,pltRmsLst,pltDateLst,title) |
Step 4 - Plotting the cluster centres
The macro to use is 'plot_tr_step4.mv'.