SCHISM native reader

import numpy as np
from datetime import timedelta, datetime
from opendrift.readers import reader_schism_native
from opendrift.readers import reader_global_landmask
from opendrift.models.oceandrift import OceanDrift

MODEL

o = OceanDrift(loglevel=20)  # Set loglevel to 0 for debug information
14:08:17 INFO    opendrift.models.basemodel:507: OpenDriftSimulation initialised (version 1.11.2 / v1.11.2-69-gb16198b)

READERS

Creating and adding reader using a native SCHISM netcdf output file SCHISM reader

reader_landmask = reader_global_landmask.Reader()

# NZTM proj4 string found at https://spatialreference.org/ref/epsg/nzgd2000-new-zealand-transverse-mercator-2000/
proj4str_nztm = '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
schism_native = reader_schism_native.Reader(
    filename = 'https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc',
    proj4 = proj4str_nztm,
    use_3d = True)
# schism_native.plot_mesh(variable = ['sea_floor_depth_below_sea_level']) # check reader was correctly loaded

o.add_reader([reader_landmask,schism_native])
o.set_config('general:use_auto_landmask', False) # prevent opendrift from making a new dynamical landmask with global_landmask
o.disable_vertical_motion()  #Deactivate any vertical processes/advection"""

# Seed elements at defined positions, depth and time
o.seed_elements(lon=174.046669, lat=-40.928116, radius=20, number=100,
                z=np.linspace(0,-10, 100), time=schism_native.start_time)

o.seed_elements(lon= 173.8839, lat=-40.9160, radius=20, number=100,
                z=np.linspace(0,-10, 100), time=schism_native.start_time)

o.seed_elements(lon=174.2940, lat=-41.0888, radius=20, number=100,
                z=np.linspace(0,-10, 100), time=schism_native.start_time)
14:08:24 INFO    opendrift.readers.reader_schism_native:109: Opening dataset: https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc
14:08:24 INFO    opendrift.readers.reader_schism_native:115: Opening file with dataset
14:08:26 INFO    opendrift.models.oceandrift:377: Setting config: drift:vertical_advection -> False
14:08:26 INFO    opendrift.models.oceandrift:377: Setting config: drift:vertical_mixing -> False
14:08:26 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
14:08:26 INFO    opendrift.models.basemodel.environment:248:    x_wind: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    y_wind: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_to_direction: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_significant_height: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_to_direction: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_mean_period: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_significant_height: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    surface_downward_x_stress: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    surface_downward_y_stress: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    turbulent_kinetic_energy: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    turbulent_generic_length_scale: 0.000000
14:08:26 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000

Running model

o.run(time_step=900,
      end_time = schism_native.start_time+timedelta(days=0.1))
      # outfile='schism_native_output.nc')

# Print and plot results
print(o)
o.plot(fast=True)
o.animation()
o.animation_profile()
OpenDrift - OceanDrift 2008-01-01 00:30 to 2008-01-01 02:45 UTC (10 steps)
14:08:26 INFO    opendrift.models.basemodel:885: Using existing reader for land_binary_mask
14:08:26 INFO    opendrift.models.basemodel:896: All points are in ocean
14:08:26 WARNING opendrift.models.basemodel:679: Seafloor check not being run because environment is missing. This will happen the first time the function is run but if it happens subsequently there is probably a problem.
14:08:26 INFO    opendrift.models.basemodel:1985: 2008-01-01 00:30:00 - step 1 of 9 - 300 active elements (0 deactivated)
14:08:26 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:08:42 INFO    opendrift.models.basemodel:1985: 2008-01-01 00:45:00 - step 2 of 9 - 300 active elements (0 deactivated)
14:08:42 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:08:58 INFO    opendrift.models.basemodel:1985: 2008-01-01 01:00:00 - step 3 of 9 - 300 active elements (0 deactivated)
14:08:58 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:08:59 INFO    opendrift.models.basemodel:1985: 2008-01-01 01:15:00 - step 4 of 9 - 300 active elements (0 deactivated)
14:08:59 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:09:13 INFO    opendrift.models.basemodel:1985: 2008-01-01 01:30:00 - step 5 of 9 - 300 active elements (0 deactivated)
14:09:13 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:09:13 INFO    opendrift.models.basemodel:1985: 2008-01-01 01:45:00 - step 6 of 9 - 300 active elements (0 deactivated)
14:09:13 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:09:28 INFO    opendrift.models.basemodel:1985: 2008-01-01 02:00:00 - step 7 of 9 - 300 active elements (0 deactivated)
14:09:28 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:09:28 INFO    opendrift.models.basemodel:1985: 2008-01-01 02:15:00 - step 8 of 9 - 300 active elements (0 deactivated)
14:09:28 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
14:09:43 INFO    opendrift.models.basemodel:1985: 2008-01-01 02:30:00 - step 9 of 9 - 300 active elements (0 deactivated)
14:09:43 WARNING opendrift.readers.basereader.unstructured:141: z-coordinates are not bounds-checked
===========================
--------------------
Reader performance:
--------------------
global_landmask
 0:00:00.0  total
 0:00:00.0  preparing
 0:00:00.0  reading
 0:00:00.0  masking
--------------------
https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc
 0:01:16.7  total
 0:00:19.0  preparing
 0:01:16.7  reading
 0:00:00.2  interpolation
 0:00:00.0  interpolation_time
 0:00:00.0  rotating vectors
 0:00:00.0  masking
--------------------
Performance:
 1:25.7 total time
    8.7 configuration
    0.0 preparing main loop
      0.0 moving elements to ocean
 1:16.9 main loop
      0.0 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  OceanDrift     (OpenDrift version 1.11.2)
        300 active Lagrangian3DArray particles  (0 deactivated, 0 scheduled)
-------------------
Environment variables:
  -----
  land_binary_mask
     1) global_landmask
  -----
  sea_floor_depth_below_sea_level
  sea_surface_height
  upward_sea_water_velocity
  x_sea_water_velocity
  y_sea_water_velocity
     1) https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc
  -----
Readers not added for the following variables:
  ocean_mixed_layer_thickness
  ocean_vertical_diffusivity
  sea_surface_swell_wave_peak_period_from_variance_spectral_density
  sea_surface_swell_wave_significant_height
  sea_surface_swell_wave_to_direction
  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
  sea_surface_wind_wave_mean_period
  sea_surface_wind_wave_significant_height
  sea_surface_wind_wave_to_direction
  surface_downward_x_stress
  surface_downward_y_stress
  turbulent_generic_length_scale
  turbulent_kinetic_energy
  x_wind
  y_wind

Discarded readers:

Time:
        Start: 2008-01-01 00:30:00 UTC
        Present: 2008-01-01 02:45:00 UTC
        Calculation steps: 9 * 0:15:00 - total time: 2:15:00
        Output steps: 10 * 0:15:00
===========================

14:09:43 WARNING opendrift.models.basemodel:2356: Plotting fast. This will make your plots less accurate.
/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1683: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  result = super().scatter(*args, **kwargs)
14:09:59 INFO    opendrift.models.basemodel:4547: Saving animation to /root/project/docs/source/gallery/animations/example_schism_native_0.gif...
14:10:28 INFO    opendrift.models.basemodel:2980: Time to make animation: 0:00:43.470935
/root/project/opendrift/models/basemodel/__init__.py:3099: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  points = ax.scatter([], [],
14:10:29 INFO    opendrift.models.basemodel:4547: Saving animation to /root/project/docs/source/gallery/animations/example_schism_native_1.gif...
14:10:30 INFO    opendrift.models.basemodel:3194: Time to make animation: 0:00:01.160294

Total running time of the script: (2 minutes 14.075 seconds)

Gallery generated by Sphinx-Gallery