model

Retrieves tide model parameters for named tide models and from model definition files

Source code

General Attributes and Methods

pyTMD.io.load_database(extra_databases: list = [])[source]

Load the JSON database of model files

Parameters:
extra_databases: list, default []

A list of additional databases to load, as either JSON file paths or dictionaries

Returns:
parameters: dict

Database of model parameters

class pyTMD.io.model(directory: str | Path | None = None, **kwargs)[source]

Retrieves tide model parameters for named models or from a model definition file

Attributes:
compressed: bool

Model files are gzip compressed

directory: str, pathlib.Path or None, default None

Working data directory for tide models

extra_databases: list, default []

Additional databases for model parameters

verify: bool

Verify that all model files exist

from_database(m: str, group: tuple = ('z', 'u', 'v'))[source]

Create a model object from database of known tidal models

Parameters:
m: str

Model name

group: tuple, default (‘z’, ‘u’, ‘v’)

Model variable(s) to extract

from_file(definition_file: str | Path | IOBase, **kwargs)[source]

Create a model object from an input definition file

Parameters:
definition_file: str, pathlib.Path or io.IOBase

Model definition file for creating model object

from_dict(d: dict)[source]

Create a model object from a dictionary of parameters

Parameters:
d: dict

Model object parameters

to_dict(**kwargs)[source]

Create a dictionary from a model object

Parameters:
fields: list, default all

List of model attributes to output

serialize: bool, default False

Serialize dictionary for JSON output

property gzip: str

Returns suffix for gzip compression

property corrections: str

Returns the corrections group for the model

property file_format: str

Returns the file format for the model

property multifile: bool

Returns if the model uses individual files for constituents

property crs

Coordinate reference system of the model

static known_formats(**kwargs) list[source]

Returns list of known model formats

static ocean_elevation(**kwargs) list[source]

Returns list of ocean tide elevation models

static load_elevation(**kwargs) list[source]

Returns list of load tide elevation models

static ocean_current(**kwargs) list[source]

Returns list of tidal current models

static OTIS(**kwargs) list[source]

Returns list of OTIS formatted models

static ATLAS_compact(**kwargs) list[source]

Returns list of ATLAS-compact formatted models

static TMD3(**kwargs) list[source]

Returns list of TMD3 formatted models

static ATLAS(**kwargs) list[source]

Returns list of ATLAS-netcdf formatted models

static GOT(**kwargs) list[source]

Returns list of GOT formatted models

static FES(**kwargs) list[source]

Returns list of FES formatted models

pathfinder(model_file: str | Path | list)[source]

Completes file paths and appends gzip suffix

Parameters:
model_file: str, pathlib.Path or list

Model file(s) to complete

validate_format()[source]

Asserts that the model format is a known type

serialize(d: dict)[source]

Encodes dictionary to be JSON serializable

Parameters:
d: dict

Parameters to serialize

parse_constituents(group: str = 'z', **kwargs) list[source]

Parses tide model files for a list of model constituents

Parameters:
group: str, default ‘z’

Model group

static parse_file(model_file: str | Path, raise_error: bool = False)[source]

Parses a model file for a tidal constituent name

Parameters:
model_file: str or pathlib.Path

Tide model file to parse

raise_error: bool, default False

Raise ValueError if constituent is not found in file name

Returns:
constituent: str or list

Constituent name

reduce_constituents(constituents: str | list, group: str = 'z')[source]

Reduce model files to a subset of constituents

Parameters:
constituents: str or list

List of constituents names

group: str, default ‘z’

Model group

open_dataset(**kwargs)[source]

Open model files as an xarray Dataset

Parameters:
kwargs: dict

Additional keyword arguments for opening model files

Returns:
ds: xarray.Dataset

Tide model data

open_datatree(group: tuple = ('z', 'u', 'v'), **kwargs)[source]

Open model files as an xarray DataTree

Parameters:
group: tuple, default (‘z’, ‘u’, ‘v’)

List of model types to extract

kwargs: dict

Additional keyword arguments for opening model files

Returns:
dtree: xr.DataTree

Tide model data