rompy.swan.components.cgrid.REGULAR#

pydantic model rompy.swan.components.cgrid.REGULAR[source]#

SWAN regular computational grid.

CGRID REGULAR [xpc] [ypc] [alpc] [xlenc] [ylenc] [mxc] [myc] &
    ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]

This is a group component that includes a CGRID and a READGRID component.

Note

In 1D-mode, alpc should be equal to the direction alpinp.

Examples

In [24]: from rompy.swan.components.cgrid import REGULAR

In [25]: cgrid = REGULAR(
   ....:     grid=dict(xp=0, yp=0, alp=0, xlen=2000, ylen=1300, mx=100, my=100),
   ....:     spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),
   ....: )
   ....: 

In [26]: print(cgrid.render())
CGRID REGULAR xpc=0.0 ypc=0.0 alpc=0.0 xlenc=2000.0 ylenc=1300.0 mxc=100 myc=100 CIRCLE mdc=36 flow=0.04 fhigh=1.0

Show JSON schema
{
   "title": "REGULAR",
   "description": "SWAN regular computational grid.\n\n.. code-block:: text\n\n    CGRID REGULAR [xpc] [ypc] [alpc] [xlenc] [ylenc] [mxc] [myc] &\n        ->CIRCLE|SECTOR [mdc] [flow] [fhigh] [msc]\n\nThis is a group component that includes a `CGRID` and a `READGRID` component.\n\nNote\n----\nIn 1D-mode, `alpc` should be equal to the direction `alpinp`.\n\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.components.cgrid import REGULAR\n    cgrid = REGULAR(\n        grid=dict(xp=0, yp=0, alp=0, xlen=2000, ylen=1300, mx=100, my=100),\n        spectrum=dict(mdc=36, flow=0.04, fhigh=1.0),\n    )\n    print(cgrid.render())",
   "type": "object",
   "properties": {
      "model_type": {
         "default": "regular",
         "description": "Model type discriminator",
         "enum": [
            "regular",
            "REGULAR"
         ],
         "title": "Model Type",
         "type": "string"
      },
      "spectrum": {
         "$ref": "#/$defs/SPECTRUM",
         "description": "Spectrum subcomponent"
      },
      "grid": {
         "$ref": "#/$defs/GRIDREGULAR",
         "description": "Computational grid definition"
      }
   },
   "$defs": {
      "GRIDREGULAR": {
         "additionalProperties": false,
         "description": "SWAN Regular Grid subcomponent.\n\n.. code-block:: text\n\n    xp yp alp xlen ylen mx my\n\nNote\n----\nThe direction of the x-axis `alp` must be 0 in case of spherical coordinates\n\nNote\n----\nAll coordinates and distances should be given in m when Cartesian coordinates are\nused or degrees when Spherical coordinates are used (see command COORD).\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.readgrid import GRIDREGULAR\n    kwargs = dict(xp=173, yp=-40, alp=0, xlen=2, ylen=2, mx=199, my=199)\n    grid = GRIDREGULAR(suffix=\"c\", **kwargs)\n    print(grid.render())\n    grid = GRIDREGULAR(suffix=\"inp\", **kwargs)\n    print(grid.render())",
         "properties": {
            "model_type": {
               "default": "gridregular",
               "description": "Model type discriminator",
               "enum": [
                  "gridregular",
                  "GRIDREGULAR"
               ],
               "title": "Model Type",
               "type": "string"
            },
            "xp": {
               "description": "The x-coordinate of the origin in problem coordinates",
               "title": "Xp",
               "type": "number"
            },
            "yp": {
               "description": "The y-coordinate of the origin in problem coordinates",
               "title": "Yp",
               "type": "number"
            },
            "alp": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": 0.0,
               "description": "Direction of the xaxis in degrees",
               "title": "Alp"
            },
            "xlen": {
               "description": "Length of the computational grid in the x-direction",
               "title": "Xlen",
               "type": "number"
            },
            "ylen": {
               "description": "Length of the computational grid in the y-direction",
               "title": "Ylen",
               "type": "number"
            },
            "mx": {
               "description": "Number of meshes in computational grid in x-direction (this number is one less than the number of grid points in this domain)",
               "title": "Mx",
               "type": "integer"
            },
            "my": {
               "description": "Number of meshes in computational grid in y-direction (this number is one less than the number of grid points in this domain)",
               "title": "My",
               "type": "integer"
            },
            "suffix": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "",
               "description": "Suffix for rendering with each output grid parameter.",
               "title": "Suffix"
            }
         },
         "required": [
            "xp",
            "yp",
            "xlen",
            "ylen",
            "mx",
            "my"
         ],
         "title": "GRIDREGULAR",
         "type": "object"
      },
      "SPECTRUM": {
         "additionalProperties": false,
         "description": "SWAN spectrum specification.\n\n.. code-block:: text\n\n    ->CIRCLE|SECTOR ([dir1] [dir2]) [mdc] [flow] [fhigh] [msc]\n\nNotes\n-----\n\nDirections in the spectra are defined either as a CIRCLE or as a SECTOR. In the\ncase of a SECTOR, both `dir1` and `dir2` must be specified. In the case of a\nCIRCLE, neither `dir1` nor `dir2` should be specified.\n\nAt least two of `flow`, `fhigh` and `msc` must be specified in which case the\nthird parameter will be calculated by SWAN such that the frequency resolution\n`df/f = 0.1` (10% increments).\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.subcomponents.spectrum import SPECTRUM\n    spec = SPECTRUM(mdc=36, flow=0.04, fhigh=1.0)\n    print(spec.render())\n    spec = SPECTRUM(mdc=36, dir1=0, dir2=180, flow=0.04, msc=31)\n    print(spec.render())",
         "properties": {
            "model_type": {
               "default": "spectrum",
               "description": "Model type discriminator",
               "enum": [
                  "spectrum",
                  "SPECTRUM"
               ],
               "title": "Model Type",
               "type": "string"
            },
            "mdc": {
               "description": "Number of meshes in theta-space. In the case of CIRCLE, this is the number of subdivisions of the 360 degrees of a circle so `dtheta = [360]/[mdc]` is the spectral directional resolution. In the case of SECTOR, `dtheta = ([dir2] - [dir1])/[mdc]`. The minimum number of directional bins is 3 per directional quadrant.",
               "title": "Mdc",
               "type": "integer"
            },
            "flow": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Lowest discrete frequency that is used in the calculation (in Hz).",
               "title": "Flow"
            },
            "fhigh": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Highest discrete frequency that is used in the calculation (in Hz).",
               "title": "Fhigh"
            },
            "msc": {
               "anyOf": [
                  {
                     "minimum": 3,
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "One less than the number of frequencies. This defines the grid resolution in frequency-space between the lowest discrete frequency `flow` and the highest discrete frequency `fhigh`. This resolution is not constant, since the frequencies are distributed logarithmical: `fi+1 = yfi` where `y` is a constant. The minimum number of frequencies is 4",
               "title": "Msc"
            },
            "dir1": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The direction of the right-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.",
               "title": "Dir1"
            },
            "dir2": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The direction of the left-hand boundary of the sector when looking outward from the sector (required for option SECTOR) in degrees.",
               "title": "Dir2"
            }
         },
         "required": [
            "mdc"
         ],
         "title": "SPECTRUM",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "spectrum",
      "grid"
   ]
}

Fields:
Validators:
field grid: GRIDREGULAR [Required]#

Computational grid definition

Validated by:
field model_type: Literal['regular', 'REGULAR'] = 'regular'#

Model type discriminator

Validated by:
field spectrum: SPECTRUM [Required]#

Spectrum subcomponent

Validated by:
cmd() str[source]#

Return the string or list of strings to render the component to the CMD.

validator grid_suffix  »  all fields[source]#

Set expected grid suffix.