- Timestamp:
- Oct 1, 2012, 1:29:35 AM (12 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/gale.py
r793 r796 45 45 import matplotlib.pyplot as mpl 46 46 #mpl.show() 47 mpl.savefig(" img/temp.png",dpi=110,bbox_inches='tight',pad_inches=0.4)47 mpl.savefig("temp.png",dpi=110,bbox_inches='tight',pad_inches=0.4) -
trunk/UTIL/PYTHON/mcd/mcd.py
r793 r796 32 32 ## 1. spatio-temporal coordinates 33 33 self.lat = 0. 34 self.lats = None 35 self.late = None 34 36 self.lon = 0. 37 self.lons = None 38 self.lone = None 35 39 self.loct = 0. 40 self.locts = None 41 self.locte = None 36 42 self.xdate = 0. # see datekey 37 43 self.xz = 10. # see zkey 44 self.xzs = None 45 self.xze = None 38 46 ## 1bis. related settings 39 47 self.zkey = 3 # specify that xz is the altitude above surface (m) … … 177 185 def getnameset(self): 178 186 # set a name referring to settings [convenient for databases] 179 name = str(self.zkey)+str(self.xz)+str(self.lon)+str(self.lat)+str(self.hrkey)+str(self.datekey)+str(self.xdate)+str(self.loct)+str(self.dust) 187 strlat = str(self.lat)+str(self.lats)+str(self.late) 188 strlon = str(self.lon)+str(self.lons)+str(self.lone) 189 strxz = str(self.xz)+str(self.xzs)+str(self.xze) 190 strloct = str(self.loct)+str(self.locts)+str(self.locte) 191 name = str(self.zkey)+strxz+strlon+strlat+str(self.hrkey)+str(self.datekey)+str(self.xdate)+strloct+str(self.dust) 180 192 return name 181 193 … … 257 269 self.extvartab[i,1:100] = self.extvar[0:99] ## note: var numbering according to MCD manual is kept 258 270 259 def diurnal(self,nd=13 ,start=0.,end=24.):271 def diurnal(self,nd=13): 260 272 ### retrieve a local time slice 261 273 self.xlabel = "Local time (Martian hour)" 262 self.prepare(ndx=nd) ; self.xcoord = np.linspace(start,end,nd) 274 self.prepare(ndx=nd) 275 if self.locts is not None and self.locte is not None: 276 if self.locts > self.locte: yeah = self.locts ; self.locts = self.locte ; self.locte = yeah 277 self.xcoord = np.linspace(self.locts,self.locte,nd) 278 else: 279 self.xcoord = np.linspace(0.,24.,nd) 263 280 for i in range(nd): self.loct = self.xcoord[i] ; self.update() ; self.put1d(i) 264 281 265 def zonal(self,nd=37 ,start=-180.,end=180.):282 def zonal(self,nd=37): 266 283 ### retrieve a longitude slice 267 284 self.xlabel = "East longitude (degrees)" 268 self.prepare(ndx=nd) ; self.xcoord = np.linspace(start,end,nd) 285 self.prepare(ndx=nd) 286 if self.lons is not None and self.lone is not None: 287 if self.lons > self.lone: yeah = self.lons ; self.lons = self.lone ; self.lone = yeah 288 self.xcoord = np.linspace(self.lons,self.lone,nd) 289 else: 290 self.xcoord = np.linspace(-180.,180.,nd) 269 291 for i in range(nd): self.lon = self.xcoord[i] ; self.update() ; self.put1d(i) 270 292 271 def meridional(self,nd=19 ,start=-90.,end=90.):293 def meridional(self,nd=19): 272 294 ### retrieve a latitude slice 273 295 self.xlabel = "North latitude (degrees)" 274 self.prepare(ndx=nd) ; self.xcoord = np.linspace(start,end,nd) 296 self.prepare(ndx=nd) 297 if self.lats is not None and self.late is not None: 298 if self.lats > self.late: yeah = self.lats ; self.lats = self.late ; self.late = yeah 299 self.xcoord = np.linspace(self.lats,self.late,nd) 300 else: 301 self.xcoord = np.linspace(-90.,90.,nd) 275 302 for i in range(nd): self.lat = self.xcoord[i] ; self.update() ; self.put1d(i) 276 303 277 def profile(self,nd=20, start=0.,end=120000.,tabperso=None):304 def profile(self,nd=20,tabperso=None): 278 305 ### retrieve an altitude slice (profile) 279 306 self.xlabel = "Altitude (m)" 280 307 if tabperso is not None: nd = len(tabperso) 281 308 self.prepare(ndx=nd) 282 if tabperso is None: self.xcoord = np.linspace(start,end,nd) 283 else: self.xcoord = tabperso 309 if tabperso is not None: 310 self.xcoord = tabperso 311 elif self.xzs is not None and self.xze is not None: 312 ## here we should code the log axis for pressure 313 self.xcoord = np.linspace(self.xzs,self.xze,nd) 314 else: 315 self.xcoord = np.linspace(0.,120000.,nd) 284 316 for i in range(nd): self.xz = self.xcoord[i] ; self.update() ; self.put1d(i) 285 317 … … 332 364 ################### 333 365 334 def latlon(self,ndx=37, startx=-180.,endx=180.,ndy=19,starty=-90.,endy=90.,fixedlt=False):366 def latlon(self,ndx=37,ndy=19,fixedlt=False): 335 367 ### retrieve a latitude/longitude slice 336 368 ### default is: local time is not fixed. user-defined local time is at longitude 0. 337 369 self.xlabel = "East longitude (degrees)" ; self.ylabel = "North latitude (degrees)" 338 370 self.prepare(ndx=ndx,ndy=ndy) 339 self.xcoord = np.linspace(startx,endx,ndx) ; self.ycoord = np.linspace(starty,endy,ndy) 371 if self.lons is not None and self.lone is not None: 372 if self.lons > self.lone: yeah = self.lons ; self.lons = self.lone ; self.lone = yeah 373 self.xcoord = np.linspace(self.lons,self.lone,ndx) 374 else: 375 self.xcoord = np.linspace(-180.,180.,ndx) 376 if self.lats is not None and self.late is not None: 377 if self.lats > self.late: yeah = self.lats ; self.lats = self.late ; self.late = yeah 378 self.ycoord = np.linspace(self.lats,self.late,ndy) 379 else: 380 self.ycoord = np.linspace(-90.,90.,ndy) 340 381 if not fixedlt: umst = self.loct 341 382 for i in range(ndx): … … 355 396 self.extvartab[i,j,1:100] = self.extvar[0:99] ## note: var numbering according to MCD manual is kept 356 397 357 def makemap2d(self,choice,incwind=False,fixedlt=False ):398 def makemap2d(self,choice,incwind=False,fixedlt=False,proj="cyl"): 358 399 ### one 2D map is created for the user-defined variable in choice. 359 400 self.latlon(fixedlt=fixedlt) ## a map is implicitely a lat-lon plot. otherwise it is a plot (cf. makeplot2d) 360 (field, fieldlab) = self.definefield(choice) 361 if incwind: 401 if choice == "wind" or incwind: 362 402 (windx, fieldlabwx) = self.definefield("u") 363 403 (windy, fieldlabwy) = self.definefield("v") 364 myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj="cyl",vecx=windx,vecy=windy) 365 else: 366 myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj="moll") 404 if choice == "wind": 405 field = np.sqrt(windx*windx + windy*windy) 406 fieldlab = "Horizontal wind speed (m/s)" 407 else: 408 (field, fieldlab) = self.definefield(choice) 409 if incwind: myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj=proj,vecx=windx,vecy=windy) #,stride=1) 410 else: myplot.maplatlon(self.xcoord,self.ycoord,field,title=fieldlab,proj=proj) 367 411 mpl.figtext(0.5, 0.0, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center') 368 412 369 def map2d(self,tabtodo,incwind=False,fixedlt=False ):413 def map2d(self,tabtodo,incwind=False,fixedlt=False,proj="cyl"): 370 414 ### complete 2D figure with possible multiplots 371 415 if isinstance(tabtodo,np.str): tabtodo=[tabtodo] ## so that asking one element without [] is possible. … … 373 417 fig = mpl.figure() 374 418 subv,subh = myplot.definesubplot( len(tabtodo) , fig ) 375 for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1) ; self.makemap2d(tabtodo[i],incwind=incwind,fixedlt=fixedlt )376 377 def htmlmap2d(self,tabtodo,incwind=False,fixedlt=False,figname="temp.png" ):419 for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1) ; self.makemap2d(tabtodo[i],incwind=incwind,fixedlt=fixedlt,proj=proj) 420 421 def htmlmap2d(self,tabtodo,incwind=False,fixedlt=False,figname="temp.png",title=""): 378 422 ### complete 2D figure with possible multiplots 379 423 ### added in 09/2012 for online MCD … … 392 436 yeah = fig.add_subplot(subv,subh,i+1) 393 437 choice = tabtodo[i] 394 self.latlon(fixedlt=fixedlt) ## a map is implicitely a lat-lon plot. otherwise it is a plot (cf. makeplot2d) 438 self.latlon(fixedlt=fixedlt) 439 ## a map is implicitely a lat-lon plot. otherwise it is a plot (cf. makeplot2d) 395 440 (field, fieldlab) = self.definefield(choice) 396 441 if incwind: (windx, fieldlabwx) = self.definefield("u") ; (windy, fieldlabwy) = self.definefield("v") … … 428 473 Figure.colorbar(fig,c,orientation='vertical',format="%.1e") 429 474 ax = fig.gca() ; ax.set_title(fieldlab) ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude") 430 ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower= -180, upper=180)431 ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower= -90, upper=90)475 ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 476 ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late) 432 477 if incwind: 433 478 [x2d,y2d] = np.meshgrid(x,y) 434 479 yeah.quiver(x2d,y2d,np.transpose(windx),np.transpose(windy)) 480 fig.text(0.5, 0.95, title, ha='center') 435 481 fig.text(0.5, 0.01, "Mars Climate Database (c) LMD/OU/IAA/ESA/CNES", ha='center') 436 482 canvas = FigureCanvasAgg(fig) -
trunk/UTIL/PYTHON/mcd/proto/cgi-bin/mcdcgi.py
r794 r796 1 ###!/usr/bin/env python 1 2 #!/usr/bin/python 2 3 ###!/home/aymeric/Software/epd-7.0-2-rh5-x86/bin/python … … 12 13 ################################################## 13 14 ### ajouts et corrections par Franck Guyon 09/2012 15 ### ajouts suite a brainstorm equipe AS 10/2012 14 16 15 17 import cgi, cgitb … … 36 38 # Get data from user-defined fields and define free dimensions 37 39 # FG: add tests if var==None to have values in local without forms ones 40 query.lat = -9999. 38 41 getlat = form.getvalue("latitude") 39 if getlat == None: getlat = 1 40 if getlat == "all": islatfree = 1 ; query.lat = -9999. 42 if getlat == None: getlat = "1" 43 if getlat == "all": islatfree = 1 ; query.lats = -90. ; query.late = 90. 44 elif ";" in getlat: islatfree = 1 ; ind = getlat.find(";") ; query.lats = float(getlat[:ind]) ; query.late = float(getlat[ind+1:]) 41 45 else: islatfree = 0 ; query.lat = float(getlat) 42 46 47 query.lon = -9999. 43 48 getlon = form.getvalue("longitude") 44 if getlon == None: getlon = 1 45 if getlon == "all": islonfree = 1 ; query.lon = -9999. 49 if getlon == None: getlon = "1" 50 if getlon == "all": islonfree = 1 ; query.lons = -180. ; query.lone = 180. 51 elif ";" in getlon: islonfree = 1 ; ind = getlon.find(";") ; query.lons = float(getlon[:ind]) ; query.lone = float(getlon[ind+1:]) 46 52 else: islonfree = 0 ; query.lon = float(getlon) 47 53 54 query.loct = -9999. 48 55 getloct = form.getvalue("localtime") 49 if getloct == None: getloct = 1 50 if getloct == "all": isloctfree = 1 ; query.loct = -9999. 56 if getloct == None: getloct = "1" 57 if getloct == "all": isloctfree = 1 ; query.locts = 0. ; query.locte = 24. 58 elif ";" in getloct: isloctfree = 1 ; ind = getloct.find(";") ; query.locts = float(getloct[:ind]) ; query.locte = float(getloct[ind+1:]) 51 59 else: isloctfree = 0 ; query.loct = float(getloct) 52 60 61 query.xz = -9999. 53 62 getalt = form.getvalue("altitude") 54 if getalt == None: getalt = 1 55 if getalt == "all": isaltfree = 1 ; query.xz = -9999. 63 if getalt == None: getalt = "1" 64 if getalt == "all": isaltfree = 1 ; query.xzs = 0. ; query.xze = 120000. 65 elif ";" in getalt: isaltfree = 1 ; ind = getalt.find(";") ; query.xzs = float(getalt[:ind]) ; query.xze = float(getalt[ind+1:]) 56 66 else: isaltfree = 0 ; query.xz = float(getalt) 57 67 … … 96 106 97 107 # reference name (to test which figures are already in the database) 98 reference = str(islatfree)+str(islonfree)+str(isloctfree)+str(isaltfree)+query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt)108 reference = query.getnameset()+str(var1)+str(var2)+str(var3)+str(var4)+str(iswind)+str(isfixedlt) 99 109 figname = '../img/'+reference+'.png' 100 110 … … 127 137 128 138 ### figure 129 query.htmlmap2d(vartoplot,incwind=iswindlog,fixedlt=input_fixedlt,figname=figname) 139 zetitle = "MCD v4.3 - Dust scenario "+str(query.dust)+" - Date is "+str(query.xdate) 140 query.htmlmap2d(vartoplot,incwind=iswindlog,fixedlt=input_fixedlt,figname=figname,title=zetitle) 130 141 #mpl.savefig("img/temp.png",dpi=110,bbox_inches='tight',pad_inches=0.4) 131 142 #Image.open("img/temp.png").save(figname,'JPEG') ##lighter images -
trunk/UTIL/PYTHON/mcd/proto/index.html
r793 r796 96 96 <td align="center"> 97 97 <b>CUSTOMIZE COORDINATES ON MARS</b><br /> 98 please give: a value (or) a range val1;val2 (or) 'all'<br /> 98 99 <ul> 99 <li> Latitude <input type="text" size="3" name="latitude" value="0."> (write a value or 'all')100 <li> Longitude <input type="text" size="3" name="longitude" value="0."> (write a value or 'all')101 <li>Local Time <input type="text" size=" 2" name="localtime" value="0."> (write a value or 'all')102 <li>Altitude (m) <input type="text" size=" 3" name="altitude" value="10."> (write a value or 'all')100 <li>North Latitude <input type="text" size="7" name="latitude" value="0."> 101 <li>East Longitude <input type="text" size="7" name="longitude" value="0."> 102 <li>Local Time <input type="text" size="7" name="localtime" value="0."> 103 <li>Altitude (m) <input type="text" size="7" name="altitude" value="10."> 103 104 <!-- 104 105 <li>Latitude -
trunk/UTIL/PYTHON/myplot.py
r792 r796 1419 1419 elif numdim == 1: [lon2d,lat2d] = np.meshgrid(lon,lat) 1420 1420 else: errormess("lon and lat arrays must be 1D or 2D") 1421 [wlon,wlat] = latinterv() 1421 #[wlon,wlat] = latinterv() 1422 [wlon,wlat] = simplinterv(lon2d,lat2d) 1422 1423 ## define projection and background. define x and y given the projection 1423 1424 m = define_proj(proj,wlon,wlat,back=zeback,blat=None,blon=None)
Note: See TracChangeset
for help on using the changeset viewer.