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.

Note

This class is managed by footprint.

  • info: Not documented

  • priority: PriorityLevel::DEFAULT (rank=1)

Automatic parameters from the footprint:

  • compressed (builtins.bool) - rwx - Compression flag.

    • Optional. Default is False.

  • filename (builtins.str) - rxx - File name (absolute or relative) of the resource.

  • fmtdelayedopen (builtins.bool) - rxx - Opening of the resource delayed (not at time of construction).

    • Optional. Default is False.

  • format (builtins.str) - rxx - Format of the resource.

    • Optional. Default is ‘LFI’.

    • Values: set([‘LFI’])

  • moveOnMass (builtins.bool) - rxx - If True, 3d fields are put on mass levels

    • Optional. Default is False.

  • openmode (builtins.str) - rxx - Opening mode.

    • Values: set([‘append’, ‘r’, ‘read’, ‘w’, ‘a’, ‘write’])

    • Remap: dict(append = ‘a’, read = ‘r’, write = ‘w’,)

  • true3d (builtins.bool) - rxx - If False, 3D fields are seen as a collection of H2D fields

    • Optional. Default is False.

Constructor. See its footprint for arguments.

close()[source]

Closes a LFI with ifsaux’ LFIFER.

compressed

Compression flag (see the documentation above for more details).

delfield(fid)[source]

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.

Parameters
  • 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 – the geometry on which extract data. None to keep the geometry untouched.

  • vertical_coordinate – defines the requested vertical coordinate of the V2DField (cf. :module:`epygram.geometries` coordinate possible values).

:param 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.

Parameters
  • exclude_extralevels – if True, not physical levels are removed

  • cheap_height – has no effect (compatibity with FA format)

  • global_shift_center – for global lon/lat grids, shift the center by the requested angle (in degrees). Enables a [0,360] grid to be shifted to a [-180,180] grid, for instance (with -180 argument).

extractprofile(*args, **kwargs)

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

Parameters
  • 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 – the longitude of the desired point.

  • lat – the latitude of the desired point.

  • geometry – 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. :module:`epygram.geometries` 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)

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.

Parameters
  • 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 – 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. :module:`epygram.geometries` 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)

  • global_shift_center – for global lon/lat grids, shift the center by the requested angle (in degrees). Enables a [0,360] grid to be shifted to a [-180,180] grid, for instance (with -180 argument).

filename

File name (absolute or relative) of the resource (see the documentation above for more details).

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

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

Parameters
  • 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.

fmtdelayedopen

Opening of the resource delayed (not at time of construction) (see the documentation above for more details).

format

Format of the resource (see the documentation above for more details).

listfields(**kwargs)[source]

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

moveOnMass

If True, 3d fields are put on mass levels (see the documentation above for more details).

open(openmode=None)[source]

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

Parameters

openmode – optional, to open with a specific openmode, eventually different from the one specified at initialization.

openmode

Opening mode (see the documentation above for more details).

readfield(*args, **kwargs)

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

Parameters
  • 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.

Parameters
  • 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)[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.

true3d

If False, 3D fields are seen as a collection of H2D fields (see the documentation above for more details).

what(*args, **kwargs)

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

Parameters
  • out – the output open file-like object

  • sortfieldsTrue if the fields have to be sorted by type.

writefield(field)[source]

Write a field in the resource.

Parameters

field – a epygram.base.Field instance or epygram.H2DField.

writefields(fieldset)[source]

Write the fields of the fieldset in the resource.

Parameters

fieldset – must be a epygram.base.FieldSet instance.