Commit 24424ab6 authored by saeed's avatar saeed
Browse files

now we can choose either experiment or operational or both to be plotted

parent 381e68fc
{
"dovalidation":{"experiment":1,"operational":1},
"station" : "barseback",
"startdate":"2017100100",
"endate" :"2017102900",
"obstyle":"r-",
"experiment":{"NS01_GEBCO_6minns_4minh":{"path":"ssh_ns6_minh_4_correct_sss.csv","style":"b-"}},
"operational":{"NS01_NEMO":{"title":"NS01_OPER","style":"g-"}},
"tickinterval" : 48
"tickinterval_hour" : 48
}
......@@ -10,7 +10,7 @@ sys.setdefaultencoding('utf8')
clegend = []
vexpr = []
vssh = []
cstyle = []
def readConfig():
......@@ -27,14 +27,15 @@ def readConfig():
with open(config_file, 'r') as fptr_cfg:
cfg = json.load(fptr_cfg)
station = cfg["station"]
startdate = cfg["startdate"]
enddate = cfg["endate"]
obstyle = cfg["obstyle"]
expname = cfg["experiment"]
oper = cfg["operational"]
tickint = cfg["tickinterval"]
return station, startdate, enddate,obstyle, expname, oper, tickint
dovalidation = cfg["dovalidation"]
station = cfg["station"]
startdate = cfg["startdate"]
enddate = cfg["endate"]
obstyle = cfg["obstyle"]
expname = cfg["experiment"]
oper = cfg["operational"]
tickint = cfg["tickinterval_hour"]
return dovalidation, station, startdate, enddate,obstyle, expname, oper, tickint
def strDate(day):
cyear, cmonth, cday, chour="%04d"%int(day.year),"%02d"%int(day.month),"%02d"%int(day.day),"%02d"%int(day.hour)
......@@ -84,7 +85,7 @@ def readObs(station, startdate,enddate,obstyle):
vob = vo.loc[startdate:enddate].values
vobs = np.ma.masked_where(np.array(vob) == -999.0, np.array(vob))
clegend.append("OBSERVATION")
vexpr.append(vobs)
vssh.append(vobs)
cstyle.append(obstyle)
return vobs
......@@ -98,7 +99,7 @@ def readExpr(expname,station,startdate,enddate,vobs):
vmod = vm.loc[startdate:enddate].values
vmod = vmod + biasMean(vobs,vmod)
clegend.append(model)
vexpr.append(vmod)
vssh.append(vmod)
cstyle.append(expname[model]["style"])
def readOper(oper,station,startdate,enddate,vobs):
......@@ -110,17 +111,17 @@ def readOper(oper,station,startdate,enddate,vobs):
voper = vm["raw"].loc[startdate:enddate].values
voper = voper + biasMean(vobs,voper)
clegend.append(oper[model]["title"])
vexpr.append(voper)
vssh.append(voper)
cstyle.append(oper[model]["style"])
##############################
def main():
station, startdate, enddate, obstyle, expname, oper,tickint = readConfig()
dovalidation, station, startdate, enddate, obstyle, expname, oper,tickint = readConfig()
vobs = readObs(station, startdate, enddate,obstyle)
readExpr(expname,station,startdate,enddate,vobs)
readOper(oper,station,startdate,enddate,vobs)
if dovalidation["experiment"] :readExpr(expname,station,startdate,enddate,vobs)
if dovalidation["operational"] :readOper(oper,station,startdate,enddate,vobs)
stick = getDateRange(startdate,enddate)
itick = range(len(stick))
......@@ -130,15 +131,15 @@ def main():
ax.set_xlabel('Time',fontsize='20',weight='bold')
ax.set_ylabel ('SSH(m)',fontsize='20',weight='bold')
for im in range(len(vexpr)):
ax.plot(vexpr[im],cstyle[im])
for im in range(len(vssh)):
ax.plot(vssh[im],cstyle[im])
ax.legend(clegend, loc="best")
ax.grid()
ax.set_title(station,fontsize="30")
ax.xaxis.set_ticks(itick[::tickint])
ax.xaxis.set_ticklabels(stick[::tickint],rotation="vertical",fontsize="15")
print "Creating figure ", "ssh"+station+'.png'
print "Creating figure for station", station, " ssh"+station+'.png'
plt.savefig("ssh"+station+'.png', bbox_inches='tight',dpi=300,facecolor='w',edgecolor='w',orientation='portrait')
plt.close(1)
......
Supports Markdown
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