Boundaries¶
Boundary data objects select data along the open boundaries of a model grid.
Boundary classes.
DataBoundary
pydantic-model
¶
DataBoundary(**data: Any)
Bases: DataGrid
Gridded data along the open boundary of a model grid.
Selects data from a gridded source at points along the grid boundary, spaced by
spacing (or at the source grid spacing with spacing="parent"), with
sel_method choosing nearest-neighbour selection or interpolation.
Fields:
-
source(Union[SOURCE_TYPES]) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
buffer(float) -
time_buffer(list[int]) -
model_type(Literal['boundary']) -
id(str) -
spacing(Optional[Union[float, Literal['parent']]]) -
sel_method(Literal['sel', 'interp']) -
sel_method_kwargs(dict) -
crop_data(bool)
Validators:
model_type
pydantic-field
¶
model_type: Literal['boundary'] = 'data_boundary'
Model type discriminator
spacing
pydantic-field
¶
Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If 'parent', the resolution of the parent dataset is used to define the spacing.
sel_method
pydantic-field
¶
sel_method: Literal['sel', 'interp'] = 'sel'
Xarray method to use for selecting boundary points from the dataset
crop_data
pydantic-field
¶
crop_data: bool = True
Update crop filter from Time object if passed to get method
source
pydantic-field
¶
source: Union[SOURCE_TYPES]
Source reader, must return an xarray gridded 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
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 crop_data is True
get
¶
Write the selected boundary data to a netcdf 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 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
outfile |
Path
|
Path to the netcdf file. |
plot_boundary
¶
Plot the boundary points on a map.
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.
BoundaryWaveStation
pydantic-model
¶
BoundaryWaveStation(**data: Any)
Bases: DataBoundary
Wave boundary data from station datasets.
Note
The tolerance behaves differently with sel_methods idw and nearest; in idw
sites with no enough neighbours within tolerance are masked whereas in nearest
an exception is raised (see wavespectra documentation for more details).
Note
Be aware that when using idw missing values will be returned for sites with less
than 2 neighbours within tolerance in the original dataset. This is okay for land
mask areas but could cause boundary issues when on an open boundary location. To
avoid this either use nearest or increase tolerance to include more neighbours.
Fields:
-
model_type(Literal['boundary']) -
id(str) -
filter(Optional[Filter]) -
variables(Optional[list[str]]) -
coords(Optional[DatasetCoords]) -
crop_data(bool) -
time_buffer(list[int]) -
spacing(Optional[Union[float, Literal['parent']]]) -
sel_method_kwargs(dict) -
grid_type(Literal['boundary_wave_station']) -
source(Union[SOURCE_TYPES]) -
sel_method(Literal['idw', 'nearest']) -
buffer(float)
Validators:
grid_type
pydantic-field
¶
grid_type: Literal["boundary_wave_station"] = (
"boundary_wave_station"
)
Model type discriminator
source
pydantic-field
¶
source: Union[SOURCE_TYPES]
Dataset source reader, must return a wavespectra-enabled xarray dataset in the open method
sel_method
pydantic-field
¶
sel_method: Literal['idw', 'nearest'] = 'idw'
Wavespectra method to use for selecting boundary points from the dataset
buffer
pydantic-field
¶
buffer: float = 2.0
Space to buffer the grid bounding box if crop_data is True
model_type
pydantic-field
¶
model_type: Literal['boundary'] = 'data_boundary'
Model type discriminator
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 filter from Time object if passed to get method
time_buffer
pydantic-field
¶
Number of source data timesteps to buffer the time range if crop_data is True
spacing
pydantic-field
¶
Spacing between points along the grid boundary to retrieve data for. If None (default), points are defined from the the actual grid object passed to the get method. If 'parent', the resolution of the parent dataset is used to define the spacing.
get
¶
Write the selected boundary data to a netcdf 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 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
outfile |
Path
|
Path to the netcdf file. |
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_boundary
¶
Plot the boundary points on a map.