rompy.swan.data.SwanDataGrid#

pydantic model rompy.swan.data.SwanDataGrid[source]#

This class is used to write SWAN data from a dataset.

Fields:
Validators:
field buffer: float = 0.0#

Space to buffer the grid bounding box if filter_grid is True

Validated by:
field coords: DatasetCoords | None = DatasetCoords(t='time', x='longitude', y='latitude', z='depth')#

Names of the coordinates in the dataset

Validated by:
field crop_data: bool = True#

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

Validated by:
field fac: float = 1.0#

SWAN multiplies all values that are read from file by fac. For instance if the values are given in unit decimeter, one should make fac=0.1 to obtain values in m. To change sign use a negative fac

Validated by:
field filter: Filter | None [Optional]#

Optional filter specification to apply to the dataset

Validated by:
field id: str = 'data'#

Unique identifier for this data source

Validated by:

Whether to create a symbolic link instead of copying the file

Validated by:
field model_type: Literal['data_grid'] = 'data_grid'#

Model type discriminator

Validated by:
field source: DATA_SOURCE_MODELS [Required]#

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

Validated by:
field time_buffer: list[int] = [0, 0]#

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

Validated by:
field var: GridOptions [Required]#

SWAN input grid name

Validated by:
field variables: list[str] | None = []#

Subset of variables to extract from the dataset

Validated by:
field z1: str | None = None#

Name of the data variable in dataset representing either a scaler parameter or the u-componet of a vector field

Validated by:
field z2: str | None = None#

Name of the data variable in dataset representing the v-componet of a vector field

Validated by:
validator ensure_z1_in_data_vars  »  all fields[source]#
get(destdir: str | Path, grid: SwanGrid | None = None, time: TimeRange | None = None) Path[source]#

Write the data source to a new location.

Parameters:
  • destdir (str | Path) – The destination directory to write the netcdf data to.

  • grid (SwanGrid, optional) – The grid to filter the data to, only used if self.filter_grid is True.

  • time (TimeRange, optional) – The times to filter the data to, only used if self.filter_time is True.

Returns:

cmd – The command line string with the INPGRID/READINP commands ready to be written to the SWAN input file.

Return type:

str

Note

The data are assumed to not have been rotated. We cannot use the grid.rot attr as this is the rotation from the model grid object which is not necessarily the same as the rotation of the data.

model_post_init(context: Any, /) None#

We need to both initialize private attributes and call the user-defined model_post_init method.