rompy.schism.grid.SCHISMGrid#

pydantic model rompy.schism.grid.SCHISMGrid[source]#

SCHISM grid in geographic space.

Show JSON schema
{
   "title": "SCHISMGrid",
   "description": "SCHISM grid in geographic space.",
   "type": "object",
   "properties": {
      "grid_type": {
         "const": "schism",
         "default": "schism",
         "description": "Model descriminator",
         "title": "Grid Type",
         "type": "string"
      },
      "hgrid": {
         "$ref": "#/$defs/DataBlob",
         "description": "Path to hgrid.gr3 file"
      },
      "vgrid": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "$ref": "#/$defs/VgridGenerator"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to vgrid.in file",
         "title": "Vgrid"
      },
      "drag": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to drag.gr3 file",
         "title": "Drag"
      },
      "rough": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to rough.gr3 file",
         "title": "Rough"
      },
      "manning": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to manning.gr3 file",
         "title": "Manning"
      },
      "hgridll": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "integer"
            },
            {
               "$ref": "#/$defs/GridLinker"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to hgrid.ll file",
         "title": "Hgridll"
      },
      "diffmin": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": 1e-06,
         "description": "Path to diffmax.gr3 file or constant value",
         "title": "Diffmin"
      },
      "diffmax": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": 1.0,
         "description": "Path to diffmax.gr3 file or constant value",
         "title": "Diffmax"
      },
      "albedo": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": 0.15,
         "description": "Path to albedo.gr3 file or constant value",
         "title": "Albedo"
      },
      "watertype": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "integer"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": 1,
         "description": "Path to watertype.gr3 file or constant value",
         "title": "Watertype"
      },
      "windrot_geo2proj": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "type": "number"
            },
            {
               "$ref": "#/$defs/GR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": 0.0,
         "description": "Path to windrot_geo2proj.gr3 file or constant value",
         "title": "Windrot Geo2Proj"
      },
      "hgrid_WWM": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "$ref": "#/$defs/GridLinker"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to hgrid_WWM.gr3 file",
         "title": "Hgrid Wwm"
      },
      "wwmbnd": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataBlob"
            },
            {
               "$ref": "#/$defs/WWMBNDGR3Generator"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Path to wwmbnd.gr3 file",
         "title": "Wwmbnd"
      },
      "crs": {
         "default": "epsg:4326",
         "description": "Coordinate reference system",
         "title": "Crs",
         "type": "string"
      }
   },
   "$defs": {
      "DataBlob": {
         "additionalProperties": false,
         "description": "Data source for model ingestion.\n\nGeneric data source for files that either need to be copied to the model directory\nor linked if `link` is set to True.",
         "properties": {
            "model_type": {
               "default": "data_blob",
               "description": "Model type discriminator",
               "enum": [
                  "data_blob",
                  "data_link"
               ],
               "title": "Model Type",
               "type": "string"
            },
            "id": {
               "default": "data",
               "description": "Unique identifier for this data source",
               "title": "Id",
               "type": "string"
            },
            "source": {
               "description": "URI of the data source, either a local file path or a remote uri",
               "title": "Source"
            },
            "link": {
               "default": false,
               "description": "Whether to create a symbolic link instead of copying the file",
               "title": "Link",
               "type": "boolean"
            }
         },
         "required": [
            "source"
         ],
         "title": "DataBlob",
         "type": "object"
      },
      "GR3Generator": {
         "additionalProperties": false,
         "properties": {
            "model_type": {
               "const": "gr3_generator",
               "default": "gr3_generator",
               "description": "Model discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "hgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DataBlob"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to hgrid.gr3 file",
               "title": "Hgrid"
            },
            "gr3_type": {
               "description": "Type of gr3 file. Must be one of 'albedo', 'diffmin', 'diffmax', 'watertype', 'windrot_geo2proj'",
               "title": "Gr3 Type",
               "type": "string"
            },
            "value": {
               "default": null,
               "description": "Constant value to set in gr3 file",
               "title": "Value",
               "type": "number"
            },
            "crs": {
               "default": "epsg:4326",
               "description": "Coordinate reference system",
               "title": "Crs",
               "type": "string"
            }
         },
         "required": [
            "hgrid",
            "gr3_type"
         ],
         "title": "GR3Generator",
         "type": "object"
      },
      "GridLinker": {
         "additionalProperties": false,
         "properties": {
            "hgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DataBlob"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to hgrid.gr3 file",
               "title": "Hgrid"
            },
            "gridtype": {
               "description": "Type of grid to link",
               "title": "Gridtype",
               "type": "string"
            }
         },
         "required": [
            "hgrid",
            "gridtype"
         ],
         "title": "GridLinker",
         "type": "object"
      },
      "Vgrid2D": {
         "additionalProperties": false,
         "properties": {
            "model_type": {
               "const": "vgrid2D_generator",
               "default": "vgrid2D_generator",
               "description": "Model descriminator",
               "title": "Model Type",
               "type": "string"
            }
         },
         "title": "Vgrid2D",
         "type": "object"
      },
      "Vgrid3D_LSC2": {
         "additionalProperties": false,
         "properties": {
            "model_type": {
               "const": "vgrid3D_lsc2",
               "default": "vgrid3D_lsc2",
               "description": "Model descriminator",
               "title": "Model Type",
               "type": "string"
            },
            "hgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DataBlob"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to hgrid.gr3 file",
               "title": "Hgrid"
            },
            "hsm": {
               "description": "Depth for each master grid",
               "items": {
                  "type": "number"
               },
               "title": "Hsm",
               "type": "array"
            },
            "nv": {
               "description": "Total number of vertical levels",
               "items": {
                  "type": "integer"
               },
               "title": "Nv",
               "type": "array"
            },
            "h_c": {
               "description": "Transition depth between sigma and z-coordinates",
               "title": "H C",
               "type": "number"
            },
            "theta_b": {
               "description": "Vertical resolution near the surface",
               "title": "Theta B",
               "type": "number"
            },
            "theta_f": {
               "description": "Vertical resolution near the seabed",
               "title": "Theta F",
               "type": "number"
            },
            "crs": {
               "default": "epsg:4326",
               "description": "Coordinate reference system",
               "title": "Crs",
               "type": "string"
            }
         },
         "required": [
            "hgrid",
            "hsm",
            "nv",
            "h_c",
            "theta_b",
            "theta_f"
         ],
         "title": "Vgrid3D_LSC2",
         "type": "object"
      },
      "Vgrid3D_SZ": {
         "additionalProperties": false,
         "properties": {
            "model_type": {
               "const": "vgrid3D_sz",
               "default": "vgrid3D_sz",
               "description": "Model descriminator",
               "title": "Model Type",
               "type": "string"
            },
            "hgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DataBlob"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to hgrid.gr3 file",
               "title": "Hgrid"
            },
            "h_s": {
               "description": "Depth for each master grid",
               "title": "H S",
               "type": "number"
            },
            "ztot": {
               "description": "Total number of vertical levels",
               "items": {
                  "type": "integer"
               },
               "title": "Ztot",
               "type": "array"
            },
            "h_c": {
               "description": "Transition depth between sigma and z-coordinates",
               "title": "H C",
               "type": "number"
            },
            "theta_b": {
               "description": "Vertical resolution near the surface",
               "title": "Theta B",
               "type": "number"
            },
            "theta_f": {
               "description": "Vertical resolution near the seabed",
               "title": "Theta F",
               "type": "number"
            },
            "sigma": {
               "description": "Sigma levels",
               "items": {
                  "type": "number"
               },
               "title": "Sigma",
               "type": "array"
            }
         },
         "required": [
            "hgrid",
            "h_s",
            "ztot",
            "h_c",
            "theta_b",
            "theta_f",
            "sigma"
         ],
         "title": "Vgrid3D_SZ",
         "type": "object"
      },
      "VgridGenerator": {
         "additionalProperties": false,
         "description": "Generate vgrid.in.\nThis is all hardcoded for now, may look at making this more flexible in the future.",
         "properties": {
            "model_type": {
               "const": "vgrid_generator",
               "default": "vgrid_generator",
               "description": "Model descriminator",
               "title": "Model Type",
               "type": "string"
            },
            "vgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Vgrid2D"
                  },
                  {
                     "$ref": "#/$defs/Vgrid3D_LSC2"
                  },
                  {
                     "$ref": "#/$defs/Vgrid3D_SZ"
                  }
               ],
               "description": "Type of vgrid to generate. 2d will create the minimum required for a 2d model. LSC2 will create a full vgrid for a 3d model using pyschsim's LSC2 class",
               "title": "Vgrid"
            }
         },
         "title": "VgridGenerator",
         "type": "object"
      },
      "WWMBNDGR3Generator": {
         "additionalProperties": false,
         "properties": {
            "model_type": {
               "const": "wwmbnd_generator",
               "default": "wwmbnd_generator",
               "description": "Model discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "hgrid": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DataBlob"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to hgrid.gr3 file",
               "title": "Hgrid"
            },
            "bcflags": {
               "default": null,
               "description": "List of boundary condition flags. This replicates the functionality of the gen_wwmbnd.in file. Must be the same length as the number of open boundaries in the hgrid.gr3 file. If not specified, it is assumed that all open hgrid files are open to waves",
               "items": {
                  "type": "integer"
               },
               "title": "Bcflags",
               "type": "array"
            }
         },
         "required": [
            "hgrid"
         ],
         "title": "WWMBNDGR3Generator",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "hgrid"
   ]
}

Fields:
Validators:
field albedo: DataBlob | float | GR3Generator | None = 0.15#

Path to albedo.gr3 file or constant value

Validated by:
field crs: str = 'epsg:4326'#

Coordinate reference system

Validated by:
field diffmax: DataBlob | float | GR3Generator | None = 1.0#

Path to diffmax.gr3 file or constant value

Validated by:
field diffmin: DataBlob | float | GR3Generator | None = 1e-06#

Path to diffmax.gr3 file or constant value

Validated by:
field drag: DataBlob | float | GR3Generator | None = None#

Path to drag.gr3 file

Validated by:
field grid_type: Literal['schism'] = 'schism'#

Model descriminator

Validated by:
field hgrid: DataBlob [Required]#

Path to hgrid.gr3 file

Validated by:
field hgrid_WWM: DataBlob | GridLinker | None = None#

Path to hgrid_WWM.gr3 file

Validated by:
field hgridll: DataBlob | int | GridLinker | None = None#

Path to hgrid.ll file

Validated by:
field manning: DataBlob | float | GR3Generator | None = None#

Path to manning.gr3 file

Validated by:
field rough: DataBlob | float | GR3Generator | None = None#

Path to rough.gr3 file

Validated by:
field vgrid: DataBlob | VgridGenerator | None = None#

Path to vgrid.in file

Validated by:
field watertype: DataBlob | int | GR3Generator | None = 1#

Path to watertype.gr3 file or constant value

Validated by:
field windrot_geo2proj: DataBlob | float | GR3Generator | None = 0.0#

Path to windrot_geo2proj.gr3 file or constant value

Validated by:
field wwmbnd: DataBlob | WWMBNDGR3Generator | None = None#

Path to wwmbnd.gr3 file

Validated by:
boundary(tolerance=None) Polygon[source]#

Returns the convex hull boundary polygon from the grid.

Parameters:

tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

Returns:

polygon – See https://shapely.readthedocs.io/en/stable/manual.html#Polygon

Return type:

shapely.Polygon

boundary_points(spacing=None) tuple[source]#

Returns array of coordinates from boundary polygon.

Parameters:
  • tolerance (float) – Simplify polygon shape based on maximum distance from original geometry, see https://shapely.readthedocs.io/en/stable/manual.html#object.simplify.

  • spacing (float) – If specified, points are returned evenly spaced along the boundary at the specified spacing, otherwise all points are returned.

  • Returns

  • --------

  • points (tuple) – Tuple of x and y coordinates of the boundary points.

generate_tvprop(destdir: Path) Path[source]#

Generate tvprop.in file

Parameters:

destdir (Path) – Destination directory

Returns:

Path to tvprop.in file

Return type:

iath

get(destdir: Path) dict[source]#
validator gr3_source_validator  »  diffmax, albedo, rough, watertype, manning, diffmin, drag, windrot_geo2proj[source]#
land_boundary()[source]#
model_post_init(context: Any, /) None#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

ocean_boundary()[source]#
plot(ax=None, **kwargs)[source]#

Plot the grid

plot_hgrid()[source]#
serialize_model(**kwargs)[source]#

Custom serializer to handle optional fields properly during serialization.

validator validate_gr3_fields  »  all fields[source]#

Custom validator to handle GR3Generator conversion during deserialization.

validator validate_rough_drag_manning  »  all fields[source]#
validator vgrid_validator  »  vgrid[source]#
validator wwmbnd_validator  »  wwmbnd[source]#
property is_3d#
property pyschism_hgrid#
property pyschism_vgrid#
property x: ndarray#
property y: ndarray#