Hands-on Creta 01

Hands-on Creta 01#

Accessing all profiles at once#

Example used during the in person training during the Euro-Argo Science Meeting celebrated on 23-25 September 2025, in the HCMR, Hellenic Centre for Marine Research premises in Crete, Greece

For this examples it is requires to have downloaded the full version of the Argo Global Data Assembly Centre (Argo GDAC) snapshot from september 2025 DOI 10.17882/42182

Conveniently, all the core mission profiles are compacted in a single file, named: <FloatWmoID>_prof.nc. However, some information is only in the individual profile files, but we will see it.

import numpy as np
import xarray as xr
import netCDF4
from matplotlib import pyplot as plt
%matplotlib inline
prof  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/6903296/6903296_prof.nc',decode_timedelta=False)
Rtraj  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/6903296/6903296_Rtraj.nc',decode_timedelta=False)
prof  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/3902474/3902474_prof.nc',decode_timedelta=False)
Rtraj  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/3902474/3902474_Rtraj.nc',decode_timedelta=False)
prof  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/6903297/6903297_prof.nc',decode_timedelta=False)
Rtraj  = xr.open_dataset('../../Data/202509-ArgoData/dac/coriolis/6903297/6903297_Rtraj.nc',decode_timedelta=False)
#prof  = xr.open_dataset('../../Data/6903296/6903296_prof.nc')

Let’s visualize all the salinity observations, a first a quick-look

fig , ax = plt.subplots(figsize=(10,10))
ax.contourf(prof.PSAL);
../../_images/c01ce2d2894c0aa312ebdbd7a27e742e345072977cab5114a8f61435334a95fd.png
prei=np.arange(5,1005,5) # we define a common set of pressure values:

We define the new vectors

juld=prof.JULD.values
psal=prof.PSAL.values
temp=prof.TEMP.values
pres=prof.PRES.values

psali= np.zeros((juld.shape[0],prei.shape[0]))
psali.fill(np.nan)

tempi= np.zeros((juld.shape[0],prei.shape[0]))
tempi.fill(np.nan)

and then we interpolate the salinity and the temperature onto the new levels:

for ip in range(0,pres.shape[0]-1):
    psali[ip,:]=np.interp(prei,pres[ip,:],psal[ip,:])
    tempi[ip,:]=np.interp(prei,pres[ip,:],temp[ip,:])

and let’s plot the time evolution of the saliniy measured by this float. in oceanography we usually call it a section

fig, ax = plt.subplots(figsize=(15,10))

#Draw the contours for the salinity
cs=ax.contourf(juld,prei,psali.transpose(),levels=np.arange(37.5,39.9,0.05),cmap="RdBu_r")

#Draw the contours lines to be labelled
cs2=ax.contour(juld,prei,psali.transpose(),colors=('k'), levels=cs.levels[::4])

#Since pressure increase away from the surface we invert the y-axis
ax.invert_yaxis()
ax.clabel(cs2, fmt='%2.1f', colors='w', fontsize=10)

#Add the titles
ax.set_title(f"Vertical Salinity section for float {prof.PLATFORM_NUMBER[0].astype(str).values}")
ax.set_xlabel(f"{prof.JULD.standard_name}")
ax.set_ylabel(f"{prof.PRES.long_name}")

#Add the colorbar
cbar=fig.colorbar(cs,ax=ax)
../../_images/c4790e4e25da79828726c679d779411d75fd3b89d3dbeaf2b7dea40e90d77010.png

And the same for temperature:

fig, ax = plt.subplots(figsize=(15,10))

cs=ax.contourf(juld,prei,tempi.transpose(),40,cmap="RdBu_r")
cs2=ax.contour(juld,prei,tempi.transpose(),colors=('k'), levels=cs.levels[::4])

ax.invert_yaxis()
ax.clabel(cs2, fmt='%2.1f', colors='w', fontsize=10)

ax.set_title(f"Vertical Temperature section for float {prof.PLATFORM_NUMBER[0].astype(str).values}")
ax.set_xlabel(f"{prof.JULD.standard_name}")
ax.set_ylabel(f"{prof.PRES.long_name}")

cbar=fig.colorbar(cs,ax=ax)
../../_images/9996a524dd064c282dfbdb2c68d345f3a5396bc75d7afee60d9e8becdc1098f2.png

TS-diagram#

In oceanography, temperature-salinity diagrams, sometimes called T-S diagrams, are used to identify water masses. In a T-S diagram, rather than plotting plotting temperatute and salinity as a separate “profile,” with pressure or depth as the vertical coordinate, potential temperature (on the vertical axis) is plotted versus salinity (on the horizontal axis).

This diagrams area very useful since as long as it remains isolated from the surface, where heat or fresh water can be gained or lost, and in the absence of mixing with other water masses, a water parcel’s potential temperature and salinity are conserved. Deep water masses thus retain their T-S characteristics for long periods of time, and can be identified readily on a T-S plot.

In this case we add a colobar bar to show the pressure of each data point.

import seawater as sw
/var/folders/tj/cj2twzcd30jbzn574lsp6phw0000gn/T/ipykernel_2165/1793873256.py:1: UserWarning: The seawater library is deprecated! Please use gsw instead.
  import seawater as sw
#temp=prof.TEMP.values.flatten()
#psal=prof.PSAL.values.flatten()
#pres=prof.PRES.values.flatten()
#ptmp=sw.ptmp(psal, temp, pres, pr=0)

compute potential temperature

temp=prof.TEMP.values
psal=prof.PSAL.values
pres=prof.PRES.values
ptmp= np.zeros((temp.shape[0],temp.shape[1]))
for ip in range(0,temp.shape[0]):
    ptmp[ip,:]=sw.ptmp(psal[ip,:], temp[ip,:], pres[ip,:], pr=0)
fig, ax = plt.subplots(figsize=(10,10))
sc=ax.scatter(psal, ptmp, c=pres,alpha=0.5, cmap="RdBu_r",vmin=0, vmax=1000)
ax.plot(psal[0,:], ptmp[0,:],'k')
ax.plot(psal[-1,:], ptmp[-1,:],'r')
ax.set_title(f"T/S diagram for float {prof.PLATFORM_NUMBER[0].astype(str).values}")
ax.set_ylabel("potential temperature [C]")
ax.set_xlabel(f"{prof.PSAL.long_name}")
cbar=fig.colorbar(sc,extend='both');
cbar.set_label('Pressure [dbar]')
../../_images/111d9d1f80df3b026cebf43b5dd8a9dbe6a21008f421f55192595146ff86a546.png
import cartopy.crs as ccrs
import cartopy
lon=Rtraj.LONGITUDE[~np.isnan(Rtraj.LONGITUDE) & ~np.isnan(Rtraj.LATITUDE)]
lat=Rtraj.LATITUDE[~np.isnan(Rtraj.LONGITUDE) & ~np.isnan(Rtraj.LATITUDE)]

fig,ax = plt.subplots(figsize=(10,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.plot(lon,lat,'-b.',label='Float surfacing')
ax.plot(lon[0],lat[0],'ok',markersize=12,label='Deployment')
ax.plot(lon[-1],lat[-1],'sk',markersize=12,label='Last surfacing')

ax.add_feature(cartopy.feature.LAND.with_scale('10m'))
ax.add_feature(cartopy.feature.COASTLINE.with_scale('10m'), edgecolor='black')

ax.set_title(f"Data from {Rtraj.PLATFORM_NUMBER.values.astype(str)}")
ax.legend()
ax.gridlines(draw_labels=True);
../../_images/dd8fc046f2700305fdade0d88f089b25a3d7c77faf911c389c5cc8644c0e5534.png
Rtraj
<xarray.Dataset> Size: 4MB
Dimensions:                              (N_PARAM: 3, N_MEASUREMENT: 16885,
                                          N_CYCLE: 291, N_CALIB_PARAM: 1,
                                          N_CALIB_JULD: 1, N_HISTORY: 570)
Dimensions without coordinates: N_PARAM, N_MEASUREMENT, N_CYCLE, N_CALIB_PARAM,
                                N_CALIB_JULD, N_HISTORY
Data variables: (12/113)
    DATA_TYPE                            object 8B ...
    FORMAT_VERSION                       object 8B ...
    HANDBOOK_VERSION                     object 8B ...
    REFERENCE_DATE_TIME                  object 8B ...
    DATE_CREATION                        object 8B ...
    DATE_UPDATE                          object 8B ...
    ...                                   ...
    HISTORY_PARAMETER                    (N_HISTORY) object 5kB ...
    HISTORY_PREVIOUS_VALUE               (N_HISTORY) float32 2kB ...
    HISTORY_INDEX_DIMENSION              (N_HISTORY) object 5kB ...
    HISTORY_START_INDEX                  (N_HISTORY) float64 5kB ...
    HISTORY_STOP_INDEX                   (N_HISTORY) float64 5kB ...
    HISTORY_QCTEST                       (N_HISTORY) object 5kB ...
Attributes:
    title:                        Argo float trajectory file
    institution:                  CORIOLIS
    source:                       Argo float
    history:                      2023-03-21T11:02:27Z creation; 2025-09-08T0...
    references:                   http://www.argodatamgt.org/Documentation
    user_manual_version:          3.4
    Conventions:                  Argo-3.2 CF-1.6
    featureType:                  trajectory
    decoder_version:              CODA_079a
    id:                           https://doi.org/10.17882/42182
    comment_on_resolution:        JULD and PRES variable resolutions depend o...
    comment_on_measurement_code:  Meaning of some specific measurement codes ...
lon=Rtraj.LONGITUDE.where(Rtraj.POSITION_QC.values.astype(float) == 1)
lat=Rtraj.LATITUDE.where(Rtraj.POSITION_QC.values.astype(float) == 1)

lon=lon[~np.isnan(lon) & ~np.isnan(Rtraj.LATITUDE)]
lat=lat[~np.isnan(lat) & ~np.isnan(Rtraj.LATITUDE)]

fig,ax = plt.subplots(figsize=(10,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.plot(lon,lat,'-b.',label='Float surfacing')
ax.plot(lon[0],lat[0],'ok',markersize=12,label='Deployment')
ax.plot(lon[-1],lat[-1],'sk',markersize=12,label='Last surfacing')


ax.add_feature(cartopy.feature.LAND.with_scale('10m'))
ax.add_feature(cartopy.feature.COASTLINE.with_scale('10m'), edgecolor='black')

#ax.set_title(f"Data from {Rtraj.PLATFORM_NUMBER.values.astype(str)}")
ax.legend()
ax.gridlines(draw_labels=True);
../../_images/27c01cb2e56292b09e807aaa6944c5d3ce68da6931e1b4d5130a005b3b48623a.png