Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CTDRefDataFetcher to argopy.related #300

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions argopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = (
Expand Down
28 changes: 13 additions & 15 deletions argopy/data_fetchers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
# )
3 changes: 2 additions & 1 deletion argopy/data_fetchers/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions argopy/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions argopy/related/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand All @@ -14,12 +15,13 @@
"ArgoNVSReferenceTables",
"ArgoDocs",
"ArgoDOI",
"CTDRefDataFetcher",

# Functions:
# Functions :
"get_coriolis_profile_id",
"get_ea_profile_page",

# Utilities:
# Utilities :
"load_dict",
"mapp_dict",
)
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions docs/api-hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://www.github.com/gmaze>`_

- Pin upper bound on xarray < 2024.3 to fix failing upstream tests because of ``AttributeError: 'ScipyArrayWrapper' object has no attribute 'oindex'``, `reported here <https://github.com/pydata/xarray/issues/8909>`_. (:pr:`326`) by `G. Maze <http://www.github.com/gmaze>`_

- Fix :class:`argopy.ArgoDocs` that was not working with new Archimer webpage design, :issue:`351`. (:pr:`352`) by `G. Maze <http://www.github.com/gmaze>`_.
Expand Down
Loading