.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_coastline.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_coastline.py: No stranding ============= .. GENERATED FROM PYTHON SOURCE LINES 6-24 .. code-block:: Python import numpy as np from opendrift import test_data_folder as tdf from opendrift.readers import reader_netCDF_CF_generic from opendrift.readers import reader_ROMS_native from opendrift.models.oceandrift import OceanDrift o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information o.set_config('drift:max_speed', 3) # This example works better using hourly input from Thredds than the daily data from test folder reader_current = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml') #reader_current = reader_ROMS_native.Reader(tdf + # '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') o.add_reader([reader_current]) o.set_config('general:coastline_action', 'previous') .. rst-class:: sphx-glr-script-out .. code-block:: none 17:20:54 INFO opendrift:513: OpenDriftSimulation initialised (version 1.14.2 / v1.14.2-88-gf09b7bd) 17:20:54 INFO opendrift.readers:61: Opening file with xr.open_dataset 17:20:57 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'x': 'x', 'y': 'y', 'time': 'time'} .. GENERATED FROM PYTHON SOURCE LINES 25-26 Seeding elements on a grid .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: Python lons = np.linspace(12, 14.5, 30) lats = np.linspace(67.5, 68.5, 30) lons, lats = np.meshgrid(lons, lats) lon = lons.ravel() lat = lats.ravel() time = reader_current.start_time o.seed_elements(lon, lat, radius=0, number=30*30, time=time) o.run(steps=24*2, time_step=3600) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:20:57 INFO opendrift.models.basemodel.environment:206: Adding a global landmask from GSHHG 17:21:02 INFO opendrift.models.basemodel.environment:229: Fallback values will be used for the following variables which have no readers: 17:21:02 INFO opendrift.models.basemodel.environment:232: x_wind: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: y_wind: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: upward_sea_water_velocity: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: ocean_vertical_diffusivity: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_significant_height: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_x_velocity: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_y_velocity: 0.000000 17:21:02 INFO opendrift.models.basemodel.environment:232: ocean_mixed_layer_thickness: 50.000000 17:21:02 INFO opendrift:1732: Skipping environment variable ocean_vertical_diffusivity because of condition ['drift:vertical_mixing', 'is', False] 17:21:02 INFO opendrift:1732: Skipping environment variable ocean_mixed_layer_thickness because of condition ['drift:vertical_mixing', 'is', False] 17:21:02 INFO opendrift:1743: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 17:21:02 INFO opendrift:1743: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 17:21:02 INFO opendrift:1751: Storing previous values of environment variable sea_surface_height because of condition ['drift:vertical_advection', 'is', True] 17:21:02 INFO opendrift:899: Using existing reader for land_binary_mask 17:21:04 INFO opendrift:930: Moving 81 out of 900 points from land to water 17:21:04 INFO opendrift:2035: 2023-01-01 00:00:00 - step 1 of 48 - 900 active elements (0 deactivated) 17:21:05 INFO opendrift:2035: 2023-01-01 01:00:00 - step 2 of 48 - 900 active elements (0 deactivated) 17:21:06 INFO opendrift:2035: 2023-01-01 02:00:00 - step 3 of 48 - 900 active elements (0 deactivated) 17:21:06 INFO opendrift:2035: 2023-01-01 03:00:00 - step 4 of 48 - 900 active elements (0 deactivated) 17:21:07 INFO opendrift:2035: 2023-01-01 04:00:00 - step 5 of 48 - 900 active elements (0 deactivated) 17:21:08 INFO opendrift:2035: 2023-01-01 05:00:00 - step 6 of 48 - 900 active elements (0 deactivated) 17:21:08 INFO opendrift:2035: 2023-01-01 06:00:00 - step 7 of 48 - 900 active elements (0 deactivated) 17:21:09 INFO opendrift:2035: 2023-01-01 07:00:00 - step 8 of 48 - 900 active elements (0 deactivated) 17:21:10 INFO opendrift:2035: 2023-01-01 08:00:00 - step 9 of 48 - 900 active elements (0 deactivated) 17:21:10 INFO opendrift:2035: 2023-01-01 09:00:00 - step 10 of 48 - 900 active elements (0 deactivated) 17:21:11 INFO opendrift:2035: 2023-01-01 10:00:00 - step 11 of 48 - 900 active elements (0 deactivated) 17:21:11 INFO opendrift:2035: 2023-01-01 11:00:00 - step 12 of 48 - 900 active elements (0 deactivated) 17:21:12 INFO opendrift:2035: 2023-01-01 12:00:00 - step 13 of 48 - 900 active elements (0 deactivated) 17:21:13 INFO opendrift:2035: 2023-01-01 13:00:00 - step 14 of 48 - 900 active elements (0 deactivated) 17:21:13 INFO opendrift:2035: 2023-01-01 14:00:00 - step 15 of 48 - 900 active elements (0 deactivated) 17:21:14 INFO opendrift:2035: 2023-01-01 15:00:00 - step 16 of 48 - 900 active elements (0 deactivated) 17:21:15 INFO opendrift:2035: 2023-01-01 16:00:00 - step 17 of 48 - 900 active elements (0 deactivated) 17:21:15 INFO opendrift:2035: 2023-01-01 17:00:00 - step 18 of 48 - 900 active elements (0 deactivated) 17:21:16 INFO opendrift:2035: 2023-01-01 18:00:00 - step 19 of 48 - 900 active elements (0 deactivated) 17:21:16 INFO opendrift:2035: 2023-01-01 19:00:00 - step 20 of 48 - 900 active elements (0 deactivated) 17:21:17 INFO opendrift:2035: 2023-01-01 20:00:00 - step 21 of 48 - 900 active elements (0 deactivated) 17:21:18 INFO opendrift:2035: 2023-01-01 21:00:00 - step 22 of 48 - 900 active elements (0 deactivated) 17:21:18 INFO opendrift:2035: 2023-01-01 22:00:00 - step 23 of 48 - 900 active elements (0 deactivated) 17:21:19 INFO opendrift:2035: 2023-01-01 23:00:00 - step 24 of 48 - 900 active elements (0 deactivated) 17:21:20 INFO opendrift:2035: 2023-01-02 00:00:00 - step 25 of 48 - 900 active elements (0 deactivated) 17:21:21 INFO opendrift:2035: 2023-01-02 01:00:00 - step 26 of 48 - 900 active elements (0 deactivated) 17:21:21 INFO opendrift:2035: 2023-01-02 02:00:00 - step 27 of 48 - 900 active elements (0 deactivated) 17:21:22 INFO opendrift:2035: 2023-01-02 03:00:00 - step 28 of 48 - 900 active elements (0 deactivated) 17:21:23 INFO opendrift:2035: 2023-01-02 04:00:00 - step 29 of 48 - 900 active elements (0 deactivated) 17:21:23 INFO opendrift:2035: 2023-01-02 05:00:00 - step 30 of 48 - 900 active elements (0 deactivated) 17:21:24 INFO opendrift:2035: 2023-01-02 06:00:00 - step 31 of 48 - 900 active elements (0 deactivated) 17:21:24 INFO opendrift:2035: 2023-01-02 07:00:00 - step 32 of 48 - 900 active elements (0 deactivated) 17:21:25 INFO opendrift:2035: 2023-01-02 08:00:00 - step 33 of 48 - 900 active elements (0 deactivated) 17:21:26 INFO opendrift:2035: 2023-01-02 09:00:00 - step 34 of 48 - 900 active elements (0 deactivated) 17:21:26 INFO opendrift:2035: 2023-01-02 10:00:00 - step 35 of 48 - 900 active elements (0 deactivated) 17:21:27 INFO opendrift:2035: 2023-01-02 11:00:00 - step 36 of 48 - 900 active elements (0 deactivated) 17:21:28 INFO opendrift:2035: 2023-01-02 12:00:00 - step 37 of 48 - 900 active elements (0 deactivated) 17:21:28 INFO opendrift:2035: 2023-01-02 13:00:00 - step 38 of 48 - 900 active elements (0 deactivated) 17:21:29 INFO opendrift:2035: 2023-01-02 14:00:00 - step 39 of 48 - 900 active elements (0 deactivated) 17:21:30 INFO opendrift:2035: 2023-01-02 15:00:00 - step 40 of 48 - 900 active elements (0 deactivated) 17:21:30 INFO opendrift:2035: 2023-01-02 16:00:00 - step 41 of 48 - 900 active elements (0 deactivated) 17:21:31 INFO opendrift:2035: 2023-01-02 17:00:00 - step 42 of 48 - 900 active elements (0 deactivated) 17:21:32 INFO opendrift:2035: 2023-01-02 18:00:00 - step 43 of 48 - 900 active elements (0 deactivated) 17:21:32 INFO opendrift:2035: 2023-01-02 19:00:00 - step 44 of 48 - 900 active elements (0 deactivated) 17:21:33 INFO opendrift:2035: 2023-01-02 20:00:00 - step 45 of 48 - 900 active elements (0 deactivated) 17:21:33 INFO opendrift:2035: 2023-01-02 21:00:00 - step 46 of 48 - 900 active elements (0 deactivated) 17:21:34 INFO opendrift:2035: 2023-01-02 22:00:00 - step 47 of 48 - 900 active elements (0 deactivated) 17:21:35 INFO opendrift:2035: 2023-01-02 23:00:00 - step 48 of 48 - 900 active elements (0 deactivated) .. raw:: html
<xarray.Dataset> Size: 4MB
    Dimensions:                                   (trajectory: 900, time: 49)
    Coordinates:
      * trajectory                                (trajectory) int64 7kB 0 1 ... 899
      * time                                      (time) datetime64[ns] 392B 2023...
    Data variables: (12/21)
        status                                    (trajectory, time) float32 176kB ...
        moving                                    (trajectory, time) float32 176kB ...
        age_seconds                               (trajectory, time) float32 176kB ...
        origin_marker                             (trajectory, time) float32 176kB ...
        lon                                       (trajectory, time) float32 176kB ...
        lat                                       (trajectory, time) float32 176kB ...
        ...                                        ...
        upward_sea_water_velocity                 (trajectory, time) float32 176kB ...
        sea_surface_wave_significant_height       (trajectory, time) float32 176kB ...
        sea_surface_wave_stokes_drift_x_velocity  (trajectory, time) float32 176kB ...
        sea_surface_wave_stokes_drift_y_velocity  (trajectory, time) float32 176kB ...
        sea_floor_depth_below_sea_level           (trajectory, time) float32 176kB ...
        land_binary_mask                          (trajectory, time) float32 176kB ...
    Attributes: (12/119)
        Conventions:                                                           CF...
        standard_name_vocabulary:                                              CF...
        featureType:                                                           tr...
        title:                                                                 Op...
        summary:                                                               Ou...
        keywords:                                                              tr...
        ...                                                                    ...
        geospatial_lon_units:                                                  de...
        geospatial_lon_resolution:                                             point
        runtime:                                                               0:...
        geospatial_vertical_min:                                               0.0
        geospatial_vertical_max:                                               0.0
        geospatial_vertical_positive:                                          up


.. GENERATED FROM PYTHON SOURCE LINES 38-39 Print and plot results .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python print(o) o.plot() #o.plot(background=['x_sea_water_velocity', 'y_sea_water_velocity']) o.animation() .. image-sg:: /gallery/images/sphx_glr_example_coastline_001.png :alt: OpenDrift - OceanDrift 2023-01-01 00:00 to 2023-01-03 00:00 UTC (49 steps) :srcset: /gallery/images/sphx_glr_example_coastline_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none =========================== -------------------- Reader performance: -------------------- https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml 0:00:29.5 total 0:00:00.0 preparing 0:00:29.4 reading 0:00:00.1 interpolation 0:00:00.0 interpolation_time 0:00:00.0 rotating vectors 0:00:00.0 masking -------------------- global_landmask 0:00:01.9 total 0:00:00.0 preparing 0:00:01.9 reading 0:00:00.0 masking -------------------- Performance: 40.8 total time 8.0 configuration 1.9 preparing main loop 1.9 moving elements to ocean 30.9 main loop 0.0 updating elements 0.0 cleaning up -------------------- =========================== Model: OceanDrift (OpenDrift version 1.14.2) 900 active Lagrangian3DArray particles (0 deactivated, 0 scheduled) ------------------- Environment variables: ----- sea_floor_depth_below_sea_level sea_surface_height x_sea_water_velocity y_sea_water_velocity 1) https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml ----- land_binary_mask 1) global_landmask ----- Readers not added for the following variables: sea_surface_wave_significant_height sea_surface_wave_stokes_drift_x_velocity sea_surface_wave_stokes_drift_y_velocity upward_sea_water_velocity x_wind y_wind Discarded readers: Time: Start: 2023-01-01 00:00:00 UTC Present: 2023-01-03 00:00:00 UTC Calculation steps: 48 * 1:00:00 - total time: 2 days, 0:00:00 Output steps: 49 * 1:00:00 =========================== 17:21:51 INFO opendrift:4553: Saving animation to /root/project/docs/source/gallery/animations/example_coastline_0.gif... 17:22:23 INFO opendrift:2994: Time to make animation: 0:00:33.403735 .. GENERATED FROM PYTHON SOURCE LINES 45-46 .. image:: /gallery/animations/example_coastline_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 36.488 seconds) .. _sphx_glr_download_gallery_example_coastline.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_coastline.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_coastline.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_coastline.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_