rompy.swan.components.lockup.COMPUTE_STAT#
- pydantic model rompy.swan.components.lockup.COMPUTE_STAT[source]#
Multiple SWAN stationary computations.
COMPUTE STATIONARY [time] HOTFILE 'fname' ->FREE|UNFORMATTED COMPUTE STATIONARY [time] COMPUTE STATIONARY [time] HOTFILE 'fname' ->FREE|UNFORMATTED . .
This component can be used to define multiple stationary compute commands and write intermediate results as hotfiles between then.
Note
The field times is optional to allow for the case where the user wants to set times dynamically after instantiating this component.
Examples
In [1]: from rompy.swan.subcomponents.time import STATIONARY, NONSTATIONARY In [2]: from rompy.swan.components.lockup import COMPUTE_STAT In [3]: time = STATIONARY(time="1990-01-01T00:00:00") In [4]: comp = COMPUTE_STAT(times=time) In [5]: print(comp.render()) COMPUTE STATIONARY time=19900101.000000 In [6]: times = NONSTATIONARY( ...: tbeg="1990-01-01T00:00:00", ...: tend="1990-01-01T03:00:00", ...: delt="PT1H", ...: ) ...: In [7]: comp = COMPUTE_STAT(times=times) In [8]: print(comp.render()) COMPUTE STATIONARY time=19900101.000000 COMPUTE STATIONARY time=19900101.010000 COMPUTE STATIONARY time=19900101.020000 COMPUTE STATIONARY time=19900101.030000 In [9]: hotfile = dict(fname="./hotfile.swn") In [10]: hottimes=["1990-01-01T03:00:00"] In [11]: comp = COMPUTE_STAT(times=times, hotfile=hotfile, hottimes=hottimes) In [12]: print(comp.render()) COMPUTE STATIONARY time=19900101.000000 COMPUTE STATIONARY time=19900101.010000 COMPUTE STATIONARY time=19900101.020000 COMPUTE STATIONARY time=19900101.030000 HOTFILE fname='hotfile_19900101T030000.swn' In [13]: comp = COMPUTE_STAT(times=times, hotfile=hotfile, hottimes=[2, -1]) In [14]: print(comp.render()) COMPUTE STATIONARY time=19900101.000000 COMPUTE STATIONARY time=19900101.010000 COMPUTE STATIONARY time=19900101.020000 HOTFILE fname='hotfile_19900101T020000.swn' COMPUTE STATIONARY time=19900101.030000 HOTFILE fname='hotfile_19900101T030000.swn'
Show JSON schema
{ "title": "COMPUTE_STAT", "description": "Multiple SWAN stationary computations.\n\n.. code-block:: text\n\n COMPUTE STATIONARY [time]\n HOTFILE 'fname' ->FREE|UNFORMATTED\n COMPUTE STATIONARY [time]\n COMPUTE STATIONARY [time]\n HOTFILE 'fname' ->FREE|UNFORMATTED\n .\n .\n\nThis component can be used to define multiple stationary compute commands and\nwrite intermediate results as hotfiles between then.\n\nNote\n----\nThe field `times` is optional to allow for the case where the user wants to set\ntimes dynamically after instantiating this component.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.subcomponents.time import STATIONARY, NONSTATIONARY\n from rompy.swan.components.lockup import COMPUTE_STAT\n time = STATIONARY(time=\"1990-01-01T00:00:00\")\n comp = COMPUTE_STAT(times=time)\n print(comp.render())\n times = NONSTATIONARY(\n tbeg=\"1990-01-01T00:00:00\",\n tend=\"1990-01-01T03:00:00\",\n delt=\"PT1H\",\n )\n comp = COMPUTE_STAT(times=times)\n print(comp.render())\n hotfile = dict(fname=\"./hotfile.swn\")\n hottimes=[\"1990-01-01T03:00:00\"]\n comp = COMPUTE_STAT(times=times, hotfile=hotfile, hottimes=hottimes)\n print(comp.render())\n comp = COMPUTE_STAT(times=times, hotfile=hotfile, hottimes=[2, -1])\n print(comp.render())", "type": "object", "properties": { "model_type": { "default": "stat", "description": "Model type discriminator", "enum": [ "stat", "STAT" ], "title": "Model Type", "type": "string" }, "times": { "description": "Compute times", "discriminator": { "mapping": { "NONSTATIONARY": "#/$defs/NONSTATIONARY", "STATIONARY": "#/$defs/STATIONARY", "nonstationary": "#/$defs/NONSTATIONARY", "stationary": "#/$defs/STATIONARY" }, "propertyName": "model_type" }, "oneOf": [ { "$ref": "#/$defs/STATIONARY" }, { "$ref": "#/$defs/NONSTATIONARY" } ], "title": "Times" }, "hotfile": { "anyOf": [ { "$ref": "#/$defs/HOTFILE" }, { "type": "null" } ], "default": null, "description": "Write results to restart files" }, "hottimes": { "anyOf": [ { "items": { "format": "date-time", "type": "string" }, "type": "array" }, { "items": { "type": "integer" }, "type": "array" } ], "default": [], "description": "Times to write hotfiles, can be a list of datetimes or times indices", "title": "Hottimes" }, "suffix": { "default": "_%Y%m%dT%H%M%S", "description": "Time-template suffix to add to hotfile fname", "title": "Suffix", "type": "string" } }, "$defs": { "HOTFILE": { "additionalProperties": false, "description": "Write intermediate results.\n\n.. code-block:: text\n\n HOTFILE 'fname' ->FREE|UNFORMATTED\n\nThis command can be used to write the entire wave field at the end of a computation\nto a so-called hotfile, to be used as initial condition in a subsequent SWAN run\n(see command `INITIAL HOTSTART`). This command must be entered immediately after a\n`COMPUTE` command.\n\nThe user may choose the format of the hotfile to be written either as free or\nunformatted. If the free format is chosen, then this format is identical to the\nformat of the files written by the `SPECOUT` command (option `SPEC2D`). This\nhotfile is therefore an ASCII file which is human readable.\n\nAn unformatted (or binary) file usually requires less space on your computer than\nan ASCII file. Moreover, it can be readed by a subsequent SWAN run much faster than\nan ASCII file. Especially, when the hotfile might become a big file, the choice for\nunformatted is preferable. Note that your compiler and OS should follow the same\nABI (Application Binary Interface) conventions (e.g. word size, endianness), so\nthat unformatted hotfiles may transfer properly between different OS or platforms.\nThis implies that the present and subsequent SWAN runs do not have to be carried\nout on the same operating system (e.g. Windows, Linux) or on the same computer,\nprovided that distinct ABI conventions have been followed.\n\nNote\n----\nFor parallel MPI runs, more than one hotfile will be generated depending on the\nnumber of processors (`fname-001`, `fname-002`, etc).\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.components.lockup import HOTFILE\n hotfile = HOTFILE(fname=\"hotfile.swn\")\n print(hotfile.render())\n hotfile = HOTFILE(fname=\"hotfile.dat\", format=\"unformatted\")\n print(hotfile.render())", "properties": { "model_type": { "default": "hotfile", "description": "Model type discriminator", "enum": [ "hotfile", "HOTFILE" ], "title": "Model Type", "type": "string" }, "fname": { "description": "Name of the file to which the wave field is written", "format": "path", "title": "Fname", "type": "string" }, "format": { "anyOf": [ { "enum": [ "free", "unformatted" ], "type": "string" }, { "type": "null" } ], "default": null, "description": "Choose between free (SWAN ASCII) or unformatted (binary) format", "title": "Format" } }, "required": [ "fname" ], "title": "HOTFILE", "type": "object" }, "NONSTATIONARY": { "additionalProperties": false, "description": "Nonstationary time specification.\n\n.. code-block:: text\n\n NONSTATIONARY [tbeg] [delt] SEC|MIN|HR|DAY [tend]\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 NONSTATIONARY\n nonstat = NONSTATIONARY(\n tbeg=\"2012-01-01T00:00:00\",\n tend=\"2012-02-01T00:00:00\",\n delt=\"PT1H\",\n dfmt=\"hr\",\n )\n print(nonstat.render())\n from datetime import datetime, timedelta\n nonstat = NONSTATIONARY(\n tbeg=datetime(1990, 1, 1),\n tend=datetime(1990, 1, 7),\n delt=timedelta(minutes=30),\n tfmt=1,\n dfmt=\"min\",\n suffix=\"tbl\",\n )\n print(nonstat.render())", "properties": { "model_type": { "default": "nonstationary", "description": "Model type discriminator", "enum": [ "nonstationary", "NONSTATIONARY" ], "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" }, "tend": { "default": "1970-01-02T00:00:00", "description": "End time", "format": "date-time", "title": "Tend", "type": "string" } }, "title": "NONSTATIONARY", "type": "object" }, "STATIONARY": { "additionalProperties": false, "description": "Stationary time specification.\n\n.. code-block:: text\n\n STATIONARY [time]\n\nNote\n----\nThe field `time` is optional to allow for the case where the user wants to set the\ntime dynamically after instantiating this component.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.subcomponents.time import STATIONARY\n stat = STATIONARY(time=\"2012-01-01T00:00:00\")\n print(stat.render())", "properties": { "model_type": { "default": "stationary", "description": "Model type discriminator", "enum": [ "stationary", "STATIONARY" ], "title": "Model Type", "type": "string" }, "time": { "default": "1970-01-01T00:00:00", "description": "Stationary time", "format": "date-time", "title": "Time", "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" } }, "title": "STATIONARY", "type": "object" } }, "additionalProperties": false }
- Fields:
- Validators:
hotfile_with_hottimes
»all fields
- field hottimes: list[datetime] | list[int] = []#
Times to write hotfiles, can be a list of datetimes or times indices
- Validated by:
- field model_type: Literal['stat', 'STAT'] = 'stat'#
Model type discriminator
- Validated by:
- field suffix: str = '_%Y%m%dT%H%M%S'#
Time-template suffix to add to hotfile fname
- Validated by:
- field times: STATIONARY | NONSTATIONARY [Optional]#
Compute times
- Validated by:
- validator timestamp_to_datetime » hottimes[source]#
Ensure pandas.Timestamp entries are coerced into datatime.
- property hotids: list#
List time ids at which to write hotfiles.