rompy.swan.interface.DataInterface#

pydantic model rompy.swan.interface.DataInterface[source]#

SWAN forcing data interface.

Examples

In [1]: from rompy.swan.interface import DataInterface

Show JSON schema
{
   "title": "DataInterface",
   "description": "SWAN forcing data interface.\n\nExamples\n--------\n\n.. ipython:: python\n    :okwarning:\n\n    from rompy.swan.interface import DataInterface",
   "type": "object",
   "properties": {
      "model_type": {
         "default": "data_interface",
         "description": "Model type discriminator",
         "enum": [
            "data_interface",
            "DATA_INTERFACE"
         ],
         "title": "Model Type",
         "type": "string"
      },
      "bottom": {
         "anyOf": [
            {
               "$ref": "#/$defs/SwanDataGrid"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Bathymetry data"
      },
      "input": {
         "default": [],
         "description": "Input grid data",
         "items": {
            "$ref": "#/$defs/SwanDataGrid"
         },
         "title": "Input",
         "type": "array"
      }
   },
   "$defs": {
      "DatasetCoords": {
         "additionalProperties": false,
         "description": "Coordinates representation.",
         "properties": {
            "t": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "time",
               "description": "Name of the time coordinate",
               "title": "T"
            },
            "x": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "longitude",
               "description": "Name of the x coordinate",
               "title": "X"
            },
            "y": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "latitude",
               "description": "Name of the y coordinate",
               "title": "Y"
            },
            "z": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "depth",
               "description": "Name of the z coordinate",
               "title": "Z"
            },
            "s": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "site",
               "description": "Name of the site coordinate",
               "title": "S"
            }
         },
         "title": "DatasetCoords",
         "type": "object"
      },
      "Filter": {
         "additionalProperties": false,
         "properties": {
            "sort": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Sort"
            },
            "subset": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Subset"
            },
            "crop": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Crop"
            },
            "timenorm": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Timenorm"
            },
            "rename": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Rename"
            },
            "derived": {
               "anyOf": [
                  {
                     "additionalProperties": true,
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {},
               "title": "Derived"
            }
         },
         "title": "Filter",
         "type": "object"
      },
      "GridOptions": {
         "description": "Valid options for the input grid type.\n\nAttributes\n----------\nBOTTOM: \"bottom\"\n    Bottom level grid.\nWLEVEL: \"wlevel\"\n    Water level grid.\nCURRENT: \"current\"\n    Current field grid.\nVX: \"vx\"\n    Current field x-component grid.\nVY: \"vy\"\n    Current field y-component grid.\nWIND: \"wind\"\n    Wind velocity grid.\nWX: \"wx\"\n    Wind velocity x-component grid.\nWY: \"wy\"\n    Wind velocity y-component grid.\nFRICTION: \"friction\"\n    Bottom friction grid.\nNPLANTS: \"nplants\"\n    Horizontally varying vegetation density grid.\nTURBVISC: \"turbvisc\"\n    Horizontally varying turbulent viscosity grid.\nMUDLAYER: \"mudlayer\"\n    Horizontally varying mud layer thickness grid.\nAICE: \"aice\"\n    Areal ice fraction grid, a number between 0 and 1.\nHICE: \"hice\"\n    Ice thickness grid.\nHSS: \"hss\"\n    Sea-swell significant wave height grid.\nTSS: \"tss\"\n    Sea-swell mean wave period.",
         "enum": [
            "bottom",
            "wlevel",
            "current",
            "vx",
            "vy",
            "wind",
            "wx",
            "wy",
            "friction",
            "nplants",
            "turbvisc",
            "mudlayer",
            "aice",
            "hice",
            "hss",
            "tss"
         ],
         "title": "GridOptions",
         "type": "string"
      },
      "SourceDatamesh": {
         "additionalProperties": false,
         "description": "Source dataset from Datamesh.\n\nDatamesh documentation: https://docs.oceanum.io/datamesh/index.html",
         "properties": {
            "model_type": {
               "const": "datamesh",
               "default": "datamesh",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "datasource": {
               "description": "The id of the datasource on Datamesh",
               "title": "Datasource",
               "type": "string"
            },
            "token": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Datamesh API token, taken from the environment if not provided",
               "title": "Token"
            },
            "kwargs": {
               "additionalProperties": true,
               "default": {},
               "description": "Keyword arguments to pass to `oceanum.datamesh.Connector`",
               "title": "Kwargs",
               "type": "object"
            }
         },
         "required": [
            "datasource",
            "token"
         ],
         "title": "SourceDatamesh",
         "type": "object"
      },
      "SourceFile": {
         "additionalProperties": false,
         "description": "Source dataset from file to open with xarray.open_dataset.",
         "properties": {
            "model_type": {
               "const": "file",
               "default": "file",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "uri": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to the dataset",
               "title": "Uri"
            },
            "kwargs": {
               "additionalProperties": true,
               "default": {},
               "description": "Keyword arguments to pass to xarray.open_dataset",
               "title": "Kwargs",
               "type": "object"
            }
         },
         "required": [
            "uri"
         ],
         "title": "SourceFile",
         "type": "object"
      },
      "SourceIntake": {
         "additionalProperties": false,
         "description": "Source dataset from intake catalog.\n\nnote\n----\nThe intake catalog can be prescribed either by the URI of an existing catalog file\nor by a YAML string defining the catalog. The YAML string can be obtained from\ncalling the `yaml()` method on an intake dataset instance.",
         "properties": {
            "model_type": {
               "const": "intake",
               "default": "intake",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "dataset_id": {
               "description": "The id of the dataset to read in the catalog",
               "title": "Dataset Id",
               "type": "string"
            },
            "catalog_uri": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The URI of the catalog to read from",
               "title": "Catalog Uri"
            },
            "catalog_yaml": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The YAML string of the catalog to read from",
               "title": "Catalog Yaml"
            },
            "kwargs": {
               "additionalProperties": true,
               "default": {},
               "description": "Keyword arguments to define intake dataset parameters",
               "title": "Kwargs",
               "type": "object"
            }
         },
         "required": [
            "dataset_id"
         ],
         "title": "SourceIntake",
         "type": "object"
      },
      "SourceTimeseriesCSV": {
         "additionalProperties": false,
         "description": "Timeseries source class from CSV file.\n\nThis class should return a timeseries from a CSV file. The dataset variables are\ndefined from the column headers, therefore the appropriate read_csv kwargs must be\npassed to allow defining the columns. The time index is defined from column name\nidentified by the tcol field.",
         "properties": {
            "model_type": {
               "const": "csv",
               "default": "csv",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "filename": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to the csv file",
               "title": "Filename"
            },
            "tcol": {
               "default": "time",
               "description": "Name of the column containing the time data",
               "title": "Tcol",
               "type": "string"
            },
            "read_csv_kwargs": {
               "additionalProperties": true,
               "default": {},
               "description": "Keyword arguments to pass to pandas.read_csv",
               "title": "Read Csv Kwargs",
               "type": "object"
            }
         },
         "required": [
            "filename"
         ],
         "title": "SourceTimeseriesCSV",
         "type": "object"
      },
      "SourceWavespectra": {
         "additionalProperties": false,
         "description": "Wavespectra dataset from wavespectra reader.",
         "properties": {
            "model_type": {
               "const": "wavespectra",
               "default": "wavespectra",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "uri": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "format": "path",
                     "type": "string"
                  }
               ],
               "description": "Path to the dataset",
               "title": "Uri"
            },
            "reader": {
               "description": "Name of the wavespectra reader to use, e.g., read_swan",
               "title": "Reader",
               "type": "string"
            },
            "kwargs": {
               "additionalProperties": true,
               "default": {},
               "description": "Keyword arguments to pass to the wavespectra reader",
               "title": "Kwargs",
               "type": "object"
            }
         },
         "required": [
            "uri",
            "reader"
         ],
         "title": "SourceWavespectra",
         "type": "object"
      },
      "SwanDataGrid": {
         "additionalProperties": false,
         "description": "This class is used to write SWAN data from a dataset.",
         "properties": {
            "model_type": {
               "const": "grid",
               "default": "grid",
               "description": "Model type discriminator",
               "title": "Model Type",
               "type": "string"
            },
            "id": {
               "default": "data",
               "description": "Unique identifier for this data source",
               "title": "Id",
               "type": "string"
            },
            "source": {
               "description": "Source reader, must return an xarray gridded dataset in the open method",
               "discriminator": {
                  "mapping": {
                     "csv": "#/$defs/SourceTimeseriesCSV",
                     "datamesh": "#/$defs/SourceDatamesh",
                     "file": "#/$defs/SourceFile",
                     "intake": "#/$defs/SourceIntake",
                     "wavespectra": "#/$defs/SourceWavespectra"
                  },
                  "propertyName": "model_type"
               },
               "oneOf": [
                  {
                     "$ref": "#/$defs/SourceTimeseriesCSV"
                  },
                  {
                     "$ref": "#/$defs/SourceDatamesh"
                  },
                  {
                     "$ref": "#/$defs/SourceFile"
                  },
                  {
                     "$ref": "#/$defs/SourceIntake"
                  },
                  {
                     "$ref": "#/$defs/SourceWavespectra"
                  }
               ],
               "title": "Source"
            },
            "link": {
               "default": false,
               "description": "Whether to create a symbolic link instead of copying the file",
               "title": "Link",
               "type": "boolean"
            },
            "filter": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Filter"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Optional filter specification to apply to the dataset"
            },
            "variables": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": [],
               "description": "Subset of variables to extract from the dataset",
               "title": "Variables"
            },
            "coords": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DatasetCoords"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": {
                  "t": "time",
                  "x": "longitude",
                  "y": "latitude",
                  "z": "depth",
                  "s": "site"
               },
               "description": "Names of the coordinates in the dataset"
            },
            "crop_data": {
               "default": true,
               "description": "Update crop filters from Grid and Time objects if passed to get method",
               "title": "Crop Data",
               "type": "boolean"
            },
            "buffer": {
               "default": 0.0,
               "description": "Space to buffer the grid bounding box if `filter_grid` is True",
               "title": "Buffer",
               "type": "number"
            },
            "time_buffer": {
               "default": [
                  0,
                  0
               ],
               "description": "Number of source data timesteps to buffer the time range if `filter_time` is True",
               "items": {
                  "type": "integer"
               },
               "title": "Time Buffer",
               "type": "array"
            },
            "z1": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Name of the data variable in dataset representing either a scaler parameter or the u-componet of a vector field",
               "title": "Z1"
            },
            "z2": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Name of the data variable in dataset representing the v-componet of a vector field",
               "title": "Z2"
            },
            "var": {
               "$ref": "#/$defs/GridOptions",
               "description": "SWAN input grid name"
            },
            "fac": {
               "default": 1.0,
               "description": "SWAN multiplies all values that are read from file by `fac`. For instance if the values are given in unit decimeter, one should make `fac=0.1` to obtain values in m. To change sign use a negative `fac`",
               "title": "Fac",
               "type": "number"
            }
         },
         "required": [
            "source",
            "var"
         ],
         "title": "SwanDataGrid",
         "type": "object"
      }
   },
   "additionalProperties": false
}

Fields:
Validators:
field bottom: SwanDataGrid | None = None#

Bathymetry data

field input: list[SwanDataGrid] = []#

Input grid data

Validated by:
field model_type: Literal['data_interface', 'DATA_INTERFACE'] = 'data_interface'#

Model type discriminator

validator ensure_unique_var  »  input[source]#

Ensure that each input var is unique.

get(staging_dir: Path, grid: SwanGrid, period: TimeRange)[source]#
render(*args, **kwargs)[source]#

Make this class consistent with the components API.