Skip to content

Input grids

INPGRID and READINP: input grids for bottom, water level, currents, friction, wind and other fields, and the constant WIND and ICE forcing.

Input grid for SWAN.

HERE module-attribute

HERE = Path(__file__).parent

INPGRID pydantic-model

INPGRID(**data: Any)

Bases: BaseComponent, ABC

SWAN input grid.

INPGRID [grid_type] ->REGULAR|CURVILINEAR|UNSTRUCTURED (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])

This is the base class for all input grids. It is not meant to be used directly.

Fields:

Validators:

model_type pydantic-field

model_type: Literal['inpgrid', 'INPGRID'] = 'inpgrid'

Model type discriminator

grid_type pydantic-field

grid_type: GridOptions

Type of the swan input grid, e.g, 'bottom', 'wind', etc

excval pydantic-field

excval: Optional[float] = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

nonstationary pydantic-field

nonstationary: Optional[NONSTATIONARY] = None

Nonstationary time specification

readinp pydantic-field

readinp: READINP

SWAN input grid file reader specification

set_nonstat_suffix pydantic-validator

set_nonstat_suffix() -> INPGRID

Set the nonstationary suffix.

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

REGULAR pydantic-model

REGULAR(**data: Any)

Bases: INPGRID

SWAN regular input grid.

INPGRID [grid_type] REGULAR [xpinp] [ypinp] [alpinp] [mxinp] [myinp] &
    [dxinp] [dyinp] (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

from rompy_swan.components.inpgrid import REGULAR
inpgrid = REGULAR(
    grid_type="bottom",
    excval=-99.0,
    xpinp=172.0,
    ypinp=-41.0,
    alpinp=0.0,
    mxinp=99,
    myinp=99,
    dxinp=0.005,
    dyinp=0.005,
    readinp=dict(fname1="bottom.txt"),
)
print(inpgrid.render())
inpgrid = REGULAR(
    grid_type="wind",
    excval=-99.0,
    xpinp=172.0,
    ypinp=-41.0,
    alpinp=0.0,
    mxinp=99,
    myinp=99,
    dxinp=0.005,
    dyinp=0.005,
    readinp=dict(fname1="wind.txt"),
    nonstationary=dict(
        tbeg="2019-01-01T00:00:00",
        tend="2019-01-07 00:00:00",
        delt=3600,
        dfmt="hr",
    ),
)
print(inpgrid.render())
INPGRID BOTTOM REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0
READINP BOTTOM fac=1.0 fname1='bottom.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE
INPGRID WIND REGULAR xpinp=172.0 ypinp=-41.0 alpinp=0.0 mxinp=99 myinp=99 dxinp=0.005 dyinp=0.005 EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR &
    tendinp=20190107.000000
READINP WIND fac=1.0 fname1='wind.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

TODO: Use grid object, requires different grid parameters to be allowed.

Fields:

Validators:

model_type pydantic-field

model_type: Literal['regular', 'REGULAR'] = 'regular'

Model type discriminator

xpinp pydantic-field

xpinp: float

Geographic location (x-coordinate) of the origin of the input grid in problem coordinates (in m) if Cartesian coordinates are used or in degrees if spherical coordinates are used. In case of spherical coordinates there is no default

ypinp pydantic-field

ypinp: float

Geographic location (y-coordinate) of the origin of the input grid in problem coordinates (in m) if Cartesian coordinates are used or in degrees if spherical coordinates are used. In case of spherical coordinates there is no default

alpinp pydantic-field

alpinp: Optional[float] = 0.0

Direction of the positive x-axis of the input grid (in degrees, Cartesian convention)

mxinp pydantic-field

mxinp: int

Number of meshes in x-direction of the input grid (this number is one less than the number of grid points in this direction)

myinp pydantic-field

myinp: int

Number of meshes in y-direction of the input grid (this number is one less than the number of grid points in this direction). In 1D-mode, myinp should be 0

dxinp pydantic-field

dxinp: float

Mesh size in x-direction of the input grid, in m in case of Cartesian coordinates or in degrees if spherical coordinates are used

dyinp pydantic-field

dyinp: float

Mesh size in y-direction of the input grid, in m in case of Cartesian coordinates or in degrees if spherical coordinates are used. In 1D-mode, dyinp may have any value

grid_type pydantic-field

grid_type: GridOptions

Type of the swan input grid, e.g, 'bottom', 'wind', etc

excval pydantic-field

excval: Optional[float] = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

nonstationary pydantic-field

nonstationary: Optional[NONSTATIONARY] = None

Nonstationary time specification

readinp pydantic-field

readinp: READINP

SWAN input grid file reader specification

cmd

cmd() -> list

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

set_nonstat_suffix pydantic-validator

set_nonstat_suffix() -> INPGRID

Set the nonstationary suffix.

CURVILINEAR pydantic-model

CURVILINEAR(**data: Any)

Bases: INPGRID

SWAN curvilinear input grid.

INPGRID [grid_type] CURVILINEAR [stagrx] [stagry] [mxinp] [myinp] &
    (EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

from rompy_swan.components.inpgrid import CURVILINEAR
inpgrid = CURVILINEAR(
    grid_type="wind",
    stagrx=0.0,
    stagry=0.0,
    mxinp=199,
    myinp=199,
    excval=-99.0,
    readinp=dict(fname1="wind.txt"),
    nonstationary=dict(
        tbeg="2019-01-01T00:00:00",
        tend="2019-01-07 00:00:00",
        delt=3600,
        dfmt="hr",
    ),
)
print(inpgrid.render())
INPGRID WIND CURVILINEAR stagrx=0.0 stagry=0.0 mxinp=199 myinp=199  EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR tendinp=20190107.000000
READINP WIND fac=1.0 fname1='wind.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

TODO: Handle (or not) setting default values for mxinp and myinp from cgrid.

Fields:

Validators:

model_type pydantic-field

model_type: Literal["curvilinear", "CURVILINEAR"] = (
    "curvilinear"
)

Model type discriminator

stagrx pydantic-field

stagrx: float = 0.0

Staggered x'-direction with respect to computational grid, e.g., stagrx=0.5 means that the input grid points are shifted a half step in x'-direction; in many flow models x-velocities are defined in points shifted a half step in x'-direction

stagry pydantic-field

stagry: float = 0.0

Staggered y'-direction with respect to computational grid, e.g., stagry=0.5 means that the input grid points are shifted a half step in y'-direction; in many flow models y-velocities are defined in points shifted a half step in y'-direction

mxinp pydantic-field

mxinp: int

Number of meshes in ξ-direction of the input grid (this number is one less than the number of grid points in this direction)

myinp pydantic-field

myinp: int

Number of meshes in η-direction of the input grid (this number is one less than the number of grid points in this direction)

grid_type pydantic-field

grid_type: GridOptions

Type of the swan input grid, e.g, 'bottom', 'wind', etc

excval pydantic-field

excval: Optional[float] = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

nonstationary pydantic-field

nonstationary: Optional[NONSTATIONARY] = None

Nonstationary time specification

readinp pydantic-field

readinp: READINP

SWAN input grid file reader specification

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

set_nonstat_suffix pydantic-validator

set_nonstat_suffix() -> INPGRID

Set the nonstationary suffix.

UNSTRUCTURED pydantic-model

UNSTRUCTURED(**data: Any)

Bases: INPGRID

SWAN unstructured input grid.

INPGRID [grid_type] UNSTRUCTURED EXCEPTION [excval]) &
    (NONSTATIONARY [tbeginp] [deltinp] ->SEC|MIN|HR|DAY [tendinp])
READGRID [grid_type] [fac] 'fname1' [idla] [nhedf] ([nhedt]) ([nhedvec]) &
    ->FREE|FORMAT|UNFORMATTED ('form'|[idfm])

This is a group component that includes an INPGRID and a READGRID component.

Examples

from rompy_swan.components.inpgrid import UNSTRUCTURED
inpgrid = UNSTRUCTURED(
    grid_type="bottom",
    excval=-99.0,
    readinp=dict(fname1="bottom.txt"),
    nonstationary=dict(
        tbeg="2019-01-01T00:00:00",
        tend="2019-01-07 00:00:00",
        delt=3600,
        dfmt="hr",
    ),
)
print(inpgrid.render())
INPGRID BOTTOM UNSTRUCTURED EXCEPTION excval=-99.0 NONSTATIONARY tbeginp=20190101.000000 deltinp=1.0 HR tendinp=20190107.000000
READINP BOTTOM fac=1.0 fname1='bottom.txt' idla=1 nhedf=0 nhedt=0 nhedvec=0 FREE

Fields:

Validators:

model_type pydantic-field

model_type: Literal["unstructured", "UNSTRUCTURED"] = (
    "unstructured"
)

Model type discriminator

grid_type pydantic-field

grid_type: GridOptions

Type of the swan input grid, e.g, 'bottom', 'wind', etc

excval pydantic-field

excval: Optional[float] = None

Exception value to allow identifying and ignoring certain point inside the given grid during the computation. If fac != 1, excval must be given as fac times the exception value

nonstationary pydantic-field

nonstationary: Optional[NONSTATIONARY] = None

Nonstationary time specification

readinp pydantic-field

readinp: READINP

SWAN input grid file reader specification

cmd

cmd() -> str

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

set_nonstat_suffix pydantic-validator

set_nonstat_suffix() -> INPGRID

Set the nonstationary suffix.

WIND pydantic-model

WIND(**data: Any)

Bases: BaseComponent

Constant wind input field.

WIND [vel] [dir]

With this optional command, the user indicates that the wind field is constant.

Examples

from rompy_swan.components.inpgrid import WIND
wind = WIND(vel=10.0, dir=270.0)
print(wind.render())
WIND vel=10.0 dir=270.0

Fields:

model_type pydantic-field

model_type: Literal['wind', 'WIND'] = 'wind'

Model type discriminator

vel pydantic-field

vel: float

Wind velocity at 10 m elevation (m/s)

dir pydantic-field

dir: float

Wind direction at 10 m elevation (in degrees, Cartesian or Nautical convention, see command SET)

cmd

cmd()

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

ICE pydantic-model

ICE(**data: Any)

Bases: BaseComponent

Constant wind input field.

ICE [aice] [hice]

With this optional command, the user indicates that one or more ice fields are constant.

Examples

from rompy_swan.components.inpgrid import ICE
ice = ICE(aice=0.1, hice=0.1)
print(ice.render())
ICE aice=0.1 hice=0.1

Fields:

model_type pydantic-field

model_type: Literal['ice', 'ICE'] = 'ice'

Model type discriminator

aice pydantic-field

aice: float

Areal ice fraction, a number from 0 to 1

hice pydantic-field

hice: float

Ice thickness (m)

cmd

cmd()

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.