✌️ Hands-on

🛠️ Configurations

TESEO model configuration counts with a wide-range of options that make possible to adress diferent problematics with the same numerical model.

Simulation parameters

The model can be cofigured to work in a bidimensional space 2D or in a quasi-3D mode where depth-average currents can be provided to the model to simulate the motion of a release in depth. The model works in World Geodetic System 1984 epsg:4326 and needs for the configuration some external data, mainly to define the simulation domain and the metocean conditions (currents, waves, winds…)

Data

Description

Load data in TESEO format

Preprocess new data

domain

Domain of the simulation

Domain

DomainRequest

forcings

Metocean Forcings

Forcings

ForcingsRequest

Forcings

From an input, point of view of the forcings (currents, winds and waves) the model can use Cte Values, Temporal Series or Spatial and Temporal varaying fields. These inputs can be provided locally be the user or collected from some online metocean data providers as CMEMS, NOAA, EMODNet, IHCantabria

Release points

Regarding the type of elements released, 4 main types are alowed: (i) drifter for floating elements, (ii) sar for Search and Rescue operations, (iii) oil for the evaluation of the transport and weathering of oil substances, and (iv) hns for the evolution of hazardous nocious substances. Release point can be configurated as a single release puntual and instantaneous or as a continuous release. The location of the release is defined by a point and the width and lenght of the initial seeding-box where the particles will be located randomly.

Examples

Generate domain

The user is capable to define a DomainRequest instance where the definition of the desiered domain is stored, this object has a method called .process_request() to process the domain and generate all the TESEO files of a domain (grid.dat and costa.dat) in a specific folder created with the name of the domain and a random alpha-numerical key mydomain_9fe2c4e93f654fdbb24c02b15259716c.

DomainRequest is in charge of store all the user configurations needed to define the desired domain. The most simply way to define this object is defining a dictionary with all the parameters needed.

PARAMETER

TYPE

DESCRIPTION

name

string

Name of the domain

bbox

tuple

Bounding box (lon_min, lat_min, lon_max, lat_max)

n_polygons*

integrer

Maximum number of polygons to define de coastline

elevation

dict

OnlineSource or LocalSource to fetch elevation data

coastline*

dict

OnlineSource or LocalSource to fetch coastline data

*optional parameters

.process_request() method is in charge of triger the creation process of the domain, following the parameters defined in the object. Optional parameter base_path is allowed to define where the domain folder will be located in your computer; if no definition is made, the domain folder containing all the domain files will be generated at the current working directory.

from pyteseo.models.domain_request import DomainRequest

user_input = {
        "name": "ibiza",
        "bbox": (0.9, 38.5, 1.9, 39.3),
        "elevation": {
            "service": "opendap",
            "provider": "ihcantabria",
            "dataset": "gebco_2023_1min",
        },
        "coastline": {
            "service": "wfs",
            "provider": "ihcantabria",
            "dataset": "osm_land_polygons",
        },
        "n_polygons": None,
    }

domain_request = DomainRequest(**user_input)
domain_request.process_request()
  • Results:

Domain folder and files will be created at the path defined at base_path parameter in process_request method. In this specific case, as base_path is not defined, domain folder will be created at current working directory, like ./ibiza_9fe2c4e93f654fdbb24c02b15259716c.

Read and plot domain

The user is able to instance a class based on a domain folder path to read and manage all the relevant data from the grid.dat and costa.dat files if they exists.

Domain class is in charge of manage domain information. The user needs to instance the class Domain by passing the parameter path to define where the folder of the domain is located. During the initiation of the class, the following steps are automatically addressed:

  • search grid.dat and costa.dat files in the domain folder.

  • read grid.dat and calculate main domain properties at following fields path, dx, dy, nx, ny, bbox and also instance Grid at grid field.

  • read costa.dat and instance Coastline at coastline field.

Finally, once Domain is initiated, the user can use the class method .plot() to obtain a standard figure of the domain

from pyteseo.models.domain import Domain

domain_path = "../pyteseo/tests/data/ibiza_domain"

domain = Domain(path=domain_path)
domain.plot()
  • Results:

Ibiza_domain

Generate forcigns


from pyteseo.models.forcigns_request import ForcignsRequest, create_forcigns

bbox = (-1.80, 37.25, 6.18, 40.98)

timebox = (datetime(2024, 1, 1), datetime(2024, 1, 2))

forcings = {
    "currents": {
        "provider": "cmems",
        "service": "opendap",
        "dataset": "cmems_global_hourly",
    },
    "winds": {
        "provider": "cmems",
        "service": "opendap",
        "dataset": "cmems_global_winds",
    },
    "waves": None,
}

create_forcings(
    forcings_request=ForcingsRequest(**forcings),
    bbox=bbox,
    timebox=timebox,
    dir_path=tmp_dir,
)

  • Results:

Read and plot forcigns

  • Results:

Generate a TESEO simulation

from pyteseo.models.simulation_request import SimulationRequest

user_input = {
        "name": "test_simulation",
        "domain": "./pyteseo/tests/data/ibiza_domain",
        "duration": "P1D",
        "forcings": {
            "currents": {
                "provider": "ihcantabria",
                "service": "opendap",
                "dataset": "cmems_global_hourly",
            },
            "winds": {
                "provider": "ihcantabria",
                "service": "opendap",
                "dataset": "dwd_icon_europe",
            },
        },
        "releases": [
            {
                "release_type": "hns",
                "release_datetime": '2024-02-19T15:15:00',
                "lon": 1.2,
                "lat": 38.7,
                "depth": 0.0,
                "initial_width": 10,
                "initial_length": 10,
                "substance": "benceno",
                "mass": 1000,
                "thickness": 0.1,
            },
            {
                "release_type": "hns",
                "release_datetime": '2024-02-19T16:15:00',
                "lon": 1.6,
                "lat": 38.8,
                "depth": 0.0,
                "initial_width": 10,
                "initial_length": 10,
                "substance": "acetona",
                "mass": 100,
                "thickness": 0.1,
            },
        ],
    }

simulaiton_request = SimulationRequest(**user_input)
simulation_request.process_request(base_path=tmp_dir, gif=True)
  • Results: particles_animation