Skip to content

Commit

Permalink
🐛 fix the andro datasets (#489)
Browse files Browse the repository at this point in the history
* fix url

* put back decode_times default value to True

* update docstring

* Enhance andro tests

* format

* bump version

---------

Co-authored-by: Kevin Santana <[email protected]>
  • Loading branch information
philippemiron and kevinsantana11 authored Jul 13, 2024
1 parent 1751f4b commit dddc803
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
6 changes: 3 additions & 3 deletions clouddrift/adapters/andro.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from clouddrift.adapters.utils import download_with_progress

# order of the URLs is important
ANDRO_URL = "https://www.seanoe.org/data/00360/47077/data/91950.dat"
ANDRO_URL = "https://www.seanoe.org/data/00360/47077/data/109566.dat"
ANDRO_TMP_PATH = os.path.join(tempfile.gettempdir(), "clouddrift", "andro")
ANDRO_VERSION = "2022-03-04"
ANDRO_VERSION = "2024-03-25"


def to_xarray(tmp_path: str | None = None):
Expand Down Expand Up @@ -325,7 +325,7 @@ def to_xarray(tmp_path: str | None = None):

# global attributes
attrs = {
"title": "ANDRO: An Argo-based deep displacement dataset",
"title": "ANDRO: An Argo-based deep displacement dataset (Quality controlled data)",
"history": f"Dataset updated on {ANDRO_VERSION}",
"date_created": datetime.now().isoformat(),
"publisher_name": "SEANOE (SEA scieNtific Open data Edition)",
Expand Down
48 changes: 24 additions & 24 deletions clouddrift/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def yomaha(decode_times: bool = True) -> xr.Dataset:
return _dataset_filecache("yomaha.nc", decode_times, adapters.yomaha.to_xarray)


def andro(decode_times: bool = False) -> xr.Dataset:
def andro(decode_times: bool = True) -> xr.Dataset:
"""Returns the ANDRO as a ragged array Xarray dataset.
The function will first look for the ragged-array dataset on the local
Expand All @@ -573,36 +573,36 @@ def andro(decode_times: bool = False) -> xr.Dataset:
>>> from clouddrift.datasets import andro
>>> ds = andro()
>>> ds
<xarray.Dataset>
Dimensions: (obs: 1360753, traj: 9996)
<xarray.Dataset> Size: 110MB
Dimensions: (obs: 510630, traj: 3344)
Coordinates:
time_d (obs) datetime64[ns] ...
time_s (obs) datetime64[ns] ...
time_lp (obs) datetime64[ns] ...
time_lc (obs) datetime64[ns] ...
id (traj) int64 ...
time_d (obs) datetime64[ns] 4MB ...
time_s (obs) datetime64[ns] 4MB ...
time_lp (obs) datetime64[ns] 4MB ...
time_lc (obs) datetime64[ns] 4MB ...
id (traj) float32 13kB ...
Dimensions without coordinates: obs, traj
Data variables: (12/33)
lon_d (obs) float64 ...
lat_d (obs) float64 ...
pres_d (obs) float32 ...
temp_d (obs) float32 ...
sal_d (obs) float32 ...
ve_d (obs) float32 ...
lon_d (obs) float64 4MB ...
lat_d (obs) float64 4MB ...
pres_d (obs) float32 2MB ...
temp_d (obs) float32 2MB ...
sal_d (obs) float32 2MB ...
ve_d (obs) float32 2MB ...
... ...
lon_lc (obs) float64 ...
lat_lc (obs) float64 ...
surf_fix (obs) int64 ...
cycle (obs) int64 ...
profile_id (obs) float32 ...
rowsize (traj) int64 ...
lon_lc (obs) float64 4MB ...
lat_lc (obs) float64 4MB ...
surf_fix (obs) float32 2MB ...
cycle (obs) float32 2MB ...
profile_id (obs) float32 2MB ...
rowsize (traj) int64 27kB ...
Attributes:
title: ANDRO: An Argo-based deep displacement dataset
history: 2022-03-04
date_created: 2023-12-08T00:52:00.937120
title: ANDRO: An Argo-based deep displacement dataset (Quality ...
history: Dataset updated on 2024-03-25
date_created: 2024-07-02T12:11:50.643492
publisher_name: SEANOE (SEA scieNtific Open data Edition)
publisher_url: https://www.seanoe.org/data/00360/47077/
license: freely available
license: Creative Commons Attribution 4.0 International License (...
Reference
---------
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "clouddrift"
version = "0.38.1"
version = "0.39.0"

authors = [
{ name="Shane Elipot", email="[email protected]" },
Expand Down
11 changes: 10 additions & 1 deletion tests/datasets_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ def test_subsurface_floats_opens(self):

def test_andro_opens(self):
with datasets.andro() as ds:
self.assertTrue(ds)
self.assertTrue(ds is not None)
self.assertTrue(len(ds.variables) > 0)
self.assertTrue(len(ds["lon_d"]) > 0)

self.assertTrue(
len(ds.lat_d[np.logical_or(ds.lat_d > 90, ds.lat_d < -90)]) == 0
)
self.assertTrue(
len(ds.lat_d[np.logical_or(ds.lon_d > 180, ds.lon_d < -180)]) == 0
)

def test_yomaha_opens(self):
with datasets.yomaha() as ds:
Expand Down

0 comments on commit dddc803

Please sign in to comment.