Classes | |
class | BinaryFile |
HELPER FUNCTIONS ##########. More... | |
class | Structure |
class | Header |
Variables | |
string | __version__ = '0.9.5' |
tuple | __path__ = os.path.abspath(os.curdir) |
readheader = read_header | |
readheaderV8 = read_header | |
readheaderV6 = read_header | |
readgridBF = _readgrid_noFF | |
plot_footprint = plot_at_level | |
tuple | start_time = time.time() |
tuple | parser |
string | default = 'verbose output' |
tuple | exit_code = main() |
LateX #####. More... | |
|
private |
|
private |
returns max and min for footprint and total column for a given range of releases [default is all]
Definition at line 4992 of file pflexible.py.
|
private |
|
private |
Uses H.loutstep to calculate 'days back' for plotting on clusters and trajectories.
Definition at line 4978 of file pflexible.py.
|
private |
Generate the ast colormap for FLEXPART
Definition at line 5068 of file pflexible.py.
|
private |
Define some default map parameters from the Header File.
Definition at line 4950 of file pflexible.py.
|
private |
Generates ellipses based on input array 'data'. Requires basemap instance, 'm'. NOTE:: data = [itime,x,y,z,[size]] r,c = data.shape if c == 5: size function of data[:,4] else: size = 1*sizescale uses functions: * _gen_altitude_color * _gen_daylabels for labeling/color of ellipses
Definition at line 5013 of file pflexible.py.
|
private |
Open and read the binary file (bf) header only to the point of the Flexpart version string, return the string, seek to the start of the file.
Definition at line 794 of file pflexible.py.
|
private |
returns all lines from a file or file string reverts to beginning of file.
Definition at line 4940 of file pflexible.py.
|
private |
## create logorithmic color scale ## method uses strings to get the magnitude of variable #ss = "%1.2e" % (dat_max) #dmx = int('%s%s' % (ss[-3],int(ss[-2:]))) #dmx=float(len(str(int(np.ceil(dat_max))))) #if data_range is None: # dmn = int(np.round(np.log((1e-10*(dat_max-dat_min))))) # ss = "%1.2e" % (1e-10*(dat_max-dat_min)) #else: # ss = "%1.2e" % (dat_min) #dmn = int('%s%s' % (ss[-3],int(ss[-2:])))
Definition at line 4875 of file pflexible.py.
|
private |
Definition at line 4872 of file pflexible.py.
|
private |
FLEXPART Plotting Functions ########.
Definition at line 2622 of file pflexible.py.
|
private |
DEPRECATED Called from read_header if readp_ff is True, uses FortFlex.readheader to read all releasepoints. This function is dependant on the FortFlex.so module see FortFlex.f and the f2py directory
Definition at line 1758 of file pflexible.py.
|
private |
Grid Reading Routines ###############.
accepts a header dictionary as input, returns dictionary of Grid values %=========================================== % %------------------------------------------- % input % - H: required header dictionary % % optional (most is obtained from header dict) % - date: which yyyymmddhhmmss from dates % - unit: 'conc', 'pptv', ['time'], 'footprint' % - nspec_ret: numspecies % - pspec_ret: % - age_ret: % - time_ret: % - nested: nested = True % % % output % - grid dictionary object % - fail indicator (-1=fail, 0=success) %------------------------------------------- % FLEXPART python import routines %------------------------------------------- % last changes: JFB, 10.10.2008 %===========================================
Definition at line 1336 of file pflexible.py.
|
private |
|
private |
|
private |
def flextest.flexread.pflexible.add_nilu_logo | ( | fig, | |
xo = 10 , |
|||
yo = 520 , |
|||
origin = 'upper' |
|||
) |
def flextest.flexread.pflexible.closest | ( | num, | |
numlist | |||
) |
def flextest.flexread.pflexible.curtain_agltoasl | ( | H, | |
curtain_agl, | |||
coords, | |||
below_gl = 0.0 |
|||
) |
converts the agl curtain to asl adds .asl_axis attribute to H
Definition at line 603 of file pflexible.py.
def flextest.flexread.pflexible.curtain_for_flightrack | ( | H, | |
flighttrack, | |||
nspec = 0 , |
|||
npspec_int = 0 , |
|||
index = 0 , |
|||
get_track = False |
|||
) |
extracts curtain data along a given flight track input: H (a pf.Header with a FD data object from H.read_grid) if the read_grid method has not been called, we'll call it below. flighttrack (a numpy array with datetime, lon, lat, elv values) nspec: is optional for reference to the FD dict. index: is optional in case numpointspec > 1 get_track: if True extracts the points along the flight track rather than the curtain. output: curtain (a 2-d array with shape (len(flighttrack), len(H.outheight) TODO:: add interpolation, extract a track, not curtain (e.g. z points)
Definition at line 457 of file pflexible.py.
def flextest.flexread.pflexible.curtain_for_line | ( | grid, | |
X, | |||
Y, | |||
coords, | |||
index = 0 |
|||
) |
extracts curtain data from a grid given pairs of lon, lat input: H (a pf.Header with a FD data object from H.read_grid) if the read_grid method has not been called, we'll call it below. flighttrack (a numpy array with datetime, lon, lat, elv values) nspec: is optional for reference to the FD dict. index: is optional in case numpointspec > 1 get_track: if True extracts the points along the flight track rather than the curtain. output: curtain (a 2-d array with shape (len(flighttrack), len(H.outheight) TODO:: add interpolation, extract a track, not curtain (e.g. z points)
Definition at line 529 of file pflexible.py.
def flextest.flexread.pflexible.data_range | ( | data, | |
min = 'median' |
|||
) |
return a data range for flexpart data optional keyword min = ['median', 'mean', 'min']
Definition at line 4851 of file pflexible.py.
def flextest.flexread.pflexible.fill_grids | ( | H, | |
nspec = 0 , |
|||
FD = None , |
|||
add_attributes = False |
|||
) |
for backward runs, calculates the 20-day sensitivity at each release point. Usage:: > C = fill_backward(H,nspec=(0)) This will cycle through all available_dates and create the filled backward array for each k in H.numpointspec. Returns A dictionary keyed by a (species,k) tuple. OR C & FD attributes on H Each element in the dictionary is a 3D array (x,y,z) for each species,k .. note:: USE with *caution*, this is **MEMORY** intensive! Arguments ============== ======================================== keyword Description [default] ============== ======================================== nspec the specied ID or a tuple of species IDs FD FD can be passed if it is already read add_attributes will add C and FD as attributes to H, rather than returning just C ============== ======================================== .. todo:: There's a lot of redundancy in the storage of attributes, maybe there is a better way to handle this.
Definition at line 2415 of file pflexible.py.
def flextest.flexread.pflexible.get_slabs | ( | H, | |
G, | |||
index = None , |
|||
normAreaHeight = True , |
|||
scale = 1.0 |
|||
) |
Preps grid from readgridV8 for plotting. Accepts an 3D or 4D GRID from readgrid with optional index. shape ~= (360, 180, 3, 88, 1) Usage:: plotgrid = get_slabs(H,G) Inputs H = A Header instance from a FLEXPART run G = A grid from the FLEXPARTDATA or FD dictionary returned from read_grid Returns slabs : a dictionary of rank-2 arrays corresponding to vertical levels. **Note**: transposes the grid for plotting. Total Column as D[0] Level 1 as D[1] Level 2 as D[2] ... Arguments .. tabularcolumns:: |l|L| =============== ======================================== keyword Description [default] =============== ======================================== index a release point index (k) normAreaHeight [True], normalizes by the area/height =============== ======================================== .. todo:: Need to check the normalization and indexing.
Definition at line 2540 of file pflexible.py.
def flextest.flexread.pflexible.gridarea | ( | H | ) |
returns an array of area corresponding to each nx,ny,nz Usage:: > area = gridarea(H) Returns OUT = array area corresponding to nx,ny,nz Arguments H = :class:`Header` object from readheader function.
Definition at line 746 of file pflexible.py.
def flextest.flexread.pflexible.groundlevel_for_line | ( | H, | |
X, | |||
Y, | |||
coords, | |||
index = 0 |
|||
) |
extracts ground level from H.heightnn along a track of lon, lat input: H or H.heightnn (takes the lowest level) X, Y ,= H.longitude, H.latitude coords = zip(x, y) output: groundlevel (a 1-d array with shape (len(flighttrack)
Definition at line 569 of file pflexible.py.
def flextest.flexread.pflexible.main | ( | ) |
Below for use from command line ##########################################.
Definition at line 5141 of file pflexible.py.
def flextest.flexread.pflexible.monthly_footprints | ( | H | ) |
Definition at line 2401 of file pflexible.py.
def flextest.flexread.pflexible.plot_agespectra | ( | H, | |
agespectra, | |||
plt_title = '' , |
|||
y_label = None , |
|||
cbar_labels = None , |
|||
FIGURE = None , |
|||
y_datarange = None , |
|||
web_version = False , |
|||
continental = False , |
|||
cum = False , |
|||
bars = False , |
|||
debug = False |
|||
) |
plot an agespectra Usage:: > FIG = plot_agespectra(H,agespectra,*kwargs) This creates an filled in between agespectra plot using information from the header "H". Returns A "mapping.py" ``FIGURE`` object. Arguments .. tabularcolumns:: |l|L| ============= ======================================== keyword Description [default] ============= ======================================== runid an ID for the title yunits units for the y-axis [None] FIGURE A "FIGURE" object[None] (see mapping.py) data_range y-axis data range web_version Set to True if using the make_webpages function. see: :func:`read_agespectrum` continental Set to True if continental_spectrum cum Set to true if data should be cumulative bars Plot using stacked bars rather than a filled line plot ============= ======================================== .. todo:: There's a lot of redundancy in the storage of attributes, maybe there is a better way to handle this. .. note:: Required attributes of 'H' if you want to make a dummy H. Or just set H to "None" and it will be taken from the agespectra input. H.numageclasses H.releasetimes
Definition at line 2961 of file pflexible.py.
def flextest.flexread.pflexible.plot_at_level | ( | H, | |
D, | |||
level = 1 , |
|||
ID = ' ' , |
|||
map_region = 5 , |
|||
projection = 'lcc' , |
|||
overlay = False , |
|||
datainfo_str = None , |
|||
log = True , |
|||
data_range = None , |
|||
coords = None , |
|||
FIGURE = None , |
|||
plot_title = None , |
|||
units = None , |
|||
kwargs | |||
) |
TODO: -make units a function of H['species']
Definition at line 3625 of file pflexible.py.
def flextest.flexread.pflexible.plot_clusters | ( | H, | |
T, | |||
rel_i = 0 , |
|||
ncluster = 0 , |
|||
sizescale = 10000 , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None , |
|||
FIGURE = None , |
|||
overlay = False , |
|||
opacity = 0.7 , |
|||
draw_circles = True , |
|||
draw_labels = True , |
|||
MapPar = None |
|||
) |
def flextest.flexread.pflexible.plot_curtain | ( | H, | |
data, | |||
nx = None , |
|||
ny = None , |
|||
data_range = None , |
|||
units = 'ppbv' , |
|||
datainfo_str = None , |
|||
asl = True , |
|||
plottitle = None , |
|||
log = True , |
|||
FIGURE = None , |
|||
cax_title = None , |
|||
method = 'contourf' , |
|||
figPar = None |
|||
) |
plot_sensitivity: core function for plotting FLEXPART output. Usage:: > FIG = plot_sensitivity(H,data,*kwargs) This returns the FIGURE object, and plots the sensitivity from the data contained in the "D" array. Inputs H = a :class:`Header` instance for a FLEXPART run. data = a 2d data array containing the sensitivity values to plot, this can be extracted from a grid instance (see :func:`readgridV8` and :func:`get_slabs`) Returns A "mapping.py" ``FIGURE`` object. Arguments .. tabularcolumns:: |l|L| ============= ================================================ keyword Description [default] ============= ================================================ data_range range of data for scale bars, if None will be taken from min/max of data asl [True] plot the units in m.a.s.l cax_title string to be passed as colorbar title (units will be passed to the format argument) units units for the scale bar datainfo_str A string for labeling the scale bar. plottitle Title for the plot. rel_i Release index to plot from the data array map_region A map_region specified in mapping.py projection [deprecated] use pre-defined map_regions. dropm Force creation of a new basemap instance coords Used with autofit option. An array of lat,lon values for the mapping module to autofit a basemap instance to. autofit Try to generate map_region automagically (flakey) overlay Force removal of previous figure elements. transform For use with imshow method, if your data is not in same coordinates as projection, try to transform the data to the basemap projection. log Create a logarithmic color scale. FIGURE A FIGURE instance from mapping module get_FIGURE MapPar A Structure of paramters to be passed to the basemap class when creating an instance. method The method to use for plotting array data. May be one of: [pcolormesh], imshow, or contourf lsmask set to True to draw a grey landseamask [False] ============= ================================================ .. todo:: A lot!! There are some problems here and it is sensitive to options. lsmask = True seems to only work with certain projections (POLARCAT) .. note:: This is the primary main function for creating plots of flexpart output. Most the other routines are simply wrappers to this function, passing arguments in with some predefined settings. For more information on the mechanics of this function, see the mapping.py module and the matplotlib basemap toolkit.
Definition at line 4215 of file pflexible.py.
def flextest.flexread.pflexible.plot_markers | ( | H, | |
lon, | |||
lat, | |||
zsize = None , |
|||
zlevel = None , |
|||
FIGURE = None , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None , |
|||
overlay = True , |
|||
draw_circles = True , |
|||
draw_labels = False , |
|||
cbar2 = True , |
|||
cbar2_title = None , |
|||
MapPar = None , |
|||
color = 'blue' , |
|||
edgecolor = 'none' , |
|||
zorder = 10 , |
|||
alpha = 0.85 |
|||
) |
Plot a group of x,y pairs, with optional size and color information. Usage:: > FIG = plot_trajectory(H,RT,rel_id,*kwargs) .. note:: You can substitude "None" for the :class:`Header` instance if you haven't created one Returns A :mod:`mapping` "FIGURE" object. Arguments .. tabularcolumns:: |l|L| ============= ============================================= keyword Description [default] ============= ============================================= rel_i **required** release index FIGURE A "FIGURE" object[None] (see mapping.py) projection A projection pre-defined in :mod:`mapping` coords A set of lon,lat coords for autosetting map map_region (not really working). overlay [True] will overlay the trajectory on top of another map instance. draw_circles [True] will mark the trajectory with circles. If [False] nothing is drawn. draw_labels [False] unimplemented cbar2 [True] draws the scale bar as a second axis. cbar2_title Optional argument to overide the cbar title. MapPar A Structure of mapping parameters to pass to the basemap instance if desired. ============= ============================================= .. todo:: Who knows?! Could probably handle the overlaying better. .. note:: Just set H to "None" if you haven't already created a "Header" instance.
Definition at line 3305 of file pflexible.py.
def flextest.flexread.pflexible.plot_METDATA | ( | METDATA, | |
FIGURE, | |||
date = None , |
|||
level = None |
|||
) |
plots met data returned from :module:`pflexible.mapping.get_OpenDAP`
Definition at line 4400 of file pflexible.py.
def flextest.flexread.pflexible.plot_releases | ( | R, | |
FIGURE = None , |
|||
threedim = False , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None , |
|||
overlay = True , |
|||
draw_circles = True , |
|||
draw_labels = True , |
|||
cbar2 = True , |
|||
MapPar = None |
|||
) |
plot the llon,llat,elv1 of the releases. Usage:: >F = plot_releases(R) See the :func:`read_releases` function for information on how to generate "R"
Definition at line 2681 of file pflexible.py.
def flextest.flexread.pflexible.plot_sensitivity | ( | H, | |
data, | |||
data_range = None , |
|||
units = 'ns m^2 / kg' , |
|||
datainfo_str = None , |
|||
plottitle = None , |
|||
rel_i = None , |
|||
map_region = None , |
|||
projection = None , |
|||
dropm = None , |
|||
coords = None , |
|||
overlay = False , |
|||
transform = True , |
|||
log = True , |
|||
FIGURE = None , |
|||
MapPar = None , |
|||
FigPar = None , |
|||
cax_title = None , |
|||
autofit = False , |
|||
method = 'contourf' , |
|||
lsmask = False |
|||
) |
plot_sensitivity: core function for plotting FLEXPART output. Usage:: > FIG = plot_sensitivity(H,data,*kwargs) This returns the FIGURE object, and plots the sensitivity from the data contained in the "D" array. Inputs H = a :class:`Header` instance for a FLEXPART run. data = a 2d data array containing the sensitivity values to plot, this can be extracted from a grid instance (see :func:`readgridV8` and :func:`get_slabs`) Returns A "mapping.py" ``FIGURE`` object. Arguments .. tabularcolumns:: |l|L| ============= ================================================ keyword Description [default] ============= ================================================ data_range range of data for scale bars, if None will be taken from min/max of data cax_title string to be passed as colorbar title (units will be passed to the format argument) units units for the scale bar datainfo_str A string for labeling the scale bar. plottitle Title for the plot. rel_i Release index to plot from the data array map_region A map_region specified in mapping.py projection [deprecated] use pre-defined map_regions. dropm Force creation of a new basemap instance coords Used with autofit option. An array of lat,lon values for the mapping module to autofit a basemap instance to. autofit Try to generate map_region automagically (flakey) overlay Force removal of previous figure elements. transform For use with imshow method, if your data is not in same coordinates as projection, try to transform the data to the basemap projection. log Create a logarithmic color scale. FIGURE A FIGURE instance from mapping module get_FIGURE MapPar A Structure of paramters to be passed to the basemap class when creating an instance. method The method to use for plotting array data. May be one of: [pcolormesh], imshow, or contourf lsmask set to True to draw a grey landseamask [False] ============= ================================================ .. todo:: A lot!! There are some problems here and it is sensitive to options. lsmask = True seems to only work with certain projections (POLARCAT) .. note:: This is the primary main function for creating plots of flexpart output. Most the other routines are simply wrappers to this function, passing arguments in with some predefined settings. For more information on the mechanics of this function, see the mapping.py module and the matplotlib basemap toolkit.
Definition at line 3894 of file pflexible.py.
def flextest.flexread.pflexible.plot_sourcecontribution | ( | H, | |
D, | |||
rel_i = None , |
|||
s = None , |
|||
ID = ' ' , |
|||
map_region = 'POLARCAT' , |
|||
data_range = None , |
|||
coords = None , |
|||
datainfo_str = None , |
|||
units = None , |
|||
FIGURE = None , |
|||
overlay = False , |
|||
cax_title = None , |
|||
kwargs | |||
) |
plot_sourcecontribution: a wrapper around :func:`plot_sensitivity` for plotting a source contribution field. .. warning: This function is still quite finicky, I'm working on resolving it. Usage:: > FIG = plot_sourcecontribution(H,D,*kwargs) Inputs H = a :class:`Header` instance from a FLEXPART run D = a grid instance from a FLEXDATA dictionary. See :func:`readgridV8` .. note:: I am trying to create this so D can be a number of different types from a 2-d array to the grid instance type. Returns A "mapping.py" ``FIGURE`` object. Arguments .. tabularcolumns:: |l|L| ============= ================================================ keyword Description [default] ============= ================================================ ID Can be passed to prefix the title. data_range range of data for scale bars, if None will be taken from min/max of data datainfo_str A string for labeling the scale bar. cax_title A string to pass to plot_sensitivity for colorbar title (units will be passed as format argument) k Release index to plot from the data array (aka rel_i) s Species index map_region A map_region specified in mapping.py projection [deprecated] use pre-defined map_regions. overlay Force removal of previous figure elements. FIGURE A FIGURE instance from mapping module get_FIGURE ============= ================================================ .. todo:: A lot!! There are some problems here and it is sensitive to options. .. note:: k and rel_i are used throughout pflexible, should be more consistent in future.
Definition at line 3755 of file pflexible.py.
def flextest.flexread.pflexible.plot_spectra | ( | inspectra, | |
plt_title = '' , |
|||
fig_title = '' , |
|||
y_label = None , |
|||
spectra_label = 'bins' , |
|||
FIGURE = None , |
|||
y_datarange = None , |
|||
cum = False , |
|||
labels = [] , |
|||
bars = False , |
|||
debug = False |
|||
) |
plot a spectra Usage:: > FIG = plot_agespectra(spectra,*kwargs) Returns A "mapping.py" ``FIGURE`` object. Arguments .. tabularcolumns:: |l|L| ============= ======================================== keyword Description [default] ============= ======================================== runid an ID for the title yunits units for the y-axis [None] FIGURE A "FIGURE" object[None] (see mapping.py) data_range y-axis data range web_version Set to True if using the make_webpages function. see: :func:`read_agespectrum` continental Set to True if continental_spectrum cum Set to true if data should be cumulative bars Plot using stacked bars rather than a filled line plot ============= ======================================== .. todo:: There's a lot of redundancy in the storage of attributes, maybe there is a better way to handle this.
Definition at line 2789 of file pflexible.py.
def flextest.flexread.pflexible.plot_totalcolumn | ( | H, | |
D = None , |
|||
ID = ' ' , |
|||
map_region = 5 , |
|||
projection = 'lcc' , |
|||
data_range = None , |
|||
coords = None , |
|||
FIGURE = None , |
|||
overlay = False , |
|||
datainfo_str = None , |
|||
kwargs | |||
) |
Definition at line 3688 of file pflexible.py.
def flextest.flexread.pflexible.plot_trajchar | ( | H, | |
R, | |||
numrelease = 1 , |
|||
varindex = [4 , |
|||
FIGURE = None , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None |
|||
) |
plot FLEXPART trajectory (or set of trajectories) characteristics R is a dictionary returned from pflexible.read_trajectories varindex is a list of the variables to plot from the trajectories
Definition at line 2637 of file pflexible.py.
def flextest.flexread.pflexible.plot_trajectory | ( | H, | |
T, | |||
rel_i, | |||
FIGURE = None , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None , |
|||
overlay = True , |
|||
draw_circles = True , |
|||
draw_labels = True , |
|||
days_back = 20 , |
|||
cbar2 = True , |
|||
cbar2_title = None , |
|||
MapPar = None |
|||
) |
Plot the center trajectory of the plume on the map Usage:: > FIG = plot_trajectory(H,RT,rel_id,*kwargs) .. note:: You can substitude "None" for the :class:`Header` instance if you haven't created one Returns A :mod:`mapping` "FIGURE" object. Arguments .. tabularcolumns:: |l|L| ============= ============================================= keyword Description [default] ============= ============================================= rel_i **required** release index FIGURE A "FIGURE" object[None] (see mapping.py) projection A projection pre-defined in :mod:`mapping` coords A set of lon,lat coords for autosetting map map_region (not really working). overlay [True] will overlay the trajectory on top of another map instance. draw_circles [True] will mark the trajectory with circles. If [False] nothing is drawn. draw_labels [True] will draw the 'day' numbers on the trajectories. days_back For how many days back should the labels be shown? [20] cbar2 [True] draws the scale bar as a second axis. cbar2_title Optional argument to overide the cbar title. MapPar A Structure of mapping parameters to pass to the basemap instance if desired. ============= ============================================= .. todo:: Who knows?! Could probably handle the overlaying better. .. note:: Just set H to "None" if you haven't already created a "Header" instance.
Definition at line 3453 of file pflexible.py.
def flextest.flexread.pflexible.plot_trajectory_ellipses | ( | H, | |
T, | |||
rel_i = 0 , |
|||
ncluster = 0 , |
|||
sizescale = 10000 , |
|||
map_region = None , |
|||
projection = None , |
|||
coords = None , |
|||
FIGURE = None , |
|||
overlay = False , |
|||
opacity = 0.7 , |
|||
draw_circles = True , |
|||
draw_labels = True , |
|||
MapPar = None |
|||
) |
def flextest.flexread.pflexible.read_agespectrum | ( | filename, | |
part = False , |
|||
ndays = 20 |
|||
) |
Reads the spectrum.txt files generated from the "make_webpages" scripts. .. note:: This functionality depends on having run the make_webpages scripts in-house. It is not supported in the public API. USAGE:: > A = read_agespectrum(filename) Returns a dictionary containing ageclass information .. tabularcolumns:: |l|L| ============= ======================================== Keys Description ============= ======================================== agespectrum 2d-array (dt, lat, lon, alt, tracer[:numageclass] for each release) ageclasses 1d-array(ageclass ages) numpspec number of species numageclass number of ageclassesA part if it is from make webpages without the header information. ndays The number of ageclasses ============= ========================================
Definition at line 624 of file pflexible.py.
def flextest.flexread.pflexible.read_command | ( | path, | |
headerrows = 7 |
|||
) |
Functions for reading FLEXPART output #####.
Reads a FLEXPART COMMAND file. .. note:: Assumes releases file has a header of 7 lines. Use option "headerrows" to override this. USAGE:: > A = read_command(filepath) where filepath is either a file object or a path. Returns a dictionary with the following keys ================ ================================================================= fields description ================ ================================================================= SIM_DIR Simulation direction SIM_START Text str of YYYYMMDD HHMMSS SIM_END Text str of YYYYMMDD HHMMSS AVG_CNC_INT Average concentrations are calculated every SSSSS seconds AVG_CNC_TAVG The average concentrations are time averages of SSSSS sec CNC_SAMP_TIME The concentrations are sampled every SSSSS seconds to calculate the time average concentration. T_PARTSPLIT Time constant for particle splitting. SYNC All processes are synchronized with this time interval CTL -- IFINE IFINE=Reduction factor for time step used for vertical wind IOUT IOUT determines how the output shall be made: concentration (ng/m3, Bq/m3), mixing ratio (pptv), or both, or plume trajectory mode, or concentration + plume trajectory mode. IPOUT IPOUT determines whether particle positions are outputted (in addition to the gridded concentrations or mixing ratios) or not. 0=no output, 1 output every output interval, 2 only at end of the simulation LSUBGRID Switch on/off subgridscale terrain parameterization (increase of mixing heights due to subgridscale orog. var LCONVECTION Switch on/off the convection parameterization LAGESPECTRA Switch on/off the calculation of age spectra: if yes, the file AGECLASSES must be available IPIN If IPIN=1, a file "partposit_end" from a previous run must be available in the output directory. Particle positions are read in and previous simulation is continued. If IPIN=0, no particles from a previous run are used IOFR Switch on/off writing out each release. IFLUX If IFLUX is set to 1, fluxes of each species through each of the output boxes are calculated. Six fluxes, corresponding to northward, southward, eastward, westward, upward and downward are calculated for each grid cell of the output grid. The control surfaces are placed in the middle of each output grid cell. If IFLUX is set to 0, no fluxes are determined. MDOMAINFILL If MDOMAINFILL is set to 1, the first box specified in file RELEASES is used as the domain where domain-filling trajectory calculations are to be done. Particles are initialized uniformly distributed (according to the air mass distribution) in that domain at the beginning of the simulation, and are created at the boundaries throughout the simulation period IND_SOURCE IND_SOURCE switches between different units for concentrations at the source. NOTE that in backward simulations the release of computational particles takes place at the "receptor" and the sampling of particles at the "source". 1=mass units (for bwd-runs = concentration) 2=mass mixing ratio units'''], IND_RECEPTOR IND_RECEPTOR switches between different units for concentrations at the receptor 1=mass units (concentrations) 2=mass mixing ratio units MQUASILAG MQUASILAG indicates whether particles shall be numbered consecutively (1) or with their release location number (0). The first option allows tracking of individual particles using the partposit output files NESTED_OUTPUT NESTED_OUTPUT decides whether model output shall be made also for a nested output field (normally with higher resolution) LINIT_COND For Backward Runs, sets initial conditions: [0]=No, 1=Mass Unit, 2=Mass Mixing ================ =================================================================
Definition at line 90 of file pflexible.py.
def flextest.flexread.pflexible.read_emissions | ( | emissionsfile, | |
E = None , |
|||
maxemissions = 1 |
|||
) |
def flextest.flexread.pflexible.read_grid | ( | H, | |
kwargs | |||
) |
Accepts a header object as input, returns dictionary of Grid values keyed by species and datestring from H['available_dates']. A grid instance from this dictionary may be passed to the get_slabs function to return a dictionary of slabs suitable for plotting with the plotting routines. See below for more information. **DEPENDENCY** Requires FortFlex.so module compiled using f2py. See FortFlex.f for more details. Usage:: > FLEXDATA = read_grid(H,**kwargs) Returns: A grid dictionary key by tuples with (species,available_dates), where species is and integer. See grid.keys() FLEXDATA[(s,datestring)]['grid'] FLEXDATA[(s,datestring)]['itime'] FLEXDATA[(s,datestring)]['shape'] FLEXDATA[(s,datestring)]['max'] FLEXDATA[(s,datestring)]['min'] FLEXDATA[(s,datestring)]['timestamp'] FLEXDATA[(s,datestring)]['species'] FLEXDATA[(s,datestring)]['gridfile'] FLEXDATA[(s,datestring)]['rel_i'] FLEXDATA[(s,datestring)]['spec_i'] Arguments .. tabularcolumns:: |l|L| ============= ======================================== keyword Description [default] ============= ======================================== date which yyyymmddhhmmss from available_dates or use (time_ret) time_ret index to time unit 'conc', 'pptv', ['time'], 'footprint' nspec_ret numspecies pspec_ret index to ??? age_ret index to ageclass nested obtained from H['nested'] BinaryFile Use BinaryFile vs. FortFlex [False] getwet True, [False] getdry True, [False] scaledepo A float value to scale deposition [1.0] scaleconc A float value to scale conc [1.0] decayconstant A float for decay const. [9e6] calcfoot Will cause footprint to be calculated [False] verbose more output version A string 'V8' or 'V6', ['V8'] ============= ======================================== .. note:: most arguments are able to be extracted fro the header "H"
Definition at line 1804 of file pflexible.py.
def flextest.flexread.pflexible.read_header | ( | pathname, | |
kwargs | |||
) |
The readheader function returns a special class (Structure) which behaves like a dictionary. It contains all the metadata from the simulation which is contained in the "header" or "header_nest" binary files from the model output. .. warning:: It is recommended to use the :class:`Header` class: H = pf.Header(path) This version is using the BinaryFile class rather than FortFlex. Usage:: > H = read_header(pathname) #Don't include header filename Returns a dictionary H = dictionary like object with all the run metadata. Arguments .. tabularcolumns:: |l|L| ============= ======================================== keyword Description [default] ============= ======================================== pathname FLEXPART run output directory readp read release points 0=no, [1]=y nested nested output [False] or True headerfile provide custom name for header file datefile provide a custom name for the date file verbose print information while loading header ============= ======================================== .. note:: **This function is in development** Please report any bugs found. .. TODO:: probably a lot of things, among which ... [] choose skip/getbin or direct seek/read [] define output keys in docstring .. note:: The user is no longer required to indicate which version of FLEXPART the header is from. Checks are made, and the header is read accordingly. Please report any problems...
Definition at line 813 of file pflexible.py.
def flextest.flexread.pflexible.read_releases | ( | path, | |
headerrows = 11 |
|||
) |
Reads a FLEXPART releases file. .. note:: Assumes releases file has a header of 11 lines. Use option "headerrows" to override this. USAGE:: > A = read_releases(filepath) where filepath is either a file object or a path. Returns a record array with fields: ============ ========================== fields description ============ ========================== start_time datetime start end_time datetime end lllon lower left longitude llat lower left latitude urlon upper right longitude urlat upper right latitude altunit 1=magl, 2=masl, 3=hPa elv1 lower z level elv2 upper z level numpart numparticles mass mass for each spec, so the array will actually have fields: mass0, mass1,.. id ID for each release ============ ==========================
Definition at line 224 of file pflexible.py.
def flextest.flexread.pflexible.read_trajectories | ( | H, | |
trajfile = 'trajectories.txt' , |
|||
ncluster = 5 , |
|||
ageclasses = 20 |
|||
) |
Reads the trajectories.txt file in a FLEXPART run output directory. Based on output from plumetraj.f:: ******************************************************************************** * * * Determines a plume centroid trajectory for each release site, and manages * * clustering of particle locations. Certain parameters (average PV, * * tropopause height, etc., are provided along the plume trajectories. * * At the end, output is written to file 'trajectories.txt'. * * * * Author: A. Stohl * * * * 24 January 2002 * * * * Variables: * * fclust fraction of particles belonging to each cluster * * hmixcenter mean mixing height for all particles * * ncluster number of clusters to be used * * pvcenter mean PV for all particles * * pvfract fraction of particles with PV<2pvu * * rms total horizontal rms distance after clustering * * rmsdist total horizontal rms distance before clustering * * rmsclust horizontal rms distance for each individual cluster * * topocenter mean topography underlying all particles * * tropocenter mean tropopause height at the positions of particles * * tropofract fraction of particles within the troposphere * * zrms total vertical rms distance after clustering * * zrmsdist total vertical rms distance before clustering * * xclust,yclust, Cluster centroid positions * * zclust * * * ******************************************************************************** USAGE:: > T = read_trajectories(H_OR_path_to_directory, **kwargs) .. note:: The first argument is either a path to a trajectory file, or simply a :class:`Header` instance. Returns a dictionary of the trajectories for each release. .. tabularcolumns:: |l|L| ============= ======================================== Keys Description ============= ======================================== Trajectories array_of_floats(j,it1,xi,yi,zi,topoi,hmixi,tropoi,pvi, rmsdisti,rmsi,zrmsdisti,zrmsi,hfri,pvfri,trfri, (xclusti(k),yclusti(k),zclusti(k),fclusti(k),rmsclusti(k),k=1,5)) RELEASE_ID 1array(i1,i2,xp1,yp1,xp2,yp2,zp1,zp2,k,npart) numpspec number of species numageclass number of ageclasses ============= ======================================== Arguments .. tabularcolumns:: |l|L| ============= ======================================== keyword Description [default] ============= ======================================== trajfile over the name of the input file ['trajectories.txt'] ncluster number of clusters [5] ageclasses number of ageclasses [20] ============= ========================================
Definition at line 305 of file pflexible.py.
def flextest.flexread.pflexible.readgridV6 | ( | H, | |
kwargs | |||
) |
Accepts a header object as input, and selects appropriate readgrid function to use for reading in data from the flexpart binary Fortran files. See the :func:`read_grid` for more information on keyword arguments This is the 'V6' version of the function.
Definition at line 2149 of file pflexible.py.
def flextest.flexread.pflexible.readgridV8 | ( | H, | |
kwargs | |||
) |
Accepts a header object as input, and selects appropriate readgrid function to use for reading in data from the flexpart binary Fortran files. See the :func:`read_grid` for more information on keyword arguments This is the 'V8' version of the function.
Definition at line 1878 of file pflexible.py.
def flextest.flexread.pflexible.save_spectrum | ( | outf, | |
H, | |||
agespectra, | |||
spectype = 'agespec' , |
|||
header = '## AGECLASS File' |
|||
) |
tuple flextest.flexread.pflexible.__path__ = os.path.abspath(os.curdir) |
Definition at line 85 of file pflexible.py.
string flextest.flexread.pflexible.__version__ = '0.9.5' |
Definition at line 84 of file pflexible.py.
string flextest.flexread.pflexible.default = 'verbose output' |
Definition at line 5166 of file pflexible.py.
int flextest.flexread.pflexible.exit_code = main() |
LateX #####.
Definition at line 5184 of file pflexible.py.
tuple flextest.flexread.pflexible.parser |
Definition at line 5161 of file pflexible.py.
flextest.flexread.pflexible.plot_footprint = plot_at_level |
Definition at line 3681 of file pflexible.py.
flextest.flexread.pflexible.readgridBF = _readgrid_noFF |
Definition at line 1608 of file pflexible.py.
flextest.flexread.pflexible.readheader = read_header |
Definition at line 1271 of file pflexible.py.
flextest.flexread.pflexible.readheaderV6 = read_header |
Definition at line 1273 of file pflexible.py.
flextest.flexread.pflexible.readheaderV8 = read_header |
Definition at line 1272 of file pflexible.py.
tuple flextest.flexread.pflexible.start_time = time.time() |
Definition at line 5160 of file pflexible.py.