pypago.coords

Module related to model coordinates

Functions

create_coord(modelname, filename) Returns a Coord object, depending on the modelname

Classes

CcsmCoords(filename) Coords class associated with the CCSM ocean model Inheritates from the pypago.coords.Coords class.
Coords(filename) Initialisation of the Coords class.
GfdlCoords(filename) Coords class associated with the GFDL ocean model Inheritates from the pypago.coords.Coords class.
HycoCoords(filename) Coords class associated with the Hyco ocean model Inheritates from the pypago.coords.Coords class.
MicoCoords(filename) Coords class associated with the Mico ocean model Inheritates from the pypago.coords.Coords class.
MpioCoords(filename) Coords class associated with the MPIO ocean model Inheritates from the pypago.coords.Coords class.
NemoCoords(filename) Coords class associated with the NEMO ocean model Inheritates from the pypago.coords.Coords class.
OfamCoords(filename) Coords class associated with the Ofam ocean model Inheritates from the pypago.coords.Coords class.
RomsCoords(filename) Coords class associated with the Roms ocean model Inheritates from the pypago.coords.Coords class.
class CcsmCoords(filename)[source]

Coords class associated with the CCSM ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import CcsmCoords

filename = 'ccsm_mesh.nc'
coords = CcsmCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_coord()[source]

Processes CCSM file coordinates (bathy, longitude, latitude, mask). - If converts the bathymetry array from centimeters to meters

read_scalefactors()[source]

Processes CCSM scale factors. - Converts the scale factors from cm into m - Copy the dzt into dzw and dzn (no partial steps)

class Coords(filename)[source]

Initialisation of the Coords class. It is initialised by providing a NetCDF mesh file. The class reads and assigns the following attributes: - longitude - latitude - bathy (if exists, else None) - mask (if exists, else None) - dxt - dyt - dye (if exists, else None) - dxn (if exists, else None) - dzt (if exists, else None)

Parameters:filename (str) – Name of the NetCDF mesh file

Note

At this stage, all the file is read (no extraction over a subdomain)

plot_mask(ax=None)[source]

Contours the mask attribute

class GfdlCoords(filename)[source]

Coords class associated with the GFDL ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import GfdlCoords

filename = 'gfdl_mesh.nc'
coords = GfdlCoords(filename)
Parameters:filename (str) – Name of the mesh file
read_coord()[source]

Processes GFDL file coordinates (bathy, longitude, latitude, mask). - If sets to 0 all the masked/NaN values within the tmask array

read_scalefactors()[source]

Processes GFDL scale factors. - Extracts the dzc array - Set the dzt, dzc arrays to NaN where 0 - Shift from west to east of the dzc array (depending on user input)

class HycoCoords(filename)[source]

Coords class associated with the Hyco ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import HycoCoords

filename = 'Hyco_mesh.nc'
coords = HycoCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_coord()[source]

Processes HYCO file coordinates (bathy, longitude, latitude, mask). - Reconstructs the mask array from the bathy (where bathy>0, mask=1)

read_scalefactors()[source]

Processes HYCO scale factors. - Reconstruction of dxn from dxt by adding a line of NaN at the bottom of dxt - Extraction of the dyw array - Extraction of the layer index in order to recover the number of vertical levels - Creation of dzt, dzn and dze as 3D arrays of ones.

class MicoCoords(filename)[source]

Coords class associated with the Mico ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import MicoCoords

filename = 'Mico_mesh.nc'
coords = MicoCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_scalefactors()[source]

Processes MICO scale factors. - Extract dx at southern faces - Reconstruct dx at northern faces (dxn) - Extraction of dyw - Creation of vertical scale factors: a) In isopicnic coordinates: asking for the number of vertical levels, setting dzt, dzw and dzn as 1D array of ones b) In interpolated z-coordinates: opening of a file with the z-bounds, reconstruction of dzt. And copy of the dzt values to dzw and dzn (no scale factors)

class MpioCoords(filename)[source]

Coords class associated with the MPIO ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import MpioCoords

filename = 'mpio_mesh.nc'
coords = MpioCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_coord()[source]

Processes MPIO file coordinates (bathy, longitude, latitude, mask). - If flips all the arrays along their rightmost dimension (latitude) so that north is on the top of the figures (using flipud) - Extracts the first level of the tmask array - Setting the tmask to 0 where Nan/masked

read_scalefactors()[source]

Processes MPIO scale factors. - Flipping the dxt, dyt, dxn and dye arrays along the first dimension (flipud) - Flipping the dzt array along the 2nd dimension - Creation of dzw by multiplication of dzt with the flipped amsuo variable - Creation of dzn by multiplication of dzt with the flipped amsue variable

class NemoCoords(filename)[source]

Coords class associated with the NEMO ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import NemoCoords

filename = 'nemo_mesh.nc'
coords = NemoCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_coord()[source]

Processes NEMO file coordinates (bathy, longitude, latitude, mask). - If the bathy array is None (i.e not read from input file) it is constructed from the mbathy and deptht arrays - Extracts the first level of the mask array

read_scalefactors()[source]

Processes NEMO scale factors. - Initialises the dzw and dzn arrays. If dzt is 1D, then no partial step is assumed. If dzt is 2D, then 3D dzt, dzn and dze are reconstructed using the mbathy array. If dzt is 3D then we assume that dze and dzn are in files - Masking the dzt, dzw, dzn arrays where the associated masks are 0 or masked - Reconstruction of dzw from dze

reconstruct_3d_e3t()[source]

Creates, from 2D partial step value, a 3D cell width at T points. It is constructed by using the “mbathy” variable (index of the last non-ocean point) and the 1D constant scale factor

Returns:A numpy array containing the cell width at T, U and V points
Return type:numpy.array
reconstruct_3d_e3uv()[source]

Creates, from the dzt variable, a 3D cell width at northern and southern grid faces.

Returns:A tuple containing the cell width at U and V points
Return type:numpy.array
class OfamCoords(filename)[source]

Coords class associated with the Ofam ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import OfamCoords

filename = 'Ofam_mesh.nc'
coords = OfamCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_scalefactors()[source]

Processes OFAM scale factors. - Extraction of the dyw array - Extraction of the dzb array (width at z-levels) - Reconstruction of dzt array from dzb - Setting dzw and dzn as equal to dzt (no partial steps)

class RomsCoords(filename)[source]

Coords class associated with the Roms ocean model Inheritates from the pypago.coords.Coords class:

from pypago.coords import RomsCoords

filename = 'Roms_mesh.nc'
coords = RomsCoords(filename)
Parameters:filename (str) – Name of the NetCDF mesh file
read_scalefactors()[source]

Processes ROMS scale factors. - Taking the inverse of dxt, dyt, dye and dxn - Adding a line of NaNs at the bottom of the dzt array - Extracting the dze and dzn arrays - Creating the dzw array from the dze array by adding a layer of NaNs on the easternmost face of the “cube”

create_coord(modelname, filename)[source]

Returns a Coord object, depending on the modelname

Parameters:
  • modelname (str) – Name of the model
  • filename (str) – Name of the NetCDF mesh file