Пример #1
0
def test_get_variables(benchmark):
    r = shyfem.Reader(ismar)

    x = np.array([13., 13.])
    y = np.array([40, 40.1])
    z = np.array([0, -100])

    u = benchmark(r.get_variables, ['x_sea_water_velocity'], r.start_time, x,
                  y, z)['x_sea_water_velocity']
    print(u)
    print(u.shape)
    assert u.shape == (len(x),)
    assert len(u) == len(x)
Пример #2
0
def test_get_values():
    r = shyfem.Reader(ismar)

    x = np.array([12.411164, 12.411164])
    y = np.array([45.445023, 45.445023])
    z = np.array([0, -500])

    u = r.get_variables(['x_sea_water_velocity'], r.start_time, x,
                  y, z)['x_sea_water_velocity']

    ni = 20000
    zi = np.array([0, 25])

    uu = r.dataset['u_velocity'][0, ni, zi]
    np.testing.assert_array_equal(u, uu)
Пример #3
0
def test_get_values():
    r = shyfem.Reader(ismar)

    x = np.array([16.175186, 16.175186])
    y = np.array([42.457916, 42.457916])
    z = np.array([0, -500])

    u = r.get_variables(['x_sea_water_velocity'], r.start_time, x,
                  y, z)['x_sea_water_velocity']

    ni = 20000
    zi = np.array([0, 25])

    uu = r.dataset['u_velocity'][0, ni, zi]
    np.testing.assert_array_equal(u, uu)
Пример #4
0
#!/usr/bin/env python
"""
SHYFEM: Using model input from unstructured grid
===============================================
"""

from datetime import timedelta
import numpy as np
from opendrift.readers.unstructured import shyfem
from opendrift.models.oceandrift import OceanDrift

o = OceanDrift(loglevel=20)  # Set loglevel to 0 for debug information

o.set_config('general:coastline_action', 'previous')

shyfem = shyfem.Reader('https://iws.ismar.cnr.it/thredds/dodsC/emerge/shyfem_unstructured_adriatic.nc')
o.add_reader(shyfem)
print(shyfem)

# Seed elements at defined positions, depth and time
N = 1000
z = -15*np.random.uniform(0, 1, N)
o.seed_elements(lon=12.4, lat=45.25, radius=1000, number=N,
                z=z, time=shyfem.start_time)

#%%
# Running model
o.run(time_step=1800, duration=timedelta(hours=12))

#%%
# Print and plot results
Пример #5
0
def test_open():
    r = shyfem.Reader(ismar)
    print(r)
Пример #6
0
def test_z_polarity():
    r = shyfem.Reader(ismar)
    assert r.zmax > r.zmin
    assert (r.z < 0).all()