
from scipy import interpolate
import numpy as np
import matplotlib.pyplot as plt


## Test scipy.interp1d
#x = np.arange(0, 10)
#y = np.exp(-x/3.0)
#f = interpolate.interp1d(x, y)
#xnew = np.arange(0,9, 0.1)
#ynew = f(xnew)   # use interpolation function returned by `interp1d`
#plt.plot(x, y, 'o', xnew, ynew, '-')
#plt.show()



#   5        -36    24.0
#  10        -16    23.9
#  25         11    23.1
#  45         51    21.3
#  80         93    17.1
# 120         67    14.8
# 200         18    13.0



############################################################@
#  tout moyenne
fig1,ax1=plt.subplots(figsize=(7,12))

zz=[-5,-10,-25,-45,-80,-120,-200]
TT=[24.0,23.9,23.1,21.3,17.1,14.8,13.0]
UU=[-36,-16,11,51,93,67,18]

#plt.plot(UU, zz, 'o')

fU_tao = interpolate.interp1d(zz, UU,'cubic')
fT_tao = interpolate.interp1d(zz, TT,'cubic')


zznew = np.arange(-5,-200,-1)
UUnew=fU_tao(zznew)
TTnew=fT_tao(zznew)
ax1.plot(UU, zz, 'bo', UUnew, zznew, 'b-')
ax1.grid()
ax1.set_xlabel('ZONAL CURRENT (CM/S)',color='blue')
ax1.set_ylabel('depth (m)')
ax1.set_xlim(-40,100)

ax2 = ax1.twiny()
ax2.plot(TT, zz, 'ro', TTnew, zznew, 'r-')
ax2.grid()
ax2.set_xlabel('TEMPERATURE (C)',color='red')
ax2.set_xlim(13,25)

plt.title ('TAO mean 1989-2019')
plt.savefig('tao_mean_plot.png')


############################################################@
#  profils complets
#ig1,ax1=plt.subplots(figsize=(7,12))


zz2=[-10,-25,-45,-80,-120]
TT2=[23.6,22.9,21.1,17.5,14.8]
UU2=[-25,1,45,90,66]

fU2_tao = interpolate.interp1d(zz2, UU2,'cubic')
fT2_tao = interpolate.interp1d(zz2, TT2,'cubic')


zz2new = np.arange(-10,-120,-1)
UU2new=fU2_tao(zz2new)
TT2new=fT2_tao(zz2new)
ax1.plot(UU2, zz2, 'go', UU2new, zz2new, 'g-')
ax1.grid()
ax1.set_xlabel('ZONAL CURRENT (CM/S)',color='blue')
ax1.set_ylabel('depth (m)')
ax1.set_xlim(-40,100)

ax2 = ax1.twiny()
ax2.plot(TT2, zz2, 'mo', TT2new, zz2new, 'm-')
ax2.grid()
ax2.set_xlabel('TEMPERATURE (C)',color='red')
ax2.set_xlim(13,25)

#lt.title ('TAO mean 1989-2019  with complete profiles')
plt.savefig('tao_mean_plot_complete.png')












