ROMS native reader

import numpy as np
from opendrift.readers import reader_ROMS_native
from opendrift.models.oceandrift import OceanDrift

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

Out:

13:47:49 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)

Creating and adding reader for Nordic 4km current dataset

nordic_native = reader_ROMS_native.Reader(o.test_data_folder() +
    '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc')
o.add_reader(nordic_native)

Out:

13:47:49 INFO    opendrift.readers.reader_ROMS_native: Opening dataset: /root/project/tests/test_data/2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc
13:47:49 INFO    opendrift.readers.reader_ROMS_native: Opening file with Dataset
13:47:49 INFO    opendrift.readers.reader_ROMS_native: Read GLS parameters from file.
13:47:49 WARNING opendrift.readers.basereader.structured: No proj string or projection could be derived, using 'fakeproj'. This assumes that the variables are structured and gridded approximately equidistantly on the surface (i.e. in meters). This must be guaranteed by the user. You can get rid of this warning by suppling a valid projection to the reader.
13:47:49 INFO    opendrift.readers.basereader.structured: Making interpolator for lon,lat to x,y conversion...

Seed elements at defined positions, depth and time

o.seed_elements(lon=12.0, lat=68.3, radius=0, number=10,
                z=np.linspace(0, -150, 10), time=nordic_native.start_time)

Running model

o.run(time_step=3600)

Out:

13:47:49 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:47:49 INFO    opendrift.models.basemodel:    x_wind: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    y_wind: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    surface_downward_x_stress: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    surface_downward_y_stress: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    turbulent_kinetic_energy: 0.000000
13:47:49 INFO    opendrift.models.basemodel:    turbulent_generic_length_scale: 0.000000
13:47:49 INFO    opendrift.models.basemodel: Duration, steps or end time not specified, running until end of first reader: 2016-02-04 12:00:00
13:47:49 INFO    opendrift.models.basemodel: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1 m/s. Adding a customised landmask may be faster...
13:47:52 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:47:52 INFO    opendrift.models.basemodel: All points are in ocean
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 12:00:00 - step 1 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.readers.reader_ROMS_native: Time: 0:00:00.035691
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 13:00:00 - step 2 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 14:00:00 - step 3 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 15:00:00 - step 4 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 16:00:00 - step 5 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 17:00:00 - step 6 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 18:00:00 - step 7 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 19:00:00 - step 8 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 20:00:00 - step 9 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 21:00:00 - step 10 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 22:00:00 - step 11 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-02 23:00:00 - step 12 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 00:00:00 - step 13 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 01:00:00 - step 14 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 02:00:00 - step 15 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 03:00:00 - step 16 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 04:00:00 - step 17 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 05:00:00 - step 18 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 06:00:00 - step 19 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 07:00:00 - step 20 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 08:00:00 - step 21 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 09:00:00 - step 22 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 10:00:00 - step 23 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 11:00:00 - step 24 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 12:00:00 - step 25 of 48 - 10 active elements (0 deactivated)
13:47:52 INFO    opendrift.models.basemodel: 2016-02-03 13:00:00 - step 26 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 14:00:00 - step 27 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 15:00:00 - step 28 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 16:00:00 - step 29 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 17:00:00 - step 30 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 18:00:00 - step 31 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 19:00:00 - step 32 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 20:00:00 - step 33 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 21:00:00 - step 34 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 22:00:00 - step 35 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-03 23:00:00 - step 36 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 00:00:00 - step 37 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 01:00:00 - step 38 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 02:00:00 - step 39 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 03:00:00 - step 40 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 04:00:00 - step 41 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 05:00:00 - step 42 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 06:00:00 - step 43 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 07:00:00 - step 44 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 08:00:00 - step 45 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 09:00:00 - step 46 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 10:00:00 - step 47 of 48 - 10 active elements (0 deactivated)
13:47:53 INFO    opendrift.models.basemodel: 2016-02-04 11:00:00 - step 48 of 48 - 10 active elements (0 deactivated)

Print and plot results, with lines colord by particle depth

print(o)
o.plot(linecolor='z', fast=True)
#o.animation()
OpenDrift - OceanDrift 2016-02-02 12:00 to 2016-02-04 12:00 UTC (49 steps)

Out:

===========================
--------------------
Reader performance:
--------------------
roms native
 0:00:00.7  total
 0:00:00.0  preparing
 0:00:00.1  reading
 0:00:00.1  interpolation
 0:00:00.0  interpolation_time
 0:00:00.0  masking
 0:00:00.5  rotating vectors
--------------------
global_landmask
 0:00:00.0  total
 0:00:00.0  preparing
 0:00:00.0  reading
 0:00:00.0  masking
--------------------
Performance:
    4.5 total time
    0.9 configuration
    2.4 preparing main loop
      2.4 making dynamical landmask
      0.0 moving elements to ocean
      0.8 readers
        0.0 global_landmask
        0.0 postprocessing
    1.0 main loop
        0.7 roms native
      0.0 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  OceanDrift     (OpenDrift version 1.7.1)
        10 active Lagrangian3DArray particles  (0 deactivated, 0 scheduled)
-------------------
Environment variables:
  -----
  sea_floor_depth_below_sea_level
  x_sea_water_velocity
  y_sea_water_velocity
     1) roms native
  -----
  land_binary_mask
     1) global_landmask
  -----
Readers not added for the following variables:
  ocean_vertical_diffusivity
  sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment
  sea_surface_wave_period_at_variance_spectral_density_maximum
  sea_surface_wave_significant_height
  sea_surface_wave_stokes_drift_x_velocity
  sea_surface_wave_stokes_drift_y_velocity
  surface_downward_x_stress
  surface_downward_y_stress
  turbulent_generic_length_scale
  turbulent_kinetic_energy
  upward_sea_water_velocity
  x_wind
  y_wind

Time:
        Start: 2016-02-02 12:00:00
        Present: 2016-02-04 12:00:00
        Calculation steps: 48 * 1:00:00 - total time: 2 days, 0:00:00
        Output steps: 49 * 1:00:00
===========================

13:47:53 WARNING opendrift.models.basemodel: Plotting fast. This will make your plots less accurate.

(<GeoAxesSubplot:title={'center':'OpenDrift - OceanDrift\n2016-02-02 12:00 to 2016-02-04 12:00 UTC (49 steps)'}>, <module 'matplotlib.pyplot' from '/opt/conda/envs/opendrift/lib/python3.9/site-packages/matplotlib/pyplot.py'>)

Total running time of the script: ( 0 minutes 6.248 seconds)

Gallery generated by Sphinx-Gallery