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

Contains the class to handle LFI format.

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

Bases: epygram.resources.FileResource.FileResource

Class implementing all specificities for LFI resource format.

Footprint:

dict(
    attr = dict(
        compressed = dict(
            access = 'rwx', 
            alias = set([]), 
            default = False, 
            info = 'Compression flag.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = bool, 
            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 = 'LFI', 
            info = 'Format of the resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['LFI']),
        ), 
        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']),
        ), 
        true3d = dict(
            access = 'rxx', 
            alias = set([]), 
            default = False, 
            info = '', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = bool, 
            values = set([]),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
close()[source]

Closes a LFI with ifsaux’ LFIFER.

delfield(fid)

Deletes a field from file “in place”.

extract_subdomain(*args, **kwargs)

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

Args:

  • fid must have syntax: (‘PARAMETER’, ‘*’) if not true3d else ‘PARAMETER’, * being a true star character, and PARAMETER being the name of the parameter requested, as named in LFI.
  • 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 has no effect (compatibity with FA format)
extractprofile(*args, **kwargs)[source]

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

Args:

  • fid must have syntax: (‘PARAMETER’, ‘*’) if not true3d, else ‘PARAMETER’, * being a true star character, and PARAMETER being the name of the parameter requested, as named in LFI.
  • 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 (cf. epygram.geometries.V1DGeometry coordinate possible values).
  • 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.
  • 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|
  • cheap_height has no effect (compatibity with FA format)
extractsection(*args, **kwargs)[source]

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

Args:

  • fid must have syntax: (‘PARAMETER’, ‘*’) if not true3d else ‘PARAMETER’, * being a true star character, and PARAMETER being the name of the parameter requested, as named in LFI.
  • 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 has no effect (compatibity with FA format)
find_fields_in_resource(seed=None, fieldtype=[], generic=False)[source]

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

Args:

  • seed: might be: - a tuple of regular expressions, - a string meant to be converted to a tuple - a list of regular expressions tuples - None. If None (default), returns the list of all fields in resource. If self.true3d: tuples are replaced by string
  • 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 a list of tuples (fieldname, generic fid) of the fields.
listfields(**kwargs)[source]

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

open()[source]

Opens a LFI with ifsaux’ LFIOUV, and initializes some attributes.

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

Reads one field, given its identifier (tuple (LFI name, level)), and returns a Field instance. Interface to Fortran routines from ‘ifsaux’.

Args:

  • fieldidentifier: “LFI fieldname” if true3d, else (LFI fieldname, level).

  • getdata: optional, if False, only metadata are read, the field do not contain data.

    Default is True.

readfields(requestedfields=None, getdata=True)[source]

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

Args:

  • requestedfields: might be

    • a tuple of regular expressions (e.g. (‘RVT’, ‘?’)) or a regular expression (e.g. ‘R?T’) if true3d
    • a list of LFI fields identifiers with regular expressions (e.g. [(‘COVER???’, 0), (‘RVT’, ‘*’)])
    • 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(fid, new_fid)

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.

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

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

Args:

  • out: the output open file-like object (duck-typing: out.write() only is needed).
  • sortfields: True if the fields have to be sorted by type.
writefield(field)

Write a field in the resource.

Args:

writefields(fieldset)

Write the fields of the fieldset in the resource.

Args:

Previous topic

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

Next topic

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

This Page