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

Contains the class that handle a Horizontal 2D field.

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

Bases: epygram.fields.D3Field.D3Field

Horizontal 2-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.H2DGeometry.H2DGeometry, 
            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(['H2D']),
        ), 
        validity = dict(
            access = 'rwx', 
            alias = set([]), 
            default = epygram.base.FieldValidityList::<<
                    as_list:: [epygram.base.FieldValidity::<epygram.base.FieldValidity object at 0x7f7afd4d6c90>]
                >>, 
            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,
    ),
)
extract_zoom(zoom)

Extract an unstructured field with the gridpoints contained in zoom, zoom being a dict(lonmin=, lonmax=, latmin=, latmax=).

getlevel(level=None, k=None)

Returns self. Useless but for compatibility reasons.

morph_with_points(points, alpha=1.0, morphing='nearest', **kwargs)

Perturb the field values with the values of a set of points.

points meant to be a list/fieldset of PointField. alpha is the blending value, ranging from 0. to 1.:

e.g. with ‘nearest’ morphing, the final value of the point is alpha*point.value + (1-alpha)*original_field.value
morphing is the way the point modify the field:
  • ‘nearest’: only the nearest point is modified
  • ‘exp_decay’: modifies the surrounding points with an isotrop exponential decay weighting
  • ‘gaussian’: modifies the surrounding points with an isotrop gaussian weighting. Its standard deviation sigma must then be passed as argument, in meters.
plotfield(subzone=None, title=None, gisquality='i', specificproj=None, zoom=None, existingbasemap=None, minmax=None, graphicmode='colorshades', levelsnumber=21, colormap='jet', center_cmap_on_0=False, drawrivers=False, drawcoastlines=True, drawcountries=True, meridians='auto', parallels='auto', colorbar='right', minmax_in_title=True, departments=False, existingfigure=None, pointsize=20, contourcolor='blue', contourwidth=1, contourlabel=True, bluemarble=0.0, background=False, mask_threshold=None, contourlabelfmt='%0i', pointsmarker=', ')[source]

Makes a simple plot of the field, with a number of options.

Requires matplotlib

Options:

  • subzone: 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.

  • gisquality: among (‘c’, ‘l’, ‘i’, ‘h’, ‘f’) – by increasing quality. Defines the quality for GIS elements (coastlines, countries boundaries...). Cf. ‘basemap’ doc for more details.

  • specificproj: enables to make basemap on the specified projection, among: ‘kav7’, ‘cyl’, ‘ortho’, (‘nsper’, {...}) (cf. Basemap doc).

    In ‘nsper’ case, the {} may contain:

    • ‘sat_height’ = satellite height in km;
    • ‘lon’ = longitude of nadir in degrees;
    • ‘lat’ = latitude of nadir in degrees.
  • zoom: specifies the lon/lat borders of the map, implying hereby a ‘cyl’ projection. Must be a dict(lonmin=, lonmax=, latmin=, latmax=).

    Overwrites specificproj.

  • existingbasemap: as making Basemap is the most time-consuming step, it is possible to bring an already existing basemap object. In that case, all the above options are ignored, overwritten by those of the existingbasemap.

  • title: title for the plot. Default is field identifier.

  • minmax: defines the min and max values for the plot colorbar.

    Syntax: [min, max]. [0.0, max] also works. Default is min/max of the field.

  • graphicmode: among (‘colorshades’, ‘contourlines’, ‘points’).

  • levelsnumber: number of levels for contours and colorbar.

  • colormap: name of the matplotlib colormap to use (or an epygram one, or a user-defined one, cf. config.usercolormaps).

  • center_cmap_on_0: aligns the colormap center on the value 0.

  • drawrivers: to add rivers on map.

  • drawcoastlines: to add coast lines on map.

  • drawcountries: to add countries on map.

  • colorbar: if False, hide colorbar the plot; else, befines the colorbar position, among (‘bottom’, ‘right’). Defaults to ‘right’.

  • meridians and parallels enable to fine-tune the choice of lines to plot, with either:

    • ‘auto’: automatic scaling to the basemap extents
    • ‘default’: range(0,360,10) and range(-90,90,10)
    • a list of values
    • a grid step, e.g. 5 to plot each 5 degree.
    • None: no one is plot
    • meridians == ‘greenwich’ // ‘datechange’ // ‘greenwich+datechange’ parallels == ‘equator’ // ‘polarcircles’ // ‘tropics’ or any combination (+) will plot only these.
  • minmax_in_title: if True and minmax != None, adds min and max values in title.

  • departments: if True, adds the french departments on map (instead of countries).

  • existingfigure: to plot the field over an existing figure (e.g. contourlines over colorshades). Be aware that no check is done between the existingfigure basemap and either the existingbasemap or the one that is created from the field geometry: there might be inconsistency.

  • pointsize: size of points for graphicmode == ‘points’.

  • contourcolor: color or colormap to be used for ‘contourlines’ graphicmode. It can be either a legal html color name, or a colormap name.

  • contourwidth: width of contours for ‘contourlines’ graphicmode.

  • contourlabel: displays labels on contours.

  • bluemarble: if > 0.0 (and <=1.0), displays NASA’s “blue marble” as background. The numerical value sets its transparency.

  • background: if True, set a background color to continents and oceans.

  • mask_threshold: dict with min and/or max value(s) to mask outside.

  • contourlabelfmt: format of the contour labels: e.g. 273.15 will appear: ‘%0i’ => 273, ‘%0f’ => 273.150000, ‘%0.2f’ => 273.15,

    ‘%04i’ => 0273, ‘%0.5e’ => 2.731500e+02

  • pointsmarker: shape of the points if graphicmode=’points’. Cf. matplotlib.scatter() for possible markers.

This method uses (hence requires) ‘matplotlib’ and ‘basemap’ libraries.

Previous topic

epygram.fields.D3Field — 3-D Field class

Next topic

epygram.fields.V2DField — Vertical 2-D Field class

This Page