Commit 542eb1e4 authored by saeed's avatar saeed
Browse files

taylorDiagram.py is added

parent 043a5a86
......@@ -8,25 +8,23 @@ def TaylorDiagram(RMSVEC, RMSDVEC, CORVEC,COLORVEC,LABELVEC, station, info):
print "rms ",RMSVEC
print "rmsd",RMSDVEC
######################################################
rms_max = max(RMSVEC)
delta = rms_max/10.0
rms_max = max(RMSVEC)
delta = rms_max/10.0
rmsd_max = max(RMSDVEC)
ddelta = rmsd_max/10.0
ddelta = rmsd_max/10.0
######################################################
X=np.arange(0.0,(1.20)*rms_max+delta/100.0,delta/100.0)
Y=np.arange(0.0,(1.20)*rms_max+delta/100.0,delta/100.0)
X=np.arange(0.0,(1.20)*rms_max+delta,delta/200.0)
Y=np.arange(0.0,(1.20)*rms_max+delta,delta/200.0)
nx=X.shape[0]
ny=Y.shape[0]
XX, YY = np.meshgrid(X,Y)
h = np.zeros((ny,nx),dtype=np.float32)
hh = np.zeros((ny,nx),dtype=np.float32)
for j in range(ny):
for i in range(nx):
h[j,i] = math.sqrt(X[i] * X[i] + Y[j] * Y[j])
h = np.sqrt(XX * XX + YY * YY )
hmax = np.amax(h)
hh[:,:] = -1.0
for j in range(ny):
for i in range(nx):
if (math.sqrt((X[i])*(X[i])+ Y[j]*Y[j]) <= (1.20*rms_max)):hh[j,i] = math.sqrt((X[i]-RMSVEC[0]) * (X[i]-RMSVEC[0]) + Y[j] * Y[j])
hh = np.sqrt((XX-RMSVEC[0])*(XX-RMSVEC[0]) + YY * YY)
hh[h > X[-1] ] = -1.0
hh=np.ma.masked_where(hh==-1.0,hh)
######################################################
fig=plt.figure(num=1,figsize=(9.0,9.0),dpi=300,facecolor='w',edgecolor='k')
......@@ -35,28 +33,30 @@ def TaylorDiagram(RMSVEC, RMSDVEC, CORVEC,COLORVEC,LABELVEC, station, info):
ax.set_ylabel('Standard Deviation',fontsize='15',weight='bold',color="green")
ax.grid(False)
#######################################################
vc=np.arange(0.0,(1.20*rms_max)+delta,delta)
vvc=np.arange(0.0,rmsd_max+ddelta,ddelta)
crm=ax.contour(XX,YY,hh,vvc[::2],colors='lightgreen',linestyles="solid",linewidths=1.5)
ax.clabel(crm,vvc[::2],inline=1,fontsize=12,colors='k',fmt='%.2f')
############################################
vc=np.arange(0.0,X[-1]+delta,delta)
nl, = vc.shape
lines=[]
for i in range(nl-1):
lines.append("dashed")
lines.append("solid")
ax.contour(X,Y,h,vc,colors='0.5',linestyles=lines,linewidths=0.2)
############################################
vvc=np.arange(0.0,rmsd_max+ddelta,ddelta)
crm=ax.contour(X,Y,hh,vvc[::2],colors='lightgreen',linestyles="solid",linewidths=1.5)
ax.clabel(crm,vvc[::2],inline=1,fontsize=12,colors='k',fmt='%.2f')
############################################
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_xlim(0.0,(1.25)*rms_max)
ax.set_ylim(0.0,(1.25)*rms_max)
ax.contour(XX,YY,h,vc,colors='0.5',linestyles=lines,linewidths=0.2)
########################################
#ax.spines['top'].set_visible(False)
#ax.spines['right'].set_visible(False)
#ax.set_xlim(0.0,X[-1]+4.0*delta)
#ax.set_ylim(0.0,Y[-1]+4.0*delta)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
############################################
radius = np.arange(0.0,(1.20)*rms_max+delta,delta)
radius = np.arange(0.0,X[-1]+delta,delta)
xangle = list(np.arange(0.0,0.9,0.10)) + [0.9, 0.95, 0.99]
rdmax = np.amax(radius)
print radius
print rdmax
for rd in radius:
for ang in xangle:
ax.plot([0.0,rd*ang],[0.0,rd*math.sqrt(1.0 - (ang * ang))],color="0.5",ls="-",lw="0.10")
......@@ -81,12 +81,15 @@ def TaylorDiagram(RMSVEC, RMSDVEC, CORVEC,COLORVEC,LABELVEC, station, info):
#############################################
def main():
rms = [0.4,2.4,2.1,2.9]
cor = [0.5,0.25,0.76,0.24]
rmsd = [0.04,0.24,.21,.29]
lab = ["exp1","exp2","exp3","exp4"]
lab = ['OBSERVATION','NS01_GEBCO_hmin4_alvin_newbfr','NS01_GEBCO_hmin_4_alvin','NS01_GEBCO_hmin6_alvin']
cor = [1.0, 0.821, 0.839, 0.811]
rms = [0.21, 0.172, 0.174, 0.164]
rmsd = [0.0, 0.12, 0.114, 0.123]
col = ["b","g","r","k"]
TaylorDiagram(RMSVEC=rms, RMSDVEC=rmsd, CORVEC=cor,COLORVEC=col,LABELVEC=lab, station="viken")
TaylorDiagram(RMSVEC=rms, RMSDVEC=rmsd, CORVEC=cor,COLORVEC=col,LABELVEC=lab, station="viken",info="20170101-20170501")
if __name__ == "__main__":main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment