epygram.fields.D3VectorField — 3-D Vector Field class

Contains the class for a 3D field.

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


epygram.fields.D3VectorField.make_vector_field(*components)[source]

Creates a new epygram.D3VectorField or subclass from several epygram.D3Field or subclass representing the components of the vector in the field geometry.


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

Bases: epygram.base.Field

3-Dimensions Vector field class.

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

Note

This class is managed by footprint.

  • info: Not documented

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

Automatic parameters from the footprint:

  • comment (builtins.str) - rwd - Not documented, sorry.

    • Optional. Default is None.

  • components (footprints.stdtypes.FPList) - rxx - List of Fields that each compose a component of the vector.

    • Optional. Default is FPList::<<as_list:: []>>.

  • fid (footprints.stdtypes.FPDict) - rwx - Not documented, sorry.

  • misc_metadata (footprints.stdtypes.FPDict) - rwd - Not documented, sorry.

    • Optional. Default is FPDict::<<as_dict:: dict()>>.

  • processtype (builtins.str) - rxx - Generating process.

    • Optional. Default is None.

  • structure (builtins.str) - rxx - Type of Field geometry.

    • Values: set([‘3D’])

  • units (builtins.str) - rwd - Not documented, sorry.

    • Optional. Default is ‘’.

  • validity (epygram.base.FieldValidityList) - rwx - Validity of the field.

    • Optional. Default is FieldValidityList::<<as_list:: [FieldValidity::<epygram.base.FieldValidity object at 0x74bef559c1f0>]>>.

  • vector (builtins.bool) - rxx - Intrinsic vectorial nature of the field.

    • Values: set([True])

Constructor. See its footprint for arguments.

as_vtkGrid(rendering, grid_type, subzone=None, filename=None, module_name='module', vector_name='vector', grid=None, version='XML', binary=True, compression='ZLib', compression_level=5, transform_wind=0)

Note

Requires plugin: with_vtk (config.activate_plugins)

Returns a vtkStructuredGrid filled with the field :param rendering: a usevtk.Usevtk instance :param grid_type: can be:

  • sgrid_point: structured grid filled with points

  • sgrid_cell: structured grid filled with hexahedron

    If the field is 2D, a zero thickness is used. If the field is 3D, thickness are approximately computed

  • ugrid_point: unstructured grid filled with points

  • ugrid_cell: unstructured grid build filled with cells

    If the field is 2D, a zero thickness is used. If the field is 3D, thickness are approximately computed

Parameters
  • subzone

    optional, among (‘C’, ‘CI’), for LAM grids only, returns the grid resp. for the C or C+I zone off the C+I+E zone.

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

  • filename – if not None, resulting grid will be written into filename

  • module_name – name to give to the scalar field containing the module (useful with the grid option)

  • vector_name' – name of the vector field (useful with the grid option)

  • grid – if grid is not None, the method will add the data to it.

  • version – must be ‘legacy’ or ‘XML’, used with filename

  • binary – True (default) for a binary file, used with filename

  • compression – must be None, ‘LZ4’ or ‘ZLib’ only used for binary XML

  • compression_level – between 1 and 9, only used for binary XML Zlib-compressed

  • transform_wind

    to rotate ans scale wind according to vtk coordinates: 0: do nothing 1: scale the w component to take into account the z axis expansion,

    the total module is not preserved but the horizontal one is preserved. The horizontal components must be oriented along the vtk axes.

    2: same as option 1 but the total module is preserved whereas the horizontal

    one is not preserved

    3: same as option 1 but, in addition, all the components are rotated.

    The horizontal components must be oriented along north-south and east-west axes.

    4: same as option 3 but (as for option 2), the total module is preserved whereas

    the horizontal one is not preserved

If grid_type is ‘sgrid_point’, the result is the grid; otherwise the result is the function is the last filter used.

attach_components(*components)[source]

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

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

Cf. D3Field.center()

comment

(see the documentation above for more details).

components

List of Fields that each compose a component of the vector (see the documentation above for more details).

compute_direction()[source]

Returns a epygram.D3Field or subclass whose data is the direction of the horizontal part of the Vector field (the two firsts components), in degrees.

compute_vordiv(divide_by_m=False)[source]

Compute vorticity and divergence fields from the vector field.

Parameters

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

property data

Accessor to the field data.

deldata()[source]

Empties the data.

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

Cf. D3Field.extract_subarray()

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

Cf. D3Field.extract_subdomain()

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

Cf. D3Field.extract_subsample

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

Cf. D3Field.extract_zoom()

fid

(see the documentation above for more details).

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.

Parameters

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

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

Returns a level of the field as a new field.

Parameters
  • level – the requested level expressed in coordinate value (Pa, m…)

  • k – the index of the requested level

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)[source]

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.

For global RegLLGeometry grids only.

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.

Parameters

spectral_geometry – instance of SpectralGeometry, actually containing spectral transform subroutine (in in its own gp2sp() method).

map_factorize(reverse=False)[source]

Multiply the field by its map factor. Only the first two components are affected.

Parameters

reverse – if True, 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.

misc_metadata

(see the documentation above for more details).

nonzero(subzone=None)[source]

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

plot3DOutline(*args, **kwargs)

Note

Requires plugin: with_vtk (config.activate_plugins)

Cf. D3Field.plot3DOutline()

plot3DStream(rendering, samplerate=None, maxLength=None, tubesRadius=0.1, color='Blue', opacity=1.0, plot_tube=False, colorbar=True, subzone=None, transform_wind=0)

Note

Requires plugin: with_vtk (config.activate_plugins)

This method adds contour lines and/or colorize the field. If the field is 3D, contours appear as isosurface. :param rendering: a usevtk.Usevtk instance :param samplerate: if not None, must be a dictionary. Allowed keys are

‘x’, ‘y’ and ‘z’ and values are the sample rate in the given direction. For example {‘x’:3} means take one over 3 points in the x direction

Parameters
  • maxLength – integration length to build the stream lines and tubes

  • tubesRadius – radius of the tubes

  • color – a color name, a vtk.vtkColorTransferFunction or a vtk.vtkLookupTable to associate colors to the stream lines or tubes

  • opacity – opacity value

  • plot_tube – True to plot the tubes instead of lines

  • colorbar – True to plot a colorbar

  • subzone

    optional, among (‘C’, ‘CI’), for LAM grids only, returns the grid resp. for the C or C+I zone off the C+I+E zone.

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

  • transform_wind

    to rotate ans scale wind according to vtk coordinates: 0: do nothing 1: scale the w component to take into account the z axis expansion,

    the total module is not preserved but the horizontal one is preserved. The horizontal components must be oriented along the vtk axes.

    2: same as option 1 but the total module is preserved whereas the horizontal

    one is not preserved

    3: same as option 1 but, in addition, all the components are rotated.

    The horizontal components must be oriented along north-south and east-west axes.

    4: same as option 3 but (as for option 2), the total module is preserved whereas

    the horizontal one is not preserved

Returns

actor, mapper, colorbaractor

Note: the wind components, whatever is the transform_wind option, must contain

the map factor corrections.

plot3DVector(rendering, samplerate=None, arrowScaleFactor=1.0, color='Blue', opacity=1.0, colorbar=True, subzone=None, transform_wind=0)

Note

Requires plugin: with_vtk (config.activate_plugins)

This method adds contour lines and/or colorize the field. If the field is 3D, contours appear as isosurface. :param rendering: a usevtk.Usevtk instance :param samplerate: if not None, must be a dictionary. Allowed keys are

‘x’, ‘y’ and ‘z’ and values are the sample rate in the given direction. For example {‘x’:3} means take one over 3 points in the x direction

Parameters
  • arrowScaleFactor – scale factor used to plot the vector

  • color – color name or lookup table or color transfer function to associate colors to the vector norms

  • opacity – opacity value

  • colorbar – True to plot a colorbar

  • subzone

    optional, among (‘C’, ‘CI’), for LAM grids only, returns the grid resp. for the C or C+I zone off the C+I+E zone.

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

  • transform_wind

    to rotate ans scale wind according to vtk coordinates: 0: do nothing 1: scale the w component to take into account the z axis expansion,

    the total module is not preserved but the horizontal one is preserved. The horizontal components must be oriented along the vtk axes.

    2: same as option 1 but the total module is preserved whereas the horizontal

    one is not preserved

    3: same as option 1 but, in addition, all the components are rotated.

    The horizontal components must be oriented along north-south and east-west axes.

    4: same as option 3 but (as for option 2), the total module is preserved whereas

    the horizontal one is not preserved

Returns

actor, mapper, colorbaractor

Note: the wind components, whatever is the transform_wind option, must contain

the map factor corrections.

processtype

Generating process (see the documentation above for more details).

quadmean(subzone=None)[source]

Returns the quadratic mean of data.

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

Cf. D3Field.remove_level()

reproject_wind_on_lonlat(map_factor_correction=True, reverse=False)[source]

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

Parameters
  • map_factor_correction – if True, apply a correction of magnitude due to map factor.

  • reverse – if True, apply the reverse reprojection.

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

Cf. D3Field.resample()

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

Cf. D3Field.resample_on_regularll()

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

Cf. D3Field.select_subzone()

setdata(data)[source]

Sets data to its components.

Parameters

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.

property spectral

Returns True if the field is spectral.

std(subzone=None)[source]

Returns the standard deviation of data.

structure

Type of Field geometry (see the documentation above for more details).

to_module()[source]

Returns a epygram.D3Field (or subclass) whose data is the module of the Vector field.

units

(see the documentation above for more details).

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

Cf. D3Field.use_field_as_vcoord()

validity

Validity of the field (see the documentation above for more details).

vector

Intrinsic vectorial nature of the field (see the documentation above for more details).

vtk_guess_param_from_field(*args, **kwargs)

Note

Requires plugin: with_vtk (config.activate_plugins)

Cf. D3Field.vtk_guess_param_from_field()

what(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, vertical_geometry=True, cumulativeduration=True)[source]

Writes in file a summary of the field.

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