#!/usr/bin/env python
# coding: utf-8
#
# Import the ``argopy`` data fetcher:
# In[ ]:
from argopy import DataFetcher as ArgoDataFetcher
# Then, to get access to Argo data, all you need is 1 line of code:
# In[ ]:
ds = ArgoDataFetcher().region([-75, -45, 20, 30, 0, 100, '2011', '2012']).to_xarray()
# In this example, we used a data fetcher to get data for a given space/time region.
# We retrieved all Argo data measurements from 75W to 45W, 20N to 30N, 0db to 100db and from January to May 2011 (the max date is exclusive).
# Data are returned as a collection of measurements in a [xarray.Dataset](http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html).
# In[ ]:
print(ds)
# Fetched data are returned as a 1D array collection of measurements.
#
# If you prefer to work with a 2D array collection of vertical profiles, simply transform the dataset with the [xarray.Dataset](http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html) accessor method [argo.point2profile](https://argopy.readthedocs.io/en/latest/api.html#argopy.ArgoAccessor.point2profile):
# In[ ]:
ds = ds.argo.point2profile()
print(ds)
# You can also fetch data for a specific float using its [WMO number](