mom6_bathy.grid module

class mom6_bathy.grid.Grid(nx: int, ny: int, lenx: float, leny: float, srefine: int = 2, xstart: float = 0.0, ystart: Optional[float] = None, cyclic_x: bool = False, tripolar_n: bool = False, displace_pole: bool = False)

Bases: object

Horizontal MOM6 grid. The first step of constructing a MOM6 grid within the CESM simpler models framework is to create a Grid instance.

tlon

array of t-grid longitudes

Type:

xr.DataArray

tlat

array of t-grid latitudes

Type:

xr.DataArray

ulon

array of u-grid longitudes

Type:

xr.DataArray

ulat

array of u-grid latitudes

Type:

xr.DataArray

vlon

array of v-grid longitudes

Type:

xr.DataArray

vlat

array of v-grid latitudes

Type:

xr.DataArray

qlon

array of corner longitudes

Type:

xr.DataArray

qlat

array of corner latitudes

Type:

xr.DataArray

dxt

x-distance between U points, centered at t

Type:

xr.DataArray

dyt

y-distance between V points, centered at t

Type:

xr.DataArray

dxCv

x-distance between q points, centered at v

Type:

xr.DataArray

dyCu

y-distance between q points, centered at u

Type:

xr.DataArray

dxCu

x-distance between y points, centered at u

Type:

xr.DataArray

dyCv

y-distance between t points, centered at v

Type:

xr.DataArray

angle

angle T-grid makes with latitude line

Type:

xr.DataArray

tarea

T-cell area

Type:

xr.DataArray

Grid instance constructor.

Parameters:
  • nx (int) – Number of grid points in x direction

  • ny (int) – Number of grid points in y direction

  • lenx (float) – grid length in x direction, e.g., 360.0 (degrees)

  • leny (float) – grid length in y direction, e.g., 160.0 (degrees)

  • srefine (int, optional) – refinement factor for the supergrid. 2 by default

  • xstart (float, optional) – starting x coordinate. 0.0 by default.

  • ystart (float, optional) – starting y coordinate. -0.5*leny by default.

  • cyclic_x (bool, optional) – flag to make the grid cyclic in x direction. False by default.

  • tripolar_n (bool, optional) – flag to make the grid tripolar. False by default.

  • displace_pole (bool, optional) – flag to make the grid displaced polar. False by default.

static check_supergrid(supergrid: Dataset) None

Check if a given supergrid contains the necessary attributes and has consistent units.

Parameters:

supergrid (xarray.Dataset) – MOM6 Supergrid dataset

classmethod from_supergrid(path: str, srefine: int = 2) Grid

Create a Grid instance from a supergrid file.

Parameters:
  • path (str) – Path to the supergrid file to be written

  • srefine (int, optional) – refinement factor for the supergrid. 2 by default

Returns:

The Grid instance created from the supergrid file.

Return type:

Grid

static is_cyclic_x(supergrid: Dataset) bool

Check if a supergrid instance is cyclic along the x-axis.

Parameters:

supergrid (xarray.Dataset) – MOM6 Supergrid dataset

static is_tripolar(supergrid: Dataset) bool

Check if a supergrid instance is tripolar.

Parameters:

supergrid (xarray.Dataset) – MOM6 Supergrid dataset

property nx

Number of cells in x-direction.

property ny

Number of cells in y-direction.

plot(property_name)

Plot a given grid property using cartopy. Warning: cartopy module must be installed seperately

Parameters:

property_name (str) – The name of the grid property to plot, e.g., ‘tlat’.

plot_cross_section(property_name, iy=None, ix=None)

Plot the cross-section of a given grid metric.

Parameters:
  • property_name (str) – The name of the grid property to plot, e.g., ‘tlat’.

  • iy (int) – y-index of the cross section

  • ix (int) – x-inted of the cross section

property supergrid: supergrid

MOM6 supergrid contains the grid metrics and the areas at twice the nominal resolution (by default) of the actual computational grid.

update_supergrid(xdat: array, ydat: array) None

Update the supergrid x and y coordinates. Running this method also updates the nominal grid coordinates and metrics.

Parameters:
  • xdat (np.array) – 2-dimensional array of the new x coordinates.

  • ydat (np.array) – 2-dimensional array of the new y coordinates.

write_supergrid(path: Optional[str] = None, author: Optional[str] = None) None

Write supergrid to a netcdf file. The supergrid file is to be read in by MOM6 during runtime.

Parameters:
  • path (str, optional) – Path to the supergrid file to be written.

  • author (str, optional) – Name of the author. If provided, the name will appear in files as metadata.