Repository: GliderToolsCommunity/GliderTools (language: python)

Issue:
Documentation
<!-- Feel free to remove check-list items aren't relevant to your change -->

Documentation added to docs/api.rst and docs/whats-new.rst
I documented some changes that where made in the previous release (v2022.12.13), as well as changes that are yet unreleased but that are hopefully going to happen with (#169 , #170, #166 )



Discussion / hints:

Fix patch:
diff --git a/glidertools/load/__init__.py b/glidertools/load/__init__.py
index e4e161c..6f81f59 100644
--- a/glidertools/load/__init__.py
+++ b/glidertools/load/__init__.py
@@ -7,3 +7,4 @@
 from .seaglider import load_multiple_vars as seaglider_basestation_netCDFs
 from .seaglider import show_variables as seaglider_show_variables
 from .slocum import slocum_geomar_matfile
+from .voto_seaexplorer import voto_seaexplorer_dataset, voto_seaexplorer_nc
diff --git a/glidertools/load/voto_seaexplorer.py b/glidertools/load/voto_seaexplorer.py
new file mode 100644
index 0000000..bd72c52
--- /dev/null
+++ b/glidertools/load/voto_seaexplorer.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+import numpy as np
+import xarray as xr
+
+
+def voto_seaexplorer_nc(filename):
+    """
+    Load .nc file downloaded from https://observations.voiceoftheocean.org/.
+    A dives column is generated on importing the data.
+
+    Parameters
+    ----------
+    filename : str
+        path of .nc file.
+
+    Returns
+    -------
+    xarray.Dataset
+        Dataset containing the all columns in the source file and dives column
+    """
+    ds = xr.open_dataset(filename)
+    ds = voto_seaexplorer_dataset(ds)
+    return ds
+
+
+def voto_seaexplorer_dataset(ds):
+    """
+    Adapts a VOTO xarray dataset, for example downloaded from the VOTO ERDAP
+    server (https://erddap.observations.voiceoftheocean.org/erddap/index.html)
+    to be used in GliderTools
+
+    Parameters
+    ----------
+    ds : xarray.Dataset
+
+    Returns
+    -------
+    xarray.Dataset
+        Dataset containing the all columns in the source file and dives column
+    """
+    ds = add_dive_column(ds)
+    return ds
+
+
+def add_dive_column(ds):
+    """add dive column to dataset
+
+    Parameters:
+    -----------
+    ds: xarray.Dataset
+
+    Returns:
+    --------
+    xarray.Dataset
+        Dataset containing a dives column
+    """
+    ds["dives"] = (
+        ["time"],
+        np.where(ds.profile_direction == 1, ds.profile_num, ds.profile_num + 0.5),
+    )
+    return ds


Test patch:
diff --git a/tests/data/voto_nrt.nc b/tests/data/voto_nrt.nc
new file mode 100644
index 0000000..1af9ce5
Binary files /dev/null and b/tests/data/voto_nrt.nc differ
diff --git a/tests/test_load.py b/tests/test_load.py
new file mode 100644
index 0000000..5e8199f
--- /dev/null
+++ b/tests/test_load.py
@@ -0,0 +1,9 @@
+from glidertools.load.voto_seaexplorer import voto_seaexplorer_nc
+
+
+filename = "./tests/data/voto_nrt.nc"
+ds = voto_seaexplorer_nc(filename)
+
+
+def test_dives_column_addition():
+    assert len(ds.dives) > 1