waves.utilities.library#

Provides a consistent way to read and write YAML data, largely based on WOMBAT's library module.

All library data should adhere to the following directory structure within a library path:

├── project
  ├── config     <- Project-level configuration files
  ├── port       <- Port configuration files
  ├── plant      <- Wind farm layout files
├── cables       <- Export and Array cable configuration files
├── substations  <- Substation configuration files
├── turbines     <- Turbine configuration and power curve files
├── vessels      <- Land-based and offshore servicing equipment configuration files
├── weather      <- Weather profiles
├── results      <- The analysis log files and any saved output data

Functions

load_yaml(path, fname)

Loads and returns the contents of the YAML file.

resolve_path(value)

Converts a user-input string to a Path object and resolves it.

Classes

CustomSafeLoader(stream)

Customized yaml.SafeLoader that adds custom constructors for consistent data loading in safe mode.

class waves.utilities.library.CustomSafeLoader(stream)[source]#

Customized yaml.SafeLoader that adds custom constructors for consistent data loading in safe mode.

construct_python_tuple(node)[source]#

Loads a YAML object to a Pytho Tuple.s.

waves.utilities.library.resolve_path(value)[source]#

Converts a user-input string to a Path object and resolves it.

Return type:

Path

Parameters:

value (str | Path) -- A string or Path to a configuration library.

Raises:

TypeError -- Raised if the input to value is not either a str or pathlib.Path.:

Returns:

Path -- The resolved Path object version of the input library path.

waves.utilities.library.load_yaml(path, fname)[source]#

Loads and returns the contents of the YAML file.

Return type:

Any

Parameters:
  • path (str | Path) -- Path to the file to be loaded.

  • fname (str | Path) -- Name of the file (ending in .yaml) to be loaded.

Returns:

Any -- Whatever content is in the YAML file.