This notebook shows how to:
from argopy import ArgoIndex # This is the class to work with Argo index content
from argopy import ArgoNVSReferenceTables # This is the class to retrieve data from Argo reference tables
from argopy import ArgoColors # This is a class with usefull pre-defined colors
from argopy.plot import scatter_map # This is a function to easily make maps
import numpy as np
from matplotlib import pyplot as plt
/Users/gmaze/miniconda3/envs/argopy-docs/lib/python3.8/site-packages/pyproj/__init__.py:89: UserWarning: pyproj unable to set database path. _pyproj_global_context_initialize()
idx = ArgoIndex(index_file='bgc-b').load() # 'bgc-b' is a shortcut for 'argo_bio-profile_index.txt'
idx
<argoindex.pyarrow> Host: https://data-argo.ifremer.fr Index: argo_bio-profile_index.txt Convention: argo_bio-profile_index (Bio-Profile directory file of the Argo GDAC) Loaded: True (289254 records) Searched: False
param = 'BBP700'
# Get more verbose information about this parameter (usefull for plot titles):
reftbl = ArgoNVSReferenceTables().tbl('R03')
param_info = reftbl[reftbl['altLabel']==param].iloc[0]
param_info
altLabel BBP700 prefLabel Particle backscattering at 700 nanometers definition Particle backscattering (/m) at 700 nm wavelen... deprecated false id http://vocab.nerc.ac.uk/collection/R03/current... Name: 3, dtype: object
# List of all possible data mode values
# a blank string is where no data mode is found (parameter exists but data mode is empty)
# an empty string is for profiles without the parameter
dm_values = ['R', 'A', 'D', ' ', '']
# Make a census of profiles in each of possible data modes for this parameter:
n, N = [], {}
for dm in dm_values:
n_match = idx.search_parameter_data_mode({param: dm}).N_MATCH
n.append(n_match), N.update({dm: n_match})
# Census result
N
{'R': 64360, 'A': 34992, 'D': 17529, ' ': 0, '': 172373}
# Check that the census is correct:
# Number of profiles with this PARAMETER vs decomposition by data mode:
assert idx.search_params(param).N_MATCH == np.sum(n[0:-1])
# Number of index profiles vs all expected data modes:
assert idx.N_RECORDS == np.sum(n)
pf = lambda n: "{:,}".format(n)
autopct = lambda v: "%0.0f%%" % v
x = N.copy()
x.pop('')
if x[' '] == 0:
x.pop(' ')
labels = ["%s (%s profiles)" % (k, pf(x[k])) for k in x.keys()]
fix, ax = plt.subplots()
ax.pie(x.values(),
labels=labels,
autopct=autopct,
colors=ArgoColors('data_mode').lookup.values(),
textprops=dict(weight="bold")
);
ax.set_title("Data mode for '%s' (%s)\n%s profiles from the %s" % (param_info['prefLabel'],
param,
pf(idx.search_params(param).N_MATCH),
idx.convention_title)
);