Fetching Argo data#

To access Argo data, you need to use a data fetcher. You can import and instantiate the default argopy data fetcher like this:

In [1]: from argopy import DataFetcher as ArgoDataFetcher

In [2]: argo_loader = ArgoDataFetcher()

In [3]: argo_loader
Out[3]: 
<datafetcher.erddap> 'No access point initialised'
Available access points: float, profile, region
Performances: cache=False, parallel=False
User mode: standard
Dataset: phy

Then, you can request data for a specific space/time domain, for a given float or for a given vertical profile.

If you fetch a lot of data, you may want to look at the Performances section.

For a space/time domain#

Use the fetcher access point argopy.DataFetcher.region() to specify a domain and chain with the argopy.DataFetcher.to_xarray() to get the data returned as xarray.Dataset.

For instance, to retrieve data from 75W to 45W, 20N to 30N, 0db to 10db and from January to May 2011:

In [4]: ds = argo_loader.region([-75, -45, 20, 30, 0, 10, '2011-01-01', '2011-06']).to_xarray()

In [5]: ds
Out[5]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 998)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 4 5 ... 993 994 995 996 997
    LATITUDE               (N_POINTS) float64 24.54 24.54 25.04 ... 24.96 24.96
    LONGITUDE              (N_POINTS) float64 -45.14 -45.14 ... -50.4 -50.4
    TIME                   (N_POINTS) datetime64[ns] 2011-01-01T11:49:19 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 2 2 2 2 1 1
    CYCLE_NUMBER           (N_POINTS) int32 23 23 10 10 10 10 ... 2 10 10 38 38
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D'
    DIRECTION              (N_POINTS) <U1 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int32 1901463 1901463 ... 1901463 1901463
    POSITION_QC            (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 37.45 37.45 37.28 ... 37.08 37.05
    PSAL_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 24.08 24.08 24.03 ... 25.1 24.79
    TEMP_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
Attributes:
    DATA_ID:              ARGO
    DOI:                  http://doi.org/10.17882/42182
    Fetched_from:         https://erddap.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2023/07/19
    Fetched_constraints:  [x=-75.00/-45.00; y=20.00/30.00; z=0.0/10.0; t=2011...
    Fetched_uri:          ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo...
    history:              Variables filtered according to DATA_MODE; Variable...

Note that:

  • the constraints on time is not mandatory: if not specified, the fetcher will return all data available in this region.

  • the last time bound is exclusive: that’s why here we specify June to retrieve data collected in May.

For one or more floats#

If you know the Argo float unique identifier number called a WMO number you can use the fetcher access point argopy.DataFetcher.float() to specify the float WMO platform number and chain with the argopy.DataFetcher.to_xarray() to get the data returned as xarray.Dataset.

For instance, to retrieve data for float WMO 6902746:

In [6]: ds = argo_loader.float(6902746).to_xarray()

In [7]: ds
Out[7]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 12518)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 ... 12514 12515 12516 12517
    LATITUDE               (N_POINTS) float64 20.08 20.08 20.08 ... 16.67 16.67
    LONGITUDE              (N_POINTS) float64 -60.17 -60.17 ... -77.13 -77.13
    TIME                   (N_POINTS) datetime64[ns] 2017-07-06T14:49:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 3 3 3 3 3 3 3 3
    CYCLE_NUMBER           (N_POINTS) int32 1 1 1 1 1 1 ... 117 117 117 117 117
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D'
    DIRECTION              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int32 6902746 6902746 ... 6902746 6902746
    POSITION_QC            (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 36.06 36.06 36.06 ... 34.97 34.97
    PSAL_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 28.04 28.03 28.02 ... 4.254 4.238
    TEMP_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
Attributes:
    DATA_ID:              ARGO
    DOI:                  http://doi.org/10.17882/42182
    Fetched_from:         https://erddap.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2023/07/19
    Fetched_constraints:  phy;WMO6902746
    Fetched_uri:          ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo...
    history:              Variables filtered according to DATA_MODE; Variable...

To fetch data for a collection of floats, input them in a list:

In [8]: ds = argo_loader.float([6902746, 6902755]).to_xarray()

In [9]: ds
Out[9]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 31289)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 ... 31285 31286 31287 31288
    LATITUDE               (N_POINTS) float64 20.08 20.08 20.08 ... 43.81 43.81
    LONGITUDE              (N_POINTS) float64 -60.17 -60.17 ... -28.85 -28.85
    TIME                   (N_POINTS) datetime64[ns] 2017-07-06T14:49:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int32 1 1 1 1 1 1 ... 177 177 177 177 177
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    DIRECTION              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int32 6902746 6902746 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 36.06 36.06 36.06 ... 35.76 35.78
    PSAL_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 28.04 28.03 28.02 ... 13.45 13.49
    TEMP_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
Attributes:
    DATA_ID:              ARGO
    DOI:                  http://doi.org/10.17882/42182
    Fetched_from:         https://erddap.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2023/07/19
    Fetched_constraints:  phy;WMO6902746;WMO6902755
    Fetched_uri:          ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo...
    history:              Variables filtered according to DATA_MODE; Variable...

For one or more profiles#

Use the fetcher access point argopy.DataFetcher.profile() to specify the float WMO platform number and the profile cycle number to retrieve profiles for, then chain with the argopy.DataFetcher.to_xarray() to get the data returned as xarray.Dataset.

For instance, to retrieve data for the 12th profile of float WMO 6902755:

In [10]: ds = argo_loader.profile(6902755, 12).to_xarray()
---------------------------------------------------------------------------
ServerDisconnectedError                   Traceback (most recent call last)
Cell In[10], line 1
----> 1 ds = argo_loader.profile(6902755, 12).to_xarray()

File ~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.13/argopy/fetchers.py:428, in ArgoDataFetcher.to_xarray(self, **kwargs)
    423 if not self.fetcher:
    424     raise InvalidFetcher(
    425         " Initialize an access point (%s) first."
    426         % ",".join(self.Fetchers.keys())
    427     )
--> 428 xds = self.fetcher.to_xarray(**kwargs)
    429 xds = self.postproccessor(xds)
    431 # data_path = self.fetcher.cname() + self._mode + ".zarr"
    432 # log.debug(data_path)
    433 # if self.cache and self.fs.exists(data_path):
   (...)
    437 #     xds = self.postproccessor(xds)
    438 #     xds = self._write(data_path, xds)._read(data_path)

File ~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.13/argopy/data_fetchers/erddap_data.py:459, in ErddapArgoDataFetcher.to_xarray(self, errors)
    457 if len(self.uri) == 1:
    458     try:
--> 459         ds = self.fs.open_dataset(self.uri[0])
    460     except ClientResponseError as e:
    461         raise ErddapServerError(e.message)

File ~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.13/argopy/stores/filesystems.py:455, in httpstore.open_dataset(self, url, *args, **kwargs)
    444 """ Open and decode a xarray dataset from an url
    445 
    446 Parameters
   (...)
    452 :class:`xarray.Dataset`
    453 """
    454 try:
--> 455     data = self.fs.cat_file(url)
    456 except aiohttp.ClientResponseError as e:
    457     if e.status == 413:

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/fsspec/asyn.py:121, in sync_wrapper.<locals>.wrapper(*args, **kwargs)
    118 @functools.wraps(func)
    119 def wrapper(*args, **kwargs):
    120     self = obj or args[0]
--> 121     return sync(self.loop, func, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/fsspec/asyn.py:106, in sync(loop, func, timeout, *args, **kwargs)
    104     raise FSTimeoutError from return_result
    105 elif isinstance(return_result, BaseException):
--> 106     raise return_result
    107 else:
    108     return return_result

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/fsspec/asyn.py:61, in _runner(event, coro, result, timeout)
     59     coro = asyncio.wait_for(coro, timeout=timeout)
     60 try:
---> 61     result[0] = await coro
     62 except Exception as ex:
     63     result[0] = ex

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/fsspec/implementations/http.py:229, in HTTPFileSystem._cat_file(self, url, start, end, **kwargs)
    227     kw["headers"] = headers
    228 session = await self.set_session()
--> 229 async with session.get(self.encode_url(url), **kw) as r:
    230     out = await r.read()
    231     self._raise_not_found_for_status(r, url)

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/aiohttp/client.py:1141, in _BaseRequestContextManager.__aenter__(self)
   1140 async def __aenter__(self) -> _RetType:
-> 1141     self._resp = await self._coro
   1142     return self._resp

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/aiohttp/client.py:560, in ClientSession._request(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, proxy_headers, trace_request_ctx, read_bufsize)
    558 resp = await req.send(conn)
    559 try:
--> 560     await resp.start(conn)
    561 except BaseException:
    562     resp.close()

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/aiohttp/client_reqrep.py:899, in ClientResponse.start(self, connection)
    897 try:
    898     protocol = self._protocol
--> 899     message, payload = await protocol.read()  # type: ignore[union-attr]
    900 except http.HttpProcessingError as exc:
    901     raise ClientResponseError(
    902         self.request_info,
    903         self.history,
   (...)
    906         headers=exc.headers,
    907     ) from exc

File ~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.13/lib/python3.8/site-packages/aiohttp/streams.py:616, in DataQueue.read(self)
    614 self._waiter = self._loop.create_future()
    615 try:
--> 616     await self._waiter
    617 except (asyncio.CancelledError, asyncio.TimeoutError):
    618     self._waiter = None

ServerDisconnectedError: Server disconnected

In [11]: ds
Out[11]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 31289)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 ... 31285 31286 31287 31288
    LATITUDE               (N_POINTS) float64 20.08 20.08 20.08 ... 43.81 43.81
    LONGITUDE              (N_POINTS) float64 -60.17 -60.17 ... -28.85 -28.85
    TIME                   (N_POINTS) datetime64[ns] 2017-07-06T14:49:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int32 1 1 1 1 1 1 ... 177 177 177 177 177
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    DIRECTION              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int32 6902746 6902746 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 36.06 36.06 36.06 ... 35.76 35.78
    PSAL_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 28.04 28.03 28.02 ... 13.45 13.49
    TEMP_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
Attributes:
    DATA_ID:              ARGO
    DOI:                  http://doi.org/10.17882/42182
    Fetched_from:         https://erddap.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2023/07/19
    Fetched_constraints:  phy;WMO6902746;WMO6902755
    Fetched_uri:          ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo...
    history:              Variables filtered according to DATA_MODE; Variable...

To fetch data for more than one profile, input them in a list:

In [12]: ds = argo_loader.profile(6902755, [3, 12]).to_xarray()

In [13]: ds
Out[13]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 215)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 4 5 ... 210 211 212 213 214
    LATITUDE               (N_POINTS) float64 59.72 59.72 59.72 ... 63.68 63.68
    LONGITUDE              (N_POINTS) float64 -31.24 -31.24 ... -28.81 -28.81
    TIME                   (N_POINTS) datetime64[ns] 2018-07-22T00:03:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int32 2 2 2 2 2 2 2 2 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int32 3 3 3 3 3 3 3 ... 12 12 12 12 12 12
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D'
    DIRECTION              (N_POINTS) <U1 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int32 6902755 6902755 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 34.76 34.76 34.76 ... 34.94 34.94
    PSAL_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 8.742 8.743 8.744 ... 3.549 3.536
    TEMP_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
Attributes:
    DATA_ID:              ARGO
    DOI:                  http://doi.org/10.17882/42182
    Fetched_from:         https://erddap.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2023/07/19
    Fetched_constraints:  phy;WMO6902755_CYC3_CYC12
    Fetched_uri:          ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo...
    history:              Variables filtered according to DATA_MODE; Variable...