.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_model_along_trajectory.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_model_along_trajectory.py: Read variables from a model along the trajectories of drifters. ============================================================================= .. GENERATED FROM PYTHON SOURCE LINES 5-15 .. code-block:: Python import xarray as xr import numpy as np import cf_xarray as _ import pyproj import trajan as ta import matplotlib.pyplot as plt print(ta.versions()) .. rst-class:: sphx-glr-script-out .. code-block:: none ------------------------------------------------------ Software and hardware: TrajAn version 0.8.0 Platform: Linux, 6.11.0-1018-azure 15.615982055664062 GB memory 4 processors (x86_64) NumPy version 2.4.2 SciPy version 1.17.0 Matplotlib version 3.10.8 NetCDF4 version 1.7.4 Xarray version 2025.9.0 Pandas version 3.0.1 OpenDrift version 1.14.8 Python version 3.14.3 | packaged by conda-forge | (main, Feb 9 2026, 21:56:02) [GCC 14.3.0] ------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 16-17 Open drifter dataset from a CSV file .. GENERATED FROM PYTHON SOURCE LINES 17-24 .. code-block:: Python ds = ta.read_csv('bug05_pos.csv.xz', lon='Longitude', lat='Latitude', time='Time', name='Device') print(ds) .. rst-class:: sphx-glr-script-out .. code-block:: none 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detecting trajectory dimension 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG No trajectory_id attribute/variable found, trying to identify by name. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detecting time-variable for "obs".. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detected obs-dim: obs, detected time-variable: time. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detected un-structured (2D) trajectory dataset 2026-02-22 07:38:28 runnervmwffz4 trajan.traj2d[3928] DEBUG Condensing 844 observations. 2026-02-22 07:38:28 runnervmwffz4 trajan.traj2d[3928] DEBUG Condensed observations from: 844 to 844 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detecting trajectory dimension 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG No trajectory_id attribute/variable found, trying to identify by name. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detecting time-variable for "obs".. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detected obs-dim: obs, detected time-variable: time. 2026-02-22 07:38:28 runnervmwffz4 trajan.accessor[3928] DEBUG Detected un-structured (2D) trajectory dataset 2026-02-22 07:38:28 runnervmwffz4 trajan.traj[3928] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2026-02-22 07:38:28 runnervmwffz4 trajan.traj[3928] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2026-02-22 07:38:28 runnervmwffz4 trajan.traj[3928] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. 2026-02-22 07:38:28 runnervmwffz4 trajan.traj[3928] DEBUG No grid-mapping specified, checking if coordinates are lon/lat.. Size: 27kB Dimensions: (trajectory: 1, obs: 844) Coordinates: * trajectory (trajectory) Size: 6kB Dimensions: (trajectory: 1, time: 239) Coordinates: * time (time) datetime64[us] 2kB 2022-05-10T13:00:00 ... 2022-05-20T... * trajectory (trajectory) Size: 2kB array([[341742.63684573, 341746.32710342, 341750.58095892, 341754.83482578, 341759.08870403, 341763.34259365, 341767.59649465, 341771.85040703, 341776.10433078, 341780.35826591, 341784.61221241, 341788.86617029, 341793.12013955, 341797.37412018, 341801.62811219, 341805.88211558, 341810.13613034, 341814.39015647, 341818.64419399, 341822.89824288, 341827.15230314, 341831.40637478, 341835.6604578 , 341839.91455219, 341844.16865796, 341848.42277511, 341852.67690363, 341856.93104353, 341861.1851948 , 341865.43935745, 341869.69353147, 341873.94771687, 341878.20191364, 341882.45612179, 341886.71034132, 341890.96457222, 341895.2188145 , 341899.47306815, 341903.72733318, 341907.98160959, 341912.23589736, 341916.49019652, 341920.74450705, 341924.99882895, 341929.25316223, 341933.50750689, 341937.76186292, 341942.01623033, 341946.27060911, 341950.52499926, 341954.7794008 , 341959.0338137 , 341963.28823798, 341967.54267364, 341971.79712067, 341976.05157908, 341980.30604886, 341984.56053002, 341988.81502255, 341993.06952645, ... 342507.94844798, 342512.2043394 , 342516.46024219, 342520.71615635, 342524.97208188, 342529.22801879, 342533.48396706, 342537.7399267 , 342541.99589772, 342546.25188011, 342550.50787387, 342554.763879 , 342559.0198955 , 342563.27592337, 342567.53196261, 342571.78801322, 342576.0440752 , 342580.30014856, 342584.55623328, 342588.81232938, 342593.06843685, 342597.32455568, 342601.58068589, 342605.83682747, 342610.09298042, 342614.34914474, 342618.60532043, 342622.86150749, 342627.11770592, 342631.37391573, 342635.6301369 , 342639.88636944, 342644.14261335, 342648.39886864, 342652.65513529, 342656.91141331, 342661.16770271, 342665.42400347, 342669.68031561, 342673.93663911, 342678.19297399, 342682.44932023, 342686.70567785, 342690.96204683, 342695.21842719, 342699.47481891, 342703.73122201, 342707.98763647, 342712.24406231, 342716.50049951, 342720.75694809, 342725.01340803, 342729.26987935, 342733.52636203, 342743.94356181, 346363.11391299, 345860.07469316, 345775.39990869, 346050.77654721]]) Coordinates: * time (time) datetime64[us] 2kB 2022-05-10T13:00:00 ... 2022-05-20T... * trajectory (trajectory) Size: 956B [239 values with dtype=float32] Coordinates: X (trajectory, time) float64 2kB 3.416e+05 3.416e+05 ... 3.464e+05 Y (trajectory, time) float64 2kB 4.344e+05 4.344e+05 ... 4.416e+05 depth float64 8B 0.0 * time (time) datetime64[ns] 2kB 2022-05-10T13:00:00 ... 2022-05-20T... lat (trajectory, time) float64 2kB ... lon (trajectory, time) float64 2kB ... * trajectory (trajectory) ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_model_along_trajectory.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_model_along_trajectory.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_