diff --git a/argopy/__init__.py b/argopy/__init__.py index 3eef4a017..a6cf4b912 100644 --- a/argopy/__init__.py +++ b/argopy/__init__.py @@ -36,14 +36,20 @@ 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/__init__.py b/argopy/data_fetchers/__init__.py index 0876b7bc1..070f83dc1 100644 --- a/argopy/data_fetchers/__init__.py +++ b/argopy/data_fetchers/__init__.py @@ -2,18 +2,16 @@ This package contains implementations for data and index fetchers for specific data sources. Most of these fetchers are meant to be used and discovered automatically by the facades (in fetchers.py) 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", +# ) diff --git a/argopy/data_fetchers/proto.py b/argopy/data_fetchers/proto.py index a47b3ec8d..b326086b6 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 from ..utils.format import UriCName @@ -75,6 +74,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 7626e840f..58882a2ca 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 68f16bd70..71510421a 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,12 +15,13 @@ "ArgoNVSReferenceTables", "ArgoDocs", "ArgoDOI", + "CTDRefDataFetcher", - # Functions: + # Functions : "get_coriolis_profile_id", "get_ea_profile_page", - # Utilities: + # Utilities : "load_dict", "mapp_dict", ) diff --git a/argopy/data_fetchers/erddap_refdata.py b/argopy/related/erddap_refdata.py similarity index 88% rename from argopy/data_fetchers/erddap_refdata.py rename to argopy/related/erddap_refdata.py index c0e451424..bc02beffd 100644 --- a/argopy/data_fetchers/erddap_refdata.py +++ b/argopy/related/erddap_refdata.py @@ -1,25 +1,27 @@ """ -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 .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 +from ..data_fetchers.erddap_data import ErddapArgoDataFetcher log = logging.getLogger("argopy.erddap.refdata") @@ -34,7 +36,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 3ba8b8759..e59412533 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 @@ -136,6 +132,10 @@ argopy.related.ArgoDocs.show argopy.related.ArgoDocs.js + argopy.related.erddap_refdata.ErddapREFDataFetcher + argopy.related.erddap_refdata.Fetch_box + argopy.related.CTDRefDataFetcher + argopy.related.ArgoDOI argopy.related.ArgoDOI.search argopy.related.ArgoDOI.file diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 9fcf842c4..ab151cf5e 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -35,6 +35,8 @@ 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. (:pr:`300`) by `G. Maze `_ + - Pin upper bound on xarray < 2024.3 to fix failing upstream tests because of ``AttributeError: 'ScipyArrayWrapper' object has no attribute 'oindex'``, `reported here `_. (:pr:`326`) by `G. Maze `_ - Fix :class:`argopy.ArgoDocs` that was not working with new Archimer webpage design, :issue:`351`. (:pr:`352`) by `G. Maze `_.