epygram.formats.FA — Interface-Class to the FA format

Contains the class for FA format.

Plus a function to guess a field type given its name.

epygram.formats.FA.inquire_field_dict(fieldname)[source]

Returns the info contained in the FA _field_dict for the requested field.

epygram.formats.FA.get_generic_fid(fieldname)

Return a generic fid from fieldname (via Field Dict).

class epygram.formats.FA.FA(*args, **kwargs)[source]

Bases: epygram.resources.FileResource.FileResource

Class implementing all specificities for FA resource format.

Footprint:

dict(
    attr = dict(
        cdiden = dict(
            access = 'rwx', 
            alias = set([]), 
            default = 'unknown', 
            info = 'With openmode == 'w', identifies the FA by a keyword, usually the model abbreviation.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        default_compression = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Default compression for writing fields in resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPDict, 
            values = set([]),
        ), 
        filename = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'File name (absolute or relative) of the resource.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        fmtdelayedopen = dict(
            access = 'rxx', 
            alias = set([]), 
            default = False, 
            info = 'Opening of the resource delayed (not at time of construction).', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = bool, 
            values = set([]),
        ), 
        format = dict(
            access = 'rxx', 
            alias = set([]), 
            default = 'FA', 
            info = 'Format of the resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['FA']),
        ), 
        headername = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'With openmode == 'w', name of an existing header, for the new FA to use its geometry.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        openmode = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Opening mode.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(
                append = 'a', 
                read = 'r', 
                write = 'w',
            ), 
            values = set(['a', 'write', 'r', 'w', 'read', 'append']),
        ), 
        processtype = dict(
            access = 'rwx', 
            alias = set([]), 
            default = 'analysis', 
            info = 'With openmode == 'w', identifies the processus that produced the resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        validity = dict(
            access = 'rwx', 
            alias = set([]), 
            default = None, 
            info = 'With openmode == 'w', describes the temporal validity of the resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.base.FieldValidityList, 
            values = set([]),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
close()[source]

Closes a FA with ifsaux’ FAIRME.

delfield(fieldname)[source]

Deletes a field from file “in place”.

extract_subdomain(*args, **kwargs)

Extracts a subdomain from the FA resource, given its fid and the geometry to use.

Args:

  • pseudoname must have syntax: ‘K*PARAMETER’, K being the kind of surface (S,P,H,V), * being a true star character, and PARAMETER being the name of the parameter requested, as named in FA.
  • geometry is the geometry on which extract data.
  • vertical_coordinate defines the requested vertical coordinate of the V2DField (cf. epygram.geometries.V1DGeometry coordinate possible values).
  • interpolation defines the interpolation function used to compute the profile points locations from the fields grid:
    • if ‘nearest’, each horizontal point of the section is taken as the horizontal nearest neighboring gridpoint;
    • if ‘linear’ (default), each horizontal point of the section is computed with linear spline interpolation;
    • if ‘cubic’, each horizontal point of the section is computed with linear spline interpolation.
  • cheap_height: if True and vertical_coordinate among (‘altitude’, ‘height’), the computation of heights is done without taking hydrometeors into account (in R computation) nor NH Pressure departure (Non-Hydrostatic data). Computation therefore faster.
extractprofile(*args, **kwargs)[source]

Extracts a vertical profile from the FA resource, given its pseudoname and the geographic location (lon/lat) of the profile.

Args:

  • pseudoname must have syntax: ‘K*PARAMETER’, K being the kind of surface (S,P,H,V), * being a true star character, and PARAMETER being the name of the parameter requested, as named in FA.
  • lon is the longitude of the desired point.
  • lat is the latitude of the desired point.
  • geometry is the geometry on which extract data. If None, it is built from lon/lat.
  • vertical_coordinate defines the requested vertical coordinate of the V1DField (as number of GRIB2 norm: http://apps.ecmwf.int/codes/grib/format/grib2/ctables/4/5).
  • interpolation defines the interpolation function used to compute the profile at requested lon/lat from the fields grid: - if ‘nearest’ (default), extracts profile at the horizontal nearest neighboring gridpoint; - if ‘linear’, computes profile with horizontal linear spline interpolation; - if ‘cubic’, computes profile with horizontal cubic spline interpolation.
  • cheap_height: if True and vertical_coordinate among (‘altitude’, ‘height’), the computation of heights is done without taking hydrometeors into account (in R computation) nor NH Pressure departure (Non-Hydrostatic data). Computation therefore faster.
  • external_distance can be a dict containing the target point value and an external field on the same grid as self, to which the distance is computed within the 4 horizontally nearest points; e.g. {‘target_value’:4810, ‘external_field’:an_H2DField_with_same_geometry}. If so, the nearest point is selected with distance = |target_value - external_field.data|
extractsection(*args, **kwargs)[source]

Extracts a vertical section from the FA resource, given its pseudoname and the geographic (lon/lat) coordinates of its ends. The section is returned as a V2DField.

Args:

  • pseudoname must have syntax: ‘K*PARAMETER’, K being the kind of surface (S,P,H,V), * being a true star character, and PARAMETER being the name of the parameter requested, as named in FA.
  • end1 must be a tuple (lon, lat).
  • end2 must be a tuple (lon, lat).
  • geometry is the geometry on which extract data. If None, defaults to linearily spaced positions computed from points_number.
  • points_number defines the total number of horizontal points of the section (including ends). If None, defaults to a number computed from the ends and the resolution.
  • resolution defines the horizontal resolution to be given to the field. If None, defaults to the horizontal resolution of the field.
  • vertical_coordinate defines the requested vertical coordinate of the V2DField (cf. epygram.geometries.V1DGeometry coordinate possible values).
  • interpolation defines the interpolation function used to compute the profile points locations from the fields grid:
    • if ‘nearest’, each horizontal point of the section is taken as the horizontal nearest neighboring gridpoint;
    • if ‘linear’ (default), each horizontal point of the section is computed with linear spline interpolation;
    • if ‘cubic’, each horizontal point of the section is computed with linear spline interpolation.
  • cheap_height: if True and vertical_coordinate among (‘altitude’, ‘height’), the computation of heights is done without taking hydrometeors into account (in R computation) nor NH Pressure departure (Non-Hydrostatic data). Computation therefore faster.
fieldencoding(*args, **kwargs)[source]

Returns a dict containing info about how the field is encoded: spectral? and compression. Interface to ifsaux’ FANION.

find_fields_in_resource(seed=None, fieldtype=[], generic=False)[source]

Returns a list of the fields from resource whose name match the given seed.

Args:

  • seed: might be a regular expression, a list of regular expressions or None. If None (default), returns the list of all fields in resource.
  • fieldtype: optional, among (‘H2D’, ‘Misc’) or a list of these strings. If provided, filters out the fields not of the given types.
  • generic: if True, returns complete fid’s, union of {‘FORMATname’:fieldname} and the according generic fid of the fields.
listfields(**kwargs)[source]

Returns a list containing the FA identifiers of all the fields of the resource.

open(geometry=None, spectral_geometry=None, validity=None, openmode=None)[source]

Opens a FA with ifsaux’ FAITOU, and initializes some attributes.

Actually, as FAITOU needs an existing header with ‘w’ openmode, opening file in ‘w’ openmode will require else an existing header to which the resource is linked, or to create a header from a geometry via _create_header_from_geometry() function. This explains the eventual need for geometry/spectral_geometry/validity in open() method. If neither headername nor geometry are available, resource is not opened: the open() will be called again at first writing of a field in resource.

Args:

readfield(*args, **kwargs)[source]

Reads one field, given its FA name, and returns a Field instance. Interface to Fortran routines from ‘ifsaux’.

Args:

  • fieldname: FA fieldname
  • getdata: if False, only metadata are read, the field do not contain data.
  • footprints_builder: if True, uses footprints.proxy to build fields. Defaults to False for performance reasons.
readfields(requestedfields=None, getdata=True)[source]

Returns a epygram.base.FieldSet containing requested fields read in the resource.

Args:

  • requestedfields: might be
    • a regular expression (e.g. ‘S*WIND.[U,V].PHYS’)
    • a list of FA fields identifiers with regular expressions (e.g. [‘SURFTEMPERATURE’, ‘S0[10-20]WIND.?.PHYS’])
    • if not specified, interpretated as all fields that will be found in resource
  • getdata: optional, if False, only metadata are read, the fields do not contain data. Default is True.
rename_field(fieldname, new_name)[source]

Renames a field “in place”.

sortfields()[source]

Returns a sorted list of fields with regards to their name and nature, as a dict of lists.

split_UV(fieldseed)

Return two lists of fids corresponding respectively to U and V components of wind, given a fieldseed.

what(*args, **kwargs)[source]

Writes in file a summary of the contents of the FA.

Args:

  • out: the output open file-like object (duck-typing: out.write() only is needed).

  • details: ‘spectral’ if spectralness of fields is requested;

    ‘compression’ if information about fields compression is requested.

  • sortfields: True if the fields have to be sorted by type.

  • *fastlist

writefield(field, compression=None)[source]

Write a field in the resource.

Args:

writefields(fieldset, compression=None)[source]

Write the fields of the fieldset in the resource.

Args:

  • fieldset: must be a epygram.base.FieldSet instance.
  • compression: must be a list of compression dicts (cf. writefield() method), of length equal to the length of the fieldset, and with the same order.

Previous topic

Formats

Next topic

epygram.formats.LFA — Interface-Class to the LFA format

This Page