Skip to content

Boundaries

Boundary data objects select data along the open boundaries of a model grid.

Boundary classes.

logger module-attribute

logger = logging.getLogger(__name__)

SOURCE_TYPES module-attribute

SOURCE_TYPES = load_entry_points('rompy.source')

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:

Validators:

model_type pydantic-field

model_type: Literal['boundary'] = 'data_boundary'

Model type discriminator

id pydantic-field

id: str

Unique identifier for this data source

spacing pydantic-field

spacing: Optional[Union[float, Literal['parent']]] = None

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

sel_method_kwargs pydantic-field

sel_method_kwargs: dict = {}

Keyword arguments for sel_method

crop_data pydantic-field

crop_data: bool = True

Update crop filter from Time object if passed to get method

source pydantic-field

Source reader, must return an xarray gridded 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

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] = [0, 0]

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

ds property

ds

Return the xarray dataset for this data source.

outfile property

outfile: str

spacing_gt_zero pydantic-validator

spacing_gt_zero(v)

get

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

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 self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the netcdf file.

plot

plot(
    model_grid=None,
    cmap="turbo",
    fscale=10,
    ax=None,
    **kwargs,
)

plot_boundary

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

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.

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:

Validators:

grid_type pydantic-field

grid_type: Literal["boundary_wave_station"] = (
    "boundary_wave_station"
)

Model type discriminator

source pydantic-field

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

ds property

ds

Return the filtered xarray dataset instance.

model_type pydantic-field

model_type: Literal['boundary'] = 'data_boundary'

Model type discriminator

id pydantic-field

id: str

Unique identifier for this data source

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 filter from Time object if passed to get method

time_buffer pydantic-field

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

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

outfile property

outfile: str

spacing pydantic-field

spacing: Optional[Union[float, Literal['parent']]] = None

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_kwargs pydantic-field

sel_method_kwargs: dict = {}

Keyword arguments for sel_method

get

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

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 self.crop_data is True.

None

Returns:

Name Type Description
outfile Path

Path to the netcdf file.

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.

plot

plot(
    model_grid=None,
    cmap="turbo",
    fscale=10,
    ax=None,
    **kwargs,
)

spacing_gt_zero pydantic-validator

spacing_gt_zero(v)

plot_boundary

plot_boundary(grid=None, fscale=10, ax=None, **kwargs)

Plot the boundary points on a map.

find_minimum_distance

find_minimum_distance(
    points: list[tuple[float, float]],
) -> float

Find the minimum distance between a set of points.

Parameters:

Name Type Description Default
points list[tuple[float, float]]

List of points as (x, y) tuples.

required

Returns:

Name Type Description
min_distance float

Minimum distance between all points.

scatter_plot

scatter_plot(bnd, ds=None, fscale=10, ax=None, **kwargs)

Plot the grid