Changeset 800
- Timestamp:
- Oct 1, 2012, 7:38:09 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/mcd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/mcd.py
r797 r800 27 27 # default settings 28 28 ## 0. general stuff 29 self.name = "MCD v4.3 output" 29 self.name = "MCD v4.3" 30 self.ack = "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES" 30 31 #self.dset = '/home/aymeric/Science/MCD_v4.3/data/' 31 32 self.dset = '/home/marshttp/MCD_v4.3/data/' … … 72 73 self.prestab = None ; self.denstab = None ; self.temptab = None 73 74 self.zonwindtab = None ; self.merwindtab = None ; self.meanvartab = None ; self.extvartab = None 75 ## plot stuff 76 self.xlabel = None ; self.ylabel = None 77 self.vertplot = False 74 78 75 79 def viking1(self): self.name = "Viking 1 site. MCD v4.3 output" ; self.lat = 22.48 ; self.lon = -49.97 ; self.xdate = 97. 76 80 def viking2(self): self.name = "Viking 2 site. MCD v4.3 output" ; self.lat = 47.97 ; self.lon = -225.74 ; self.xdate = 117.6 81 82 def getdustlabel(self): 83 if self.dust == 1: self.dustlabel = "MY24 minimum solar scenario" 84 elif self.dust == 2: self.dustlabel = "MY24 average solar scenario" 85 elif self.dust == 3: self.dustlabel = "MY24 maximum solar scenario" 86 elif self.dust == 4: self.dustlabel = "dust storm minimum solar scenario" 87 elif self.dust == 5: self.dustlabel = "dust storm average solar scenario" 88 elif self.dust == 6: self.dustlabel = "dust storm maximum solar scenario" 89 elif self.dust == 7: self.dustlabel = "warm scenario (dusty, maximum solar)" 90 elif self.dust == 8: self.dustlabel = "cold scenario (low dust, minimum solar)" 91 92 def gettitle(self): 93 self.getdustlabel() 94 self.title = self.name + " with " + self.dustlabel + "." 77 95 78 96 def getextvarlab(self,num): … … 185 203 self.extvar[90] = self.pres ; self.extvar[91] = self.dens 186 204 self.extvar[92] = self.temp ; self.extvar[93] = self.zonwind ; self.extvar[94] = self.merwind 205 ## treat missing values 206 if self.temp == -999: self.extvar[:] = np.NaN ; self.meanvar[:] = np.NaN 187 207 188 208 def printset(self): … … 268 288 if start is not None and end is not None: first, second = self.correctbounds(start,end) 269 289 else: first, second = self.correctbounds(dstart,dend) 270 if not yaxis: self.xcoord = np.linspace(first,second,nd) 271 else: self.ycoord = np.linspace(first,second,nd) 272 ## here we should code the log axis for pressure 290 if self.zkey != 4: tabtab = np.linspace(first,second,nd) 291 else: tabtab = np.logspace(first,second,nd) 292 if not yaxis: self.xcoord = tabtab 293 else: self.ycoord = tabtab 273 294 274 295 def correctbounds(self,start,end): … … 279 300 else: 280 301 # pressure: reversed avis 281 if start < end: first = end ; second = start282 else: first = start ; second = end302 if start < end: first = np.log10(end) ; second = np.log10(start) 303 else: first = np.log10(start) ; second = np.log10(end) 283 304 return first, second 305 306 def vertlabel(self): 307 if self.zkey == 1: self.xlabel = "radius from centre of planet (m)" 308 elif self.zkey == 2: self.xlabel = "height above areoid (m) (MOLA zero datum)" 309 elif self.zkey == 3: self.xlabel = "height above surface (m)" 310 elif self.zkey == 4: self.xlabel = "pressure level (Pa)" 311 elif self.zkey == 5: self.xlabel = "altitude above mean Mars Radius(=3396000m) (m)" 284 312 285 313 ################### … … 316 344 def profile(self,nd=20,tabperso=None): 317 345 ### retrieve an altitude slice (profile) 318 self.xlabel = "Altitude (m)" 346 self.vertlabel() 347 self.vertplot = True 319 348 if tabperso is not None: nd = len(tabperso) 320 349 correct = False … … 329 358 for i in range(nd): self.xdate = self.xcoord[i] ; self.update() ; self.put1d(i) 330 359 331 def makeplot1d(self,choice ,vertplot=0):360 def makeplot1d(self,choice): 332 361 ### one 1D plot is created for the user-defined variable in choice. 333 362 (field, fieldlab) = self.definefield(choice) 334 if vertplot != 1: absc = self.xcoord ; ordo = field ; ordolab = fieldlab ; absclab = self.xlabel335 else: ordo = self.xcoord ; absc = field ; absclab = fieldlab ; ordolab = self.xlabel363 if not self.vertplot: absc = self.xcoord ; ordo = field ; ordolab = fieldlab ; absclab = self.xlabel 364 else: ordo = self.xcoord ; absc = field ; absclab = fieldlab ; ordolab = self.xlabel 336 365 mpl.plot(absc,ordo,'-bo') ; mpl.ylabel(ordolab) ; mpl.xlabel(absclab) #; mpl.xticks(query.xcoord) 337 mpl.figtext(0.5, 0.01, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center') 338 339 def plot1d(self,tabtodo,vertplot=0): 366 if self.zkey == 4: mpl.semilogy() ; ax = mpl.gca() ; ax.set_ylim(ax.get_ylim()[::-1]) 367 mpl.figtext(0.5, 0.01, self.ack, ha='center') 368 369 def plot1d(self,tabtodo): 340 370 ### complete 1D figure with possible multiplots 341 371 if isinstance(tabtodo,np.str): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 342 372 if isinstance(tabtodo,np.int): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 343 373 fig = mpl.figure() ; subv,subh = myplot.definesubplot( len(tabtodo) , fig ) 344 for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1).grid(True, linestyle=':', color='grey') ; self.makeplot1d(tabtodo[i] ,vertplot)345 346 def htmlplot1d(self,tabtodo, vertplot=0,figname="temp.png"):374 for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1).grid(True, linestyle=':', color='grey') ; self.makeplot1d(tabtodo[i]) 375 376 def htmlplot1d(self,tabtodo,figname="temp.png",title=""): 347 377 ### complete 1D figure with possible multiplots 348 378 ### added in 09/2012 for online MCD … … 357 387 choice = tabtodo[i] 358 388 (field, fieldlab) = self.definefield(choice) 359 if vertplot != 1: absc = self.xcoord ; ordo = field ; ordolab = fieldlab ; absclab = self.xlabel360 else: ordo = self.xcoord ; absc = field ; absclab = fieldlab ; ordolab = self.xlabel389 if not self.vertplot: absc = self.xcoord ; ordo = field ; ordolab = fieldlab ; absclab = self.xlabel 390 else: ordo = self.xcoord ; absc = field ; absclab = fieldlab ; ordolab = self.xlabel 361 391 yeah.plot(absc,ordo,'-bo') #; mpl.xticks(query.xcoord) 362 392 ax = fig.gca() ; ax.set_ylabel(ordolab) ; ax.set_xlabel(absclab) 363 fig.text(0.5, 0.01, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center') 393 if self.zkey == 4: ax.set_yscale('log') ; ax.set_ylim(ax.get_ylim()[::-1]) 394 self.gettitle() 395 fig.text(0.5, 0.95, self.title, ha='center') 396 fig.text(0.5, 0.01, self.ack, ha='center') 364 397 canvas = FigureCanvasAgg(fig) 365 398 # The size * the dpi gives the final image size … … 408 441 if incwind: myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj=proj,vecx=windx,vecy=windy) #,stride=1) 409 442 else: myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj=proj) 410 mpl.figtext(0.5, 0.0, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center')443 mpl.figtext(0.5, 0.0, self.ack, ha='center') 411 444 412 445 def map2d(self,tabtodo,incwind=False,fixedlt=False,proj="cyl"): … … 477 510 [x2d,y2d] = np.meshgrid(x,y) 478 511 yeah.quiver(x2d,y2d,np.transpose(windx),np.transpose(windy)) 479 fig.text(0.5, 0.95, title, ha='center') 480 fig.text(0.5, 0.01, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center') 512 self.gettitle() 513 fig.text(0.5, 0.95, self.title, ha='center') 514 fig.text(0.5, 0.01, self.ack, ha='center') 481 515 canvas = FigureCanvasAgg(fig) 482 516 # The size * the dpi gives the final image size -
trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py
r797 r800 109 109 reference = query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt) 110 110 figname = '../img/'+reference+'.png' 111 112 111 testexist = daos.path.isfile(figname) 113 112 … … 126 125 127 126 ### generic building of figure 128 query.htmlplot1d(vartoplot, vertplot=isaltfree,figname=figname)127 query.htmlplot1d(vartoplot,figname=figname) 129 128 #mpl.savefig("img/temp.png",dpi=85,bbox_inches='tight',pad_inches=0.25) 130 129 #Image.open("../img/temp.png").save(figname,'JPEG') … … 138 137 139 138 ### figure 140 zetitle = "MCD v4.3 - Dust scenario "+str(query.dust)+" - Date is "+str(query.xdate) 141 query.htmlmap2d(vartoplot,incwind=iswindlog,fixedlt=input_fixedlt,figname=figname,title=zetitle) 139 query.htmlmap2d(vartoplot,incwind=iswindlog,fixedlt=input_fixedlt,figname=figname) 142 140 #mpl.savefig("img/temp.png",dpi=110,bbox_inches='tight',pad_inches=0.4) 143 141 #Image.open("img/temp.png").save(figname,'JPEG') ##lighter images
Note: See TracChangeset
for help on using the changeset viewer.