rompy.swan.grid.SwanGrid#
- pydantic model rompy.swan.grid.SwanGrid[source]#
Regular SWAN grid in geographic space.
Show JSON schema
{ "title": "SwanGrid", "description": "Regular SWAN grid in geographic space.", "type": "object", "properties": { "grid_type": { "default": "REG", "description": "Type of grid (REG=regular, CURV=curvilinear)", "enum": [ "REG", "CURV" ], "title": "Grid Type", "type": "string" }, "x0": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "X coordinate of the grid origin", "title": "X0" }, "y0": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "Y coordinate of the grid origin", "title": "Y0" }, "rot": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": 0.0, "description": "Rotation angle of the grid in degrees", "title": "Rot" }, "dx": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "Spacing between grid points in the x direction", "title": "Dx" }, "dy": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "Spacing between grid points in the y direction", "title": "Dy" }, "nx": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "description": "Number of grid points in the x direction", "title": "Nx" }, "ny": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "description": "Number of grid points in the y direction", "title": "Ny" }, "exc": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "Missing value", "title": "Exc" }, "gridfile": { "anyOf": [ { "maxLength": 36, "type": "string" }, { "type": "null" } ], "default": null, "description": "Name of grid file to load", "title": "Gridfile" } }, "additionalProperties": false }
- Fields:
- Validators:
validate_curvilinear_grid
»all fields
- field dx: float | None = None#
Spacing between grid points in the x direction
- Validated by:
- field dy: float | None = None#
Spacing between grid points in the y direction
- Validated by:
- field exc: float | None = None#
Missing value
- Validated by:
- field grid_type: Literal['REG', 'CURV'] = 'REG'#
Type of grid (REG=regular, CURV=curvilinear)
- Validated by:
- field gridfile: str | None = None#
Name of grid file to load
- Constraints:
max_length = 36
- Validated by:
- field nx: int | None = None#
Number of grid points in the x direction
- Validated by:
- field ny: int | None = None#
Number of grid points in the y direction
- Validated by:
- field rot: float | None = 0.0#
Rotation angle of the grid in degrees
- Validated by:
- field x0: float | None = None#
X coordinate of the grid origin
- Validated by:
- field y0: float | None = None#
Y coordinate of the grid origin
- Validated by:
- boundary(*args, **kwargs) tuple [source]#
Returns the grid boundary polygon.
Override the parent method to use the actual points from the regular grid boundary instead of the convex hull which is not always the boundary.
- classmethod from_component(component: GRIDREGULAR) SwanGrid [source]#
Swan grid from an existing component.
- Parameters:
component (GRIDREGULAR) – A GRIDREGULAR SWAN component.
- Returns:
A SwanGrid object.
- Return type:
- nearby_spectra(ds_spec, dist_thres=0.05, plot=True)[source]#
Find points nearby and project to the boundary
- Parameters:
ds_spec (xarray.Dataset) –
an XArray dataset of wave spectra at a number of points. Dataset variable names standardised using wavespectra.read_* functions.
See https://wavespectra.readthedocs.io/en/latest/api.html#input-functions
dist_thres (float, optional [Default: 0.05]) – Maximum distance to translate the input spectra to the grid boundary
plot (boolean, optional [Default: True]) – Generate a plot that shows the applied projections
- Returns:
A subset of ds_spec with lat and lon coordinates projected to the boundary
- Return type:
xarray.Dataset
- property cgrid#
- property cgrid_read#
- property component#
Return the respective SWAN component for this grid.
- property inpgrid#