epygram.fields.D3Field — 3-D Field class

Contains the class that handle a Horizontal 2D field.

class epygram.fields.D3Field.D3CommonField(*args, **kw)[source]

Bases: epygram.base.Field

3-Dimensions common field class.

Footprint:

dict(
    attr = dict(
        comment = dict(
            access = 'rwd', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = str, 
            values = set([]),
        ), 
        data = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        fid = dict(
            access = 'rwx', 
            alias = set([]), 
            default = None, 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPDict, 
            values = set([]),
        ), 
        structure = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Type of Field geometry.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['3D']),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
as_dicts(subzone=None)

Export values as a list of dicts. - subzone: defines the LAM subzone to be included, in LAM case,

among: ‘C’, ‘CI’.
as_lists(order='C', subzone=None)

Export values as a dict of lists (in fact numpy arrays). - order: whether to flatten arrays in ‘C’ (row-major) or

‘F’ (Fortran, column-major) order.
  • subzone: defines the LAM subzone to be included, in LAM case,

    among: ‘C’, ‘CI’.

as_points(subzone=None)

Export values as a fieldset of points. - subzone: defines the LAM subzone to be included, in LAM case,

among: ‘C’, ‘CI’.
as_profiles(subzone=None)

Export values as a fieldset of profiles. - subzone: defines the LAM subzone to be included, in LAM case,

among: ‘C’, ‘CI’.
dctspectrum(k=None, subzone=None)[source]

Returns the DCT spectrum of the field, as a epygram.spectra.Spectrum instance. k is the level index to use to compute de DCT

extract_subdomain(geometry, interpolation='nearest', external_distance=None, exclude_extralevels=True)[source]

Extracts a subdomain from a field, given a new geometry.

Args:

  • geometry defines the geometry on which extract data

  • 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 interpolation;
    • if ‘cubic’, computes profile with horizontal cubic 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|

  • exclude_extralevels if True levels with no physical meaning are suppressed.

getvalue_ll(lon=None, lat=None, level=None, validity=None, interpolation='nearest', neighborinfo=False, one=True, external_distance=None)[source]

Returns the value of the field on point of coordinates (lon, lat, level):

  • if interpolation == ‘nearest’ (default), returns the value of the nearest neighboring gridpoint;
  • if interpolation == ‘linear’, computes and returns the field value with linear spline interpolation;
  • if interpolation == ‘cubic’, computes and returns the field value with cubic spline interpolation.

level is the True level not the index of the level. Depending on the vertical coordinate, it could be expressed in Pa, m. validity is a FieldValidity or a FieldValidityList instance

If neighborinfo is set to True, returns a tuple (value, (lon, lat)), with (lon, lat) being the actual coordinates of the neighboring gridpoint (only for interpolation == ‘nearest’).

lon and lat may be longer than 1. If one is False and len(lon) is 1, returns [value] instead of value.

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|

Warning: for interpolation on Gauss geometries, requires the pyproj module.

global_shift_center(longitude_shift)[source]

For global RegLLGeometry grids only ! Shifts the center of the geometry (and the data accordingly) by longitude_shift (in degrees). longitude_shift has to be a multiple of the grid’s resolution in longitude.

max(subzone=None)[source]

Returns the maximum value of data.

mean(subzone=None)[source]

Returns the mean value of data.

min(subzone=None)[source]

Returns the minimum value of data.

nonzero(subzone=None)[source]

Returns the number of non-zero values (whose absolute value > config.epsilon).

quadmean(subzone=None)[source]

Returns the quadratic mean of data.

spectral[source]

Returns True if the field is spectral.

stats(subzone=None)[source]

Computes some basic statistics on the field, as a dict containing: {‘min’, ‘max’, ‘mean’, ‘std’, ‘quadmean’, ‘nonzero’}.

See each of these methods for details.

  • subzone: optional, among (‘C’, ‘CI’), for LAM fields only, plots the data resp. on the C or C+I zone.

    Default is no subzone, i.e. the whole field.

std(subzone=None)[source]

Returns the standard deviation of data.

what(out=<open file '<stdout>', mode 'w' at 0x7f7b0e24c150>, validity=True, vertical_geometry=True, cumulativeduration=True, arpifs_var_names=False, fid=True)[source]

Writes in file a summary of the field.

Args:

  • out: the output open file-like object (duck-typing: out.write() only is needed).
  • vertical_geometry: if True, writes the validity of the field.
  • vertical_geometry: if True, writes the vertical geometry of the field.
  • cumulativeduration: if False, not written.
  • arpifs_var_names: if True, prints the equivalent ‘arpifs’ variable names.
  • fid: if True, prints the fid.
class epygram.fields.D3Field.D3Field(*args, **kw)[source]

Bases: epygram.fields.D3Field.D3CommonField

3-Dimensions field class. A field is defined by its identifier ‘fid’, its data, its geometry (gridpoint and optionally spectral), and its validity.

The natural being of a field is gridpoint, so that: a field always has a gridpoint geometry, but it has a spectral geometry only in case it is spectral.

Footprint:

dict(
    attr = dict(
        comment = dict(
            access = 'rwd', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = str, 
            values = set([]),
        ), 
        data = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        fid = dict(
            access = 'rwx', 
            alias = set([]), 
            default = None, 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPDict, 
            values = set([]),
        ), 
        geometry = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Geometry defining the position of the field gridpoints.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.geometries.D3Geometry.D3Geometry, 
            values = set([]),
        ), 
        processtype = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Generating process.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        spectral_geometry = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'For a spectral field, its spectral geometry handles                       spectral transforms and dimensions.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.geometries.SpectralGeometry.SpectralGeometry, 
            values = set([]),
        ), 
        structure = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Type of Field geometry.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['3D']),
        ), 
        validity = dict(
            access = 'rwx', 
            alias = set([]), 
            default = epygram.base.FieldValidityList::<<
                    as_list:: [epygram.base.FieldValidity::<epygram.base.FieldValidity object at 0x7f7afd5844d0>]
                >>, 
            info = 'Validity of the field.', 
            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,
    ),
)
compute_xy_spderivatives()

Compute the derivatives of field in spectral space, then come back in gridpoint space Returns the two derivative fields.

The spectral transform and derivatives subroutines are actually included in the spectral geometry’s compute_xy_spderivatives() method.

getdata(subzone=None, d4=False)[source]

Returns the field data, with 3D shape if the field is not spectral, 2D if spectral.

  • subzone: optional, among (‘C’, ‘CI’), for LAM fields only, returns the data resp. on the C or C+I zone. Default is no subzone, i.e. the whole field.

  • d4: if True, returned values are shaped in a 4 dimensions array

    if False, shape of returned values is determined with respect to geometry

Shape of 3D data:

  • Rectangular grids:

    grid[k,0,0] is SW, grid[k,-1,-1] is NE

    grid[k,0,-1] is SE, grid[k,-1,0] is NW

    with k the level

  • Gauss grids:

    grid[k,0,:Nj] is first (Northern) band of latitude, masked after Nj = number of longitudes for latitude j

    grid[k,-1,:Nj] is last (Southern) band of latitude (idem).

    with k the level

getlevel(level=None, k=None)[source]

Returns a level of the field as a new field. level is the requested level expressed in coordinate value (Pa, m...) k is the index of the requested level

getvalue_ij(i=None, j=None, k=None, t=None, one=True)[source]

Returns the value of the field on point of indices (i, j, k, t). Take care (i, j, k, t) is python-indexing, ranging from 0 to dimension - 1. k is the index of the level (not a value in Pa or m...) t is the index of the temporal dimension (not a validity object) k and t can be scalar even if i and j are arrays.

If one is False, returns [value] instead of value.

gp2sp(spectral_geometry)[source]

Transforms the gridpoint field into spectral space, according to the spectral geometry mandatorily passed as argument. Replaces data in place.

The spectral transform subroutine is actually included in the spectral geometry’s gp2sp() method.

select_subzone(subzone)[source]

If a LAMzone defines the field, select only the subzone from it. subzone among (‘C’, ‘CI’). Warning: modifies the field and its geometry in place !

setdata(data)[source]

Sets field data, checking data to have the good shape according to geometry.

sp2gp()[source]

Transforms the spectral field into gridpoint, according to its spectral geometry. Replaces data in place.

The spectral transform subroutine is actually included in the spectral geometry’s sp2gp() method.

class epygram.fields.D3Field.D3VirtualField(*args, **kwargs)[source]

Bases: epygram.fields.D3Field.D3CommonField

3-Dimensions Virtual field class.

Data is taken from other fields, either: - a given fieldset - a resource in which are stored fields defined by resource_fids.

Footprint:

dict(
    attr = dict(
        comment = dict(
            access = 'rwd', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = str, 
            values = set([]),
        ), 
        data = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        fid = dict(
            access = 'rwx', 
            alias = set([]), 
            default = None, 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPDict, 
            values = set([]),
        ), 
        fieldset = dict(
            access = 'rxx', 
            alias = set([]), 
            default = epygram.base.FieldSet::<<
                    as_list:: []
                >>, 
            info = 'Set of real fields that can compose the Virtual Field.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.base.FieldSet, 
            values = set([]),
        ), 
        resource = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Resource in which is stored the fields defined by                       resource_fids.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.base.Resource, 
            values = set([]),
        ), 
        resource_fids = dict(
            access = 'rxx', 
            alias = set([]), 
            default = footprints.stdtypes.FPList::<<
                    as_list:: []
                >>, 
            info = 'Definition of the fields in resource that compose the                       virtual field.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPList, 
            values = set([]),
        ), 
        structure = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Type of Field geometry.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['3D']),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
getdata(subzone=None, d4=False)[source]

Returns the field data, with 3D shape if the field is not spectral, 2D if spectral.

  • subzone: optional, among (‘C’, ‘CI’), for LAM fields only, returns the data resp. on the C or C+I zone. Default is no subzone, i.e. the whole field.

  • d4: if True, returned values are shaped in a 4 dimensions array

    if False, shape of returned values is determined with respect to geometry

Shape of 3D data:

  • Rectangular grids:

    grid[k,0,0] is SW, grid[k,-1,-1] is NE

    grid[k,0,-1] is SE, grid[k,-1,0] is NW

    with k the level

  • Gauss grids:

    grid[k,0,:Nj] is first (Northern) band of latitude, masked after Nj = number of longitudes for latitude j

    grid[k,-1,:Nj] is last (Southern) band of latitude (idem).

    with k the level

getlevel(level=None, k=None)[source]

Returns a level of the field as a new field. level is the requested level expressed in coordinate value (Pa, m...) k is the index of the requested level

getvalue_ij(i=None, j=None, k=None, t=None, one=True)[source]

Returns the value of the field on point of indices (i, j, k, t). Take care (i, j, k, t) is python-indexing, ranging from 0 to dimension - 1. k is the index of the level (not a value in Pa or m...) t is the index of the temporal dimension (not a validity object) k and t can be scalar even if i and j are arrays.

If one is False, returns [value] instead of value.

gp2sp(spectral_geometry)[source]

Transforms the gridpoint field into spectral space, according to the spectral geometry mandatorily passed as argument. Replaces data in place.

The spectral transform subroutine is actually included in the spectral geometry’s gp2sp() method.

setdata(data)[source]

Sets field data, checking data to have the good shape according to geometry.

sp2gp()[source]

Transforms the spectral field into gridpoint, according to its spectral geometry. Replaces data in place.

The spectral transform subroutine is actually included in the spectral geometry’s sp2gp() method.

Previous topic

Fields

Next topic

epygram.fields.H2DField — Horizontal 2-D Field class

This Page