rompy.swan.components.output.BaseWrite#
- pydantic model rompy.swan.components.output.BaseWrite[source]#
Base class for SWAN output writing.
{MODEL_TYPE} sname='sname'
This is the base class for all write components. It is not meant to be used directly.
Examples
In [1]: from rompy.swan.components.output import BaseWrite In [2]: write = BaseWrite( ...: sname="outgrid", ...: fname="./output-grid.nc", ...: times=dict( ...: tbeg="2012-01-01T00:00:00", ...: delt="PT30M", ...: tfmt=1, ...: dfmt="min", ...: suffix="", ...: ) ...: ) ...: In [3]: print(write.render())
Show JSON schema
{ "title": "BaseWrite", "description": "Base class for SWAN output writing.\n\n.. code-block:: text\n\n {MODEL_TYPE} sname='sname'\n\nThis is the base class for all write components. It is not meant to be used\ndirectly.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.components.output import BaseWrite\n write = BaseWrite(\n sname=\"outgrid\",\n fname=\"./output-grid.nc\",\n times=dict(\n tbeg=\"2012-01-01T00:00:00\",\n delt=\"PT30M\",\n tfmt=1,\n dfmt=\"min\",\n suffix=\"\",\n )\n )\n print(write.render())", "type": "object", "properties": { "model_type": { "default": "write", "description": "Model type discriminator", "enum": [ "write", "WRITE" ], "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" } }, "$defs": { "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:
validate_special_names
»all fields
validate_times
»all fields
- field fname: str [Required]#
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
- Validated by:
- field model_type: Literal['write', 'WRITE'] = 'write'#
Model type discriminator
- Validated by:
- field sname: str [Required]#
Name of the set of output locations in which the output is to be written
- Constraints:
max_length = 8
- Validated by:
- field times: TimeRangeOpen | None = None#
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
- Validated by:
- property suffix: str#