roms module

Generic class and utility functions for handling ROMS grids.

class gridtools.grids.roms.ROMS(grd=None)

Bases: object

edit_mask_mesh(hgrid, proj=None, **kwargs)
getGrid(variable=None)

Return the ROMS grid to the caller.

get_ROMS_grid(gridid, zeta=None, hist_file=None, grid_file=None)

grd = get_ROMS_grid(self, gridid, hist_file=None, grid_file=None)

Load ROMS grid object.

gridid is a string with the name of the grid in it. If hist_file and grid_file are not passed into the function, or are set to None, then gridid is used to get the grid data from the gridid.txt file.

if hist_file and grid_file are given, and they are the file paths to a ROMS history file and grid file respectively, the grid information will be extracted from those files, and gridid will be used to name that grid for the rest of the python session.

grd.vgrid is a s_coordinate or a z_coordinate object, depending on gridid.grdtype. grd.vgrid.z_r and grd.vgrid.z_w (grd.vgrid.z for a z_coordinate object) can be indexed in order to retreive the actual depths. The free surface time serie zeta can be provided as an optional argument. Note that the values of zeta are not calculated until z is indexed, so a netCDF variable for zeta may be passed, even if the file is large, as only the values that are required will be retrieved from the file.

This function is based on code from [HHT+21].

get_ROMS_hgrid(gridid)

hgrid = get_ROMS_hgrid(gridid)

Load ROMS horizontal grid object

get_ROMS_vgrid(gridid, zeta=None)

vgrid = get_ROMS_vgrid(gridid)

Load ROMS vertical grid object. vgrid is a s_coordinate or a z_coordinate object, depending on gridid.grdtype. vgrid.z_r and vgrid.z_w (vgrid.z for a z_coordinate object) can be indexed in order to retreive the actual depths. The free surface time serie zeta can be provided as an optional argument. Note that the values of zeta are not calculated until z is indexed, so a netCDF variable for zeta may be passed, even if the file is large, as only the values that are required will be retrieved from the file.

read_ROMS_grid(grd)

Load the ROMS grid previous read by GridUtils().

This function is based on code from [IAH20].

trim_ROMS_grid()

Remove extraneous points on the outside of the ROMS grid.

This function is based on code from [IAH20].

write_ROMS_grid(grd, filename)

Write ROMS_CGrid class on a NetCDF file.

This function is based on code from [HHT+21].

class gridtools.grids.roms.ROMS_Grid(name, hgrid=<class 'gridtools.grids.roms_hgrid.CGrid'>, vgrid=<class 'gridtools.grids.roms_vgrid.s_coordinate'>)

Bases: object

grd = ROMS_Grid(hgrid, vgrid)

ROMS Grid object combining horizontal and vertical grid

This class is based on code from [HHT+21].

class gridtools.grids.roms.ROMS_gridinfo(gridid, grid_file=None, hist_file=None)

Bases: object

gridinfo = ROMS_gridinfo(gridid,grid_file=None,hist_file=None)

Return an object with grid information for gridid.

There are two ways to define the grid information. If grid_file and hist_file are not passed to the object when it is created, the information is retrieved from gridid.txt. To add new grid please edit your gridid.txt. You need to define an environment variable ROMS_GRIDID_FILE pointing to your gridid.txt file. Just copy an existing grid and modify the definition accordingly to your case (Be carefull with space and blank line).

If grid_file is the path to a ROMS grid file, and hist_file is the path to a ROMS history file, then the grid information will be read from those files. Gridid can then be used to refer to this grid information so that the grid and history files do not be included in subsequent calls.

This class is based on code from [HHT+21].

gridid_dictionary = {}