epygram.formats.FA
— InterfaceClass 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, defaults_to_Misc=True)[source]¶ Returns the info contained in the FA _field_dict for the requested fieldname.

epygram.formats.FA.
get_generic_fid
(fieldname)[source]¶ Return a generic fid from fieldname (via Field Dict).

epygram.formats.FA.
find_wind_pair
(fieldname)[source]¶ For a wind fieldname, find and return the pair.

class
epygram.formats.FA.
FA
(*args, **kwargs)[source]¶ Bases:
epygram.resources.FileResource.FileResource
Class implementing all specificities for FA resource format.
Note
This class is managed by footprint.
 info: Not documented
 priority: PriorityLevel::DEFAULT (rank=1)
Automatic parameters from the footprint:
 cdiden (
str
)  rwx  With openmode == ‘w’, identifies the FA by a keyword, usually the model abbreviation. Optional. Default is ‘unknown’.
 default_compression (
footprints.stdtypes.FPDict
)  rxx  Default compression for writing fields in resource. Optional. Default is None.
 filename (
str
)  rxx  File name (absolute or relative) of the resource.  fmtdelayedopen (
bool
)  rxx  Opening of the resource delayed (not at time of construction). Optional. Default is False.
 format (
str
)  rxx  Format of the resource. Optional. Default is ‘FA’.
 Values: set([‘FA’])
 headername (
str
)  rxx  With openmode == ‘w’, name of an existing header, for the new FA to use its geometry. Optional. Default is None.
 openmode (
str
)  rxx  Opening mode. Values: set([‘a’, ‘write’, ‘r’, ‘w’, ‘read’, ‘append’])
 Remap: dict(append = ‘a’, read = ‘r’, write = ‘w’,)
 processtype (
str
)  rwx  With openmode == ‘w’, identifies the processus that produced the resource. Optional. Default is ‘analysis’.
 validity (
epygram.base.FieldValidityList
)  rwx  With openmode == ‘w’, describes the temporal validity of the resource. Optional. Default is None.

extract_subdomain
(*args, **kwargs)¶ Extracts a subdomain from the FA resource, given its fid and the geometry to use.
Parameters:  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.vertical_coordinates 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 (NonHydrostatic data). Computation therefore faster.

extractprofile
(*args, **kwargs)¶ Extracts a vertical profile from the FA resource, given its pseudoname and the geographic location (lon/lat) of the profile.
Parameters:  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 – the longitude of the desired point.
 lat – the latitude of the desired point. If both None, extract a horizontallyaveraged profile.
 geometry – can replace lon/lat, geometry on which to 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, (cf. epygram.geometries.vertical_coordinates 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.
 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 (NonHydrostatic 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 = abs(target_value  external_field.data)

extractsection
(*args, **kwargs)¶ 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.
Parameters:  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 – can replace end1/end2, geometry on which to 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 aka typeOfFirstFixedSurface in GRIB2, (cf. epygram.geometries.vertical_coordinates 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 (NonHydrostatic data). Computation therefore faster.

fieldencoding
(*args, **kwargs)¶ Returns a dict containing info about how the field fieldname is encoded: spectralness 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.
Parameters:  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.
Parameters:  geometry – optional, must be a
epygram.geometries.D3Geometry
(or heirs) instance.  spectral_geometry – optional, must be a
epygram.geometries.SpectralGeometry
instance.  validity – optional, must be a
epygram.base.FieldValidity
or aepygram.base.FieldValidityList
instance.  openmode – optional, to open with a specific openmode, eventually different from the one specified at initialization.
 geometry – optional, must be a

readfield
(*args, **kwargs)¶ Reads one field, given its FA name, and returns a Field instance. Interface to Fortran routines from ‘ifsaux’.
Parameters:  fieldname – FA fieldname
 getdata – if False, only metadata are read, the field do not contain data.
 footprints_proxy_as_builder – if True, uses footprints.proxy to build fields.

readfields
(requestedfields=None, getdata=True)[source]¶ Returns a
epygram.base.FieldSet
containing requested fields read in the resource.Parameters:  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[1020]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.
 requestedfields –

sortfields
()[source]¶ Returns a sorted list of fields with regards to their name and nature, as a dict of lists.

split_UV
(fieldseed)[source]¶ Return two lists of fids corresponding respectively to U and V components of wind, given a fieldseed.

what
(*args, **kwargs)¶ Writes in file a summary of the contents of the FA.
Parameters:  out – the output open filelike object.
 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.

writefield
(field, compression=None)[source]¶ Write a field in the resource.
Parameters:  field – a
epygram.base.Field
instance orepygram.fields.H2DField
.  compression – optional, a (possibly partial) dict containing
parameters for field compression (in case of a
epygram.fields.H2DField
). Ex: {‘KNGRIB’: 2, ‘KDMOPL’: 5, ‘KPUILA’: 1, ‘KSTRON’: 10, ‘KNBPDG’: 24, ‘KNBCSP’: 24}
 field – a

writefields
(fieldset, compression=None)[source]¶ Write the fields of the fieldset in the resource.
Parameters:  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.
 fieldset – must be a