oocgcm.core.grids.generic_2d_grid

class oocgcm.core.grids.generic_2d_grid(arrays=None, parameters=None)

Model agnostic grid object, two dimensional version.

This class holds the xarrays that describe the grid and implements grid related methods.

This includes :
  • vector calculus (scalar product, norm, vector product,...)
  • interpolation between different grid locations (eg. ‘u’–>’t’)
  • differential operators (gradient, divergence, etc...)
  • spatial integration

Most methods expect and return instance of xarray.DataArray.

Assume that dimension names are ‘x’ and ‘y’.

__init__(arrays=None, parameters=None)

Initialize a grid from a dictionary of xarrays and some parameters.

Parameters:

variables : dict-like object

dictionnary of xarrays that describe the grid. Required variables for the method actually implemented are listed in _required_arrays. This naming convention follows a mixture of cf and comodo norms in order for this class to be model-agnostic.

parameters : dict-object

not used yet.

Methods

__init__([arrays, parameters]) Initialize a grid from a dictionary of xarrays and some parameters.
change_grid_location_f_to_u(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_f_to_v(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_t_to_u(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_t_to_v(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_u_to_t(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_u_to_v(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_v_to_t(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
change_grid_location_v_to_u(scalararray[, ...]) Return a xarray corresponding to scalararray averaged at a new grid location.
chunk([chunks]) Rechunk all the variables defining the grid.
frontogenesis_function(velocity, buoyancy) Return the frontogenesis function.
geostrophic_current_from_sea_surface_height(...) Return the geostrophic current on u,v-grids.
get_projection_coordinates([grid_location]) Return (x,y) the coordinate arrays (in m) at grid location.
horizontal_divergence(vectorfield) Return the horizontal divergence of a vector field at u,v-points.
horizontal_gradient(datastructure) Return the horizontal gradient of the input datastructure.
horizontal_gradient_tensor(vectorfield) Return the horizontal gradient tensor of a two-dimensional vector field at u,v locations.
horizontal_gradient_vector(scalararray) Return the horizontal gradient of a scalar field defined at t-points.
horizontal_laplacian(scalararray) Return the horizontal laplacian of a scalar field at t-points.
integrate_dxdy(array[, where, ...]) Return the horizontal integral of array in regions where where is True.
norm_of_vectorfield(vectorfield) Return the norm of a vector field, at t-point.
q_vector_due_to_kinematic_deformation(...) Return the component of the generalized Q-vector associated with kinematic deformation of a two-dimensional velocity field.
scalar_outer_product(scalararray, vectorfield) Return the outer product of a scalar (t location)
scalar_product(vectorfield1, vectorfield2) Return the scalar product of two vector fields, at t-point.
spatial_average_xy(array[, where, grid_location]) Return the horizontal average of array in regions where where is True.
vertical_component_of_curl(vectorfield) Return the vertical component of the curl of a vector field.
vertical_component_of_the_cross_product(...) Return the cross product of two vector fields.

Attributes

chunks Chunks of the xarray dataarrays describing the grid.
dims Dimensions of the xarray dataarrays describing the grid.
ndims Number of dimensions of the dataarrays describing the grid.
shape Shape of the xarray dataarrays describing the grid.