예제 #1
0
def test_get_variables_along_trajectory_and_wind_drift_factor_from_trajectory(
):
    o = OceanDrift(loglevel=50)
    o.add_readers_from_list([
        o.test_data_folder() +
        '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc',
        o.test_data_folder() +
        '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc'
    ],
                            lazy=False)

    t = o.get_variables_along_trajectory(
        variables=[
            'x_sea_water_velocity', 'y_sea_water_velocity', 'x_wind', 'y_wind'
        ],
        lons=np.array([3.5, 4, 4.5]),
        lats=np.array([59.7, 60, 60.3]),
        times=[
            o.readers[list(o.readers)[0]].start_time + i * timedelta(hours=3)
            for i in range(3)
        ])
    np.testing.assert_array_almost_equal(t['x_sea_water_velocity'],
                                         [-0.078685, -0.106489, -0.058386])
    np.testing.assert_array_almost_equal(t['x_wind'],
                                         [-8.308249, -13.063459, -11.09289])

    wdf, azimuth = wind_drift_factor_from_trajectory(t)
    np.testing.assert_array_almost_equal(wdf, [0.27189012, 0.20492421])
    np.testing.assert_array_almost_equal(azimuth, [73.0112213, 82.39749185])
    'time': drifter_times,
    'linestyle': 'b--',
    'label': 'Synthetic drifter'
}

o = OceanDrift(loglevel=50)
o.add_readers_from_list([
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc',
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc'
],
                        lazy=False)
t = o.get_variables_along_trajectory(variables=[
    'x_sea_water_velocity', 'y_sea_water_velocity', 'x_wind', 'y_wind'
],
                                     lons=drifter_lons,
                                     lats=drifter_lats,
                                     times=drifter_times)

wind_drift_factor, azimuth = wind_drift_factor_from_trajectory(t)

o.seed_elements(lon=4,
                lat=60,
                number=1,
                time=ot.readers[list(ot.readers)[0]].start_time,
                wind_drift_factor=0.033)

#%%
# New simulation, this time without diffusivity/noise
o.run(duration=timedelta(hours=12), time_step=600)