Purpose: Practice some simple, but effective, production of Python/matplotlib visualisations for a FLEXPART run
These exercises utilise data and programs that have been pre-packaged for this course. In the following,
<path to course>
refers to the path
/home/kurs/donmor/CourseFiles/
For this exercise, you should copy
<path to course>/WorkingSystem/VisFLEX.py
into your $HOME working directory
You should be run the program like
./VisFLEX.py <path to FLEXPART output directory> <path to image directory>
where the image directory must be created beforehand, and is where the individual snapshot images, the animated image, and and index.html will be placed. The program will take a couple of minutes to process the 24 hourly output files from the FLEXPART test case. You can view individual images by using the display image.png command, or, better, point your web browser to the index.html file.
To finish off the exercise, you will practice a little more basic Python programming and modify the program so that it gets release point information from the FLEXPART output header file, using the pflexible module, and then plots the locations of these release points on your graphics. Recall that you did something like this in an earlier lab, where you modified the matplotlib function calls to produce colour or size coded markers for plotted fire emissions data.
Here is a simple program to illustrate how you would get the release point information from the header using the pflexible module:
import os
import sys
# From NILU pflexible project
# Users will need to add the location of pflexible to $PYTHONPATH
import pflexible as pf
#------------------------------------------------------------------
"""
Simple demo program to show how we can extract RELEASES information from
a FLEXPART output header file. The variables extracted are the lower left
and upper right corners of the FLEXPART release box. Note that for a point
release, the points will be the same.
yp1, xp1: LL lat and lon
yp2, xp2: LL lat and lon
"""
def main(argv = sys.argv):
if len(argv) < 2:
print 'Usage: listFlexReleases.py <Flexpart output dir>'
sys.exit(1)
else:
FLEXPARTOutputDir = argv[1]
if not os.path.isdir(FLEXPARTOutputDir):
print 'FLEXPARTOutputDir not found: ' + FLEXPARTOutputDir
print 'Usage: listFlexReleases.py <Flexpart output dir>'
sys.exit(1)
# Read the general header information common to all files
H = pf.Header(FLEXPARTOutputDir, nested=False)
### Print Release info from header
numReleases = len(H['xp1'])
print 'LLLat LLLon URLat URLon'
for idx in range(numReleases):
xp1 = H['xp1'][idx]
xp2 = H['xp2'][idx]
yp1 = H['yp1'][idx]
yp2 = H['yp2'][idx]
print '%5.1f %6.1f %5.1f %6.1f' % (yp1, xp1, yp2, xp2)
# END main()
#------------------------------------------------------------
if __name__ == "__main__":
main()