[2]:
from argopy import DataFetcher as ArgoDataFetcher
/home/docs/checkouts/readthedocs.org/user_builds/argopy/checkouts/v0.1.4/argopy/plotters.py:33: UserWarning: argopy requires cartopy installed for full map plotting functionality
  warnings.warn("argopy requires cartopy installed for full map plotting functionality")

Manipulating data

Once you fetched data, argopy comes with a handy xarray.Dataset accessor namespace argo to perform specific manipulation of the data.

Transformation

Points vs profiles

Fetched data are returned as a 1D array collection of measurements:

[3]:
argo_loader = ArgoDataFetcher().region([-75,-55,30.,40.,0,100., '2011-01-01', '2011-01-15'])
ds_points = argo_loader.to_xarray()
print(ds_points)
<xarray.Dataset>
Dimensions:          (N_POINTS: 524)
Coordinates:
    LONGITUDE        (N_POINTS) float64 -66.77 -66.77 -66.77 ... -64.59 -64.59
    TIME             (N_POINTS) datetime64[ns] 2011-01-02T11:14:06 ... 2011-01-14T01:05:21
  * N_POINTS         (N_POINTS) int64 0 1 2 3 4 5 6 ... 518 519 520 521 522 523
    LATITUDE         (N_POINTS) float64 37.28 37.28 37.28 ... 33.07 33.07 33.07
Data variables:
    CYCLE_NUMBER     (N_POINTS) int64 150 150 150 150 150 150 ... 13 13 13 13 13
    DATA_MODE        (N_POINTS) <U1 'D' 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D' 'D'
    DIRECTION        (N_POINTS) <U1 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER  (N_POINTS) int64 4900803 4900803 ... 5903377 5903377
    POSITION_QC      (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    PRES             (N_POINTS) float64 5.0 10.0 15.0 20.0 ... 95.97 97.97 99.97
    PRES_QC          (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    PSAL             (N_POINTS) float64 36.67 36.67 36.67 ... 36.67 36.67 36.67
    PSAL_QC          (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    TEMP             (N_POINTS) float64 19.46 19.47 19.47 ... 19.2 19.2 19.2
    TEMP_QC          (N_POINTS) int64 1 1 1 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 1 1 1
Attributes:
    cdm_altitude_proxy:        pres
    cdm_data_type:             TrajectoryProfile
    cdm_profile_variables:     cycle_number, data_type, format_version, handb...
    cdm_trajectory_variables:  platform_number, project_name, pi_name, platfo...
    Conventions:               Argo-3.1, CF-1.6, COARDS, ACDD-1.3
    creator_email:             support@argo.net
    creator_name:              Argo
    creator_url:               http://www.argo.net/
    Easternmost_Easting:       -56.578
    featureType:               TrajectoryProfile
    geospatial_lat_max:        37.28
    geospatial_lat_min:        30.082
    geospatial_lat_units:      degrees_north
    geospatial_lon_max:        -56.578
    geospatial_lon_min:        -73.343
    geospatial_lon_units:      degrees_east
    history:                   2020-06-24T18:00:48Z (local files)\n2020-06-24...
    id:                        ArgoFloats
    infoUrl:                   http://www.argo.net/
    institution:               Argo
    keywords:                  adjusted, argo, array, assembly, best, centre,...
    keywords_vocabulary:       GCMD Science Keywords
    license:                   The data may be used and redistributed for fre...
    Northernmost_Northing:     37.28
    references:                http://www.argodatamgt.org/Documentation
    source:                    Argo float
    sourceUrl:                 (local files)
    Southernmost_Northing:     30.082
    standard_name_vocabulary:  CF Standard Name Table v29
    summary:                   Argo float vertical profiles from Coriolis Glo...
    time_coverage_end:         2011-01-14T01:05:21Z
    time_coverage_start:       2011-01-02T11:14:06Z
    title:                     Argo Float Measurements
    user_manual_version:       3.1
    Westernmost_Easting:       -73.343
    DATA_ID:                   ARGO
    DOI:                       http://doi.org/10.17882/42182
    Fetched_from:              http://www.ifremer.fr/erddap
    Fetched_by:                docs
    Fetched_date:              2020/06/24
    Fetched_constraints:       phy_[x=-75.00/-55.00; y=30.00/40.00; z=0.0/100...
    Fetched_uri:               http://www.ifremer.fr/erddap/tabledap/ArgoFloa...

If you prefer to work with a 2D array collection of vertical profiles, simply transform the dataset with argopy.xarray.ArgoAccessor.point2profile():

[4]:
ds_profiles = ds_points.argo.point2profile()
print(ds_profiles)
<xarray.Dataset>
Dimensions:          (N_LEVELS: 50, N_PROF: 18)
Coordinates:
    TIME             (N_PROF) datetime64[ns] 2011-01-02T11:14:06 ... 2011-01-14T01:05:21
    LONGITUDE        (N_PROF) float64 -66.77 -71.17 -64.93 ... -72.75 -64.59
  * N_LEVELS         (N_LEVELS) int64 0 1 2 3 4 5 6 7 ... 43 44 45 46 47 48 49
    LATITUDE         (N_PROF) float64 37.28 33.98 32.88 ... 37.03 34.39 33.07
  * N_PROF           (N_PROF) int64 7 13 15 0 6 2 9 4 11 5 1 12 10 17 3 8 14 16
Data variables:
    CYCLE_NUMBER     (N_PROF) int64 150 3 11 100 180 280 ... 17 62 148 151 4 13
    DATA_MODE        (N_PROF) <U1 'D' 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D' 'D'
    DIRECTION        (N_PROF) <U1 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER  (N_PROF) int64 4900803 4901218 5903377 ... 4901218 5903377
    POSITION_QC      (N_PROF) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    PRES             (N_PROF, N_LEVELS) float64 5.0 10.0 15.0 ... 99.97 nan
    PRES_QC          (N_PROF) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    PSAL             (N_PROF, N_LEVELS) float64 36.67 36.67 36.67 ... 36.67 nan
    PSAL_QC          (N_PROF) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    TEMP             (N_PROF, N_LEVELS) float64 19.46 19.47 19.47 ... 19.2 nan
    TEMP_QC          (N_PROF) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    TIME_QC          (N_PROF) int64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Attributes:
    cdm_altitude_proxy:        pres
    cdm_data_type:             TrajectoryProfile
    cdm_profile_variables:     cycle_number, data_type, format_version, handb...
    cdm_trajectory_variables:  platform_number, project_name, pi_name, platfo...
    Conventions:               Argo-3.1, CF-1.6, COARDS, ACDD-1.3
    creator_email:             support@argo.net
    creator_name:              Argo
    creator_url:               http://www.argo.net/
    Easternmost_Easting:       -56.578
    featureType:               TrajectoryProfile
    geospatial_lat_max:        37.28
    geospatial_lat_min:        30.082
    geospatial_lat_units:      degrees_north
    geospatial_lon_max:        -56.578
    geospatial_lon_min:        -73.343
    geospatial_lon_units:      degrees_east
    history:                   2020-06-24T18:00:48Z (local files)\n2020-06-24...
    id:                        ArgoFloats
    infoUrl:                   http://www.argo.net/
    institution:               Argo
    keywords:                  adjusted, argo, array, assembly, best, centre,...
    keywords_vocabulary:       GCMD Science Keywords
    license:                   The data may be used and redistributed for fre...
    Northernmost_Northing:     37.28
    references:                http://www.argodatamgt.org/Documentation
    source:                    Argo float
    sourceUrl:                 (local files)
    Southernmost_Northing:     30.082
    standard_name_vocabulary:  CF Standard Name Table v29
    summary:                   Argo float vertical profiles from Coriolis Glo...
    time_coverage_end:         2011-01-14T01:05:21Z
    time_coverage_start:       2011-01-02T11:14:06Z
    title:                     Argo Float Measurements
    user_manual_version:       3.1
    Westernmost_Easting:       -73.343
    DATA_ID:                   ARGO
    DOI:                       http://doi.org/10.17882/42182
    Fetched_from:              http://www.ifremer.fr/erddap
    Fetched_by:                docs
    Fetched_date:              2020/06/24
    Fetched_constraints:       phy_[x=-75.00/-55.00; y=30.00/40.00; z=0.0/100...
    Fetched_uri:               http://www.ifremer.fr/erddap/tabledap/ArgoFloa...

You can simply reverse this transformation with the argopy.argo.profile2point():

[5]:
ds = ds_profiles.argo.profile2point()
print(ds)
<xarray.Dataset>
Dimensions:          (N_POINTS: 524)
Coordinates:
  * N_POINTS         (N_POINTS) int64 0 1 2 3 4 5 6 ... 518 519 520 521 522 523
    TIME             (N_POINTS) datetime64[ns] 2011-01-02T11:14:06 ... 2011-01-14T01:05:21
    LONGITUDE        (N_POINTS) float64 -66.77 -66.77 -66.77 ... -64.59 -64.59
    LATITUDE         (N_POINTS) float64 37.28 37.28 37.28 ... 33.07 33.07 33.07
Data variables:
    CYCLE_NUMBER     (N_POINTS) int64 150 150 150 150 150 150 ... 13 13 13 13 13
    DATA_MODE        (N_POINTS) <U1 'D' 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D' 'D'
    DIRECTION        (N_POINTS) <U1 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER  (N_POINTS) int64 4900803 4900803 ... 5903377 5903377
    POSITION_QC      (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    PRES             (N_POINTS) float64 5.0 10.0 15.0 20.0 ... 95.97 97.97 99.97
    PRES_QC          (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    PSAL             (N_POINTS) float64 36.67 36.67 36.67 ... 36.67 36.67 36.67
    PSAL_QC          (N_POINTS) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1
    TEMP             (N_POINTS) float64 19.46 19.47 19.47 ... 19.2 19.2 19.2
    TEMP_QC          (N_POINTS) int64 1 1 1 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 1 1 1
Attributes:
    cdm_altitude_proxy:        pres
    cdm_data_type:             TrajectoryProfile
    cdm_profile_variables:     cycle_number, data_type, format_version, handb...
    cdm_trajectory_variables:  platform_number, project_name, pi_name, platfo...
    Conventions:               Argo-3.1, CF-1.6, COARDS, ACDD-1.3
    creator_email:             support@argo.net
    creator_name:              Argo
    creator_url:               http://www.argo.net/
    Easternmost_Easting:       -56.578
    featureType:               TrajectoryProfile
    geospatial_lat_max:        37.28
    geospatial_lat_min:        30.082
    geospatial_lat_units:      degrees_north
    geospatial_lon_max:        -56.578
    geospatial_lon_min:        -73.343
    geospatial_lon_units:      degrees_east
    history:                   2020-06-24T18:00:48Z (local files)\n2020-06-24...
    id:                        ArgoFloats
    infoUrl:                   http://www.argo.net/
    institution:               Argo
    keywords:                  adjusted, argo, array, assembly, best, centre,...
    keywords_vocabulary:       GCMD Science Keywords
    license:                   The data may be used and redistributed for fre...
    Northernmost_Northing:     37.28
    references:                http://www.argodatamgt.org/Documentation
    source:                    Argo float
    sourceUrl:                 (local files)
    Southernmost_Northing:     30.082
    standard_name_vocabulary:  CF Standard Name Table v29
    summary:                   Argo float vertical profiles from Coriolis Glo...
    time_coverage_end:         2011-01-14T01:05:21Z
    time_coverage_start:       2011-01-02T11:14:06Z
    title:                     Argo Float Measurements
    user_manual_version:       3.1
    Westernmost_Easting:       -73.343
    DATA_ID:                   ARGO
    DOI:                       http://doi.org/10.17882/42182
    Fetched_from:              http://www.ifremer.fr/erddap
    Fetched_by:                docs
    Fetched_date:              2020/06/24
    Fetched_constraints:       phy_[x=-75.00/-55.00; y=30.00/40.00; z=0.0/100...
    Fetched_uri:               http://www.ifremer.fr/erddap/tabledap/ArgoFloa...

Interpolation to standard levels

Once your dataset is a collection of vertical profiles, you can interpolate variables on standard pressure levels using argopy.xarray.ArgoAccessor.interp_std_levels() with your levels as input :

[6]:
ds_interp = ds_profiles.argo.interp_std_levels([0,10,20,30,40,50])
print(ds_interp)
<xarray.Dataset>
Dimensions:            (N_PROF: 18, PRES_INTERPOLATED: 6)
Coordinates:
    TIME               (N_PROF) datetime64[ns] 2011-01-02T11:14:06 ... 2011-01-14T01:05:21
    LONGITUDE          (N_PROF) float64 -66.77 -71.17 -64.93 ... -72.75 -64.59
  * PRES_INTERPOLATED  (PRES_INTERPOLATED) int64 0 10 20 30 40 50
    LATITUDE           (N_PROF) float64 37.28 33.98 32.88 ... 37.03 34.39 33.07
  * N_PROF             (N_PROF) int64 7 13 15 0 6 2 9 4 ... 1 12 10 17 3 8 14 16
Data variables:
    CYCLE_NUMBER       (N_PROF) float64 150.0 3.0 11.0 100.0 ... 151.0 4.0 13.0
    DATA_MODE          (N_PROF) object 'D' 'D' 'D' 'D' 'D' ... 'D' 'D' 'D' 'D'
    DIRECTION          (N_PROF) object 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    PLATFORM_NUMBER    (N_PROF) float64 4.901e+06 4.901e+06 ... 5.903e+06
    PRES               (N_PROF, PRES_INTERPOLATED) float64 5.0 10.0 ... 50.0
    PSAL               (N_PROF, PRES_INTERPOLATED) float64 36.67 36.67 ... 36.68
    TEMP               (N_PROF, PRES_INTERPOLATED) float64 19.46 19.47 ... 19.24
Attributes:
    cdm_altitude_proxy:        pres
    cdm_data_type:             TrajectoryProfile
    cdm_profile_variables:     cycle_number, data_type, format_version, handb...
    cdm_trajectory_variables:  platform_number, project_name, pi_name, platfo...
    Conventions:               Argo-3.1, CF-1.6, COARDS, ACDD-1.3
    creator_email:             support@argo.net
    creator_name:              Argo
    creator_url:               http://www.argo.net/
    Easternmost_Easting:       -56.578
    featureType:               TrajectoryProfile
    geospatial_lat_max:        37.28
    geospatial_lat_min:        30.082
    geospatial_lat_units:      degrees_north
    geospatial_lon_max:        -56.578
    geospatial_lon_min:        -73.343
    geospatial_lon_units:      degrees_east
    history:                   2020-06-24T18:00:48Z (local files)\n2020-06-24...
    id:                        ArgoFloats
    infoUrl:                   http://www.argo.net/
    institution:               Argo
    keywords:                  adjusted, argo, array, assembly, best, centre,...
    keywords_vocabulary:       GCMD Science Keywords
    license:                   The data may be used and redistributed for fre...
    Northernmost_Northing:     37.28
    references:                http://www.argodatamgt.org/Documentation
    source:                    Argo float
    sourceUrl:                 (local files)
    Southernmost_Northing:     30.082
    standard_name_vocabulary:  CF Standard Name Table v29
    summary:                   Argo float vertical profiles from Coriolis Glo...
    time_coverage_end:         2011-01-14T01:05:21Z
    time_coverage_start:       2011-01-02T11:14:06Z
    title:                     Argo Float Measurements
    user_manual_version:       3.1
    Westernmost_Easting:       -73.343
    DATA_ID:                   ARGO
    DOI:                       http://doi.org/10.17882/42182
    Fetched_from:              http://www.ifremer.fr/erddap
    Fetched_by:                docs
    Fetched_date:              2020/06/24
    Fetched_constraints:       phy_[x=-75.00/-55.00; y=30.00/40.00; z=0.0/100...
    Fetched_uri:               http://www.ifremer.fr/erddap/tabledap/ArgoFloa...

Filters

If you fetched data with the expert mode, you may want to use filters to help you curate the data.

[To be added]

Data models

By default argopy works with xarray.DataSet and comes with the xarray.Dataset accessor namespace argo.

For your own analysis, you may prefer to work with a Pandas dataframe.

[7]:
df = ArgoDataFetcher().profile(6902746, 34).to_dataframe()
df
[7]:
CYCLE_NUMBER DATA_MODE DIRECTION PLATFORM_NUMBER POSITION_QC PRES PRES_QC PSAL PSAL_QC TEMP TEMP_QC TIME_QC LONGITUDE TIME LATITUDE
N_POINTS
0 34 D A 6902746 1 3.0 1 36.262001 1 27.212000 1 1 -58.119 2017-12-20 06:58:00 18.983
1 34 D A 6902746 1 4.0 1 36.262001 1 27.212000 1 1 -58.119 2017-12-20 06:58:00 18.983
2 34 D A 6902746 1 5.0 1 36.263000 1 27.212999 1 1 -58.119 2017-12-20 06:58:00 18.983
3 34 D A 6902746 1 6.0 1 36.262001 1 27.212000 1 1 -58.119 2017-12-20 06:58:00 18.983
4 34 D A 6902746 1 7.0 1 36.262001 1 27.214001 1 1 -58.119 2017-12-20 06:58:00 18.983
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
104 34 D A 6902746 1 1913.0 1 34.976002 1 3.710000 1 1 -58.119 2017-12-20 06:58:00 18.983
105 34 D A 6902746 1 1938.0 1 34.980999 1 3.718000 1 1 -58.119 2017-12-20 06:58:00 18.983
106 34 D A 6902746 1 1964.0 1 34.984001 1 3.698000 1 1 -58.119 2017-12-20 06:58:00 18.983
107 34 D A 6902746 1 1988.0 1 34.983002 1 3.668000 1 1 -58.119 2017-12-20 06:58:00 18.983
108 34 D A 6902746 1 2007.0 1 34.983002 1 3.644000 1 1 -58.119 2017-12-20 06:58:00 18.983

109 rows × 15 columns

but keep in mind that this is merely a short cut for the xarray.Dataset.to_dataframe() method.

Data saving

Once you have your Argo data as xarray.Dataset, simply use the awesome possibilities of xarray like xarray.Dataset.to_netcdf() or xarray.Dataset.to_zarr().