rompy.core.data.DataGrid#

pydantic model rompy.core.data.DataGrid[source]#

Data object for model ingestion.

Generic data object for xarray datasets that need to be filtered and written to netcdf.

Note

The fields filter_grid and filter_time trigger updates to the crop filter from the grid and time range objects passed to the get method. This is useful for data sources that are not defined on the same grid as the model grid or the same time range as the model run.

Fields:
field buffer: float = 0.0#

Space to buffer the grid bounding box if filter_grid is True

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

Names of the coordinates in the dataset

field crop_data: bool = True#

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

field filter: Filter | None [Optional]#

Optional filter specification to apply to the dataset

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

Model type discriminator

field source: SourceDataset | SourceFile | SourceIntake | SourceDatamesh [Required]#

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

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

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

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

Subset of variables to extract from the dataset

get(destdir: str | Path, grid: BaseGrid | RegularGrid | 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 (GRID_TYPES, optional) – The grid to filter the data to, only used if self.crop_data is True.

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

Returns:

outfile – The path to the written file.

Return type:

Path

model_post_init(context: Any, /) None#

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

plot(param, isel={}, model_grid=None, cmap='turbo', figsize=None, fscale=10, borders=True, land=True, coastline=True, **kwargs)[source]#

Plot the grid.

property ds#

Return the xarray dataset for this data source.

property outfile: str#