Data from those floats are automatically downloaded in the repo by a github action, so we can use localftp source from argopy to check the data.
Here we work with argopy (https://argopy.readthedocs.io), so with xarray datasets
author = "kevin.balem@ifremer.fr"
last update: 2022/09/12 by G. Maze
from argopy import DataFetcher as ArgoDataFetcher
import matplotlib.pyplot as plt
import cmocean as cm
from matplotlib.ticker import MaxNLocator
from matplotlib.lines import Line2D
import matplotlib.gridspec as gridspec
from descartes import PolygonPatch
from shapely.geometry import Point
import alphashape
import cartopy.crs as ccrs
plt.rcParams['axes.grid'] = True
import numpy as np
import gsw
import xarray as xr
import pandas as pd
/Users/gmaze/miniconda3/envs/rbr/lib/python3.8/site-packages/pyproj/__init__.py:89: UserWarning: pyproj unable to set database path. _pyproj_global_context_initialize()
wmos = [6903075,6903076]
ArgoSet = ArgoDataFetcher().float(wmos)
ds = ArgoSet.load().data
ArgoSet.plot('trajectory')
(<Figure size 900x540 with 1 Axes>, <GeoAxesSubplot:xlabel='longitude', ylabel='latitude'>)
# GET DATA FROM REPO DATA COPY (cache=False because new profiles are added to the repo)
ds = ArgoDataFetcher(cache=False, src='gdac', mode='expert').float(wmos).to_xarray()
# ds = ArgoDataFetcher(cache=False,src='localftp',local_ftp='/export/home/kbalem/Bureau/earise-rbr/data/floats/ftp',mode='expert').float(wmos).to_xarray()
# CALCULATE TEOS10 VARIABLE
ds.argo.teos10(['SA','SIG0','PTEMP'])
# TURN TO PROFILES
ds = ds.argo.point2profile()
ds0=ds.where(ds['PLATFORM_NUMBER']==wmos[0],drop=True)
ds1=ds.where(ds['PLATFORM_NUMBER']==wmos[1],drop=True)
ds1
<xarray.Dataset> Dimensions: (N_PROF: 64, N_LEVELS: 1027) Coordinates: * N_PROF (N_PROF) int64 0 65 66 67 68 ... 124 125 126 127 * N_LEVELS (N_LEVELS) int64 0 1 2 3 4 ... 1023 1024 1025 1026 TIME (N_PROF) datetime64[ns] 2020-12-11T10:25:00 ...... LATITUDE (N_PROF) float64 29.17 29.15 29.1 ... 28.75 28.05 LONGITUDE (N_PROF) float64 -19.0 -19.02 ... -20.5 -20.3 Data variables: (12/40) CONFIG_MISSION_NUMBER (N_PROF) float64 1.0 1.0 2.0 2.0 ... 3.0 3.0 3.0 CYCLE_NUMBER (N_PROF) float64 1.0 1.0 2.0 ... 61.0 62.0 63.0 DATA_CENTRE (N_PROF) object 'IF' 'IF' 'IF' ... 'IF' 'IF' 'IF' DATA_MODE (N_PROF) object 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' DATA_STATE_INDICATOR (N_PROF) object '2B ' '2B ' ... '2B ' '2B ' DC_REFERENCE (N_PROF) object ' ... ... ... TEMP_ADJUSTED_QC (N_PROF, N_LEVELS) float64 1.0 1.0 ... 1e+05 1e+05 TEMP_QC (N_PROF, N_LEVELS) float64 1.0 1.0 ... 1e+05 1e+05 TIME_LOCATION (N_PROF) datetime64[ns] 2020-12-11T09:26:41 ...... TIME_QC (N_PROF) float64 1.0 1.0 1.0 1.0 ... 1.0 1.0 1.0 VERTICAL_SAMPLING_SCHEME (N_PROF) object 'Primary sampling: averaged [10... WMO_INST_TYPE (N_PROF) float64 878.0 878.0 878.0 ... 878.0 878.0 Attributes: DATA_ID: ARGO DOI: http://doi.org/10.17882/42182 Fetched_from: https://data-argo.ifremer.fr Fetched_by: gmaze Fetched_date: 2022/09/12 Fetched_constraints: phy;WMO6903075;WMO6903076 Fetched_uri: https://data-argo.ifremer.fr/dac/coriolis/6903076/6... history: Transformed with point2profile
def full_profiles(ds0=ds0,ds1=ds1,markersize=1):
fig,ax = plt.subplots(len(wmos),2,figsize=(16,len(wmos)*8),sharey=True)
ax[0,0].invert_yaxis();
ax[0,0].plot(ds0['TEMP'],-gsw.z_from_p(ds0['PRES'],ds0['LATITUDE'].mean()),'.k',markersize=markersize)
ax[0,1].plot(ds0['PSAL'],-gsw.z_from_p(ds0['PRES'],ds0['LATITUDE'].mean()),'.k',markersize=markersize)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[0,0].set_ylabel('Depth',fontsize='large',fontweight='bold')
a=ax[0,1].text(1.05,0.4,'float '+str(wmos[0]),rotation="vertical",transform = ax[0,1].transAxes, fontsize='large', fontweight='bold')
ax[0,0].set_xlabel('Temperature',fontsize='large',fontweight='bold')
ax[0,1].set_xlabel('Salinity',fontsize='large',fontweight='bold')
ax[1,0].plot(ds1['TEMP'],-gsw.z_from_p(ds1['PRES'],ds1['LATITUDE'].mean()),'.k',markersize=markersize)
ax[1,1].plot(ds1['PSAL'],-gsw.z_from_p(ds1['PRES'],ds1['LATITUDE'].mean()),'.k',markersize=markersize)
ax[1,0].set_ylabel('Depth',fontsize='large',fontweight='bold')
a=ax[1,1].text(1.05,0.4,'float '+str(wmos[1]),rotation="vertical",transform = ax[1,1].transAxes, fontsize='large', fontweight='bold')
ax[1,0].set_xlabel('Temperature',fontsize='large',fontweight='bold')
ax[1,1].set_xlabel('Salinity',fontsize='large',fontweight='bold')
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
return fig,ax
fig,ax = full_profiles(ds0=ds0,ds1=ds1)
# TS DIAGRAM
def full_ts(ds0=ds0,ds1=ds1,vmin=25.95,vmax=27.8,sigma=8):
mint=ds['PTEMP'].min()
maxt=ds['PTEMP'].max()
mins=ds['SA'].min()
maxs=ds['SA'].max()
tempL=np.linspace(mint-1,maxt+1,156)
salL=np.linspace(mins-1,maxs+1,156)
Tg, Sg = np.meshgrid(tempL,salL)
sigma_theta = gsw.sigma0(Sg, Tg)
fig,ax=plt.subplots(1,2,figsize=(25,10))
cs = ax[0].contour(Sg, Tg, sigma_theta,sigma, colors='grey', zorder=1)
cl=ax[0].clabel(cs,fontsize=10,inline=False,fmt='%.1f')
sc=ax[0].scatter(ds0['SA'],ds0['PTEMP'],c=ds0['SIG0'],s=10,cmap=cm.cm.matter,vmin=vmin,vmax=vmax)
ax[0].set_xlabel('Salinity ($‰$)')
ax[0].set_ylabel('Temperature[$^\circ$C]')
ax[0].set_title(str(wmos[0]),fontsize=14, fontweight='bold')
ax[0].xaxis.set_major_locator(MaxNLocator(nbins=6))
ax[0].yaxis.set_major_locator(MaxNLocator(nbins=8))
ax[0].tick_params(direction='out')
cs = ax[1].contour(Sg, Tg, sigma_theta, sigma, colors='grey', zorder=1)
cl=ax[1].clabel(cs,fontsize=10,inline=False,fmt='%.1f')
sc=ax[1].scatter(ds1['SA'],ds1['PTEMP'],c=ds1['SIG0'],s=10,cmap=cm.cm.matter,vmin=vmin,vmax=vmax)
ax[1].set_xlabel('Salinity ($‰$)')
ax[1].set_ylabel('Temperature[$^\circ$C]')
ax[1].set_title(str(wmos[1]),fontsize=14, fontweight='bold')
ax[1].xaxis.set_major_locator(MaxNLocator(nbins=6))
ax[1].yaxis.set_major_locator(MaxNLocator(nbins=8))
ax[1].tick_params(direction='out')
cb=plt.colorbar(sc,ax=ax.ravel().tolist())
cb.ax.tick_params(direction='out')
cb.set_label('Density[kg m$^{-3}$]')
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0, label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10)],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0, label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10)],loc='lower right')
return fig,ax
fig,ax = full_ts()
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
# WOA OPENDAP URL FOR 2005-2017, GLOBAL 1/4°
woa_temp='https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncei/woa/temperature/A5B7/0.25/woa18_A5B7_t13_04.nc'
woa_psal='https://www.ncei.noaa.gov/thredds-ocean/dodsC/ncei/woa/salinity/A5B7/0.25/woa18_A5B7_s13_04.nc'
# LOAD DATASETS, No need to decode times for a clim
woat = xr.open_dataset(woa_temp,decode_times=False)
woas = xr.open_dataset(woa_psal,decode_times=False)
# INTERPOLATE WOA T/S/SIG TO FLOAT POSITION
woat_float0 = woat['t_mn'].interp(lat=ds0['LATITUDE'],lon=ds0['LONGITUDE'],method='linear').squeeze().to_dataset()
woas_float0 = woas['s_mn'].interp(lat=ds0['LATITUDE'],lon=ds0['LONGITUDE'],method='linear').squeeze().to_dataset()
woa_float0 = xr.merge([woat_float0,woas_float0])
woat_float1 = woat['t_mn'].interp(lat=ds1['LATITUDE'],lon=ds1['LONGITUDE'],method='linear').squeeze().to_dataset()
woas_float1 = woas['s_mn'].interp(lat=ds1['LATITUDE'],lon=ds1['LONGITUDE'],method='linear').squeeze().to_dataset()
woa_float1 = xr.merge([woat_float1,woas_float1])
# Reduce depth range
woa_float0 = woa_float0.sel(depth=slice(0,2000))
woa_float1 = woa_float1.sel(depth=slice(0,2000))
fig,ax=full_profiles()
ax[0,0].plot(woa_float0['t_mn'],woa_float0['depth'],'.r',markersize=4)
ax[0,1].plot(woa_float0['s_mn'],woa_float0['depth'],'.r',markersize=4)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='WOA ',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[1,0].plot(woa_float1['t_mn'],woa_float1['depth'],'.r',linewidth=1)
ax[1,1].plot(woa_float1['s_mn'],woa_float1['depth'],'.r')
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='WOA ',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
<matplotlib.legend.Legend at 0x16f44baf0>
# ZOOM
fig,ax=full_profiles(markersize=4)
ax[0,0].set_ylim(2000,1500)
ax[0,0].plot(woa_float0['t_mn'],woa_float0['depth'],'.r',markersize=8)
ax[0,1].plot(woa_float0['s_mn'],woa_float0['depth'],'.r',markersize=8)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='WOA ',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[1,0].plot(woa_float1['t_mn'],woa_float1['depth'],'.r',linewidth=1)
ax[1,1].plot(woa_float1['s_mn'],woa_float1['depth'],'.r')
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='WOA ',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[0,0].set_xlim(4,6.5); ax[1,0].set_xlim(4,6.5);
ax[0,1].set_xlim(35.,35.5); ax[1,1].set_xlim(35.,35.5);
# GSW
pr0 = np.empty([len(woa_float0['depth']),len(woa_float0['N_PROF'])])
pr1 = np.empty([len(woa_float1['depth']),len(woa_float1['N_PROF'])])
for i in range(len(woa_float0['N_PROF'])):
pr0[:,i]=gsw.p_from_z(-woa_float0['depth'],woa_float0['LATITUDE'].isel(N_PROF=i))
woa_float0['PRES']=xr.DataArray(pr0,dims=['depth','N_PROF'])
woa_float0['SA']=xr.DataArray(gsw.SA_from_SP(woa_float0['s_mn'],woa_float0['PRES'],woa_float0['LONGITUDE'],woa_float0['LATITUDE']),dims=['depth','N_PROF'])
woa_float0['PTEMP']=xr.DataArray(gsw.pt0_from_t(woa_float0['SA'],woa_float0['t_mn'],woa_float0['PRES']),dims=['depth','N_PROF'])
woa_float0['SIG0']=xr.DataArray(gsw.sigma0(woa_float0['SA'], woa_float0['PTEMP']),dims=['depth','N_PROF'])
for i in range(len(woa_float1['N_PROF'])):
pr0[:,i]=gsw.p_from_z(-woa_float1['depth'],woa_float1['LATITUDE'].isel(N_PROF=i))
woa_float1['PRES']=xr.DataArray(pr0,dims=['depth','N_PROF'])
woa_float1['SA']=xr.DataArray(gsw.SA_from_SP(woa_float1['s_mn'],woa_float1['PRES'],woa_float1['LONGITUDE'],woa_float1['LATITUDE']),dims=['depth','N_PROF'])
woa_float1['PTEMP']=xr.DataArray(gsw.pt0_from_t(woa_float1['SA'],woa_float1['t_mn'],woa_float1['PRES']),dims=['depth','N_PROF'])
woa_float1['SIG0']=xr.DataArray(gsw.sigma0(woa_float1['SA'], woa_float1['PTEMP']),dims=['depth','N_PROF'])
woa_float1
<xarray.Dataset> Dimensions: (depth: 67, N_PROF: 64) Coordinates: * depth (depth) float32 0.0 5.0 10.0 15.0 ... 1.9e+03 1.95e+03 2e+03 * N_PROF (N_PROF) int64 0 65 66 67 68 69 70 ... 122 123 124 125 126 127 time float32 73.5 lat (N_PROF) float64 29.17 29.15 29.1 29.09 ... 29.05 28.75 28.05 lon (N_PROF) float64 -19.0 -19.02 -19.12 ... -20.94 -20.5 -20.3 TIME (N_PROF) datetime64[ns] 2020-12-11T10:25:00 ... 2022-08-25T06:... LATITUDE (N_PROF) float64 29.17 29.15 29.1 29.09 ... 29.05 28.75 28.05 LONGITUDE (N_PROF) float64 -19.0 -19.02 -19.12 ... -20.94 -20.5 -20.3 Data variables: t_mn (depth, N_PROF) float64 nan nan nan nan nan ... nan nan nan nan s_mn (depth, N_PROF) float64 36.85 36.85 nan nan ... nan nan nan nan PRES (depth, N_PROF) float64 0.0 0.0 0.0 ... 2.023e+03 2.023e+03 SA (depth, N_PROF) float64 37.02 37.02 nan nan ... nan nan nan nan PTEMP (depth, N_PROF) float64 nan nan nan nan nan ... nan nan nan nan SIG0 (depth, N_PROF) float64 nan nan nan nan nan ... nan nan nan nan
# TS DIAGRAM
fig,ax = full_ts()
sc_b=ax[0].scatter(woa_float0['SA'],woa_float0['PTEMP'],c=woa_float0['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k')
sc_b=ax[1].scatter(woa_float1['SA'],woa_float1['PTEMP'],c=woa_float1['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k')
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='WOA',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='WOA',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x178ef4d00>
# ZOOM
fig,ax = full_ts(vmin=27.8,vmax=27.9,sigma=40)
ax[0].set_ylim(4,7.5); ax[1].set_ylim(4,7.5)
ax[0].set_xlim(35.2,35.6); ax[1].set_xlim(35.2,35.6)
sc_b=ax[0].scatter(woa_float0['SA'],woa_float0['PTEMP'],c=woa_float0['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k')
sc_b=ax[1].scatter(woa_float1['SA'],woa_float1['PTEMP'],c=woa_float1['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k')
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='WOA',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='WOA',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x1705162e0>
points = list(zip(ds['LONGITUDE'].values,ds['LATITUDE'].values))
alpha_shape = alphashape.alphashape(points, 0.9)
#alpha_shape
fig, ax = plt.subplots()
ax.scatter(*zip(*points))
ax.add_patch(PolygonPatch(alpha_shape, alpha=0.3))
plt.show()
/Users/gmaze/miniconda3/envs/rbr/lib/python3.8/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. vertices = concatenate([
#GET NEARBY ARGO PROFILES
px = ArgoDataFetcher(cache=False,src='erddap',mode='standard').region([-28.0,-18.0,28.0,30.8,0.,2000.,'2020-01-01','2022-04-01']).load().data
# CALCULATE TEOS10 VARIABLE
px.argo.teos10(['SA','SIG0','PTEMP'])
# TURN TO PROFILES
px = px.argo.point2profile()
inalphashape = [alpha_shape.contains(Point(px['LONGITUDE'].values[i],px['LATITUDE'].values[i])) for i in range(len(px['N_PROF']))]
px = px.sel(N_PROF = px['N_PROF'][inalphashape])
px
<xarray.Dataset> Dimensions: (N_PROF: 175, N_LEVELS: 1018) Coordinates: * N_PROF (N_PROF) int64 64 4 65 5 66 ... 291 175 292 244 176 * N_LEVELS (N_LEVELS) int64 0 1 2 3 4 ... 1014 1015 1016 1017 LATITUDE (N_PROF) float64 28.64 29.51 28.56 ... 29.28 28.35 LONGITUDE (N_PROF) float64 -20.47 -23.2 ... -24.53 -21.11 TIME (N_PROF) datetime64[ns] 2020-01-08T05:11:00 ... 20... Data variables: (12/16) CONFIG_MISSION_NUMBER (N_PROF) int32 2 3 2 3 2 2 2 2 2 ... 2 4 2 2 4 2 2 4 CYCLE_NUMBER (N_PROF) int32 59 50 60 51 61 ... 47 183 48 48 184 DATA_MODE (N_PROF) <U1 'D' 'D' 'D' 'D' 'D' ... 'A' 'A' 'A' 'A' DIRECTION (N_PROF) <U1 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' PLATFORM_NUMBER (N_PROF) int32 6901258 3901989 ... 6903075 6902768 POSITION_QC (N_PROF) int32 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 ... ... PTEMP (N_PROF, N_LEVELS) float64 20.23 20.23 ... nan nan SA (N_PROF, N_LEVELS) float64 37.07 37.07 ... nan nan SIG0 (N_PROF, N_LEVELS) float64 26.15 26.15 ... nan nan TEMP (N_PROF, N_LEVELS) float32 20.23 20.24 ... nan nan TEMP_QC (N_PROF) int32 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 TIME_QC (N_PROF) int32 1 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://erddap.ifremer.fr/erddap Fetched_by: gmaze Fetched_date: 2022/09/12 Fetched_constraints: [x=-28.00/-18.00; y=28.00/30.80; z=0.0/2000.0; t=20... Fetched_uri: ['https://erddap.ifremer.fr/erddap/tabledap/ArgoFlo... history: Variables filtered according to DATA_MODE; Variable...
plt.figure()
# FETCH PROFILES META IN OUR REGION
plt.plot(px['LONGITUDE'],px['LATITUDE'],'k.',markersize=10)
# RBR PROFILES
plt.plot(ds['LONGITUDE'],ds['LATITUDE'],'r*',markersize=10)
[<matplotlib.lines.Line2D at 0x1771d0070>]
ds0b=ds0 #.isel(N_PROF=[0,1,2,3,4,5,6,7,8])
ds1b=ds1 #.isel(N_PROF=[0,1,2,3,4,5,6,7,8])
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b)
ax[0,0].plot(px['TEMP'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=0.5,zorder=0)
ax[0,1].plot(px['PSAL'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=0.5,zorder=0)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Nearby profiles',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[1,0].plot(px['TEMP'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=0.5,zorder=0)
ax[1,1].plot(px['PSAL'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=0.5,zorder=0)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Nearby profiles',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
<matplotlib.legend.Legend at 0x17c1fd6a0>
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b,markersize=4)
ax[0,0].set_ylim(2000,1500)
ax[0,0].plot(px['TEMP'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=4,zorder=0)
ax[0,1].plot(px['PSAL'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=4,zorder=0)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Nearby profiles',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[1,0].plot(px['TEMP'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=4,zorder=0)
ax[1,1].plot(px['PSAL'],-gsw.z_from_p(px['PRES'],px['LATITUDE'].mean()),'.r',markersize=4,zorder=0)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='RBR Floats',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Nearby profiles',markerfacecolor='r', markersize=10),
],loc='upper right', bbox_to_anchor=(1.3, 1))
ax[0,0].set_xlim(4,6.5); ax[1,0].set_xlim(4,6.5);
ax[0,1].set_xlim(35.,35.5); ax[1,1].set_xlim(35.,35.5);
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b)
sc_b=ax[0].scatter(px['SA'],px['PTEMP'],c=px['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',zorder=0)
sc_b=ax[1].scatter(px['SA'],px['PTEMP'],c=px['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',zorder=0)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Nearby profiles',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Nearby profiles',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x1834e8dc0>
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b,vmin=27.8,vmax=27.9,sigma=40)
ax[0].set_ylim(4,7.5); ax[1].set_ylim(4,7.5)
ax[0].set_xlim(35.2,35.6); ax[1].set_xlim(35.2,35.6)
sc_b=ax[0].scatter(px['SA'],px['PTEMP'],c=px['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',zorder=0)
sc_b=ax[1].scatter(px['SA'],px['PTEMP'],c=px['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',zorder=0)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Nearby profiles',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Nearby profiles',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x186ef6310>
st25=pd.read_csv('../data/ref/RAPROCAN2012/Station25.csv',header=4,sep=';',names=['PRES','PSAL','TEMP'])
mt25={'latitude':29.17,'longitude':-19.00,'time':np.datetime64('2020-12-10T17:41:05')}
# st25['SA'] = gsw.SA_from_SP(st25['PSAL'],st25['PRES'],mt25['longitude'],mt25['latitude'])
st25['SA'] = gsw.SA_from_SP(st25['PSAL'].values, st25['PRES'].values, np.full_like(st25['PSAL'], mt25['longitude']), np.full_like(st25['PSAL'], mt25['latitude']))
st25['PTEMP'] = gsw.pt0_from_t(st25['SA'],st25['TEMP'],st25['PRES'])
st25['SIG0'] = gsw.sigma0(st25['SA'], st25['PTEMP'])
st25.head()
PRES | PSAL | TEMP | SA | PTEMP | SIG0 | |
---|---|---|---|---|---|---|
0 | 8.0 | 36.9540 | 21.3449 | 37.128475 | 21.343339 | 25.870281 |
1 | 10.0 | 36.9541 | 21.3478 | 37.128578 | 21.345849 | 25.869658 |
2 | 12.0 | 36.9539 | 21.3508 | 37.128373 | 21.348458 | 25.868777 |
3 | 14.0 | 36.9539 | 21.3484 | 37.128369 | 21.345668 | 25.869552 |
4 | 16.0 | 36.9543 | 21.3442 | 37.128767 | 21.341078 | 25.871130 |
# LET's KEEP ONLY THE 1st PROFILES
ds0b=ds0.isel(N_PROF=[0,1,2,3])
ds1b=ds1.isel(N_PROF=[0,1,2,3])
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b)
ax[0,0].set_ylim([2000,0]);
ax[0,0].plot(st25['TEMP'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=1)
ax[0,1].plot(st25['PSAL'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=1)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Station 25 - RAPROCAN2012 ',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[1,0].plot(st25['TEMP'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=1)
ax[1,1].plot(st25['PSAL'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=1)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Station 25 - RAPROCAN2012 ',markerfacecolor='r', markersize=10),
],loc='lower right')
<matplotlib.legend.Legend at 0x182abafa0>
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b,markersize=4)
ax[0,0].set_ylim([2000,1500]);
ax[0,0].plot(st25['TEMP'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=4)
ax[0,1].plot(st25['PSAL'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=4)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Station 25 - RAPROCAN2012 ',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[1,0].plot(st25['TEMP'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=4)
ax[1,1].plot(st25['PSAL'],-gsw.z_from_p(st25['PRES'],mt25['latitude']),'.r',markersize=4)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='Station 25 - RAPROCAN2012 ',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[0,0].set_xlim(4,6.5); ax[1,0].set_xlim(4,6.5);
ax[0,1].set_xlim(35.,35.5); ax[1,1].set_xlim(35.,35.5);
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b)
sc_b=ax[0].scatter(st25['SA'],st25['PTEMP'],c=st25['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',linewidths=0.5)
sc_b=ax[1].scatter(st25['SA'],st25['PTEMP'],c=st25['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',linewidths=0.5)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Station 25 - RAPROCAN2012',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Station 25 - RAPROCAN2012',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x18eea9a60>
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b,vmin=27.8,vmax=27.9,sigma=40)
ax[0].set_ylim(4,7.5); ax[1].set_ylim(4,7.5)
ax[0].set_xlim(35.2,35.6); ax[1].set_xlim(35.2,35.6)
sc_b=ax[0].scatter(st25['SA'],st25['PTEMP'],c=st25['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',linewidths=0.5)
sc_b=ax[1].scatter(st25['SA'],st25['PTEMP'],c=st25['SIG0'],s=20,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',linewidths=0.5)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Station 25 - RAPROCAN2012',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='Station 25 - RAPROCAN2012',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x18e0beac0>
# GET DATA FROM REPO DATA COPY (cache=False because new profiles are added to the repo)
dsbe = ArgoDataFetcher(cache=False,src='gdac',mode='expert').float(6903010).to_xarray()
# dsbe = ArgoDataFetcher(cache=False,src='localftp',local_ftp='/export/home/kbalem/Bureau/earise-rbr/data/floats/ftp',mode='expert').float(6903010).to_xarray()
# CALCULATE TEOS10 VARIABLE
dsbe.argo.teos10(['SA','SIG0','PTEMP'])
# TURN TO PROFILES
dsbe = dsbe.argo.point2profile()
dsbe
<xarray.Dataset> Dimensions: (N_PROF: 64, N_LEVELS: 1022) Coordinates: * N_PROF (N_PROF) int64 0 1 2 3 4 5 6 ... 58 59 60 61 62 63 * N_LEVELS (N_LEVELS) int64 0 1 2 3 4 ... 1018 1019 1020 1021 TIME (N_PROF) datetime64[ns] 2020-12-10T18:26:00 ...... LATITUDE (N_PROF) float64 29.17 29.15 29.13 ... 25.96 25.93 LONGITUDE (N_PROF) float64 -19.01 -19.0 ... -17.52 -17.59 Data variables: (12/40) CONFIG_MISSION_NUMBER (N_PROF) int32 1 1 2 2 2 2 2 2 ... 2 2 2 3 3 3 3 3 CYCLE_NUMBER (N_PROF) int32 1 1 2 3 4 5 6 ... 58 59 60 61 62 63 DATA_CENTRE (N_PROF) <U2 'IF' 'IF' 'IF' ... 'IF' 'IF' 'IF' DATA_MODE (N_PROF) <U1 'R' 'R' 'R' 'R' ... 'R' 'R' 'R' 'R' DATA_STATE_INDICATOR (N_PROF) <U4 '2B ' '2B ' ... '2B ' '2B ' DC_REFERENCE (N_PROF) <U32 ' ... ... ... TEMP_ADJUSTED_QC (N_PROF) int32 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 TEMP_QC (N_PROF, N_LEVELS) int32 1 1 1 ... 99999 99999 TIME_LOCATION (N_PROF) datetime64[ns] 2020-12-10T17:27:19 ...... TIME_QC (N_PROF) int32 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 VERTICAL_SAMPLING_SCHEME (N_PROF) <U256 'Primary sampling: averaged [10 ... WMO_INST_TYPE (N_PROF) int32 844 844 844 844 ... 844 844 844 844 Attributes: DATA_ID: ARGO DOI: http://doi.org/10.17882/42182 Fetched_from: https://data-argo.ifremer.fr Fetched_by: gmaze Fetched_date: 2022/09/12 Fetched_constraints: phy;WMO6903010 Fetched_uri: https://data-argo.ifremer.fr/dac/coriolis/6903010/6... history: Transformed with point2profile
fig=plt.figure(figsize=(10,6))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
plt.plot(dsbe['LONGITUDE'],dsbe['LATITUDE'],'ro-',label='SBE 6903010')
plt.plot(ds0['LONGITUDE'],ds0['LATITUDE'],'bo-',label='RBR 6903075')
plt.plot(ds1['LONGITUDE'],ds1['LATITUDE'],'go-',label='RBR 6903076')
#plt.xlim([-19.3,-18.9])
#plt.ylim([29,29.2])
plt.legend()
<matplotlib.legend.Legend at 0x19935bc40>
We'll plot only until CYCLE 10, after that profiles positions differ too much
ds0b=ds0.isel(N_PROF=[0,1,2,3,4,5,6,7,8,9])
ds1b=ds1.isel(N_PROF=[0,1,2,3,4,5,6,7,8,9])
dsbe0=dsbe.isel(N_PROF=[0,1,2,3,4,5,6,7,8,9])
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b)
ax[0,0].plot(dsbe0['TEMP'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=0.5)
ax[0,1].plot(dsbe0['PSAL'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=0.5)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='SBE Float 6903010',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[1,0].plot(dsbe0['TEMP'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=0.5)
ax[1,1].plot(dsbe0['PSAL'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=0.5)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='SBE Float 6903010',markerfacecolor='r', markersize=10),
],loc='lower right')
<matplotlib.legend.Legend at 0x1911dc0d0>
# ZOOM
fig,ax = full_profiles(ds0=ds0b,ds1=ds1b,markersize=4)
ax[0,0].set_ylim([2000,1500]);
ax[0,0].plot(dsbe0['TEMP'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=4)
ax[0,1].plot(dsbe0['PSAL'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=4)
ax[0,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='SBE Float 6903010',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[1,0].plot(dsbe0['TEMP'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=4)
ax[1,1].plot(dsbe0['PSAL'],-gsw.z_from_p(dsbe0['PRES'],dsbe0['LATITUDE'].mean()),'.r',markersize=4)
ax[1,1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='k', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label='SBE Float 6903010',markerfacecolor='r', markersize=10),
],loc='lower right')
ax[0,0].set_xlim(4,6.5); ax[1,0].set_xlim(4,6.5);
ax[0,1].set_xlim(35.,35.5); ax[1,1].set_xlim(35.,35.5);
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b)
sc_b=ax[0].scatter(dsbe0['SA'],dsbe0['PTEMP'],c=dsbe0['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',linewidths=0.5)
sc_b=ax[1].scatter(dsbe0['SA'],dsbe0['PTEMP'],c=dsbe0['SIG0'],s=20,cmap=cm.cm.matter,marker='o',edgecolor='k',linewidths=0.5)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='SBE Float 6903010',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='SBE Float 6903010',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x192cb20d0>
# TS DIAGRAM
fig,ax = full_ts(ds0=ds0b,ds1=ds1b,vmin=27.8,vmax=27.9,sigma=40)
ax[0].set_ylim(4,7.5); ax[1].set_ylim(4,7.5)
ax[0].set_xlim(35.2,35.6); ax[1].set_xlim(35.2,35.6)
sc_b=ax[0].scatter(ds1b['SA'],ds1b['PTEMP'],c=ds1b['SIG0'],s=10,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',linewidths=0.5)
sc_b=ax[1].scatter(ds1b['SA'],ds1b['PTEMP'],c=ds1b['SIG0'],s=10,cmap=cm.cm.matter,vmin=27.8,vmax=27.9,marker='o',edgecolor='k',linewidths=0.5)
ax[0].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[0])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='SBE Float 6903010',markerfacecolor='orange', markersize=10),
],loc='lower right')
ax[1].legend(handles=[Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=0,
label=str(wmos[1])+' Float',markerfacecolor='orange', markersize=10),
Line2D([0], [0], marker='o', linewidth=0, markeredgewidth=1, color='k',
label='SBE Float 6903010',markerfacecolor='orange', markersize=10),
],loc='lower right')
/var/folders/ww/psmkfjds7xsc4kjsz66ghldr000nsn/T/ipykernel_51050/648577324.py:36: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first. cb=plt.colorbar(sc,ax=ax.ravel().tolist())
<matplotlib.legend.Legend at 0x198667970>
from wrangling import interp_climatology
ref_sal = st25['SA'].values
ref_theta = st25['PTEMP'].values
ref_pres = st25['PRES'].values
#Since the ow function interp_climatology uses multiple profiles as input, we just *2 our profile
#INTERP 6903075 ON ST25 THETA LEVELS
SA_i0, PR_i0 = interp_climatology(np.array([ds0.isel(N_PROF=1)['SA'].values,]*2).transpose(),
np.array([ds0.isel(N_PROF=1)['PTEMP'].values,]*2).transpose(),
np.array([ds0.isel(N_PROF=1)['PRES'].values,]*2).transpose(),
ref_sal, ref_theta, ref_pres)
SA_i0 = SA_i0[:,0]
PR_i0 = PR_i0[:,0]
#INTERP 6903076 ON ST25 THETA LEVELS
SA_i1, PR_i1 = interp_climatology(np.array([ds1.isel(N_PROF=1)['SA'].values,]*2).transpose(),
np.array([ds1.isel(N_PROF=1)['PTEMP'].values,]*2).transpose(),
np.array([ds1.isel(N_PROF=1)['PRES'].values,]*2).transpose(),
ref_sal, ref_theta, ref_pres)
SA_i1 = SA_i1[:,0]
PR_i1 = PR_i1[:,0]
#INTERP 6903010 ON ST25 THETA LEVELS
SA_i2, PR_i2 = interp_climatology(np.array([dsbe.isel(N_PROF=1)['SA'].values,]*2).transpose(),
np.array([dsbe.isel(N_PROF=1)['PTEMP'].values,]*2).transpose(),
np.array([dsbe.isel(N_PROF=1)['PRES'].values,]*2).transpose(),
ref_sal, ref_theta, ref_pres)
SA_i2 = SA_i2[:,0]
PR_i2 = PR_i2[:,0]
cl = ['#008744','#ffa700','#d62d20']
fig,ax = plt.subplots(2,2,figsize=(18,15),gridspec_kw={'height_ratios': [14, 1]})
ax[0,0].invert_yaxis();
ax[0,0].plot(SA_i0 - ref_sal, ref_pres,'-',linewidth=1.5,label='6903075',color=cl[0])
ax[0,0].plot(SA_i1 - ref_sal, ref_pres,'-',linewidth=1.5,label='6903076',color=cl[1])
ax[0,0].plot(SA_i2 - ref_sal, ref_pres,'-',linewidth=1.5,label='6903010',color=cl[2])
ax[0,0].legend(fontsize='large')
ax[0,0].set_xlabel('$\Delta$ Salinity [psu] with St25',fontsize='large',fontweight='bold')
ax[0,0].set_ylabel('PRES [dba]',fontsize='large',fontweight='bold')
ax[0,1].invert_yaxis();
ax[0,1].plot(PR_i0 - ref_pres, ref_pres,'-',linewidth=1.5,label='6903075',color=cl[0])
ax[0,1].plot(PR_i1 - ref_pres, ref_pres,'-',linewidth=1.5,label='6903076',color=cl[1])
ax[0,1].plot(PR_i2 - ref_pres, ref_pres,'-',linewidth=1.5,label='6903010',color=cl[2])
ax[0,1].legend(fontsize='large')
ax[0,1].set_xlabel('$\Delta$ Pressure [dba] with St25',fontsize='large',fontweight='bold')
ax[1,0].plot(np.nanmean((SA_i0 - ref_sal)),0,'s',markersize=15,markerfacecolor=cl[0],markeredgewidth=1,markeredgecolor='k')
ax[1,0].plot(np.nanmean((SA_i0 - ref_sal)[np.argwhere(ref_pres>1200)]),0,'v',markersize=15,markerfacecolor=cl[0],markeredgewidth=1,markeredgecolor='k')
ax[1,0].plot(np.nanmean((SA_i1 - ref_sal)),1,'s',markersize=15,markerfacecolor=cl[1],markeredgewidth=1,markeredgecolor='k')
ax[1,0].plot(np.nanmean((SA_i1 - ref_sal)[np.argwhere(ref_pres>1200)]),1,'v',markersize=15,markerfacecolor=cl[1],markeredgewidth=1,markeredgecolor='k')
ax[1,0].plot(np.nanmean((SA_i2 - ref_sal)),2,'s',markersize=15,markerfacecolor=cl[2],markeredgewidth=1,markeredgecolor='k')
ax[1,0].plot(np.nanmean((SA_i2 - ref_sal)[np.argwhere(ref_pres>1200)]),2,'v',markersize=15,markerfacecolor=cl[2],markeredgewidth=1,markeredgecolor='k')
ax[1,0].set_ylim([-0.5,2.5])
ax[1,0].legend(handles=[Line2D([0], [0], marker='s', linewidth=0, markeredgewidth=0,label='Profile',markerfacecolor='k', markersize=12),
Line2D([0], [0], marker='v', linewidth=0, markeredgewidth=0,label='>1200',markerfacecolor='k', markersize=12)],
bbox_to_anchor=(-0.02, 0.9),fontsize='large')
ax[1,1].plot(np.nanmean((PR_i0 - ref_pres)),0,'s',markersize=15,markerfacecolor=cl[0],markeredgewidth=1,markeredgecolor='k')
ax[1,1].plot(np.nanmean((PR_i0 - ref_pres)[np.argwhere(ref_pres>1200)]),0,'v',markersize=15,markerfacecolor=cl[0],markeredgewidth=1,markeredgecolor='k')
ax[1,1].plot(np.nanmean((PR_i1 - ref_pres)),1,'s',markersize=15,markerfacecolor=cl[1],markeredgewidth=1,markeredgecolor='k')
ax[1,1].plot(np.nanmean((PR_i1 - ref_pres)[np.argwhere(ref_pres>1200)]),1,'v',markersize=15,markerfacecolor=cl[1],markeredgewidth=1,markeredgecolor='k')
ax[1,1].plot(np.nanmean((PR_i2 - ref_pres)),2,'s',markersize=15,markerfacecolor=cl[2],markeredgewidth=1,markeredgecolor='k')
ax[1,1].plot(np.nanmean((PR_i2 - ref_pres)[np.argwhere(ref_pres>1200)]),2,'v',markersize=15,markerfacecolor=cl[2],markeredgewidth=1,markeredgecolor='k')
ax[1,1].set_ylim([-0.5,2.5])
ax[1,0].set_xlabel('Mean($\Delta$) [psu]',fontsize='large',fontweight='bold')
ax[1,1].set_xlabel('Mean($\Delta$) [dba]',fontsize='large',fontweight='bold')
ax[1,0].set_yticklabels([])
ax[1,1].set_yticklabels([])
plt.tight_layout()
def along_isot(isotherm):
fig,ax = plt.subplots(2,1,figsize=(18,12),sharex=True)
ds0_ai = ds0.where((ds0['PTEMP']<isotherm+.1)&(ds0['PTEMP']>isotherm-.1),drop=True).mean('N_LEVELS')
ds1_ai = ds1.where((ds1['PTEMP']<isotherm+.1)&(ds1['PTEMP']>isotherm-.1),drop=True).mean('N_LEVELS')
dsbe_ai = dsbe.where((dsbe['PTEMP']<isotherm+.1)&(dsbe['PTEMP']>isotherm-.1),drop=True).mean('N_LEVELS')
ax[0].plot(ds0_ai['CYCLE_NUMBER'],ds0_ai['PRES'],'o-',label=str(wmos[0]))
ax[0].plot(ds1_ai['CYCLE_NUMBER'],ds1_ai['PRES'],'o-',label=str(wmos[1]))
ax[0].plot(dsbe_ai['CYCLE_NUMBER'],dsbe_ai['PRES'],'o-',label='sbe 6903010')
#ax[0].set_xlabel('CYCLE')
ax[0].set_ylabel('PRES')
ax[0].legend()
ax[0].set_title('Pressure along isotherm '+str(isotherm)+'°C')
ax[1].plot(ds0_ai['CYCLE_NUMBER'],ds0_ai['SA'],'o-',label=str(wmos[0]))
ax[1].plot(ds1_ai['CYCLE_NUMBER'],ds1_ai['SA'],'o-',label=str(wmos[1]))
ax[1].plot(dsbe_ai['CYCLE_NUMBER'],dsbe_ai['SA'],'o-',label='sbe 6903010')
ax[1].set_xlabel('CYCLE')
ax[1].set_ylabel('Salinity')
ax[1].legend()
ax[1].set_title('Salinity along isotherm '+str(isotherm)+'°C')
return fig,ax
for i in [10.,5.]:
fig,ax = along_isot(i)