TidalForcing

Contents

TidalForcing#

class roms_tools.TidalForcing(*, grid: Grid, source: dict[str, str | Path | dict[str, str | Path]], ntides: int = 10, model_reference_date: datetime = datetime.datetime(2000, 1, 1, 0, 0), use_dask: bool = False, bypass_validation: bool = False)#

Represents tidal forcing for ROMS.

Parameters:
  • grid (Grid) – Object representing the grid information.

  • source (Dict[str, Union[str, Path, Dict[str, Union[str, Path]]]]) –

    Dictionary specifying the source of the tidal data. Keys include:

    • ”name” (str): Name of the data source (e.g., “TPXO”).

    • ”path” (Union[str, Path, Dict[str, Union[str, Path]]]):

      • If a string or Path is provided, it represents a single file.

      • If “name” is “TPXO”, “path” can also be a dictionary with the following keys:

        • ”grid” (Union[str, Path]): Path to the TPXO grid file.

        • ”h” (Union[str, Path]): Path to the TPXO h-file.

        • ”u” (Union[str, Path]): Path to the TPXO u-file.

  • ntides (int, optional) – Number of constituents to consider. Maximum number is 15. Default is 10.

  • model_reference_date (datetime, optional) – The reference date for the ROMS simulation. Default is datetime(2000, 1, 1).

  • use_dask (bool, optional) – Indicates whether to use dask for processing. If True, data is processed with dask; if False, data is processed eagerly. Defaults to False.

  • bypass_validation (bool, optional) – Indicates whether to skip validation checks in the processed data. When set to True, the validation process that ensures no NaN values exist at wet points in the processed dataset is bypassed. Defaults to False.

Examples

Using a TPXO dataset with separate grid, h, and u files:

>>> tidal_forcing = TidalForcing(
...     grid=grid,
...     source={
...         "name": "TPXO",
...         "path": {"grid": "tpxo_grid.nc", "h": "tpxo_h.nc", "u": "tpxo_u.nc"},
...     },
... )

Using a single file as a source:

>>> tidal_forcing = TidalForcing(
...     grid=grid,
...     source={"name": "TPXO", "path": "tpxo_merged.nc"},
... )

Methods

TidalForcing.from_yaml(filepath[, use_dask])

Create an instance of the TidalForcing class from a YAML file.

TidalForcing.plot(var_name[, ntides, save_path])

Plot the specified tidal forcing variable for a given tidal constituent.

TidalForcing.save(filepath[, format])

Save the tidal forcing information to a NetCDF file.

TidalForcing.to_yaml(filepath)

Export the parameters of the class to a YAML file, including the version of roms-tools.

Attributes

TidalForcing.bypass_validation

Whether to skip validation checks in the processed data.

TidalForcing.model_reference_date

The reference date for the ROMS simulation.

TidalForcing.ntides

Number of constituents to consider.

TidalForcing.use_dask

Whether to use dask for processing.

TidalForcing.grid

Object representing the grid information.

TidalForcing.source

Dictionary specifying the source of the tidal data.

TidalForcing.ds

An xarray Dataset containing post-processed variables ready for input into ROMS.