#!/usr/bin/env python # coding: utf-8 # ## DFO Si Plots # In[1]: import numpy as np import matplotlib.pyplot as plt import os import pandas as pd import netCDF4 as nc import datetime as dt from salishsea_tools import evaltools as et, viz_tools import gsw import matplotlib.gridspec as gridspec import matplotlib as mpl import matplotlib.dates as mdates import cmocean as cmo import scipy.interpolate as sinterp import pickle import cmocean mpl.rc('xtick', labelsize=12) mpl.rc('ytick', labelsize=12) mpl.rc('legend', fontsize=12) mpl.rc('axes', titlesize=12) mpl.rc('axes', labelsize=12) mpl.rc('figure', titlesize=12) mpl.rc('font', size=12) mpl.rc('text', usetex=True) mpl.rc('text.latex', preamble = ','.join(r''' \usepackage{txfonts} \usepackage{lmodern} '''.split())) mpl.rc('font', family='sans-serif', weight='normal', style='normal') get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: df=et.loadDFO() df.head() # In[3]: with nc.Dataset('/ocean/eolson/MEOPAR/NEMO-forcing/grid/mesh_mask201702_noLPE.nc') as mesh: navlon=mesh.variables['nav_lon'][:,:] navlat=mesh.variables['nav_lat'][:,:] tmask=mesh.variables['tmask'][:,:,:,:] gdept=mesh.variables['gdept_1d'][0,:] e3t0=mesh.variables['e3t_0'][0,:,:,:] bathy=np.sum(e3t0,0) with nc.Dataset('/results/SalishSea/hindcast.201812/01jan16/SalishSea_1h_20160101_20160101_ptrc_T.nc') as ftemp: bounds=np.copy(ftemp.variables['deptht_bounds'][:,:]) # In[4]: #d1=et._gridHoriz(df.loc[df.Z>150].copy(deep=True),tmask,navlon,navlat,wrapSearch=False,resetIndex=True); d1=et._gridHoriz(df.copy(deep=True),tmask,navlon,navlat,wrapSearch=False,resetIndex=True); d1['k']=np.nan for ind, row in d1.iterrows(): ik=et._getZInd_bin(row['Z'],None,boundsFlag=True) if (not np.isnan(ik)) and (tmask[0,ik,row['j'],row['i']]==1): d1.loc[ind,['k']]=ik # In[5]: # drop Saanich Inlet tmask2=np.copy(tmask[0,0,:,:]) tmask2[328:371,180:217]=tmask[0,0,328:371,180:217]+2 plt.pcolormesh(tmask2) plt.xlim(150,250) plt.ylim(310,400) d1.drop(d1.loc[(d1.i>=180)&(d1.i<217)&(d1.j>=328)&(d1.j<371)].index.values,inplace=True) # also drop east side Vancouver Island points: d1.drop(d1.loc[(d1.i<10)&(d1.j>=460)&(d1.j<480)].index.values,inplace=True) # In[6]: d1['YD']=[(dt.datetime(int(yy),int(mm),int(dd))-dt.datetime(int(yy),1,1)).total_seconds()/(24*3600) for yy,mm,dd in zip(d1['Year'].values,d1['Month'].values,d1['Day'].values)] # In[7]: np.unique(d1.loc[(d1.N==0)&(d1.Z>20),['Year']]) # In[8]: d1.loc[(d1.N==0)&(d1.Z>20)] # In[9]: d1.loc[(d1.Si==0)&(d1.Z>20)] # In[10]: def binmean(ddf,latEdges,lonEdges): latbins=np.digitize(ddf.Lat,latEdges) lonbins=np.digitize(ddf.Lon,lonEdges) midLats=.5*(latEdges[:-1]+latEdges[1:]) midLons=.5*(lonEdges[:-1]+lonEdges[1:]) xxlon,xxlat=np.meshgrid(midLons,midLats) sums=np.zeros(np.shape(xxlon)) counts=np.zeros(np.shape(xxlon)) means=np.nan*np.ones(np.shape(xxlon)) for jj in range(0,len(midLats)): for ii in range(0,len(midLons)): if len(ddf.loc[(latbins==jj+1)&(lonbins==ii+1),['Si']])>=1: means[jj,ii]=np.sum(ddf.loc[(latbins==jj+1)&(lonbins==ii+1),['Si']])/len(ddf.loc[(latbins==jj+1)&(lonbins==ii+1),['Si']]) return xxlon, xxlat, means # In[11]: fig,ax=plt.subplots(12,4,figsize=(16,50)) #kk=30 #36,34,32,30 simin=40 simax=80 for mon in range(1,13): iax=ax[mon-1,0] kk=30 iax.contourf(navlon,navlat,tmask[0,kk,:,:],levels=(0,.5,1.5),lw=.5,colors=('darkgray','k','k')) viz_tools.set_aspect(iax,coords='map') idf=d1.loc[(d1.k==kk)&(d1.Si>=0)&(d1.Month==mon)] lo,la,mm=binmean(idf,latEdges=np.linspace(47,51,31),lonEdges=np.linspace(-126,-122,41)) #iax.pcolormesh(lo,la,np.ma.masked_where(np.isnan(mm),mm)) mesh=iax.scatter(lo,la,c=mm,s=6,vmin=simin,vmax=simax) plt.colorbar(mesh,ax=iax) iax.set_title('Depth='+str(gdept[kk])) iax.set_ylabel('Month='+str(mon)) iax.set_xlim(-126,-122) iax.set_ylim(47.1,50.5) iax=ax[mon-1,1] kk=32 iax.contourf(navlon,navlat,tmask[0,kk,:,:],levels=(0,.5,1.5),lw=.5,colors=('darkgray','k','k')) viz_tools.set_aspect(iax,coords='map') idf=d1.loc[(d1.k==kk)&(d1.Si>=0)&(d1.Month==mon)] lo,la,mm=binmean(idf,latEdges=np.linspace(47,51,31),lonEdges=np.linspace(-126,-122,41)) #iax.pcolormesh(lo,la,np.ma.masked_where(np.isnan(mm),mm)) mesh=iax.scatter(lo,la,c=mm,s=6,vmin=simin,vmax=simax) plt.colorbar(mesh,ax=iax) iax.set_title('Depth='+str(gdept[kk])) iax.set_xlim(-126,-122) iax.set_ylim(47.1,50.5) iax=ax[mon-1,2] kk=34 iax.contourf(navlon,navlat,tmask[0,kk,:,:],levels=(0,.5,1.5),lw=.5,colors=('darkgray','k','k')) viz_tools.set_aspect(iax,coords='map') idf=d1.loc[(d1.k==kk)&(d1.Si>=0)&(d1.Month==mon)] lo,la,mm=binmean(idf,latEdges=np.linspace(47,51,31),lonEdges=np.linspace(-126,-122,41)) #iax.pcolormesh(lo,la,np.ma.masked_where(np.isnan(mm),mm)) mesh=iax.scatter(lo,la,c=mm,s=6,vmin=simin,vmax=simax) plt.colorbar(mesh,ax=iax) iax.set_title('Depth='+str(gdept[kk])) iax.set_xlim(-126,-122) iax.set_ylim(47.1,50.5) iax=ax[mon-1,3] kk=36 iax.contourf(navlon,navlat,tmask[0,kk,:,:],levels=(0,.5,1.5),lw=.5,colors=('darkgray','k','k')) viz_tools.set_aspect(iax,coords='map') idf=d1.loc[(d1.k==kk)&(d1.Si>=0)&(d1.Month==mon)] lo,la,mm=binmean(idf,latEdges=np.linspace(47,51,31),lonEdges=np.linspace(-126,-122,41)) #iax.pcolormesh(lo,la,np.ma.masked_where(np.isnan(mm),mm)) mesh=iax.scatter(lo,la,c=mm,s=6,vmin=simin,vmax=simax) plt.colorbar(mesh,ax=iax) iax.set_title('Depth='+str(gdept[kk])) iax.set_xlim(-126,-122) iax.set_ylim(47.1,50.5) # In[12]: fig,ax=plt.subplots(1,2,figsize=(10,4)) #kk=30 #36,34,32,30 simin=40 simax=80 for mon in range(1,2): iax=ax[0];#ax[mon-1,1] kk=32 iax.contourf(navlon,navlat,tmask[0,kk,:,:],levels=(0,.5,1.5),lw=.5,colors=('darkgray','k','k')) viz_tools.set_aspect(iax,coords='map') d1bath=np.array([bathy[j,i] for i,j in zip(d1['i'],d1['j'])]) df0=d1.loc[(d1.Lon<-123.3)&(d1.Lon>-123.6)&(d1.Lat<49.2)&(d1.Lat>48.85)&(d1.Si>=0)&(d1bath>400)] lo,la,mm=binmean(df0,latEdges=np.linspace(47,51,31),lonEdges=np.linspace(-126,-122,41)) #iax.pcolormesh(lo,la,np.ma.masked_where(np.isnan(mm),mm)) mesh=iax.scatter(lo,la,c=mm,s=6,vmin=simin,vmax=simax) plt.colorbar(mesh,ax=iax) #iax.set_title('Depth='+str(gdept[kk])) # In[13]: fig,ax=plt.subplots(1,3,figsize=(16,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=37 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs CT, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[14]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=36 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[15]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=34 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[16]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=32 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[17]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=30 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[18]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=29 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[19]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=28 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[20]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() for valm, groupedm in df0.groupby(['Month']): ik=34 ax[1].plot(groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['AbsSal']], groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['Si']].values/groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['N']].values, 'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['ConsT']], groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['Si']].values/groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['N']].values, 'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['AbsSal']], groupedm.loc[(groupedm.k==ik)&(groupedm.N>=0),['ConsT']].values, 'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[1],ps[2],ps[3],ps[4],ps[5],ps[6],ps[7],ps[8],ps[9],ps[10],ps[11],ps[12]], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[21]: df0.loc[(df0.k==34)].groupby(['Year'])['Si'].count() # In[22]: df0.loc[(df0.k==35)].groupby(['Year'])['Si'].count() # In[23]: df0.loc[(df0.k==36)].groupby(['Year'])['Si'].count() # In[24]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() df1=df0.loc[df0.Year==2010] for valm, groupedm in df1.groupby(['Month']): ik=34 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[ii] for ii in range(1,13) if ii in ps.keys()], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('2010 Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[25]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() df1=df0.loc[df0.Year==2010] for valm, groupedm in df1.groupby(['Month']): ik=35 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[ii] for ii in range(1,13) if ii in ps.keys()], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title('2010 Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[26]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() df1=df0.loc[df0.Year==2002] for valm, groupedm in df1.groupby(['Month']): ik=34 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[ii] for ii in range(1,13) if ii in ps.keys()], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title(' 2002 Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[27]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() df1=df0.loc[df0.Year==2003] for valm, groupedm in df1.groupby(['Month']): ik=36 ax[1].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[2].plot(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],'o',color=col[int(valm)],alpha=1) ax[3].plot(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],'o',color=col[int(valm)],alpha=1) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[ii] for ii in range(1,13) if ii in ps.keys()], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title(' 2003 Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') # In[28]: df1.keys() # In[29]: fig,ax=plt.subplots(1,4,figsize=(20,4)) fig.subplots_adjust(wspace=.5) col=('midnightblue','steelblue','darkturquoise','lime', 'seagreen','darkkhaki','darkorange','saddlebrown','firebrick', 'lightcoral','fuchsia','mediumorchid','blueviolet') ps=dict() df1=df0.loc[df0.Year==2003] for valm, groupedm in df1.groupby(['Month']): ik=36 cmin=0 cmax=365 if np.sum(groupedm.k==ik)>0: ax[1].scatter(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['Si']],c=groupedm.loc[groupedm.k==ik,['YD']], vmin=cmin,vmax=cmax,cmap=plt.get_cmap('hsv')) ax[2].scatter(groupedm.loc[groupedm.k==ik,['ConsT']],groupedm.loc[groupedm.k==ik,['Si']],c=groupedm.loc[groupedm.k==ik,['YD']], vmin=cmin,vmax=cmax,cmap=plt.get_cmap('hsv')) m=ax[3].scatter(groupedm.loc[groupedm.k==ik,['AbsSal']],groupedm.loc[groupedm.k==ik,['ConsT']],c=groupedm.loc[groupedm.k==ik,['YD']], vmin=cmin,vmax=cmax,cmap=plt.get_cmap('hsv')) means=groupedm.groupby(['k']).agg({'Si':np.mean,'Z':np.mean}) stds=groupedm.groupby(['k']).agg({'Si':np.std}) ns=groupedm.groupby(['k'])['Si'].count() ps[int(valm)],=ax[0].plot(means['Si'][ns>2],means['Z'][ns>2],'-',color=col[int(valm)], label=str(int(valm))) ax[0].errorbar(means['Si'][ns>2],means['Z'][ns>2],xerr=stds['Si'][ns>2],color=col[int(valm)]) ax[0].legend(handles=[ps[ii] for ii in range(1,13) if ii in ps.keys()], bbox_to_anchor=(1.3, 1.0)) ax[0].set_ylim(400,50) ax[0].set_xlim(30,100) ax[0].set_ylabel('Depth (m)') ax[0].set_xlabel('dSi ($\muup$M Si)') ax[1].set_ylabel('dSi ($\muup$M Si)') ax[1].set_title(' 2003 Si vs SA, '+str(int(bounds[ik,0]))+'m$<$Z$<$'+str(int(bounds[ik,1]))+'m') fig.colorbar(m,ax=ax[3]) # In[30]: df1.loc[df1.k==ik,['Year','Month','Day','Lat','Lon','Pressure','Si','AbsSal','ConsT']] # In[31]: plt.scatter(df1.loc[df1.k==ik,['Lon']],df1.loc[df1.k==ik,['Lat']],c=df1.loc[df1.k==ik,['Si']]) plt.xlim(-123.58,-123.53) plt.ylim(49.16,49.17) # In[32]: plt.scatter(xx,xx,c=xx) # In[ ]: # In[ ]: