Changeset 807 for trunk/UTIL/PYTHON/mcd/mcd.py
- Timestamp:
- Oct 15, 2012, 2:12:07 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/mcd.py
r806 r807 110 110 2: "Altitude above areoid (Mars geoid) (m)",\ 111 111 3: "Altitude above local surface (m)",\ 112 4: "orographic height (m) (surf ace altitudeabove areoid)",\112 4: "orographic height (m) (surf alt above areoid)",\ 113 113 5: "Ls, solar longitude of Mars (deg)",\ 114 114 6: "LST local true solar time (hrs)",\ … … 122 122 14: "GCM orography (m)",\ 123 123 15: "surface temperature (K)",\ 124 16: "daily max imummean surface temperature (K)",\125 17: "daily min imummean surface temperature (K)",\124 16: "daily max mean surface temperature (K)",\ 125 17: "daily min mean surface temperature (K)",\ 126 126 18: "surf. temperature RMS day to day variations (K)",\ 127 127 19: "surface pressure (high resolution if hireskey=1)",\ … … 522 522 for i in range(len(tabtodo)): mpl.subplot(subv,subh,i+1) ; self.makemap2d(tabtodo[i],incwind=incwind,fixedlt=fixedlt,proj=proj) 523 523 524 def htmlmap2d(self,tabtodo,incwind=False,fixedlt=False,figname="temp.png",title="" ):524 def htmlmap2d(self,tabtodo,incwind=False,fixedlt=False,figname="temp.png",title="",back="zMOL"): 525 525 ### complete 2D figure with possible multiplots 526 526 ### added in 09/2012 for online MCD … … 529 529 from matplotlib.backends.backend_agg import FigureCanvasAgg 530 530 from matplotlib.cm import get_cmap 531 532 #from mpl_toolkits.basemap import Basemap 533 534 from Scientific.IO import NetCDF 535 filename = "/home/marshttp/surface.nc" 536 zefile = NetCDF.NetCDFFile(filename, 'r') 537 fieldc = zefile.variables[back] 538 yc = zefile.variables['latitude'] 539 xc = zefile.variables['longitude'] 540 ## plutot que fieldc = self.getextvar(self.convertlab("topo")) 541 531 542 if isinstance(tabtodo,np.str): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 532 543 if isinstance(tabtodo,np.int): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 533 fig = Figure(figsize=(8,8)) ; subv,subh = myplot.definesubplot( len(tabtodo) , fig ) 534 535 ### topocontours 536 fieldc = self.getextvar(self.convertlab("topo")) 544 545 howmanyplots = len(tabtodo) 546 if howmanyplots == 1: fig = Figure(figsize=(16,8)) 547 elif howmanyplots == 2: fig = Figure(figsize=(8,8)) 548 elif howmanyplots == 3: fig = Figure(figsize=(8,16)) 549 elif howmanyplots == 4: fig = Figure(figsize=(16,8)) 550 551 subv,subh = myplot.definesubplot( len(tabtodo) , fig ) 537 552 538 553 for i in range(len(tabtodo)): … … 544 559 if incwind: (windx, fieldlabwx) = self.definefield("u") ; (windy, fieldlabwy) = self.definefield("v") 545 560 546 proj=" cyl" ; colorb="jet" ; ndiv=20 ; zeback="molabw" ; trans=1.0 #0.6561 proj="moll" ; colorb="jet" ; ndiv=20 ; zeback="molabw" ; trans=1.0 #0.6 547 562 title="" ; vecx=None ; vecy=None ; stride=2 548 563 lon = self.xcoord 549 564 lat = self.ycoord 550 551 ### get lon and lat in 2D version. get lat/lon intervals 552 #numdim = len(np.array(lon).shape) 553 #if numdim == 2: [lon2d,lat2d] = [lon,lat] 554 #elif numdim == 1: [lon2d,lat2d] = np.meshgrid(lon,lat) 555 #else: errormess("lon and lat arrays must be 1D or 2D") 556 #[wlon,wlat] = myplot.latinterv() 557 ### define projection and background. define x and y given the projection 558 #m = basemap.Basemap(projection='moll') marche pas 559 #m = myplot.define_proj(proj,wlon,wlat,back=zeback,blat=None,blon=None) 560 #x, y = m(lon2d, lat2d) 561 ### TEMP 565 566 #[lon2d,lat2d] = np.meshgrid(lon,lat) 567 ##### define projection and background. define x and y given the projection 568 ##[wlon,wlat] = myplot.latinterv() 569 ##yeahm = myplot.define_proj(proj,wlon,wlat,back=zeback,blat=None,blon=None) 570 ##x, y = yeahm(lon2d, lat2d) 571 #map = Basemap(projection='ortho',lat_0=45,lon_0=-100) 572 #x, y = map(lon2d, lat2d) 573 574 #### TEMP 562 575 x = lon ; y = lat 576 563 577 ## define field. bound field. 564 578 what_I_plot = np.transpose(field) … … 569 583 zelevels = np.linspace(zevmin,zevmax,ticks) 570 584 palette = get_cmap(name=colorb) 585 571 586 ## contours topo 572 zelevc = np.linspace(- 8000.,20000.,20)573 yeah.contour( x , y, np.transpose(fieldc), zelevc, colors='black',linewidths = 0.4)587 zelevc = np.linspace(-9.,20.,11) 588 yeah.contour( xc, yc, fieldc, zelevc, colors='black',linewidths = 0.4) 574 589 # contour field 575 590 c = yeah.contourf( x, y, what_I_plot, zelevels, cmap = palette, alpha = trans ) 576 clb = Figure.colorbar(fig,c,orientation='vertical',format="%. 1e")591 clb = Figure.colorbar(fig,c,orientation='vertical',format="%.2e",ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,21]))) 577 592 clb.set_label(fieldlab) 578 ax = fig.gca() ; ax.set_ title(fieldlab) ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude")593 ax = fig.gca() ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude") 579 594 ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 580 595 ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late) … … 622 637 # contour field 623 638 c = yeah.contourf( self.xcoord, self.ycoord, what_I_plot, zelevels, cmap = palette ) 624 clb = Figure.colorbar(fig,c,orientation='vertical',format="%. 1e")639 clb = Figure.colorbar(fig,c,orientation='vertical',format="%.2e",ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,21]))) 625 640 clb.set_label(fieldlab) 626 641 ax = fig.gca() ; ax.set_ylabel(self.ylabel) ; ax.set_xlabel(self.xlabel)
Note: See TracChangeset
for help on using the changeset viewer.