Configuration#
The configuration module loads a YAML file that describes which tidal atlas files to use, the grid type, and the engine. This is the recommended way to set up a prediction pipeline without hard-coding file paths.
- pyfes.config.load(path: str | PathLike, bbox: tuple[float, float, float, float] | None = None) Configuration#
Load a configuration file into memory.
- Parameters:
path – Path to the configuration file to be loaded into memory
bbox – Bounding box to consider when loading the tidal model. It is represented as a tuple of four floats: (min_lon, min_lat, max_lon, max_lat). If not provided, the whole grid is loaded.
- Returns:
models: A dictionary mapping tidal type (e.g.
tide,radial) to the corresponding tidal model.settings: Runtime settings for the tidal prediction engine (FESSettings or PerthSettings).
- Return type:
A Configuration object containing
- Raises:
ConstituentValidationError – If an invalid constituent name is used in the configuration.
InterpolationError – If an environment variable referenced in the configuration file is not defined in the environment.
InterpolationDepthError – If interpolation of environment variables is too deeply recursive, indicating a self-referential variable.
OSError – If the file cannot be opened.
TypeError – If the configuration file contains unknown sections or invalid keys for the tidal model configuration.
ValueError – If the configuration file is invalid (e.g. missing required sections, unknown tidal type, inconsistent grid properties, etc.).
yaml.YAMLError – If the YAML cannot be parsed.
Example
>>> import pyfes >>> config = pyfes.load('ocean_tide.yaml') >>> # Access the tide model >>> tide_model = config.models['tide'] >>> # Use the settings for evaluation >>> result = pyfes.core.evaluate_tide( ... tide_model, dates, lon, lat, config.settings ... )
- class pyfes.config.Configuration(models: dict[Literal['tide', 'radial'], TidalModel], settings: Settings)#
Configuration returned by the load function.
This class holds the tidal models and the runtime settings to use for tidal predictions.
- class pyfes.config.Cartesian(latitude: str = 'lat', longitude: str = 'lon', tidal_type: str = 'tide', dynamic: list[str] = <factory>, bbox: tuple[float, float, float, float] | None=None, engine: Engine = Engine.DARWIN, amplitude: str = 'amplitude', paths: dict[str, str]=<factory>, phase: str = 'phase', epsilon: float = 1e-06)#
Configuration for the Cartesian model.
- load() TidalModelInterfaceComplex64 | TidalModelInterfaceComplex128#
Load the tidal model defined by the configuration.
- class pyfes.config.LGP(latitude: str = 'lat', longitude: str = 'lon', tidal_type: str = 'tide', dynamic: list[str] = <factory>, bbox: tuple[float, float, float, float] | None=None, engine: Engine = Engine.DARWIN, amplitude: str = '{constituent}_amplitude', constituents: list[str] = <factory>, codes: str = 'codes', max_distance: float = 0.0, path: str = '', phase: str = '{constituent}_phase', triangle: str = 'triangle', type: str = 'lgp1')#
Configuration for the LGP model.
- load() TidalModelInterfaceComplex64 | TidalModelInterfaceComplex128#
Load the tidal model defined by the configuration.