FLEXPART Testing Environment CTBTO WO8
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
flextest.flexread.read_header.Header Class Reference
Inheritance diagram for flextest.flexread.read_header.Header:
Inheritance graph
[legend]
Collaboration diagram for flextest.flexread.read_header.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.read_header.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 778 of file read_header.py.

Constructor & Destructor Documentation

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

Definition at line 834 of file read_header.py.

835  def __init__(self, path=None, headerfile=None, version='V8', **readheader_ops):
836  """
837 
838 
839  """
840  try:
841  h = read_header(path, **readheader_ops)
842  self.set_with_dict(h)
843  self.lonlat()
844  self.version = 'V8'
845  except:
846  traceback.print_exc()
847  raise IOError('''
848  Could not set header variables.
849  Does the `header` file exist in path?\n{0}'''.format(path))
850 
851 
852 

Here is the call graph for this function:

Member Function Documentation

def flextest.flexread.read_header.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 872 of file read_header.py.

873  def add_fires(self, **kwargs):
874  """ uses the :mod:`emissions` module to read the MODIS hotspot data and
875  add it to the header class as a 'fires' attribute.
876 
877  **This function is only available within NILU.**
878 
879  """
880 
881  from nilu.pflexpart import emissions as em
882  self.fires = None
883  for day in self.available_dates_dt:
884  # day = day[:8]
885  firedata = em.MODIS_hotspot(day)
886  daily = firedata.daily
887  # pdb.set_trace()
888  if daily is None:
889  continue
890  else:
891  if self.fires == None:
892  self.fires = daily
893  else:
894 
895  self.fires = np.hstack((self.fires, daily)).view(np.recarray)
def flextest.flexread.read_header.Header.add_trajectory (   self,
  kwargs 
)
see :func:`read_trajectories` 

Definition at line 868 of file read_header.py.

869  def add_trajectory(self, **kwargs):
870  """ see :func:`read_trajectories` """
871  self.trajectory = read_trajectories(self)
def flextest.flexread.read_header.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 917 of file read_header.py.

918  def closest_date(self, dateval, fmt=None):
919  """ given a datestring or datetime, tries to find the closest date.
920  if passed a list, assumes it is a list of datetimes
921 
922  """
923 
924  if isinstance(dateval, str):
925  if not fmt:
926  if len(dateval) == 8:
927  fmt = '%Y%m%d'
928  if len(dateval) == 14:
929  fmt = '%Y%m%d%H%M%S'
930  else:
931  raise IOError("no format provided for datestring")
932  print("Assuming date format: {0}".format(fmt))
933  dateval = datetime.datetime.strptime(dateval, fmt)
934 
935  return closest(dateval, self['available_dates_dt'])
936 

Here is the call graph for this function:

def flextest.flexread.read_header.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 896 of file read_header.py.

897  def closest_dates(self, dateval, fmt=None, take_set=False):
898  """ given an iterable of datetimes, finds the closest dates.
899  if passed a list, assumes it is a list of datetimes
900 
901  if take_set=True, then a set of unique values will be returned.
902  This can be used with H.read_grid as the value for time_ret to
903  return only the grids matching the array of times.
904  See (e.g. `extract_curtain`).
905  """
906 
907  try:
908  vals = [closest(d, self['available_dates_dt']) for d in dateval]
909  if take_set:
910  return list(set(vals))
911  else:
912  return vals
913 
914  except IOError:
915  print('If dateval is iterable, must contain datetimes')
916 

Here is the call graph for this function:

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

Definition at line 864 of file read_header.py.

865  def fill_backward(self, **kwargs):
866  """ see :func:`fill_backward` """
867  fill_grids(self, add_attributes=True, **kwargs)

Here is the call graph for this function:

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

Definition at line 853 of file read_header.py.

854  def lonlat(self):
855  """ Add longitude and latitude attributes using data from header """
856  lons = np.arange(self.outlon0, self.outlon0 + (self.dxout * self.numxgrid), self.dxout)
857  lats = np.arange(self.outlat0, self.outlat0 + (self.dyout * self.numygrid), self.dyout)
858  self.longitude = lons
859  self.latitude = lats
def flextest.flexread.read_header.Header.read_grid (   self,
  kwargs 
)
see :func:`read_grid` 

Definition at line 860 of file read_header.py.

861  def read_grid(self, **kwargs):
862  """ see :func:`read_grid` """
863  self.FD = read_grid(self, **kwargs)

Member Data Documentation

flextest.flexread.read_header.Header.FD

Definition at line 862 of file read_header.py.

flextest.flexread.read_header.Header.fires

Definition at line 881 of file read_header.py.

flextest.flexread.read_header.Header.latitude

Definition at line 858 of file read_header.py.

flextest.flexread.read_header.Header.longitude

Definition at line 857 of file read_header.py.

flextest.flexread.read_header.Header.trajectory

Definition at line 870 of file read_header.py.

flextest.flexread.read_header.Header.version

Definition at line 843 of file read_header.py.


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