22This module provides functions to easily access ragged-array datasets.
33"""
44
5+ from clouddrift import adapters
6+ import os
57import xarray as xr
68
79
@@ -23,7 +25,8 @@ def gdp1h() -> xr.Dataset:
2325 Examples
2426 --------
2527 >>> from clouddrift.datasets import gdp1h
26- >>> gdp1h()
28+ >>> ds = gdp1h()
29+ >>> ds
2730 <xarray.Dataset>
2831 Dimensions: (traj: 17324, obs: 165754333)
2932 Coordinates:
@@ -85,7 +88,8 @@ def gdp6h() -> xr.Dataset:
8588 Examples
8689 --------
8790 >>> from clouddrift.datasets import gdp6h
88- >>> gdp6h()
91+ >>> ds = gdp6h()
92+ >>> ds
8993 <xarray.Dataset>
9094 Dimensions: (traj: 26843, obs: 44544647)
9195 Coordinates:
@@ -129,3 +133,68 @@ def gdp6h() -> xr.Dataset:
129133 """
130134 url = "https://www.aoml.noaa.gov/ftp/pub/phod/buoydata/gdp_jul22_ragged_6h.nc#mode=bytes"
131135 return xr .open_dataset (url )
136+
137+
138+ def mosaic () -> xr .Dataset :
139+ """Returns the MOSAiC sea-ice drift dataset as an Xarray dataset.
140+
141+ The function will first look for the ragged-array dataset on the local
142+ filesystem. If it is not found, the dataset will be downloaded using the
143+ corresponding adapter function and stored for later access.
144+
145+ The upstream data is available at https://arcticdata.io/catalog/view/doi:10.18739/A2KP7TS83.
146+
147+ Reference: Angela Bliss, Jennifer Hutchings, Philip Anderson, Philipp Anhaus,
148+ Hans Jakob Belter, Jørgen Berge, Vladimir Bessonov, Bin Cheng, Sylvia Cole,
149+ Dave Costa, Finlo Cottier, Christopher J Cox, Pedro R De La Torre, Dmitry V Divine,
150+ Gilbert Emzivat, Ying-Chih Fang, Steven Fons, Michael Gallagher, Maxime Geoffrey,
151+ Mats A Granskog, ... Guangyu Zuo. (2022). Sea ice drift tracks from the Distributed
152+ Network of autonomous buoys deployed during the Multidisciplinary drifting Observatory
153+ for the Study of Arctic Climate (MOSAiC) expedition 2019 - 2021. Arctic Data Center.
154+ doi:10.18739/A2KP7TS83.
155+
156+ Returns
157+ -------
158+ xarray.Dataset
159+ MOSAiC sea-ice drift dataset as a ragged array
160+
161+ Examples
162+ --------
163+ >>> from clouddrift.datasets import mosaic
164+ >>> ds = mosaic()
165+ >>> ds
166+ <xarray.Dataset>
167+ Dimensions: (obs: 1926226, traj: 216)
168+ Coordinates:
169+ time (obs) datetime64[ns] ...
170+ id (traj) object ...
171+ Dimensions without coordinates: obs, traj
172+ Data variables: (12/19)
173+ latitude (obs) float64 ...
174+ longitude (obs) float64 ...
175+ Deployment Leg (traj) int64 ...
176+ DN Station ID (traj) object ...
177+ IMEI (traj) object ...
178+ Deployment Date (traj) datetime64[ns] ...
179+ ... ...
180+ Buoy Type (traj) object ...
181+ Manufacturer (traj) object ...
182+ Model (traj) object ...
183+ PI (traj) object ...
184+ Data Authors (traj) object ...
185+ count (traj) int64 ...
186+ """
187+ clouddrift_path = (
188+ os .path .expanduser ("~/.clouddrift" )
189+ if not os .getenv ("CLOUDDRIFT_PATH" )
190+ else os .getenv ("CLOUDDRIFT_PATH" )
191+ )
192+ mosaic_path = f"{ clouddrift_path } /data/mosaic.nc"
193+ if not os .path .exists (mosaic_path ):
194+ print (f"{ mosaic_path } not found; download from upstream repository." )
195+ ds = adapters .mosaic .to_xarray ()
196+ os .makedirs (os .path .dirname (mosaic_path ), exist_ok = True )
197+ ds .to_netcdf (mosaic_path )
198+ else :
199+ ds = xr .open_dataset (mosaic_path )
200+ return ds
0 commit comments