Difference between revisions of "Python/pflexpart"

From mn/geo/geoit
Jump to: navigation, search
(Created page with "=Introduction to Working with pflexpart= Intro text (TBC) Should point to web page help ==Recipes== This is a place for keeping track of the current process for doing various ...")
 
(Plotting output from a model run for a known time/species/level)
Line 22: Line 22:
 
So, we want to get the 'grid' for our request:
 
So, we want to get the 'grid' for our request:
 
<pre>
 
<pre>
grid = H.FD[ (nspec, date) ]['grid']
+
flexdata = H.FD[ (nspec, date) ]
 
</pre>
 
</pre>
  
The next step is to calculate the total column and break the grid into 'slabs' that we want for our analysis:
+
The next step is to calculate the total column and break the grid into 'slabs' that we want for our analysis, and add it to the flexdata dictionary:
  
 
<pre>
 
<pre>
D = pf.get_grid(H, grid)
+
flexdata['slabs'] = pf.get_grid(H, flexdata['grid'])
 
</pre>
 
</pre>
  
Now D is another dictionary. This time keyed by {0 ... N} where N is the number of outheights+1. The D[0] grid will be the Total Column:
+
Now 'slabs' is another dictionary. This time keyed by {0 ... N} where N is the number of outheights+1. The flexdata['slabs'][0] grid will be the Total Column, flexdata['slabs'][1] is the footprint:
 
<pre>
 
<pre>
tc = D[0]
+
tc = flexdata['slabs'][0]
 
tc.shape
 
tc.shape
 
</pre>
 
</pre>

Revision as of 15:47, 14 October 2011

Introduction to Working with pflexpart

Intro text (TBC) Should point to web page help

Recipes

This is a place for keeping track of the current process for doing various things with pflexpart. If you are working through a plotting routine, or otherwise doing some processing with pflexpart, please feel free to contribute some notes here.

Plotting output from a model run for a known time/species/level

H = pf.Header('path/to/output')
# read a grid for a known time / nspec 
# NOTE:these are indexes to H.available_dates and H.species so 1 is not _001
H.read_grid(time_ret=0, nspec_ret=0 )

H.read_grid will create a new object on the Header. This new object ('FD') is a Python dictionary. It is keyed by tuples that represent the species and time for the request. See H.FD.keys() to get an overview of what is available.

The next step is to get the data from the FD (which is Flexpart Data, by the way). Each 'grid' for each species/date pair will have shape (X , Y, Z, nspec) but nspec now is almost always 1, and *not* related to above nspec_ret (sorry, just the way it is -- legacy)

So, we want to get the 'grid' for our request:

flexdata = H.FD[ (nspec, date) ]

The next step is to calculate the total column and break the grid into 'slabs' that we want for our analysis, and add it to the flexdata dictionary:

flexdata['slabs'] = pf.get_grid(H, flexdata['grid'])

Now 'slabs' is another dictionary. This time keyed by {0 ... N} where N is the number of outheights+1. The flexdata['slabs'][0] grid will be the Total Column, flexdata['slabs'][1] is the footprint:

tc = flexdata['slabs'][0]
tc.shape