Data interfaces¶
Base classes of the XBeach forcing interfaces (waves, water levels, wind). They select data at a point, at stations or on a grid, building on rompy's DataGrid.
rompy_xbeach.data.base¶
XBEACH Rompy data.
SOURCES_TS
module-attribute
¶
SOURCES_TS = Union[
load_entry_points("rompy.source", etype="timeseries")
]
BaseData
pydantic-model
¶
BaseData(**data: Any)
Xbeach data class.
Fields:
-
model_type(Literal['grid']) -
id(str) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
crop_data(bool) -
buffer(float) -
source(SOURCES) -
location(Literal['centre', 'offshore', 'grid']) -
time_buffer(list[int])
source
pydantic-field
¶
source: SOURCES
Source reader, must return a dataset with the rioxarray accessor in the open method
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
time_buffer
pydantic-field
¶
Number of source data timesteps to buffer the time range if filter_time is True
filter
pydantic-field
¶
Optional filter specification to apply to the dataset
variables
pydantic-field
¶
Subset of variables to extract from the dataset
coords
pydantic-field
¶
coords: Optional[DatasetCoords] = DatasetCoords()
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
get
abstractmethod
¶
Write the data source to a new location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destdir
|
str | Path
|
The destination directory to write data file to. |
required |
grid
|
RegularGrid
|
The grid to interpolate the data to. |
required |
time
|
Optional[TimeRange]
|
The times to filter the data to, only used if |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
Dataset
|
The dataset selected from the grid and times. This method is abstract and must be implemented by the subclass to generate the expected xbeach output. |
check_for_typos
classmethod
¶
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.
plot
¶
plot(
param,
isel={},
model_grid=None,
cmap="turbo",
figsize=None,
fscale=10,
borders=True,
land=True,
coastline=True,
**kwargs,
)
Plot the grid.
BaseDataPoint
pydantic-model
¶
BaseDataPoint(**data: Any)
Bases: BaseData
Base class to construct XBeach input from point timeseries type data.
Fields:
-
model_type(Literal['grid']) -
id(str) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
crop_data(bool) -
buffer(float) -
time_buffer(list[int]) -
location(Literal['centre', 'offshore', 'grid']) -
source(SOURCES_TS)
source
pydantic-field
¶
source: SOURCES_TS
Source reader, must return an xarray timeseries dataset in the open method
filter
pydantic-field
¶
Optional filter specification to apply to the dataset
variables
pydantic-field
¶
Subset of variables to extract from the dataset
coords
pydantic-field
¶
coords: Optional[DatasetCoords] = DatasetCoords()
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
¶
Number of source data timesteps to buffer the time range if filter_time is True
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
check_for_typos
classmethod
¶
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.
get
abstractmethod
¶
Write the data source to a new location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destdir
|
str | Path
|
The destination directory to write data file to. |
required |
grid
|
RegularGrid
|
The grid to interpolate the data to. |
required |
time
|
Optional[TimeRange]
|
The times to filter the data to, only used if |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
Dataset
|
The dataset selected from the grid and times. This method is abstract and must be implemented by the subclass to generate the expected xbeach output. |
plot
¶
plot(
param,
isel={},
model_grid=None,
cmap="turbo",
figsize=None,
fscale=10,
borders=True,
land=True,
coastline=True,
**kwargs,
)
Plot the grid.
BaseDataStation
pydantic-model
¶
BaseDataStation(**data: Any)
Bases: BaseData
Base class to construct XBeach input from stations type data.
Fields:
-
model_type(Literal['grid']) -
id(str) -
source(SOURCES) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
crop_data(bool) -
buffer(float) -
time_buffer(list[int]) -
location(Literal['centre', 'offshore', 'grid']) -
sel_method(Literal['idw', 'nearest']) -
sel_method_kwargs(dict)
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
source
pydantic-field
¶
source: SOURCES
Source reader, must return a dataset with the rioxarray accessor in the open method
filter
pydantic-field
¶
Optional filter specification to apply to the dataset
variables
pydantic-field
¶
Subset of variables to extract from the dataset
coords
pydantic-field
¶
coords: Optional[DatasetCoords] = DatasetCoords()
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
¶
Number of source data timesteps to buffer the time range if filter_time is True
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
check_for_typos
classmethod
¶
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.
get
abstractmethod
¶
Write the data source to a new location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destdir
|
str | Path
|
The destination directory to write data file to. |
required |
grid
|
RegularGrid
|
The grid to interpolate the data to. |
required |
time
|
Optional[TimeRange]
|
The times to filter the data to, only used if |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
Dataset
|
The dataset selected from the grid and times. This method is abstract and must be implemented by the subclass to generate the expected xbeach output. |
plot
¶
plot(
param,
isel={},
model_grid=None,
cmap="turbo",
figsize=None,
fscale=10,
borders=True,
land=True,
coastline=True,
**kwargs,
)
Plot the grid.
BaseDataGrid
pydantic-model
¶
BaseDataGrid(**data: Any)
Bases: BaseData
Base class to construct XBeach input from gridded type data.
Fields:
-
model_type(Literal['grid']) -
id(str) -
source(SOURCES) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
crop_data(bool) -
buffer(float) -
time_buffer(list[int]) -
location(Literal['centre', 'offshore', 'grid']) -
sel_method(Literal['interp', 'sel']) -
sel_method_kwargs(dict)
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
source
pydantic-field
¶
source: SOURCES
Source reader, must return a dataset with the rioxarray accessor in the open method
filter
pydantic-field
¶
Optional filter specification to apply to the dataset
variables
pydantic-field
¶
Subset of variables to extract from the dataset
coords
pydantic-field
¶
coords: Optional[DatasetCoords] = DatasetCoords()
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
¶
Number of source data timesteps to buffer the time range if filter_time is True
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
check_for_typos
classmethod
¶
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.
get
abstractmethod
¶
Write the data source to a new location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destdir
|
str | Path
|
The destination directory to write data file to. |
required |
grid
|
RegularGrid
|
The grid to interpolate the data to. |
required |
time
|
Optional[TimeRange]
|
The times to filter the data to, only used if |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
data |
Dataset
|
The dataset selected from the grid and times. This method is abstract and must be implemented by the subclass to generate the expected xbeach output. |
plot
¶
plot(
param,
isel={},
model_grid=None,
cmap="turbo",
figsize=None,
fscale=10,
borders=True,
land=True,
coastline=True,
**kwargs,
)
Plot the grid.
rompy_xbeach.data.forcing¶
XBeach forcing file writers.
This module contains helper classes for writing XBeach forcing files: - BaseFile: Abstract base class for time-series file writing - Wind: Simple constant wind parameters - WindFile: Time-varying wind file writer - TideFile: Time-varying tide/water level file writer
These classes are used internally by the data interface classes in rompy_xbeach.data.wind and rompy_xbeach.data.waterlevel.
BaseFile
pydantic-model
¶
BaseFile(**data: Any)
Bases: RompyBaseModel, ABC
Base file definition.
Fields:
Validators:
check_for_typos
classmethod
¶
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.
Wind
pydantic-model
¶
Wind(**data: Any)
Bases: RompyBaseModel
XBeach basic wind definition.
Fields:
check_for_typos
classmethod
¶
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.
WindFile
pydantic-model
¶
WindFile(**data: Any)