Analysing output from Parcels (Zarr format)#

import matplotlib.pyplot as plt
import xarray as xr
import trajan as ta

ds = xr.open_dataset('../tests/test_data/parcels.zarr', engine='zarr')

Print Xarray dataset

print(ds)
<xarray.Dataset> Size: 123kB
Dimensions:     (trajectory: 100, obs: 61)
Coordinates:
  * obs         (obs) int32 244B 0 1 2 3 4 5 6 7 8 ... 53 54 55 56 57 58 59 60
  * trajectory  (trajectory) int64 800B 700 701 702 703 704 ... 796 797 798 799
Data variables:
    lat         (trajectory, obs) float32 24kB ...
    lon         (trajectory, obs) float32 24kB ...
    time        (trajectory, obs) datetime64[ns] 49kB ...
    z           (trajectory, obs) float32 24kB ...
Attributes:
    Conventions:            CF-1.6/CF-1.7
    feature_type:           trajectory
    ncei_template_version:  NCEI_NetCDF_Trajectory_Template_v2.0
    parcels_mesh:           spherical
    parcels_version:        2.4.0

Print trajectory specific information about dataset

print(ds.traj)
=======================
TrajAn info:
------------
100 trajectories  [trajectory_dim: trajectory]
61 timesteps      [obs_dim: obs]
Time variable:    time['trajectory', 'obs']   (2D)
Timestep:       4:00:00
Time coverage:  2022-10-12T18:00:00.000000000 - 2022-10-22T18:00:00.000000000
Longitude span: 39.88391876220703 to 40.14458084106445
Latitude span:  17.2540340423584 to 17.726621627807617
Variables:
    lat  [latitude]
    lon  [longitude]
    time  [time]
    z  [depth]
=======================

Basic plot

ds.traj.plot(land='mask', margin=1)
# TODO: we must allow no time dimension for the below to work
#ds.mean('trajectory', skipna=True).traj.plot(color='r', label='Mean trajectory')

plt.show()
example parcels

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

Gallery generated by Sphinx-Gallery