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
Backend: erddap
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()
---------------------------------------------------------------------------
ServerDisconnectedError                   Traceback (most recent call last)
<ipython-input-4-16f642f11712> in <module>
----> 1 ds = argo_loader.region([-75, -45, 20, 30, 0, 10, '2011-01-01', '2011-06']).to_xarray()

~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.8/argopy/fetchers.py in to_xarray(self, **kwargs)
    334                 % ",".join(self.Fetchers.keys())
    335             )
--> 336         xds = self.fetcher.to_xarray(**kwargs)
    337         xds = self.postproccessor(xds)
    338         return xds

~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.8/argopy/data_fetchers/erddap_data.py in to_xarray(self, errors)
    417         if not self.parallel:
    418             if len(self.uri) == 1:
--> 419                 ds = self.fs.open_dataset(self.uri[0])
    420             else:
    421                 ds = self.fs.open_mfdataset(

~/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.8/argopy/stores/filesystems.py in open_dataset(self, url, *args, **kwargs)
    390         # with self.fs.open(url) as of:
    391         #     ds = xr.open_dataset(of, *args, **kwargs)
--> 392         data = self.fs.cat_file(url)
    393         ds = xr.open_dataset(data, *args, **kwargs)
    394         if "source" not in ds.encoding:

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/fsspec/asyn.py in wrapper(*args, **kwargs)
    116     def wrapper(*args, **kwargs):
    117         self = obj or args[0]
--> 118         return maybe_sync(func, self, *args, **kwargs)
    119 
    120     return wrapper

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/fsspec/asyn.py in maybe_sync(func, self, *args, **kwargs)
     95         if inspect.iscoroutinefunction(func):
     96             # run the awaitable on the loop
---> 97             return sync(loop, func, *args, **kwargs)
     98         else:
     99             # just call the blocking function

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/fsspec/asyn.py in sync(loop, func, callback_timeout, *args, **kwargs)
     66     if error[0]:
     67         typ, exc, tb = error[0]
---> 68         raise exc.with_traceback(tb)
     69     else:
     70         return result[0]

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/fsspec/asyn.py in f()
     50             if callback_timeout is not None:
     51                 future = asyncio.wait_for(future, callback_timeout)
---> 52             result[0] = await future
     53         except Exception:
     54             error[0] = sys.exc_info()

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/fsspec/implementations/http.py in _cat_file(self, url, **kwargs)
    150         kw.update(kwargs)
    151         logger.debug(url)
--> 152         async with self.session.get(url, **kw) as r:
    153             if r.status == 404:
    154                 raise FileNotFoundError(url)

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

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/aiohttp/client.py in _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)
    557                             resp = await req.send(conn)
    558                             try:
--> 559                                 await resp.start(conn)
    560                             except BaseException:
    561                                 resp.close()

~/checkouts/readthedocs.org/user_builds/argopy/envs/v0.1.8/lib/python3.8/site-packages/aiohttp/client_reqrep.py in start(self, connection)
    896                 try:
    897                     protocol = self._protocol
--> 898                     message, payload = await protocol.read()  # type: ignore[union-attr]
    899                 except http.HttpProcessingError as exc:
    900                     raise ClientResponseError(

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

ServerDisconnectedError: Server disconnected

In [5]: ds
Out[5]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 107)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 4 5 ... 102 103 104 105 106
    LATITUDE               (N_POINTS) float64 63.68 63.68 63.68 ... 63.68 63.68
    LONGITUDE              (N_POINTS) float64 -28.81 -28.81 ... -28.81 -28.81
    TIME                   (N_POINTS) datetime64[ns] 2018-10-19T23:52:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int64 2 2 2 2 2 2 2 2 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int64 12 12 12 12 12 12 ... 12 12 12 12 12
    DATA_MODE              (N_POINTS) <U1 'R' 'R' 'R' 'R' ... 'R' 'R' 'R' 'R'
    DIRECTION              (N_POINTS) <U1 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int64 6902755 6902755 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 34.87 34.87 34.87 ... 34.94 34.94
    PSAL_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 7.598 7.599 7.602 ... 3.549 3.536
    TEMP_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int64 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://www.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2021/11/02
    Fetched_constraints:  phy;WMO6902755_CYC12
    Fetched_uri:          ['https://www.ifremer.fr/erddap/tabledap/ArgoFloats...
    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: 9039)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 4 ... 9035 9036 9037 9038
    LATITUDE               (N_POINTS) float64 20.08 20.08 20.08 ... 16.3 16.3
    LONGITUDE              (N_POINTS) float64 -60.17 -60.17 ... -62.64 -62.64
    TIME                   (N_POINTS) datetime64[ns] 2017-07-06T14:49:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 3 3 3 3 3 3 3 3
    CYCLE_NUMBER           (N_POINTS) int64 1 1 1 1 1 1 1 ... 84 84 84 84 84 84
    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) int64 6902746 6902746 ... 6902746 6902746
    POSITION_QC            (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int64 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.98 34.98
    PSAL_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 2 2 2 2 2 2 2 2
    TEMP                   (N_POINTS) float64 28.04 28.03 28.02 ... 4.281 4.277
    TEMP_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int64 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://www.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2021/11/02
    Fetched_constraints:  phy;WMO6902746
    Fetched_uri:          ['https://www.ifremer.fr/erddap/tabledap/ArgoFloats...
    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: 22150)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 ... 22146 22147 22148 22149
    LATITUDE               (N_POINTS) float64 20.08 20.08 20.08 ... 43.91 43.91
    LONGITUDE              (N_POINTS) float64 -60.17 -60.17 ... -36.96 -36.96
    TIME                   (N_POINTS) datetime64[ns] 2017-07-06T14:49:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int64 1 1 1 1 1 1 ... 122 122 122 122 122
    DATA_MODE              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'R' 'R' 'R' 'R'
    DIRECTION              (N_POINTS) <U1 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int64 6902746 6902746 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int64 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.93 34.93
    PSAL_QC                (N_POINTS) int64 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 ... 3.625 3.616
    TEMP_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int64 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://www.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2021/11/02
    Fetched_constraints:  phy;WMO6902746;WMO6902755
    Fetched_uri:          ['https://www.ifremer.fr/erddap/tabledap/ArgoFloats...
    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()

In [11]: ds
Out[11]: 
<xarray.Dataset>
Dimensions:                (N_POINTS: 107)
Coordinates:
  * N_POINTS               (N_POINTS) int64 0 1 2 3 4 5 ... 102 103 104 105 106
    LATITUDE               (N_POINTS) float64 63.68 63.68 63.68 ... 63.68 63.68
    LONGITUDE              (N_POINTS) float64 -28.81 -28.81 ... -28.81 -28.81
    TIME                   (N_POINTS) datetime64[ns] 2018-10-19T23:52:00 ... ...
Data variables: (12/13)
    CONFIG_MISSION_NUMBER  (N_POINTS) int64 2 2 2 2 2 2 2 2 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int64 12 12 12 12 12 12 ... 12 12 12 12 12
    DATA_MODE              (N_POINTS) <U1 'R' 'R' 'R' 'R' ... 'R' 'R' 'R' 'R'
    DIRECTION              (N_POINTS) <U1 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int64 6902755 6902755 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    PSAL                   (N_POINTS) float64 34.87 34.87 34.87 ... 34.94 34.94
    PSAL_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TEMP                   (N_POINTS) float64 7.598 7.599 7.602 ... 3.549 3.536
    TEMP_QC                (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int64 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://www.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2021/11/02
    Fetched_constraints:  phy;WMO6902755_CYC12
    Fetched_uri:          ['https://www.ifremer.fr/erddap/tabledap/ArgoFloats...
    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) int64 2 2 2 2 2 2 2 2 ... 2 2 2 2 2 2 2 2
    CYCLE_NUMBER           (N_POINTS) int64 3 3 3 3 3 3 3 ... 12 12 12 12 12 12
    DATA_MODE              (N_POINTS) <U1 'R' 'R' 'R' 'R' ... 'R' 'R' 'R' 'R'
    DIRECTION              (N_POINTS) <U1 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER        (N_POINTS) int64 6902755 6902755 ... 6902755 6902755
    POSITION_QC            (N_POINTS) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    ...                     ...
    PRES_QC                (N_POINTS) int64 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) int64 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) int64 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1
    TIME_QC                (N_POINTS) int64 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://www.ifremer.fr/erddap
    Fetched_by:           docs
    Fetched_date:         2021/11/02
    Fetched_constraints:  phy;WMO6902755_CYC3_CYC12
    Fetched_uri:          ['https://www.ifremer.fr/erddap/tabledap/ArgoFloats...
    history:              Variables filtered according to DATA_MODE; Variable...