Grid reader¶
Sub-commands to support file reading. These are in technically components in that they render a full command line however they are not intended to be used directly but rather as sub-components of CGRID and INPGRID commands.
GRIDREGULAR ¶
Bases: BaseSubComponent
SWAN Regular Grid subcomponent.
.. code-block:: text
xp yp alp xlen ylen mx my
Note¶
The direction of the x-axis alp must be 0 in case of spherical coordinates
Note¶
All coordinates and distances should be given in m when Cartesian coordinates are used or degrees when Spherical coordinates are used (see command COORD).
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.readgrid import GRIDREGULAR
kwargs = dict(xp=173, yp=-40, alp=0, xlen=2, ylen=2, mx=199, my=199)
grid = GRIDREGULAR(suffix="c", **kwargs)
print(grid.render())
grid = GRIDREGULAR(suffix="inp", **kwargs)
print(grid.render())
Source code in src/rompy_swan/subcomponents/readgrid.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['gridregular', 'GRIDREGULAR'] = Field(default='gridregular', description='Model type discriminator')
xp
class-attribute
instance-attribute
¶
yp
class-attribute
instance-attribute
¶
alp
class-attribute
instance-attribute
¶
xlen
class-attribute
instance-attribute
¶
ylen
class-attribute
instance-attribute
¶
mx
class-attribute
instance-attribute
¶
mx: int = Field(description='Number of meshes in computational grid in x-direction (this number is one less than the number of grid points in this domain)')
my
class-attribute
instance-attribute
¶
my: int = Field(description='Number of meshes in computational grid in y-direction (this number is one less than the number of grid points in this domain)')
suffix
class-attribute
instance-attribute
¶
suffix: Optional[str] = Field(default='', description='Suffix for rendering with each output grid parameter.')
Functions¶
cmd ¶
Command file string for this subcomponent.
Source code in src/rompy_swan/subcomponents/readgrid.py
READCOORD ¶
Bases: READGRID
SWAN coordinates reader.
.. code-block:: text
READGRID COORDINATES [fac] 'fname' [idla] [nhedf] [nhedvec] &
FREE|FORMAT ('form'|idfm)
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.readgrid import READCOORD
readcoord = READCOORD(
fac=1.0,
fname="coords.txt",
idla=3,
format="free",
)
print(readcoord.render())
Source code in src/rompy_swan/subcomponents/readgrid.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['readcoord', 'READCOORD'] = Field(default='readcoord', description='Model type discriminator')
grid_type
class-attribute
instance-attribute
¶
grid_type: Literal['coordinates'] = Field(default='coordinates', description='Type of the SWAN grid file')
fname
class-attribute
instance-attribute
¶
Functions¶
READINP ¶
Bases: READGRID
SWAN input grid reader.
.. code-block:: text
READINP GRID_TYPE [fac] ('fname1' | SERIES 'fname2') [idla] [nhedf] &
([nhedt]) [nhedvec] FREE|FORMAT ('form'|idfm)|UNFORMATTED`
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.readgrid import READINP
readinp = READINP(
grid_type="wind",
fname1="wind.txt",
fac=1.0,
idla=3,
format="free",
)
print(readinp.render())
Source code in src/rompy_swan/subcomponents/readgrid.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['readinp', 'READINP'] = Field(default='readinp', description='Model type discriminator')
grid_type
class-attribute
instance-attribute
¶
grid_type: Optional[GridOptions] = Field(default=None, description='Type of the SWAN grid file')
fname1
class-attribute
instance-attribute
¶
fname2
class-attribute
instance-attribute
¶
fname2: Optional[str] = Field(default=None, description="Name of file that contains the names of the files where the variables are given when the SERIES option is used. These names are to be given in proper time sequence. SWAN reads the next file when the previous file end has been encountered. In these files the input should be given in the same format as in the above file 'fname1' (that implies that a file should start with the start of an input time step)")
nhedt
class-attribute
instance-attribute
¶
nhedt: int = Field(default=0, description='Only if variable is time dependent: number of header lines in the file at the start of each time level. A time step may start with more header lines than `nhedt` because the variable may be a vector variable which has its own header lines (see `nhedvec`)', ge=0)
Functions¶
set_undefined
classmethod
¶
Allow for undefined value so it can be redefined in INPGRID components.