From 7eb08f933d625130a1de0a13d78b844c48005c61 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Mon, 9 Oct 2023 09:17:42 +0200 Subject: [PATCH 1/4] Update whats-new.rst --- docs/whats-new.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index b6d5bda8..d55d15a7 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -8,6 +8,14 @@ What's New |pypi dwn| |conda dwn| +Coming up next +-------------- + +**Internals** + +- The :class:`CTDRefDataFetcher` was badly located in the ``data_fetchers`` private sub-module, it's been refactored in the more appropriate ``related`` public sub-module. + + v0.1.14 (29 Sep. 2023) ---------------------- From 3a643e77bca74491c614e7d712e8f379af6137c1 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Mon, 9 Oct 2023 11:16:55 +0200 Subject: [PATCH 2/4] Refactoring and fix circular imports --- argopy/__init__.py | 20 +++++++++---------- argopy/data_fetchers/proto.py | 3 ++- argopy/fetchers.py | 4 +--- argopy/related/__init__.py | 2 ++ .../erddap_refdata.py | 14 +++++++++++-- docs/api-hidden.rst | 8 ++++---- 6 files changed, 30 insertions(+), 21 deletions(-) rename argopy/{data_fetchers => related}/erddap_refdata.py (95%) diff --git a/argopy/__init__.py b/argopy/__init__.py index 1817a206..be9082a2 100644 --- a/argopy/__init__.py +++ b/argopy/__init__.py @@ -21,29 +21,27 @@ log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) -# Import facades: -from .fetchers import ArgoDataFetcher as DataFetcher # noqa: E402 -from .fetchers import ArgoIndexFetcher as IndexFetcher # noqa: E402 - -from .xarray import ArgoAccessor # noqa: E402 - -# Other Import -# from . import utils as utilities # noqa: E402 -from . import utilities # noqa: E402 # being deprecated until 0.1.15, then remove +# Low-level imports from . import stores # noqa: E402 from . import errors # noqa: E402 from . import plot # noqa: E402 from . import tutorial # noqa: E402 from .plot import dashboard, ArgoColors # noqa: E402 from .options import set_options, reset_options # noqa: E402 -from .data_fetchers import CTDRefDataFetcher # noqa: E402 from .stores import ArgoIndex # noqa: E402 from .utils import show_versions, show_options # noqa: E402 from .utils import clear_cache, lscache # noqa: E402 from .utils import MonitoredThreadPoolExecutor # noqa: E402, F401 from .utils import monitor_status as status # noqa: E402 -from .related import TopoFetcher, OceanOPSDeployments, ArgoNVSReferenceTables, ArgoDocs, ArgoDOI # noqa: E402 +# High-level imports: +from .related import TopoFetcher, OceanOPSDeployments, ArgoNVSReferenceTables, ArgoDocs, ArgoDOI, CTDRefDataFetcher # noqa: E402 +from .fetchers import ArgoDataFetcher as DataFetcher # noqa: E402 +from .fetchers import ArgoIndexFetcher as IndexFetcher # noqa: E402 + +from .xarray import ArgoAccessor # noqa: E402 + +from . import utilities # noqa: E402 # being deprecated until 0.1.15, then remove # __all__ = ( diff --git a/argopy/data_fetchers/proto.py b/argopy/data_fetchers/proto.py index 412a01e2..a5888e6b 100644 --- a/argopy/data_fetchers/proto.py +++ b/argopy/data_fetchers/proto.py @@ -4,7 +4,6 @@ import xarray import hashlib import warnings -from ..plot import dashboard from ..utils.lists import list_standard_variables @@ -122,6 +121,8 @@ def sha(self) -> str: def dashboard(self, **kw): """Return 3rd party dashboard for the access point""" + from ..plot import dashboard # Import here to avoid circular import by :class:`related.CTDRefDataFetcher` + if 'type' not in kw and self.dataset_id == 'bgc': kw['type'] = 'bgc' if self.WMO is not None: diff --git a/argopy/fetchers.py b/argopy/fetchers.py index 18d57af6..9fd11d96 100755 --- a/argopy/fetchers.py +++ b/argopy/fetchers.py @@ -17,9 +17,7 @@ from .options import OPTIONS, _VALIDATORS from .errors import InvalidFetcherAccessPoint, InvalidFetcher, OptionValueError -from .related import ( - get_coriolis_profile_id, -) +from .related import get_coriolis_profile_id from .utils.checkers import ( is_box, is_indexbox, diff --git a/argopy/related/__init__.py b/argopy/related/__init__.py index 68f16bd7..15863160 100644 --- a/argopy/related/__init__.py +++ b/argopy/related/__init__.py @@ -4,6 +4,7 @@ from .argo_documentation import ArgoDocs from .doi_snapshot import ArgoDOI from .euroargo_api import get_coriolis_profile_id, get_ea_profile_page +from .erddap_refdata import Fetch_box as CTDRefDataFetcher from .utils import load_dict, mapp_dict # @@ -14,6 +15,7 @@ "ArgoNVSReferenceTables", "ArgoDocs", "ArgoDOI", + "CTDRefDataFetcher", # Functions: "get_coriolis_profile_id", diff --git a/argopy/data_fetchers/erddap_refdata.py b/argopy/related/erddap_refdata.py similarity index 95% rename from argopy/data_fetchers/erddap_refdata.py rename to argopy/related/erddap_refdata.py index c0e45142..6625691a 100644 --- a/argopy/data_fetchers/erddap_refdata.py +++ b/argopy/related/erddap_refdata.py @@ -7,7 +7,7 @@ from ..utils.chunking import Chunker from ..utils.geo import conv_lon from ..stores import httpstore_erddap_auth -from .erddap_data import ErddapArgoDataFetcher +from ..data_fetchers.erddap_data import ErddapArgoDataFetcher # Load erddapy according to available version (breaking changes in v0.8.0) try: @@ -34,7 +34,17 @@ class ErddapREFDataFetcher(ErddapArgoDataFetcher): - """Manage access to Argo CTD-reference data through Ifremer ERDDAP""" + """Manage access to Argo CTD-reference data through Ifremer ERDDAP + + Examples + -------- + >>> from argopy import CTDRefDataFetcher + >>> with argopy.set_options(user="john_doe", password="***"): + >>> f = CTDRefDataFetcher(box=[15, 30, -70, -60, 0, 5000.0]) + >>> ds = f.to_xarray() + + + """ # @doc_inherit def __init__(self, **kwargs): diff --git a/docs/api-hidden.rst b/docs/api-hidden.rst index 2b25323e..78ebb6c7 100644 --- a/docs/api-hidden.rst +++ b/docs/api-hidden.rst @@ -48,10 +48,6 @@ argopy.data_fetchers.argovis_data.Fetch_wmo argopy.data_fetchers.argovis_data.Fetch_box - argopy.data_fetchers.erddap_refdata.ErddapREFDataFetcher - argopy.data_fetchers.erddap_refdata.Fetch_box - argopy.data_fetchers.CTDRefDataFetcher - argopy.options.set_options argopy.tutorial.open_dataset @@ -133,6 +129,10 @@ argopy.related.ArgoDocs.show argopy.related.ArgoDocs.js + argopy.related.erddap_refdata.ErddapREFDataFetcher + argopy.related.erddap_refdata.Fetch_box + argopy.related.CTDRefDataFetcher + argopy.plot argopy.plot.dashboard argopy.plot.bar_plot From 4e7d4d448f8c2731235183705ee7d57d75c1baf3 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Mon, 9 Oct 2023 11:17:29 +0200 Subject: [PATCH 3/4] Update __init__.py Clean-up dat_fetchers __init__ because all classes have the same name as sub-modules --- argopy/data_fetchers/__init__.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/argopy/data_fetchers/__init__.py b/argopy/data_fetchers/__init__.py index d88e27e6..e6e0321a 100644 --- a/argopy/data_fetchers/__init__.py +++ b/argopy/data_fetchers/__init__.py @@ -4,18 +4,16 @@ and by utilities functions list_available_data_src() and list_available_index_src() """ -from .erddap_refdata import Fetch_box as CTDRefDataFetcher -from . import erddap_data -from . import erddap_index -from . import argovis_data -from . import gdacftp_data -from . import gdacftp_index - -__all__ = ( - "erddap_data", - "erddap_index", - "argovis_data", - "gdacftp_data", - "gdacftp_index", - "CTDRefDataFetcher", -) +# from . import erddap_data +# from . import erddap_index +# from . import argovis_data +# from . import gdacftp_data +# from . import gdacftp_index +# +# __all__ = ( +# "erddap_data", +# "erddap_index", +# "argovis_data", +# "gdacftp_data", +# "gdacftp_index", +# ) From 7c698ea6e87715022f3a65ddcdfa0ad7272fa3c1 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Tue, 16 Jul 2024 11:28:11 +0200 Subject: [PATCH 4/4] docstrings --- argopy/related/__init__.py | 4 ++-- argopy/related/erddap_refdata.py | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/argopy/related/__init__.py b/argopy/related/__init__.py index 15863160..71510421 100644 --- a/argopy/related/__init__.py +++ b/argopy/related/__init__.py @@ -17,11 +17,11 @@ "ArgoDOI", "CTDRefDataFetcher", - # Functions: + # Functions : "get_coriolis_profile_id", "get_ea_profile_page", - # Utilities: + # Utilities : "load_dict", "mapp_dict", ) diff --git a/argopy/related/erddap_refdata.py b/argopy/related/erddap_refdata.py index 6625691a..bc02beff 100644 --- a/argopy/related/erddap_refdata.py +++ b/argopy/related/erddap_refdata.py @@ -1,26 +1,28 @@ """ -Fetcher to retrieve CTD reference data from Ifremer erddap +Fetcher to retrieve R/V CTD reference data for Argo DMQC from Ifremer erddap + +This module is not available from the data fetcher facade because it does not provide data from +Argo floats but from R/V CTD. + +This module is not covered by unit tests because it provide a preliminary support only (Ifremer erddap +data set not yet fully ready). + +#todo Add unit tests when Ifremer erddap ready and new feature documented + """ import xarray as xr import logging + +from erddapy.erddapy import ERDDAP # noqa: F401 +from erddapy.erddapy import _quote_string_constraints as quote_string_constraints # noqa: F401 +from erddapy.erddapy import parse_dates # noqa: F401 + from ..options import OPTIONS from ..utils.chunking import Chunker from ..utils.geo import conv_lon from ..stores import httpstore_erddap_auth from ..data_fetchers.erddap_data import ErddapArgoDataFetcher -# Load erddapy according to available version (breaking changes in v0.8.0) -try: - from erddapy import ERDDAP - from erddapy.utilities import parse_dates, quote_string_constraints -except: # noqa: E722 - # >= v0.8.0 - from erddapy.erddapy import ERDDAP # noqa: F401 - from erddapy.erddapy import _quote_string_constraints as quote_string_constraints # noqa: F401 - from erddapy.erddapy import parse_dates # noqa: F401 - - # Soon ! https://github.com/ioos/erddapy - log = logging.getLogger("argopy.erddap.refdata")