FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
flextest.flexread.pflexible.Header Class Reference
Inheritance diagram for flextest.flexread.pflexible.Header:
Inheritance graph
[legend]
Collaboration diagram for flextest.flexread.pflexible.Header:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def lonlat
 
def read_grid
 
def fill_backward
 
def add_trajectory
 
def add_fires
 
def closest_dates
 
def closest_date
 
- Public Member Functions inherited from flextest.flexread.pflexible.Structure
def __getattr__
 
def __setattr__
 
def __dir__
 
def set_with_dict
 
def __dir__
 

Public Attributes

 version
 
 longitude
 
 latitude
 
 FD
 
 trajectory
 
 fires
 

Detailed Description

This is the primary starting point for processing FLEXPART output.
The Header class ( :class:`Structure` ) behaves like a dictionary. 
It contains all the metadata from the simulation run as read from the
"header" or "header_nest" binary files from the model output.

This version is using the BinaryFile class rather than FortFlex. 

Usage::

    > H = pf.Header(inputpath)
    > H.keys() #provides a list of keys available

Returns a dictionary

    H = dictionary like object with all the run metadata. TODO: Fill in keys.

    
Arguments

  .. tabularcolumns::  |l|L|

  ==============        ========================================
  keyword               Description [default]
  ==============        ========================================
  path                  path to the run directory
  headerfile            name of the header file if non standard
  readheader_ops        optional dictionary to pass readheader
  ==============        ========================================

Arguments for readheader_ops

  .. tabularcolumns::  |l|L|

  =============       ========================================
  keyword             Description [default]
  =============       ========================================
  pathname            FLEXPART run output directory
  readp               read release points 0=no, [1]=y
  nested              nested output True or [False]
  version             version of FLEXPART, default = 'V8'
  =============       ========================================
  

.. note::
    **This function is in development**

    This function is being developed so that there is no dependence on
    using f2py to compile the FortFlex module. It is working using the
    :class:`BinaryFile`, but is notably slower than :class:`FortFlex`. 
    Please report any bugs found.

Definition at line 4693 of file pflexible.py.

Constructor & Destructor Documentation

def flextest.flexread.pflexible.Header.__init__ (   self,
  path = None,
  headerfile = None,
  version = 'V8',
  readheader_ops 
)
 

Definition at line 4749 of file pflexible.py.

4750  def __init__(self, path=None, headerfile=None, version='V8', **readheader_ops):
4751  """
4752 
4753 
4754  """
4755  try:
4756  h = read_header(path, **readheader_ops)
4757  self.set_with_dict(h)
4758  self.lonlat()
4759  self.version = 'V8'
4760  except:
4761  traceback.print_exc()
4762  raise IOError('''
4763  Could not set header variables.
4764  Does the `header` file exist in path?\n{0}'''.format(path))
4765 
4766 
4767 

Here is the call graph for this function:

Member Function Documentation

def flextest.flexread.pflexible.Header.add_fires (   self,
  kwargs 
)
uses the :mod:`emissions` module to read the MODIS hotspot data and
add it to the header class as a 'fires' attribute.

**This function is only available within NILU.**

Definition at line 4787 of file pflexible.py.

4788  def add_fires(self, **kwargs):
4789  """ uses the :mod:`emissions` module to read the MODIS hotspot data and
4790  add it to the header class as a 'fires' attribute.
4791 
4792  **This function is only available within NILU.**
4793 
4794  """
4795 
4796  from nilu.pflexpart import emissions as em
4797  self.fires = None
4798  for day in self.available_dates_dt:
4799  # day = day[:8]
4800  firedata = em.MODIS_hotspot(day)
4801  daily = firedata.daily
4802  # pdb.set_trace()
4803  if daily is None:
4804  continue
4805  else:
4806  if self.fires == None:
4807  self.fires = daily
4808  else:
4809 
4810  self.fires = np.hstack((self.fires, daily)).view(np.recarray)
def flextest.flexread.pflexible.Header.add_trajectory (   self,
  kwargs 
)
see :func:`read_trajectories` 

Definition at line 4783 of file pflexible.py.

4784  def add_trajectory(self, **kwargs):
4785  """ see :func:`read_trajectories` """
4786  self.trajectory = read_trajectories(self)
def flextest.flexread.pflexible.Header.closest_date (   self,
  dateval,
  fmt = None 
)
given a datestring or datetime, tries to find the closest date.
    if passed a list, assumes it is a list of datetimes

Definition at line 4832 of file pflexible.py.

4833  def closest_date(self, dateval, fmt=None):
4834  """ given a datestring or datetime, tries to find the closest date.
4835  if passed a list, assumes it is a list of datetimes
4836 
4837  """
4838 
4839  if isinstance(dateval, str):
4840  if not fmt:
4841  if len(dateval) == 8:
4842  fmt = '%Y%m%d'
4843  if len(dateval) == 14:
4844  fmt = '%Y%m%d%H%M%S'
4845  else:
4846  raise IOError("no format provided for datestring")
4847  print("Assuming date format: {0}".format(fmt))
4848  dateval = datetime.datetime.strptime(dateval, fmt)
4849 
4850  return closest(dateval, self['available_dates_dt'])

Here is the call graph for this function:

def flextest.flexread.pflexible.Header.closest_dates (   self,
  dateval,
  fmt = None,
  take_set = False 
)
given an iterable of datetimes, finds the closest dates.
    if passed a list, assumes it is a list of datetimes
    
    if take_set=True, then a set of unique values will be returned.
    This can be used with H.read_grid as the value for time_ret to 
    return only the grids matching the array of times.
    See (e.g. `extract_curtain`).

Definition at line 4811 of file pflexible.py.

4812  def closest_dates(self, dateval, fmt=None, take_set=False):
4813  """ given an iterable of datetimes, finds the closest dates.
4814  if passed a list, assumes it is a list of datetimes
4815 
4816  if take_set=True, then a set of unique values will be returned.
4817  This can be used with H.read_grid as the value for time_ret to
4818  return only the grids matching the array of times.
4819  See (e.g. `extract_curtain`).
4820  """
4821 
4822  try:
4823  vals = [closest(d, self['available_dates_dt']) for d in dateval]
4824  if take_set:
4825  return list(set(vals))
4826  else:
4827  return vals
4828 
4829  except IOError:
4830  print('If dateval is iterable, must contain datetimes')
4831 

Here is the call graph for this function:

def flextest.flexread.pflexible.Header.fill_backward (   self,
  kwargs 
)
see :func:`fill_backward` 

Definition at line 4779 of file pflexible.py.

4780  def fill_backward(self, **kwargs):
4781  """ see :func:`fill_backward` """
4782  fill_grids(self, add_attributes=True, **kwargs)

Here is the call graph for this function:

def flextest.flexread.pflexible.Header.lonlat (   self)
Add longitude and latitude attributes using data from header 

Definition at line 4768 of file pflexible.py.

4769  def lonlat(self):
4770  """ Add longitude and latitude attributes using data from header """
4771  lons = np.arange(self.outlon0, self.outlon0 + (self.dxout * self.numxgrid), self.dxout)
4772  lats = np.arange(self.outlat0, self.outlat0 + (self.dyout * self.numygrid), self.dyout)
4773  self.longitude = lons
4774  self.latitude = lats
def flextest.flexread.pflexible.Header.read_grid (   self,
  kwargs 
)
see :func:`read_grid` 

Definition at line 4775 of file pflexible.py.

4776  def read_grid(self, **kwargs):
4777  """ see :func:`read_grid` """
4778  self.FD = read_grid(self, **kwargs)

Member Data Documentation

flextest.flexread.pflexible.Header.FD

Definition at line 4777 of file pflexible.py.

flextest.flexread.pflexible.Header.fires

Definition at line 4796 of file pflexible.py.

flextest.flexread.pflexible.Header.latitude

Definition at line 4773 of file pflexible.py.

flextest.flexread.pflexible.Header.longitude

Definition at line 4772 of file pflexible.py.

flextest.flexread.pflexible.Header.trajectory

Definition at line 4785 of file pflexible.py.

flextest.flexread.pflexible.Header.version

Definition at line 4758 of file pflexible.py.


The documentation for this class was generated from the following file: