Versions Compared

Key

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

...

Info

In this exercise we will perform a backward simulation to compute the residence time of the particles arriving to reaching Inverness in Scotland.

Running a backward simulation

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

...

Code Block
languagepy
rel_inv = flexpart_release(
	name			:	"INVERNESS",
	starting_date	:	1,
	starting_time	:	12,
	ending_date		:	2,
	ending_time		:	12,
	area			:   [57.44/-4.23/57.46/-4.21],
	top_level		:	500,
	bottom_level	:	0,
	particle_count	:	10000,
	masses			:	1
	)

...

Here we defined both the input and output path paths and specified the simulation period, the output grid and levels as well. We also told FLEXPART to generate residence time fields 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 8 stands for SO2.

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_bwd'. The computations were actually taken took place in a temporary folder then metview Metview copied the results to the output folder. If we open this older folder we will one file heresee two files:

  • time_s001.grib is a GRIB file containing the gridded residence time field
  • log.txt is the logfile generated by FLEXPART

Plotting residence times

Step 1 - Residence time

In this step we will plot the residence time for a given level.

Inspecting the FLEXPART GRIB file

Before seeing the macro code to generate the plot we inspect the file itself we want to plot. Double-click on the 'time_s001.grib'  GRIB icon' in folder 'result_bwd' to start up the Grib Examiner. We can see that this file contains the "fprt" (=Residence time) fields

...

we want to visualise. We can find out further details about this parameter by setting the Dump mode to Namespace and Namespace to Parameter:

Image Added

Generating the plot

The macro to visualise the residence time on a given level is 'plot_time_step1.mv'.

In the macro first we define the level (700 m) and the parameter ("fprt") we want to plot. Then we call the flexpart_filter() to extract the data for all the timesteps:

Code Block
languagepy
dIn="result_fwd/"
inFile=dIn  & "time_s001.grib"
lev=700
par="fprt"
 
#Read fields on the given height level
g=flexpart_filter(source: inFile,
                  param: par,
                  levType: "hl", 
                  level: lev)

Next, we normalise the values with the maximum value of the fields and convert the units to percentage:

Code Block
languagepy
#Compute the maximum residence time for all the steps
maxTime=maxvalue(g)

#Derive percentages with regard to the maximum value
if maxTime > 1E-30 then
    g=100*g/maxTime
end if

Next, we define the contouring:

Code Block
languagepy
titleDefine contouring
collapsetrue
#The contour levels
cont_list=[0.2,0.5,1,2,3,5,10,25.0,50,100]

#Define contour shading
time_shade = mcont(
	legend	:	"on",
	contour	:	"off",	
	contour_level_selection_type	:	"level_list",
	contour_level_list  : cont_list,
	contour_label	:	"off",
	contour_shade	:	"on",
	contour_shade_method	:	"area_fill",
	contour_shade_max_level_colour	:	"red",
	contour_shade_min_level_colour	:	"RGB(0.14,0.37,0.86)",
	contour_shade_colour_direction	:	"clockwise"	      
	)

Next, we build the title with flexpart_build_title(). Please note that we need to explicitly specify the plotting units!

Code Block
languagepy
#Set precision for printing maxTime
precision(4) 

#Define the title
title=flexpart_build_title(data: g,
	fontsize: 0.3, 
	units: "% of max=" & maxTime & "s") 

Anchor
map_view
map_view

Finally we define the mapview:

Code Block
languagepy
titleDefining the map view
collapsetrue
#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				:	[40,-25,66,9],
	coastlines			: coast_grey
	)

and generate the plot:

Code Block
languagepy
plot(view,g,time_shade,title)

Having run the macro we will get a plot like this (after navigating to step -27h):

Image Added

Step 2 - Total residence time in a layer

In this step we will plot the total residence time summed up for the bottom 500m layer.

The macro to use is 'plot_time_step2.mv'. This macro is basically the same as the one in Step 1, but the data access and processing go like this:

Code Block
languagepy
dIn="result_bwd_time/"
inFile=dIn & "time_s001.grib"

#Define layer and parameter
par="fprt"
top_level=500
bottom_level=0

#Compute total column residence time between the specified levels 
#for all the timesteps
g=flexpart_total_column(source: inFile,
    param: par,
    top_level: top_level,
    bottom_level: bottom_level)

#Compute the maximum value
maxTime=maxvalue(g)

#Derive percentages with regard to the max
if maxTime > 1E-30 then
    g=100*g/maxTime
end if

In the code above we called flexpart_total_column() to add up the residence times in the specified layer. Then we took the result and normalised it with the maximum value.

We also need to customise the title:

Code Block
languagepy
#Set precision for printing maxTime
precision(4)

#Define the title
title=flexpart_build_title(data:g,
	fontsize: 0.3,
	level: bottom_level & "-" & top_level & "m",
	units: "% of max=" & maxTime & "s"
)

Having run the macro we will get a plot like this (after navigating to step -27h):

Image Added

Step 3 - Total residence time in the whole atmospheric column

Macro 'plot_time_step3.mv' shows how to plot the total residence time for the whole atmospheric column. It goes exactly like Step 2 but we need to omit top_level and bottom_level in the flexpart_total_column() call:

Code Block
languagepy
g=flexpart_total_column(source: inFile,
    param: par)

and we need to adjust the title as wel:

Code Block
languagepy
title=flexpart_build_title(data:g, 
    fontsize: 0.3,
    level: "total column", 
    units: "% of max=" & maxTime & "s"
   )  

Having run the macro we will get a plot like this (after navigating to step -27h):

Image Added

Step 4 - Total residence time in a layer for the whole period

In this step we will plot the total residence time summed up for the whole period for the bottom 500m layer.

The macro to use is 'plot_time_step4.mv'. This macro is basically the same as the one in Step 2, but after calling flexpart_total_column() we call sum() to sum up the fields over time:

Code Block
languagepy
#Compute total column residence time between the specified levels 
#for all the timesteps
g=flexpart_total_column(source: inFile,
    param: par,
    top_level: top_level,
    bottom_level: bottom_level)

#Sum up
g=sum(g)

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

Image Added

Step 5 - Total residence time in the whole atmospheric column for the whole period

In this step we will plot the total residence time summed up for the whole period for the whole atmospheric column.

The macro to use is 'plot_time_step5.mv'. This macro is basically the same as the one in Step 3, but after calling flexpart_total_column() we call sum() to sum up the fields over time:

Code Block
languagepy
#Compute total column residence time for all the timesteps
g=flexpart_total_column(source: inFile, param: par)

#Sum up
g=sum(g)

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

Image Added

...