rompy.swan.components.output.SPECOUT#

pydantic model rompy.swan.components.output.SPECOUT[source]#

Write to data file the wave spectra.

SPECOUT 'sname' SPEC1D|->SPEC2D ->ABS|REL 'fname' &
    (OUTPUT [tbeg] [delt] SEC|MIN|HR|DAY)

With this optional command the user indicates that for each location of the output location set ‘sname’ (see commands POINTS, CURVE, FRAME or GROUP) the 1D or 2D variance / energy (see command SET) density spectrum (either the relative frequency or the absolute frequency spectrum) is to be written to a data file.

Note

This write command supports the following location types: POINTS, CURVE, FRAME and GROUP.

Note

This output file can be used for defining boundary conditions for subsequent SWAN runs (command BOUNDSPEC).

Examples

In [1]: from rompy.swan.components.output import SPECOUT

In [2]: out = SPECOUT(sname="outpts", fname="./specout.swn")

In [3]: print(out.render())
SPECOUT sname='outpts' fname='./specout.swn'

In [4]: out = SPECOUT(
   ...:     sname="outpts",
   ...:     dim=dict(model_type="spec2d"),
   ...:     freq=dict(model_type="rel"),
   ...:     fname="./specout.nc",
   ...:     times=dict(tbeg="2012-01-01T00:00:00", delt="PT30M", dfmt="min"),
   ...: )
   ...: 

In [5]: print(out.render())
SPECOUT sname='outpts' SPEC2D REL fname='./specout.nc' OUTPUT tbegspc=20120101.000000 deltspc=30.0 MIN

Show JSON schema
{
   "title": "SPECOUT",
   "description": "Write to data file the wave spectra.\n\n.. code-block:: text\n\n    SPECOUT 'sname' SPEC1D|->SPEC2D ->ABS|REL 'fname' &\n        (OUTPUT [tbeg] [delt] SEC|MIN|HR|DAY)\n\nWith this optional command the user indicates that for each location of the output\nlocation set 'sname' (see commands `POINTS`, `CURVE`, `FRAME` or `GROUP`) the 1D\nor 2D variance / energy (see command `SET`) density spectrum (either the relative\nfrequency or the absolute frequency spectrum) is to be written to a data file.\n\nNote\n----\nThis write command supports the following location types: `POINTS`, `CURVE`,\n`FRAME` and `GROUP`.\n\nNote\n----\nThis output file can be used for defining boundary conditions for subsequent SWAN\nruns (command `BOUNDSPEC`).\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.components.output import SPECOUT\n    out = SPECOUT(sname=\"outpts\", fname=\"./specout.swn\")\n    print(out.render())\n    out = SPECOUT(\n        sname=\"outpts\",\n        dim=dict(model_type=\"spec2d\"),\n        freq=dict(model_type=\"rel\"),\n        fname=\"./specout.nc\",\n        times=dict(tbeg=\"2012-01-01T00:00:00\", delt=\"PT30M\", dfmt=\"min\"),\n    )\n    print(out.render())",
   "type": "object",
   "properties": {
      "model_type": {
         "default": "specout",
         "description": "Model type discriminator",
         "enum": [
            "specout",
            "SPECOUT"
         ],
         "title": "Model Type",
         "type": "string"
      },
      "sname": {
         "description": "Name of the set of output locations in which the output is to be written",
         "maxLength": 8,
         "title": "Sname",
         "type": "string"
      },
      "fname": {
         "description": "Name of the data file where the output is written to The file format is defined by the file extension, use `.mat` for MATLAB binary (single precision) or `.nc` for netCDF format. If any other extension is used the ASCII format is assumed",
         "title": "Fname",
         "type": "string"
      },
      "times": {
         "anyOf": [
            {
               "$ref": "#/$defs/TimeRangeOpen"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Time specification if the user requires output at various times. If this option is not specified data will be written for the last time step of the computation"
      },
      "dim": {
         "anyOf": [
            {
               "description": "Choose between 1D or 2D spectra output",
               "discriminator": {
                  "mapping": {
                     "SPEC1D": "#/$defs/SPEC1D",
                     "SPEC2D": "#/$defs/SPEC2D",
                     "spec1d": "#/$defs/SPEC1D",
                     "spec2d": "#/$defs/SPEC2D"
                  },
                  "propertyName": "model_type"
               },
               "oneOf": [
                  {
                     "$ref": "#/$defs/SPEC1D"
                  },
                  {
                     "$ref": "#/$defs/SPEC2D"
                  }
               ]
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Dim"
      },
      "freq": {
         "anyOf": [
            {
               "description": "Choose between absolute or relative frequency spectra",
               "discriminator": {
                  "mapping": {
                     "ABS": "#/$defs/ABS",
                     "REL": "#/$defs/REL",
                     "abs": "#/$defs/ABS",
                     "rel": "#/$defs/REL"
                  },
                  "propertyName": "model_type"
               },
               "oneOf": [
                  {
                     "$ref": "#/$defs/ABS"
                  },
                  {
                     "$ref": "#/$defs/REL"
                  }
               ]
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Freq"
      }
   },
   "$defs": {
      "ABS": {
         "additionalProperties": false,
         "description": "Absolute frequency spectra.\n\n.. code-block:: text\n\n    ABS\n\nSpectra are computed as a function of absolute frequency, i.e., the frequency as\nmeasured in a fixed point.\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.output import ABS\n    freq = ABS()\n    print(freq.render())",
         "properties": {
            "model_type": {
               "default": "abs",
               "description": "Model type discriminator",
               "enum": [
                  "abs",
                  "ABS"
               ],
               "title": "Model Type",
               "type": "string"
            }
         },
         "title": "ABS",
         "type": "object"
      },
      "REL": {
         "additionalProperties": false,
         "description": "Relative frequency spectra.\n\n.. code-block:: text\n\n    REL\n\nSpectra are computed as a function of relative frequency, i.e., the frequency as\nmeasured when moving with current.\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.output import REL\n    freq = REL()\n    print(freq.render())",
         "properties": {
            "model_type": {
               "default": "rel",
               "description": "Model type discriminator",
               "enum": [
                  "rel",
                  "REL"
               ],
               "title": "Model Type",
               "type": "string"
            }
         },
         "title": "REL",
         "type": "object"
      },
      "SPEC1D": {
         "additionalProperties": false,
         "description": "Frequency 1D spectra.\n\n.. code-block:: text\n\n    SPEC1D\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.output import SPEC1D\n    spec = SPEC1D()\n    print(spec.render())",
         "properties": {
            "model_type": {
               "default": "spec1d",
               "description": "Model type discriminator",
               "enum": [
                  "spec1d",
                  "SPEC1D"
               ],
               "title": "Model Type",
               "type": "string"
            }
         },
         "title": "SPEC1D",
         "type": "object"
      },
      "SPEC2D": {
         "additionalProperties": false,
         "description": "Frequency-direction 2D spectra.\n\n.. code-block:: text\n\n    SPEC2D\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.output import SPEC2D\n    spec = SPEC2D()\n    print(spec.render())",
         "properties": {
            "model_type": {
               "default": "spec2d",
               "description": "Model type discriminator",
               "enum": [
                  "spec2d",
                  "SPEC2D"
               ],
               "title": "Model Type",
               "type": "string"
            }
         },
         "title": "SPEC2D",
         "type": "object"
      },
      "TimeRangeOpen": {
         "additionalProperties": false,
         "description": "Regular times with an open boundary.\n\n.. code-block:: text\n\n    [tbeg] [delt] SEC|MIN|HR|DAY\n\nTime is rendered in one of the following formats:\n\n* 1: ISO-notation 19870530.153000\n* 2: (as in HP compiler) '30-May-87 15:30:00'\n* 3: (as in Lahey compiler) 05/30/87.15:30:00\n* 4: 15:30:00\n* 5: 87/05/30 15:30:00'\n* 6: as in WAM 8705301530\n\nNote\n----\nThe `tbeg` field can be specified as:\n\n* existing datetime object\n* int or float, assumed as Unix time, i.e. seconds (if >= -2e10 or <= 2e10) or\n  milliseconds (if < -2e10 or > 2e10) since 1 January 1970.\n* ISO 8601 time string.\n\nNote\n----\nThe `tdelta` field can be specified as:\n\n* existing timedelta object\n* int or float, assumed as seconds\n* ISO 8601 duration string, following formats work:\n\n    * `[-][DD ][HH:MM]SS[.ffffff]`\n    * `[\u00b1]P[DD]DT[HH]H[MM]M[SS]S` (ISO 8601 format for timedelta)\n\nNote\n----\nDefault values for the time specification fields are provided for the case where\nthe user wants to set times dynamically after instantiating this subcomponent.\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.time import TimeRangeOpen\n    from datetime import datetime, timedelta\n    times = TimeRangeOpen(\n        tbeg=datetime(1990, 1, 1), delt=timedelta(minutes=30), dfmt=\"min\"\n    )\n    print(times.render())\n    times = TimeRangeOpen(\n        tbeg=\"2012-01-01T00:00:00\", delt=\"PT1H\", tfmt=2, dfmt=\"hr\", suffix=\"blk\"\n    )\n    print(times.render())",
         "properties": {
            "model_type": {
               "default": "open",
               "description": "Model type discriminator",
               "enum": [
                  "open",
                  "OPEN"
               ],
               "title": "Model Type",
               "type": "string"
            },
            "tbeg": {
               "default": "1970-01-01T00:00:00",
               "description": "Start time",
               "format": "date-time",
               "title": "Tbeg",
               "type": "string"
            },
            "delt": {
               "default": "PT1H",
               "description": "Time interval",
               "format": "duration",
               "title": "Delt",
               "type": "string"
            },
            "tfmt": {
               "anyOf": [
                  {
                     "enum": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6
                     ],
                     "type": "integer"
                  },
                  {
                     "type": "string"
                  }
               ],
               "default": 1,
               "description": "Format to render time specification",
               "title": "Tfmt"
            },
            "dfmt": {
               "default": "sec",
               "description": "Format to render time interval specification",
               "enum": [
                  "sec",
                  "min",
                  "hr",
                  "day"
               ],
               "title": "Dfmt",
               "type": "string"
            },
            "suffix": {
               "default": "",
               "description": "Suffix to prepend to argument names when rendering",
               "title": "Suffix",
               "type": "string"
            }
         },
         "title": "TimeRangeOpen",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "sname",
      "fname"
   ]
}

Fields:
Validators:

field dim: SPEC1D | SPEC2D | None = None#
Validated by:
field freq: ABS | REL | None = None#
Validated by:
field model_type: Literal['specout', 'SPECOUT'] = 'specout'#

Model type discriminator

Validated by:
cmd() str[source]#

Command file string for this component.

property suffix: str#