epygram.fields.H2DVectorField — Horizontal 2-D Vector Field class

Contains the class for a Horizontal 2D field.

Plus a function to create a Vector field from 2 scalar fields.

epygram.fields.H2DVectorField.make_vector_field(fX, fY)[source]

Creates a new epygram.H2DVectorField from two epygram.H2DField fX, fY representing resp. the X and Y components of the vector in the field geometry.

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

Bases: epygram.base.Field

Horizontal 2-Dimensions Vector field class.

This is a wrapper to a list of H2DField(s), representing the components of a vector projected on its geometry (the grid axes).

The attribute H2DVectorField.data is a proxy to the data of the components.

Footprint:

dict(
    attr = dict(
        comment = dict(
            access = 'rwd', 
            alias = set([]), 
            default = None, 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = str, 
            values = set([]),
        ), 
        components = dict(
            access = 'rxx', 
            alias = set([]), 
            default = footprints.stdtypes.FPList::<<
                    as_list:: []
                >>, 
            info = 'List of Fields that each compose a component of the                       vector.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPList, 
            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([]),
        ), 
        processtype = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Generating process.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            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 0x7f7afd4ec990>]
                >>, 
            info = 'Validity of the field.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = epygram.base.FieldValidityList, 
            values = set([]),
        ), 
        vector = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Intrinsic vectorial nature of the field.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            type = bool, 
            values = set([True]),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
attach_components(*components)

Attach components of the vector to the VectorField. components must be a series of H2DField.

compute_direction()

Returns a epygram.H2DField whose data is the direction of the Vector field, in degrees. E.g. 45° is a South-Westerly vector.

compute_vordiv(divide_by_m=False)

Compute vorticity and divergence fields from the vector field.

If divide_by_m is True, apply f = f/m beforehand, where m is the map factor.

getdata(subzone=None, **kwargs)[source]

Returns the field data, with 2D shape if the field is not spectral, 1D if spectral, as a tuple with data for each component.

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

Shape of 2D data: (x (0) being the X component, y (1) the Y one)

  • Rectangular grids:

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

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

  • Gauss grids:

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

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

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

Returns the value of the different components of the field from indexes.

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

Returns the value of the different components of the field from coordinates.

global_shift_center(longitude_shift)

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.

gp2sp(spectral_geometry=None)[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.

map_factorize(reverse=False)

Multiply the field by its map factor. If *reverse, divide.

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).

plotfield(existingfigure=None, subzone=None, title=None, gisquality='i', specificproj=None, zoom=None, existingbasemap=None, drawcoastlines=True, drawcountries=True, drawrivers=False, parallels='auto', meridians='auto', subsampling=1, symbol='barbs', symbol_options={'color': 'k'}, plot_module=True, plot_module_options={}, bluemarble=0.0, background=False, quiverkey=None, quiver_options={}, components_are_projected_on='grid', map_factor_correction=True)[source]

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

Options:

  • existingfigure: to plot the vectors over an existing figure (e.g. 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.

  • 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...). Default is ‘i’. 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.

    Overwritten by zoom.

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

  • drawrivers: to add rivers on map.

  • drawcoastlines: to add coast lines on map.

  • drawcountries: to add countries on map.

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

  • 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
    • meridian == ‘greenwich’ // ‘datechange’ // ‘greenwich+datechange’ parallel == ‘equator’ // ‘polarcircles’ // ‘tropics’ or any combination (+) will plot only these.
  • subsampling: to subsample the number of gridpoints to plot. Ex: subsampling = 10 will only plot one gridpoint upon 10.

  • symbol: among (‘barbs’, ‘arrows’, ‘stream’)

  • symbol_options: a dict of options to be passed to barbs or quiver method.

  • plot_module: to plot module as colorshades behind vectors.

  • plot_module_options: options to be passed to module.plotfield().

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

  • quiverkey: to activate quiverkey; must contain arguments to be passed to pyplot.quiverkey(), as a dict.

  • components_are_projected_on: inform the plot on which axes the vector components are projected on (‘grid’ or ‘lonlat’).

  • map_factor_correction: if True, applies a correction of magnitude to vector due to map factor.

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

quadmean(subzone=None)[source]

Returns the quadratic mean of data.

reproject_wind_on_lonlat(map_factor_correction=True, reverse=False)

Reprojects a wind vector (u, v) from the grid axes onto real sphere, i.e. with components on true zonal/meridian axes.

If map_factor_correction, applies a correction of magnitude due to map factor.

If reverse, apply the reverse reprojection.

setdata(data)[source]

Sets data, checking it to be:

  • 2D if not spectral,
  • 1D if spectral.

data = (data_i for i components)

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.

spectral

Returns True if the field is spectral.

std(subzone=None)[source]

Returns the standard deviation of data.

to_module()[source]

Returns a epygram.H2DField whose data is the module of the Vector field.

what(out=<open file '<stdout>', mode 'w' at 0x7f7b0e24c150>, vertical_geometry=True, cumulativeduration=True)

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 vertical geometry of the field.

Previous topic

epygram.fields.MiscField — Miscellaneous Field class

Next topic

Formats

This Page