cf.RegridOperator


class cf.RegridOperator(weights=None, row=None, col=None, coord_sys=None, method=None, src_shape=None, dst_shape=None, src_cyclic=None, dst_cyclic=None, src_mask=None, dst_mask=None, src_coords=None, src_bounds=None, start_index=0, src_axes=None, dst_axes=None, dst=None, weights_file=None, src_mesh_location=None, dst_mesh_location=None, src_featureType=None, dst_featureType=None, dimensionality=None, src_z=None, dst_z=None, ln_z=False)[source]

Bases: cf.mixin_container.Container, cfdm.abstract.container.Container

A regridding operator between two grids.

Regridding is the process of interpolating from one grid resolution to a different grid resolution.

The regridding operator stores the regridding weights; auxiliary information, such as the grid shapes; the CF metadata for the destination grid; and the source grid coordinates.

New in version 3.10.0.

Initialisation

Parameters
weights: array_like

The 1-d array of regridding weights for locations in the 2-d dense weights matrix. The locations are defined by the row and col parameters.

row, col: array_like, array_like

The 1-d arrays of the row and column indices of the regridding weights in the dense weights matrix, which has J rows and I columns, where J and I are the total number of cells in the destination and source grids respectively. See the start_index parameter.

coord_sys: str

The name of the coordinate system of the source and destination grids. Either 'spherical' or 'Cartesian'.

method: str

The name of the regridding method.

src_shape: sequence of int

The shape of the source grid.

dst_shape: sequence of int

The shape of the destination grid.

src_cyclic: bool

For spherical regridding, specifies whether or not the source grid longitude axis is cyclic.

dst_cyclic: bool

For spherical regridding, specifies whether or not the destination grid longitude axis is cyclic.

src_mask: numpy.ndarray or None, optional

If a numpy.ndarray with shape src_shape then this is the source grid mask that was used during the creation of the weights. If src_mask is a scalar array with value False, then this is equivalent to a source grid mask with shape src_shape entirely populated with False.

If None (the default), then the weights are assumed to have been created assuming no source grid masked cells.

dst_mask: numpy.ndarray or None, optional

A destination grid mask to be applied to the weights matrix, in addition to those destination grid cells that have no non-zero weights. If None (the default) then no additional destination grid cells are masked. If a Boolean numpy array then it must have shape dst_shape, and a value of True signifies a masked destination grid cell.

start_index: int, optional

Specify whether the row and col parameters use 0- or 1-based indexing. By default 0-based indexing is used.

If row and col are to be read from a weights file and their netCDF variables have start_index attributes, then these will be used in preference to start_index.

parameters: Deprecated at version 3.14.0

Use keyword parameters instead.

dst: Field or Domain

The definition of the destination grid.

dst_axes: dict or sequence or None, optional

The destination grid axes to be regridded.

src_axes: dict or sequence or None, optional

The source grid axes to be regridded.

weights_file: str or None, optional

Path to a netCDF file that contained the regridding weights. If None, the default, then the weights were computed rather than read from a file.

New in version 3.15.2.

src_mesh_location: str, optional

The UGRID mesh element of the source grid (e.g. 'face').

New in version 3.16.0.

dst_mesh_location: str, optional

The UGRID mesh element of the destination grid (e.g. 'face').

New in version 3.16.2.

src_featureType: str, optional

The discrete sampling geometry (DSG) featureType of the source grid (e.g. 'trajectory').

New in version 3.16.2.

dst_featureType: str, optional

The DSG featureType of the destination grid (e.g. 'trajectory').

New in version 3.16.2.

src_z: optional

The identity of the source grid vertical coordinates used to calculate the weights. If None then no source grid vertical axis is identified.

New in version 3.16.2.

dst_z: optional

The identity of the destination grid vertical coordinates used to calculate the weights. If None then no destination grid vertical axis is identified.

New in version 3.16.2.

ln_z: bool, optional

Whether or not the weights were calculated with the natural logarithm of vertical coordinates.

New in version 3.16.2.

dimensionality: int, optional

The number of physical regridding dimensions. This may differ from the corresponding number of storage dimensions in the source or destination grids, if either has an unstructured mesh or a DSG featureType.

New in version 3.16.2.

Methods

copy

Return a deep copy.

dump

A full description of the regrid operator.

tosparse

Convert the weights to scipy sparse array format in-place.

Attributes

col

The 1-d array of the column indices of the regridding weights.

coord_sys

The name of the regridding coordinate system.

dimensionality

The number of physical regridding dimensions.

dst

The definition of the destination grid.

dst_axes

The destination grid axes to be regridded.

dst_cyclic

Whether or not the destination grid longitude axis is cyclic.

dst_featureType

The DSG featureType of the destination grid.

dst_mask

A destination grid mask to be applied to the weights matrix.

dst_mesh_location

The UGRID mesh element of the destination grid.

dst_shape

The shape of the destination grid.

dst_z

The identity of the destination grid vertical coordinates.

ln_z

Whether or not vertical weights are based on ln(z).

method

The name of the regridding method.

name

The name of the regridding method.

row

The 1-d array of the row indices of the regridding weights.

src_axes

The source grid axes to be regridded.

src_bounds

The bounds of the source grid cells.

src_coords

The coordinates of the source grid cells.

src_cyclic

Whether or not the source grid longitude axis is cyclic.

src_featureType

The DSG featureType of the source grid.

src_mask

The source grid mask that was applied during the weights creation.

src_shape

The shape of the source grid.

src_mesh_location

The UGRID mesh element of the source grid.

src_z

The identity of the source grid vertical coordinates.

start_index

The start index of the row and column indices.

weights

The 1-d array of the regridding weights, or None.

weights_file

The file which contains the weights, or None.

Deprecated

Methods

get_parameter

Return a regrid operation parameter.

parameters

Get the CF metadata parameters for the destination grid.

Special

Methods

__repr__