Data API¶
Grid¶
SwanGrid ¶
Bases: RegularGrid
Regular SWAN grid in geographic space.
Source code in src/rompy_swan/grid.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
Attributes¶
grid_type
class-attribute
instance-attribute
¶
grid_type: Literal['REG', 'CURV'] = Field('REG', description='Type of grid (REG=regular, CURV=curvilinear)')
exc
class-attribute
instance-attribute
¶
gridfile
class-attribute
instance-attribute
¶
Functions¶
validate_grid_type
classmethod
¶
boundary ¶
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.
Source code in src/rompy_swan/grid.py
nearby_spectra ¶
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¶
xarray.Dataset A subset of ds_spec with lat and lon coordinates projected to the boundary
Source code in src/rompy_swan/grid.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
from_component
classmethod
¶
from_component(component: GRIDREGULAR) -> SwanGrid
Swan grid from an existing component.
Parameters¶
component: GRIDREGULAR A GRIDREGULAR SWAN component.
Returns¶
SwanGrid A SwanGrid object.
Source code in src/rompy_swan/grid.py
Data Classes¶
SwanDataGrid ¶
Bases: DataGrid
This class is used to write SWAN data from a dataset.
Source code in src/rompy_swan/data.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
Attributes¶
z1
class-attribute
instance-attribute
¶
z1: Optional[str] = Field(default=None, description='Name of the data variable in dataset representing either a scaler parameter or the u-componet of a vector field')
z2
class-attribute
instance-attribute
¶
z2: Optional[str] = Field(default=None, description='Name of the data variable in dataset representing the v-componet of a vector field')
var
class-attribute
instance-attribute
¶
var: GridOptions = Field(description='SWAN input grid name')
fac
class-attribute
instance-attribute
¶
fac: float = Field(description='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`', default=1.0)
Functions¶
ensure_z1_in_data_vars ¶
ensure_z1_in_data_vars() -> SwanDataGrid
Source code in src/rompy_swan/data.py
get ¶
get(destdir: str | Path, grid: Optional[SwanGrid] = None, time: Optional[TimeRange] = None) -> Path
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: str The command line string with the INPGRID/READINP commands ready to be written to the SWAN input file.
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.
Source code in src/rompy_swan/data.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Boundary Data¶
Boundnest1 ¶
Bases: BoundaryWaveStation
SWAN BOUNDNEST1 NEST data class.
Source code in src/rompy_swan/boundary.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundnest1', 'BOUNDNEST1'] = Field(default='boundnest1', description='Model type discriminator')
rectangle
class-attribute
instance-attribute
¶
rectangle: Literal['closed', 'open'] = Field(default='closed', description='Defines whether boundary is defined over an closed or open rectangle')
Functions¶
get ¶
get(destdir: str, grid: SwanGrid, time: Optional[TimeRange] = None) -> str
Write the data source to a new location.
Parameters¶
destdir : str | Path
Destination directory for the SWAN ASCII file.
grid : RegularGrid
Grid instance to use for selecting the boundary points.
time: TimeRange, optional
The times to filter the data to, only used if self.crop_data is True.
Returns¶
filename: Path The filename of the written boundary file. cmd : str Boundary command string to render in the SWAN INPUT file
Source code in src/rompy_swan/boundary.py
Interfaces¶
DataInterface ¶
Bases: RompyBaseModel
SWAN forcing data interface.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.interface import DataInterface
Source code in src/rompy_swan/interface.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['data_interface', 'DATA_INTERFACE'] = Field(default='data_interface', description='Model type discriminator')
bottom
class-attribute
instance-attribute
¶
bottom: Optional[SwanDataGrid] = Field(default=None, description='Bathymetry data')
input
class-attribute
instance-attribute
¶
input: list[SwanDataGrid] = Field(default=[], description='Input grid data')
Functions¶
ensure_unique_var
classmethod
¶
ensure_unique_var(input: list[SwanDataGrid], info: ValidationInfo) -> list[SwanDataGrid]
Ensure that each input var is unique.
Source code in src/rompy_swan/interface.py
BoundaryInterface ¶
Bases: RompyBaseModel
SWAN forcing boundary interface.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.interface import BoundaryInterface
Source code in src/rompy_swan/interface.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['boundary_interface', 'BOUNDARY_INTERFACE'] = Field(default='boundary_interface', description='Model type discriminator')
kind
class-attribute
instance-attribute
¶
kind: Union[Boundnest1, BoundspecSide, BoundspecSegmentXY] = Field(default=None, description='Boundary data object')
Functions¶
OutputInterface ¶
Bases: TimeInterface
Output group component with consistent times.
Source code in src/rompy_swan/interface.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['outputinterface', 'OUTPUTINTERFACE'] = Field(default='outputinterface', description='Model type discriminator')
Functions¶
time_interface ¶
time_interface() -> OutputInterface
Set the time parameter for all WRITE components.
Note¶
- tbeg is set to the Config runtime start
- delt is set from the component's times if defined, otherwise from the runtime interval
- tfmt is set from the component's times if defined, otherwise from TimeRange default
- dfmt is set from the component's times if defined, otherwise from TimeRange default
- suffix is set to the suffix of the component
Source code in src/rompy_swan/interface.py
LockupInterface ¶
Bases: TimeInterface
Lockup group component with consistent times.
Source code in src/rompy_swan/interface.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['lockupinterface', 'LOCKUPINTERFACE'] = Field(default='lockupinterface', description='Model type discriminator')
Functions¶
time_interface ¶
time_interface() -> LockupInterface
Set the time parameter for COMPUTE components.