rompy.swan.components.group.LOCKUP#
- pydantic model rompy.swan.components.group.LOCKUP[source]#
Lockup group component.
COMPUTE ... HOTFILE ... COMPUTE ... HOTFILE ... ... STOP
This is a group component to specify SWAN “Lockup” commands including multiple COMPUTE commands that may or may not be interleaved with HOTFILE commands, and a final STOP command.
Examples
In [37]: from rompy.swan.components.group import LOCKUP In [38]: lockup = LOCKUP( ....: compute=dict( ....: model_type="stat", ....: times=dict( ....: model_type="nonstationary", ....: tbeg="1990-01-01T00:00:00", ....: tend="1990-01-01T03:00:00", ....: delt="PT1H", ....: dfmt="hr", ....: ), ....: hotfile=dict(fname="hotfile"), ....: hottimes=[-1], ....: ), ....: ) ....: In [39]: print(lockup.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' STOP
Show JSON schema
{ "title": "LOCKUP", "description": "Lockup group component.\n\n.. code-block:: text\n\n COMPUTE ...\n HOTFILE ...\n COMPUTE ...\n HOTFILE ...\n ...\n STOP\n\nThis is a group component to specify SWAN \"Lockup\" commands including multiple\n`COMPUTE` commands that may or may not be interleaved with `HOTFILE` commands,\nand a final `STOP` command.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.components.group import LOCKUP\n lockup = LOCKUP(\n compute=dict(\n model_type=\"stat\",\n times=dict(\n model_type=\"nonstationary\",\n tbeg=\"1990-01-01T00:00:00\",\n tend=\"1990-01-01T03:00:00\",\n delt=\"PT1H\",\n dfmt=\"hr\",\n ),\n hotfile=dict(fname=\"hotfile\"),\n hottimes=[-1],\n ),\n )\n print(lockup.render())", "type": "object", "properties": { "model_type": { "default": "lockup", "description": "Model type discriminator", "enum": [ "lockup", "LOCKUP" ], "title": "Model Type", "type": "string" }, "compute": { "description": "Compute components", "discriminator": { "mapping": { "NONSTAT": "#/$defs/COMPUTE_NONSTAT", "STAT": "#/$defs/COMPUTE_STAT", "nonstat": "#/$defs/COMPUTE_NONSTAT", "stat": "#/$defs/COMPUTE_STAT" }, "propertyName": "model_type" }, "oneOf": [ { "$ref": "#/$defs/COMPUTE_STAT" }, { "$ref": "#/$defs/COMPUTE_NONSTAT" } ], "title": "Compute" } }, "$defs": { "COMPUTE_NONSTAT": { "additionalProperties": false, "description": "Multiple SWAN nonstationary computations.\n\n.. code-block:: text\n\n COMPUTE NONSTATIONARY [tbegc] [deltc] SEC|MIN|HR|DAY [tendc]\n HOTFILE 'fname' ->FREE|UNFORMATTED\n COMPUTE NONSTATIONARY [tbegc] [deltc] SEC|MIN|HR|DAY [tendc]\n HOTFILE 'fname' ->FREE|UNFORMATTED\n .\n .\n\nThis component can be used to define multiple nonstationary 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 NONSTATIONARY\n from rompy.swan.components.lockup import COMPUTE_NONSTAT\n times = NONSTATIONARY(\n tbeg=\"1990-01-01T00:00:00\",\n tend=\"1990-02-01T00:00:00\",\n delt=\"PT1H\",\n dfmt=\"hr\",\n )\n comp = COMPUTE_NONSTAT(times=times)\n print(comp.render())\n comp = COMPUTE_NONSTAT(\n times=times,\n hotfile=dict(fname=\"hotfile.swn\", format=\"free\"),\n hottimes=[\"1990-02-01T00:00:00\"],\n )\n print(comp.render())\n comp = COMPUTE_NONSTAT(\n times=times,\n initstat=True,\n hotfile=dict(fname=\"hotfile\", format=\"free\"),\n hottimes=[6, 12, 18, -1],\n )\n print(comp.render())", "properties": { "model_type": { "default": "nonstat", "description": "Model type discriminator", "enum": [ "nonstat", "NONSTAT" ], "title": "Model Type", "type": "string" }, "times": { "$ref": "#/$defs/NONSTATIONARY", "description": "Compute 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" }, "initstat": { "default": false, "description": "Run a STATIONARY computation at the initial time prior to the NONSTATIONARY computation(s) to prescribe initial conditions", "title": "Initstat", "type": "boolean" } }, "title": "COMPUTE_NONSTAT", "type": "object" }, "COMPUTE_STAT": { "additionalProperties": false, "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())", "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" } }, "title": "COMPUTE_STAT", "type": "object" }, "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, "required": [ "compute" ] }
- Fields:
- field compute: COMPUTE_STAT | COMPUTE_NONSTAT [Required]#
Compute components
- field model_type: Literal['lockup', 'LOCKUP'] = 'lockup'#
Model type discriminator