rompy.swan.subcomponents.readgrid.READINP#

pydantic model rompy.swan.subcomponents.readgrid.READINP[source]#

SWAN input grid reader.

READINP GRID_TYPE [fac] ('fname1' | SERIES 'fname2') [idla] [nhedf] &
    ([nhedt]) [nhedvec] FREE|FORMAT ('form'|idfm)|UNFORMATTED`

Examples

In [100]: from rompy.swan.subcomponents.readgrid import READINP

In [101]: readinp = READINP(
   .....:     grid_type="wind",
   .....:     fname1="wind.txt",
   .....:     fac=1.0,
   .....:     idla=3,
   .....:     format="free",
   .....: )
   .....: 

In [102]: print(readinp.render())
READINP WIND fac=1.0 fname1='wind.txt' idla=3 nhedf=0 nhedt=0 nhedvec=0 FREE

Show JSON schema
{
   "title": "READINP",
   "description": "SWAN input grid reader.\n\n.. code-block:: text\n\n    READINP GRID_TYPE [fac] ('fname1' | SERIES 'fname2') [idla] [nhedf] &\n        ([nhedt]) [nhedvec] FREE|FORMAT ('form'|idfm)|UNFORMATTED`\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.readgrid import READINP\n    readinp = READINP(\n        grid_type=\"wind\",\n        fname1=\"wind.txt\",\n        fac=1.0,\n        idla=3,\n        format=\"free\",\n    )\n    print(readinp.render())",
   "type": "object",
   "properties": {
      "model_type": {
         "default": "readinp",
         "description": "Model type discriminator",
         "enum": [
            "readinp",
            "READINP"
         ],
         "title": "Model Type",
         "type": "string"
      },
      "grid_type": {
         "anyOf": [
            {
               "$ref": "#/$defs/GridOptions"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Type of the SWAN grid file"
      },
      "fac": {
         "default": 1.0,
         "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`",
         "exclusiveMinimum": 0.0,
         "title": "Fac",
         "type": "number"
      },
      "idla": {
         "$ref": "#/$defs/IDLA",
         "default": 1,
         "description": "Prescribes the order in which the values of bottom levels and other fields should be given in the file"
      },
      "nhedf": {
         "default": 0,
         "description": "The number of header lines at the start of the file. The text in the header lines is reproduced in the print file created by SWAN . The file may start with more header lines than `nhedf` because the start of the file is often also the start of a time step and possibly also of a vector variable (each having header lines, see `nhedt` and `nhedvec`)",
         "minimum": 0,
         "title": "Nhedf",
         "type": "integer"
      },
      "nhedvec": {
         "default": 0,
         "description": "For each vector variable: number of header lines in the file at the start of each component (e.g., x- or y-component)",
         "minimum": 0,
         "title": "Nhedvec",
         "type": "integer"
      },
      "format": {
         "default": "free",
         "description": "File format, one of 'free', 'fixed' or 'unformatted'. If 'free', the file is assumed to use the FREE FORTRAN format. If 'fixed', the file is assumed to use a fixed format that must be specified by (only) one of 'form' or 'idfm' arguments. Use 'unformatted' to read unformatted (binary) files (not recommended for ordinary use)",
         "enum": [
            "free",
            "fixed",
            "unformatted"
         ],
         "title": "Format",
         "type": "string"
      },
      "form": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "A user-specified format string in Fortran convention, e.g., '(10X,12F5.0)'.Only used if `format='fixed'`, do not use it if `idfm` is specified",
         "title": "Form"
      },
      "idfm": {
         "anyOf": [
            {
               "enum": [
                  1,
                  5,
                  6,
                  8
               ],
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "File format identifier, only used if `format='fixed'`",
         "title": "Idfm"
      },
      "fname1": {
         "description": "Name of the file with the values of the variable.",
         "title": "Fname1",
         "type": "string"
      },
      "fname2": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "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)",
         "title": "Fname2"
      },
      "nhedt": {
         "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`)",
         "minimum": 0,
         "title": "Nhedt",
         "type": "integer"
      }
   },
   "$defs": {
      "GridOptions": {
         "description": "Valid options for the input grid type.\n\nAttributes\n----------\nBOTTOM: \"bottom\"\n    Bottom level grid.\nWLEVEL: \"wlevel\"\n    Water level grid.\nCURRENT: \"current\"\n    Current field grid.\nVX: \"vx\"\n    Current field x-component grid.\nVY: \"vy\"\n    Current field y-component grid.\nWIND: \"wind\"\n    Wind velocity grid.\nWX: \"wx\"\n    Wind velocity x-component grid.\nWY: \"wy\"\n    Wind velocity y-component grid.\nFRICTION: \"friction\"\n    Bottom friction grid.\nNPLANTS: \"nplants\"\n    Horizontally varying vegetation density grid.\nTURBVISC: \"turbvisc\"\n    Horizontally varying turbulent viscosity grid.\nMUDLAYER: \"mudlayer\"\n    Horizontally varying mud layer thickness grid.\nAICE: \"aice\"\n    Areal ice fraction grid, a number between 0 and 1.\nHICE: \"hice\"\n    Ice thickness grid.\nHSS: \"hss\"\n    Sea-swell significant wave height grid.\nTSS: \"tss\"\n    Sea-swell mean wave period.",
         "enum": [
            "bottom",
            "wlevel",
            "current",
            "vx",
            "vy",
            "wind",
            "wx",
            "wy",
            "friction",
            "nplants",
            "turbvisc",
            "mudlayer",
            "aice",
            "hice",
            "hss",
            "tss"
         ],
         "title": "GridOptions",
         "type": "string"
      },
      "IDLA": {
         "description": "Order of values in the input files.\n\nAttributes\n----------\nONE: 1\n    SWAN reads the map from left to right starting in the upper-left-hand corner of\n    the map. A new line in the map should start on a new line in the file.\nTWO: 2\n    As `1` but a new line in the map need not start on a new line in the file.\nTHREE: 3\n    SWAN reads the map from left to right starting in the lower-left-hand corner of\n    the map. A new line in the map should start on a new line in the file.\nFOUR: 4\n    As `3` but a new line in the map need not start on a new line in the file.\nFIVE: 5\n    SWAN reads the map from top to bottom starting in the lower-left-hand corner of\n    the map. A new column in the map should start on a new line in the file.\nSIX: 6\n    As `5` but a new column in the map need not start on a new line in the file.\n\nNotes\n-----\nIt is assumed that the x-axis of the grid is pointing to the right and the y-axis\nupwards.",
         "enum": [
            1,
            2,
            3,
            4,
            5,
            6
         ],
         "title": "IDLA",
         "type": "integer"
      }
   },
   "additionalProperties": false,
   "required": [
      "fname1"
   ]
}

Fields:
Validators:
field fac: float = 1.0#

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

Constraints:
  • gt = 0.0

Validated by:
  • check_format_definition

field fname1: str [Required]#

Name of the file with the values of the variable.

Validated by:
  • check_format_definition

field fname2: str | None = None#

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)

Validated by:
  • check_format_definition

field form: str | None = None#

A user-specified format string in Fortran convention, e.g., ‘(10X,12F5.0)’.Only used if format=’fixed’, do not use it if idfm is specified

Validated by:
  • check_format_definition

field format: Literal['free', 'fixed', 'unformatted'] = 'free'#

File format, one of ‘free’, ‘fixed’ or ‘unformatted’. If ‘free’, the file is assumed to use the FREE FORTRAN format. If ‘fixed’, the file is assumed to use a fixed format that must be specified by (only) one of ‘form’ or ‘idfm’ arguments. Use ‘unformatted’ to read unformatted (binary) files (not recommended for ordinary use)

Validated by:
  • check_format_definition

field grid_type: GridOptions | None = None#

Type of the SWAN grid file

Validated by:
field idfm: Literal[1, 5, 6, 8] | None = None#

File format identifier, only used if format=’fixed’

Validated by:
  • check_format_definition

field idla: IDLA = 1#

Prescribes the order in which the values of bottom levels and other fields should be given in the file

Validated by:
  • check_format_definition

field model_type: Literal['readinp', 'READINP'] = 'readinp'#

Model type discriminator

Validated by:
  • check_format_definition

field nhedf: int = 0#

The number of header lines at the start of the file. The text in the header lines is reproduced in the print file created by SWAN . The file may start with more header lines than nhedf because the start of the file is often also the start of a time step and possibly also of a vector variable (each having header lines, see nhedt and nhedvec)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedt: int = 0#

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)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

field nhedvec: int = 0#

For each vector variable: number of header lines in the file at the start of each component (e.g., x- or y-component)

Constraints:
  • ge = 0

Validated by:
  • check_format_definition

cmd() str[source]#
validator set_undefined  »  grid_type[source]#

Allow for undefined value so it can be redefined in INPGRID components.