Skip to content

Wind

Wind forcing, written as the XBeach windfile.

XBeach wind forcing.

logger module-attribute

logger = logging.getLogger(__name__)

WindVector pydantic-model

WindVector(**data: Any)

Bases: RompyBaseModel

Wind vector variables.

Fields:

model_type pydantic-field

model_type: Literal['wind_vector'] = 'wind_vector'

Model type discriminator

u pydantic-field

u: str

Name of the u-component wind variable

v pydantic-field

v: str

Name of the v-component wind variable

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

WindScalar pydantic-model

WindScalar(**data: Any)

Bases: RompyBaseModel

Wind scalar variables.

Fields:

model_type pydantic-field

model_type: Literal['wind_scalar'] = 'wind_scalar'

Model type discriminator

spd pydantic-field

spd: str

Name of the wind speed wind variable

dir pydantic-field

dir: str

Name of the wind coming from direction variable

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

WindMixin

Wind specific functionality.

id pydantic-field

id: Literal['wind'] = 'wind'

Identifier for the wind forcing

wind_vars pydantic-field

Wind forcing variables

set_variables

set_variables()

Set the variables attribute based on the wind_vars attribute.

spddir

spddir(ds) -> tuple[DataArray, DataArray]

Wind speed and direction.

Parameters:

Name Type Description Default
ds Dataset

Dataset containing the wind data.

required

Returns:

Name Type Description
spd DataArray

Wind speed.

dir DataArray

Wind coming_from direction.

get

get(
    destdir: str | Path,
    grid: RegularGrid,
    time: Optional[TimeRange] = None,
) -> dict

Generate the wind file.

Parameters:

Name Type Description Default
destdir str | Path

Destination directory for the netcdf file.

required
grid RegularGrid

Grid instance to use for selecting the boundary points.

required
time Optional[TimeRange]

The times to filter the data to, only used if self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the boundary bcfile data.

WindGrid pydantic-model

WindGrid(**data: Any)

Bases: WindMixin, BaseDataGrid

Wind forcing from gridded data.

Namelist

  • windfile : str Name of file with non-stationary wind data.

Fields:

model_type pydantic-field

model_type: Literal['wind_grid'] = 'wind_grid'

Model type discriminator

id pydantic-field

id: Literal['wind'] = 'wind'

Identifier for the wind forcing

source pydantic-field

source: SOURCES

Source reader, must return a dataset with the rioxarray accessor in the open method

filter pydantic-field

filter: Optional[Filter]

Optional filter specification to apply to the dataset

variables pydantic-field

variables: Optional[list[str]] = []

Subset of variables to extract from the dataset

coords pydantic-field

Names of the coordinates in the dataset

crop_data pydantic-field

crop_data: bool = True

Update crop filters from Grid and Time objects if passed to get method

buffer pydantic-field

buffer: float = 0.0

Space to buffer the grid bounding box if crop_data is True

time_buffer pydantic-field

time_buffer: list[int] = [1, 1]

Number of source data timesteps to buffer the time range if filter_time is True

ds property

ds

Return the xarray dataset for this data source.

outfile property

outfile: str

location pydantic-field

location: Literal['centre', 'offshore', 'grid'] = 'centre'

Location to extract the data from the source dataset: 'centre' extracts the data at the centre of the grid, 'offshore' extracts the data at the middle of the offshore grid boundary, 'grid' at all grid points

crs cached property

crs

Return the coordinate reference system of the data source.

sel_method pydantic-field

sel_method: Literal['interp', 'sel'] = 'sel'

Defines which function from xarray to use for data selection: 'interp' uses interp() for interpolation, 'sel' uses sel() for selection

sel_method_kwargs pydantic-field

sel_method_kwargs: dict = {'method': 'nearest'}

Keyword arguments for sel_method

x_dim cached property

x_dim

Return the x dimension name.

y_dim cached property

y_dim

Return the y dimension name.

wind_vars pydantic-field

Wind forcing variables

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

get

get(
    destdir: str | Path,
    grid: RegularGrid,
    time: Optional[TimeRange] = None,
) -> dict

Generate the wind file.

Parameters:

Name Type Description Default
destdir str | Path

Destination directory for the netcdf file.

required
grid RegularGrid

Grid instance to use for selecting the boundary points.

required
time Optional[TimeRange]

The times to filter the data to, only used if self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the boundary bcfile data.

plot

plot(
    param,
    isel={},
    model_grid=None,
    cmap="turbo",
    figsize=None,
    fscale=10,
    borders=True,
    land=True,
    coastline=True,
    **kwargs,
)

Plot the grid.

set_variables

set_variables()

Set the variables attribute based on the wind_vars attribute.

spddir

spddir(ds) -> tuple[DataArray, DataArray]

Wind speed and direction.

Parameters:

Name Type Description Default
ds Dataset

Dataset containing the wind data.

required

Returns:

Name Type Description
spd DataArray

Wind speed.

dir DataArray

Wind coming_from direction.

WindStation pydantic-model

WindStation(**data: Any)

Bases: WindMixin, BaseDataStation

Wind forcing from station data.

Namelist

  • windfile : str Name of file with non-stationary wind data.

Fields:

model_type pydantic-field

model_type: Literal['wind_station'] = 'wind_station'

Model type discriminator

id pydantic-field

id: Literal['wind'] = 'wind'

Identifier for the wind forcing

source pydantic-field

source: SOURCES

Source reader, must return a dataset with the rioxarray accessor in the open method

filter pydantic-field

filter: Optional[Filter]

Optional filter specification to apply to the dataset

variables pydantic-field

variables: Optional[list[str]] = []

Subset of variables to extract from the dataset

coords pydantic-field

Names of the coordinates in the dataset

crop_data pydantic-field

crop_data: bool = True

Update crop filters from Grid and Time objects if passed to get method

buffer pydantic-field

buffer: float = 0.0

Space to buffer the grid bounding box if crop_data is True

time_buffer pydantic-field

time_buffer: list[int] = [1, 1]

Number of source data timesteps to buffer the time range if filter_time is True

ds property

ds

Return the xarray dataset for this data source.

outfile property

outfile: str

location pydantic-field

location: Literal['centre', 'offshore', 'grid'] = 'centre'

Location to extract the data from the source dataset: 'centre' extracts the data at the centre of the grid, 'offshore' extracts the data at the middle of the offshore grid boundary, 'grid' at all grid points

crs cached property

crs

Return the coordinate reference system of the data source.

sel_method pydantic-field

sel_method: Literal['idw', 'nearest'] = 'idw'

Defines which function from wavespectra.core.select to use for data selection: 'idw' uses sel_idw() for inverse distance weighting, 'nearest' uses sel_nearest() for nearest neighbor selection

sel_method_kwargs pydantic-field

sel_method_kwargs: dict = {}

Keyword arguments for sel_method

wind_vars pydantic-field

Wind forcing variables

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

get

get(
    destdir: str | Path,
    grid: RegularGrid,
    time: Optional[TimeRange] = None,
) -> dict

Generate the wind file.

Parameters:

Name Type Description Default
destdir str | Path

Destination directory for the netcdf file.

required
grid RegularGrid

Grid instance to use for selecting the boundary points.

required
time Optional[TimeRange]

The times to filter the data to, only used if self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the boundary bcfile data.

plot

plot(
    param,
    isel={},
    model_grid=None,
    cmap="turbo",
    figsize=None,
    fscale=10,
    borders=True,
    land=True,
    coastline=True,
    **kwargs,
)

Plot the grid.

validate_coords

validate_coords() -> BaseDataStation

set_variables

set_variables()

Set the variables attribute based on the wind_vars attribute.

spddir

spddir(ds) -> tuple[DataArray, DataArray]

Wind speed and direction.

Parameters:

Name Type Description Default
ds Dataset

Dataset containing the wind data.

required

Returns:

Name Type Description
spd DataArray

Wind speed.

dir DataArray

Wind coming_from direction.

WindPoint pydantic-model

WindPoint(**data: Any)

Bases: WindMixin, BaseDataPoint

Wind forcing from point timeseries data.

Namelist

  • windfile : str Name of file with non-stationary wind data.

Fields:

model_type pydantic-field

model_type: Literal['wind_point'] = 'wind_point'

Model type discriminator

id pydantic-field

id: Literal['wind'] = 'wind'

Identifier for the wind forcing

source pydantic-field

source: SOURCES_TS

Source reader, must return an xarray timeseries dataset in the open method

filter pydantic-field

filter: Optional[Filter]

Optional filter specification to apply to the dataset

variables pydantic-field

variables: Optional[list[str]] = []

Subset of variables to extract from the dataset

coords pydantic-field

Names of the coordinates in the dataset

crop_data pydantic-field

crop_data: bool = True

Update crop filters from Grid and Time objects if passed to get method

buffer pydantic-field

buffer: float = 0.0

Space to buffer the grid bounding box if crop_data is True

time_buffer pydantic-field

time_buffer: list[int] = [1, 1]

Number of source data timesteps to buffer the time range if filter_time is True

ds property

ds

Return the xarray dataset for this data source.

outfile property

outfile: str

location pydantic-field

location: Literal['centre', 'offshore', 'grid'] = 'centre'

Location to extract the data from the source dataset: 'centre' extracts the data at the centre of the grid, 'offshore' extracts the data at the middle of the offshore grid boundary, 'grid' at all grid points

crs cached property

crs

Return the coordinate reference system of the data source.

wind_vars pydantic-field

Wind forcing variables

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

get

get(
    destdir: str | Path,
    grid: RegularGrid,
    time: Optional[TimeRange] = None,
) -> dict

Generate the wind file.

Parameters:

Name Type Description Default
destdir str | Path

Destination directory for the netcdf file.

required
grid RegularGrid

Grid instance to use for selecting the boundary points.

required
time Optional[TimeRange]

The times to filter the data to, only used if self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the boundary bcfile data.

plot

plot(
    param,
    isel={},
    model_grid=None,
    cmap="turbo",
    figsize=None,
    fscale=10,
    borders=True,
    land=True,
    coastline=True,
    **kwargs,
)

Plot the grid.

set_variables

set_variables()

Set the variables attribute based on the wind_vars attribute.

spddir

spddir(ds) -> tuple[DataArray, DataArray]

Wind speed and direction.

Parameters:

Name Type Description Default
ds Dataset

Dataset containing the wind data.

required

Returns:

Name Type Description
spd DataArray

Wind speed.

dir DataArray

Wind coming_from direction.