rompy.swan.components.output.BLOCK#
- pydantic model rompy.swan.components.output.BLOCK[source]#
Write spatial distributions.
BLOCK 'sname' ->HEADER|NOHEADER 'fname' (LAYOUT [idla]) < output > & [unit] (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY
With this optional command the user indicates that one or more spatial distributions should be written to a file.
Note
The SWAN special frames ‘BOTTGRID’ or ‘COMPGRID’ can be set with the sname field.
Note
The text of the header indicates run identification (see command PROJECT), time, frame or group name (‘sname’), variable and unit. The number of header lines is 8.
Note
Cannot be used in 1D-mode.
Examples
In [1]: from rompy.swan.components.output import BLOCK In [2]: block = BLOCK(sname="outgrid", fname="./depth-frame.nc", output=["depth"]) In [3]: print(block.render()) BLOCK sname='outgrid' fname='./depth-frame.nc' DEPTH In [4]: block = BLOCK( ...: sname="COMPGRID", ...: header=False, ...: fname="./output-grid.nc", ...: idla=3, ...: output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"], ...: times=dict( ...: tbeg="2012-01-01T00:00:00", ...: delt="PT30M", ...: tfmt=1, ...: dfmt="min", ...: suffix="", ...: ) ...: ) ...: In [5]: print(block.render()) BLOCK sname='COMPGRID' NOHEADER fname='./output-grid.nc' LAYOUT idla=3 & HSIGN & HSWELL & DIR & TPS & TM01 & WATLEV & QP & OUTPUT tbegblk=20120101.000000 deltblk=30.0 MIN
Show JSON schema
{ "title": "BLOCK", "description": "Write spatial distributions.\n\n.. code-block:: text\n\n BLOCK 'sname' ->HEADER|NOHEADER 'fname' (LAYOUT [idla]) < output > &\n [unit] (OUTPUT [tbegblk] [deltblk]) SEC|MIN|HR|DAY\n\nWith this optional command the user indicates that one or more spatial\ndistributions should be written to a file.\n\nNote\n----\nThe SWAN special frames 'BOTTGRID' or 'COMPGRID' can be set with the `sname` field.\n\nNote\n----\nThe text of the header indicates run identification (see command `PROJECT`), time,\nframe or group name ('sname'), variable and unit. The number of header lines is 8.\n\nNote\n----\nCannot be used in 1D-mode.\n\nExamples\n--------\n\n.. ipython:: python\n :okwarning:\n\n from rompy.swan.components.output import BLOCK\n block = BLOCK(sname=\"outgrid\", fname=\"./depth-frame.nc\", output=[\"depth\"])\n print(block.render())\n block = BLOCK(\n sname=\"COMPGRID\",\n header=False,\n fname=\"./output-grid.nc\",\n idla=3,\n output=[\"hsign\", \"hswell\", \"dir\", \"tps\", \"tm01\", \"watlev\", \"qp\"],\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(block.render())", "type": "object", "properties": { "model_type": { "default": "block", "description": "Model type discriminator", "enum": [ "block", "BLOCK" ], "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" }, "header": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": null, "description": "Indicate if the output should be written to a file with header lines (SWAN default: True)", "title": "Header" }, "idla": { "anyOf": [ { "$ref": "#/$defs/IDLA" }, { "type": "null" } ], "default": null, "description": "Prescribe the lay-out of the output to file (supported options here are 1, 3, 4). Option 4 is recommended for postprocessing an ASCII file by MATLAB, however option 3 is recommended in case of binary MATLAB output (SWAN default: 1)" }, "output": { "description": "The output variables to output to block file", "items": { "$ref": "#/$defs/BlockOptions" }, "minItems": 1, "title": "Output", "type": "array" }, "unit": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "description": "Controls the scaling of the output. The program divides computed values by `unit` before writing to file, so the user should multiply the written value by `unit` to obtain the proper value. By default, if HEADER is selected, value is written as a 5 position integer. SWAN takes `unit` such that the largest number occurring in the block can be printed. If NOHEADER is selected, values are printed in floating-point format by default (`unit=1`)", "title": "Unit" } }, "$defs": { "BlockOptions": { "description": "Valid options for block output parameters.\n\nAttributes\n----------\nHSIGN: \"hsign\"\n Significant wave height (in m).\nHSWELL: \"hswell\"\n Swell wave height (in m).\nDIR: \"dir\"\n Mean wave direction (in degrees).\nDPM: \"dpm\"\n Mean wave direction at the peak frequency (in degrees).\nPDIR: \"pdir\"\n Peak wave direction (in degrees).\nTDIR: \"tdir\"\n Direction of energy transport (in degrees).\nTM01: \"tm01\"\n Mean absolute wave period (in s).\nRTM01: \"rtm01\"\n Mean relative wave period (in s).\nRTP: \"rtp\"\n Peak period of the (relative frequency) variance density spectrum (in s).\nTPS: \"tps\"\n Smoothed peak period (in s).\nPER: \"per\"\n Mean absolute wave period (in s).\nRPER: \"rper\"\n Mean relative wave period (in s).\nTMM10: \"tmm10\"\n Mean absolute wave period (in s).\nRTMM10: \"rtmm10\"\n Mean relative wave period (in s).\nTM02: \"tm02\"\n Mean absolute zero-crossing period (in s).\nFSPR: \"fspr\"\n The normalised width of the frequency spectrum.\nDSPR: \"dspr\"\n Directional spreading of the waves (in degrees).\nQP: \"qp\"\n Peakedness of the wave spectrum (dimensionless).\nDEPTH: \"depth\"\n Water depth (in m).\nWATLEV: \"watlev\"\n Water level (in m).\nBOTLEV: \"botlev\"\n Bottom level (in m).\nVEL: \"vel\"\n Current velocity (vector; in m/s).\nFRCOEF: \"frcoef\"\n Friction coefficient (equal to `cfw` or `kn` in command `FRICTION`).\nWIND: \"wind\"\n Wind velocity (vector; in m/s).\nAICE: \"aice\"\n Ice concentration (as a fraction from 0 to 1).\nPROPAGAT: \"propagat\"\n Sum of PROPXY, PROPTHETA and PROPSIGMA (in W/m2 or m2/s).\nPROPXY: \"propxy\"\n Energy propagation in geographic space; sum of x- and y-direction\n (in W/m2 or m2/s).\nPROPTHETA: \"proptheta\"\n Energy propagation in theta space (in W/m2 or m2/s).\nPROPSIGMA: \"propsigma\"\n Energy propagation in sigma space (in W/m2 or m2/s).\nGENERAT: \"generat\"\n Total energy generation (in W/m2 or m2/s).\nGENWIND: \"genwind\"\n Energy generation due to wind (in W/m2 or m2/s).\nREDIST: \"redist\"\n Total energy redistribution (in W/m2 or m2/s).\nREDQUAD: \"redquad\"\n Energy redistribution due to quadruplets (in W/m2 or m2/s).\nREDTRIAD: \"redtriad\"\n Energy redistribution due to triads (in W/m2 or m2/s).\nDISSIP: \"dissip\"\n Total energy dissipation (in W/m2 or m2/s).\nDISBOT: \"disbot\"\n Energy dissipation due to bottom friction (in W/m2 or m2/s).\nDISSURF: \"dissurf\"\n Energy dissipation due to surf breaking (in W/m2 or m2/s).\nDISWCAP: \"diswcap\"\n Energy dissipation due to whitecapping (in W/m2 or m2/s).\nDISSWELL: \"disswell\"\n Energy dissipation due to swell dissipation (in W/m2 or m2/s).\nDISVEG: \"disveg\"\n Energy dissipation due to vegetation (in W/m2 or m2/s).\nDISMUD: \"dismud\"\n Energy dissipation due to mud (in W/m2 or m2/s).\nDISICE: \"disice\"\n Energy dissipation due to sea ice (in W/m2 or m2/s).\nRADSTR: \"radstr\"\n Energy transfer between waves and currents due to radiation stress\n (in W/m2 or m2/s).\nQB: \"qb\"\n Fraction of breaking waves due to depth-induced breaking.\nTRANSP: \"transp\"\n Transport of energy (vector; in W/m2 or m2/s).\nFORCE: \"force\"\n Wave-induced force per unit surface area (vector; in N/m2).\nUBOT: \"ubot\"\n The rms-value of the maxima of the orbital velocity near the bottom (in m/s).\nURMS: \"urms\"\n The rms-value of the orbital velocity near the bottom (in m/s).\nTMBOT: \"tmbot\"\n The bottom wave period (in s).\nWLENGTH: \"wlength\"\n Average wave length (in m).\nLWAVP: \"lwavp\"\n Peak wave length (in m).\nSTEEPNESS: \"steepness\"\n Average wave steepness (dimensionless).\nBFI: \"bfi\"\n Benjamin-Feir index (dimensionless).\nNPLANTS: \"nplants\"\n Number of plants per square meter.\nDHSIGN: \"dhsign\"\n Difference in significant wave height from the last two iterations (in m).\nDRTM01: \"drtm01\"\n Difference in average wave period (RTM01) from the last two iterations (in s).\nLEAK: \"leak\"\n Numerical loss of energy equal to `cthetaE(omega,theta)` across boundaries.\nTIME: \"time\"\n Full date-time string as part of line used in TABLE only.\nTSEC: \"tsec\"\n Time in seconds with respect to a reference time (see command QUANTITY).\nXP: \"xp\"\n The x-coordinate in the problem coordinate system of the output location.\nYP: \"yp\"\n The y-coordinate in the problem coordinate system of the output location.\nDIST: \"dist\"\n If output has been requested along a curve then the distance along the curve\n can be obtained with the command TABLE. DIST is the distance along the curve\n measured from teh first point on the curve to the output location on the curve\n in meters (also in the case of spherical coordinates).\nSETUP: \"setup\"\n Set-up due to waves (in m).\nPTHSIGN: \"pthsign\"\n Watershed partitions of the significant wave height (in m).\nPTRTP: \"ptrtp\"\n Watershed partitions of the relative peak period (in s).\nPTWLEN: \"ptwlen\"\n Watershed partitions of the average wave length (in m).\nPTDIR: \"ptdir\"\n Watershed partitions of the peak wave direction (in degrees).\nPTDSPR: \"ptdspr\"\n Watershed partitions of the directional spreading (in degrees).\nPTWFRAC: \"ptwfrac\"\n Watershed partitions of the wind fraction (dimensionless).\nPTSTEEPNE: \"ptsteepne\"\n Watershed partition of the wave steepness (dimensionless).\nPARTITION: \"partition\"\n The raw spectral partition for wave system tracking post-processing.\n\nNote\n----\nEnergy given in W/m2 or m2/s depending on command SET.\n\nNote\n----\nUBOT and URMS required command `FRICTION` to be used. If friction is ignored in the\ncomputation, then one should use the command `FRICTION` with the value of the\nfriction set to zero (e.g., `FRICTION COLLINS 0`).", "enum": [ "hsign", "hswell", "dir", "dpm", "pdir", "tdir", "tm01", "rtm01", "rtp", "tps", "per", "rper", "tmm10", "rtmm10", "tm02", "fspr", "dspr", "qp", "depth", "watlev", "botlev", "vel", "frcoef", "wind", "aice", "propagat", "propxy", "proptheta", "propsigma", "generat", "genwind", "redist", "redquad", "redtriad", "dissip", "disbot", "dissurf", "diswcap", "disswell", "disveg", "dismud", "disice", "radstr", "qb", "transp", "force", "ubot", "urms", "tmbot", "wlength", "lwavp", "steepness", "bfi", "nplants", "dhsign", "drtm01", "leak", "time", "tsec", "xp", "yp", "dist", "setup", "pthsign", "ptrtp", "ptwlen", "ptdir", "ptdspr", "ptwfrac", "ptsteepne", "partition" ], "title": "BlockOptions", "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" }, "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", "output" ] }
- Fields:
- Validators:
- field header: bool | None = None#
Indicate if the output should be written to a file with header lines (SWAN default: True)
- Validated by:
- field idla: IDLA | None = None#
Prescribe the lay-out of the output to file (supported options here are 1, 3, 4). Option 4 is recommended for postprocessing an ASCII file by MATLAB, however option 3 is recommended in case of binary MATLAB output (SWAN default: 1)
- Validated by:
- field model_type: Literal['block', 'BLOCK'] = 'block'#
Model type discriminator
- Validated by:
- field output: list[BlockOptions] [Required]#
The output variables to output to block file
- Constraints:
min_length = 1
- Validated by:
- field unit: float | None = None#
Controls the scaling of the output. The program divides computed values by unit before writing to file, so the user should multiply the written value by unit to obtain the proper value. By default, if HEADER is selected, value is written as a 5 position integer. SWAN takes unit such that the largest number occurring in the block can be printed. If NOHEADER is selected, values are printed in floating-point format by default (unit=1)
- Validated by:
- property suffix: str#