Changeset 811 for trunk/UTIL/PYTHON/mcd/mcd.py
- Timestamp:
- Oct 20, 2012, 11:45:11 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/mcd.py
r807 r811 200 200 def update(self): 201 201 # retrieve fields from MCD (call_mcd). more info in fmcd.call_mcd.__doc__ 202 ## sanity first 203 self.loct = abs(self.loct)%24 204 if self.locts is not None and self.locte is not None: 205 self.locts = abs(self.locts)%24 206 self.locte = abs(self.locte)%24 207 if self.locts == self.locte: self.locte = self.locts + 24 208 if self.lat > 90.: self.lat = 90. 209 if self.lat < -90.: self.lat = -90. 210 if self.lats is not None and self.late is not None: 211 if abs(self.lats) > 90.: self.lats = 90. 212 if abs(self.late) > 90.: self.late = 90. 213 if abs(self.lats) < -90.: self.lats = -90. 214 if abs(self.late) < -90.: self.late = -90. 215 ## now MCD request 202 216 (self.pres, self.dens, self.temp, self.zonwind, self.merwind, \ 203 217 self.meanvar, self.extvar, self.seedout, self.ierr) \ … … 388 402 for i in range(nd): self.xdate = self.xcoord[i] ; self.update() ; self.put1d(i) 389 403 self.xdate = save 404 405 def getascii(self,tabtodo,filename="output.txt"): 406 ### print out values in an ascii file 407 if isinstance(tabtodo,np.str): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 408 if isinstance(tabtodo,np.int): tabtodo=[tabtodo] ## so that asking one element without [] is possible. 409 asciifile = open(filename, "w") 410 for i in range(len(tabtodo)): 411 (field, fieldlab) = self.definefield(tabtodo[i]) 412 self.gettitle() 413 asciifile.write("### " + self.title + "\n") 414 asciifile.write("### " + self.ack + "\n") 415 asciifile.write("### Column 1 is " + self.xlabel + "\n") 416 asciifile.write("### Column 2 is " + fieldlab + "\n") 417 for ix in range(len(self.xcoord)): 418 asciifile.write("%15.5e%15.5e\n" % ( self.xcoord[ix], field[ix] ) ) 419 asciifile.close() 420 return 390 421 391 422 def makeplot1d(self,choice): … … 423 454 ax = fig.gca() ; ax.set_ylabel(ordolab) ; ax.set_xlabel(absclab) 424 455 if self.zkey == 4: ax.set_yscale('log') ; ax.set_ylim(ax.get_ylim()[::-1]) 456 457 if self.lats is not None: ax.set_xticks(np.arange(-90,91,15)) ; ax.set_xbound(lower=self.lats, upper=self.late) 458 elif self.lons is not None: ax.set_xticks(np.arange(-360,361,30)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 459 elif self.locts is not None: ax.set_xticks(np.arange(0,26,2)) ; ax.set_xbound(lower=self.locts, upper=self.locte) 460 425 461 self.gettitle() 426 462 fig.text(0.5, 0.95, self.title, ha='center') … … 529 565 from matplotlib.backends.backend_agg import FigureCanvasAgg 530 566 from matplotlib.cm import get_cmap 567 from matplotlib import rcParams 531 568 532 569 #from mpl_toolkits.basemap import Basemap … … 554 591 yeah = fig.add_subplot(subv,subh,i+1) 555 592 choice = tabtodo[i] 556 self.latlon(fixedlt=fixedlt )593 self.latlon(fixedlt=fixedlt,ndx=64,ndy=48) 557 594 ## a map is implicitely a lat-lon plot. otherwise it is a plot (cf. makeplot2d) 558 595 (field, fieldlab) = self.definefield(choice) … … 584 621 palette = get_cmap(name=colorb) 585 622 623 # You can set negative contours to be solid instead of dashed: 624 rcParams['contour.negative_linestyle'] = 'solid' 586 625 ## contours topo 587 626 zelevc = np.linspace(-9.,20.,11) 588 627 yeah.contour( xc, yc, fieldc, zelevc, colors='black',linewidths = 0.4) 628 yeah.contour( np.array(xc) + 360., yc, fieldc, zelevc, colors='black',linewidths = 0.4) 629 yeah.contour( np.array(xc) - 360., yc, fieldc, zelevc, colors='black',linewidths = 0.4) 589 630 # contour field 590 631 c = yeah.contourf( x, y, what_I_plot, zelevels, cmap = palette, alpha = trans ) 591 632 clb = Figure.colorbar(fig,c,orientation='vertical',format="%.2e",ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,21]))) 592 633 clb.set_label(fieldlab) 593 ax = fig.gca() ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude")594 ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone)595 ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late)596 634 if incwind: 597 635 [x2d,y2d] = np.meshgrid(x,y) 598 636 yeah.quiver(x2d,y2d,np.transpose(windx),np.transpose(windy)) 637 ax = fig.gca() ; ax.set_ylabel("Latitude") ; ax.set_xlabel("Longitude") 638 ax.set_xticks(np.arange(-360,361,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 639 ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late) 599 640 self.gettitle() 600 641 fig.text(0.5, 0.95, self.title, ha='center') … … 640 681 clb.set_label(fieldlab) 641 682 ax = fig.gca() ; ax.set_ylabel(self.ylabel) ; ax.set_xlabel(self.xlabel) 642 if self.zkey == 4: ax.set_yscale('log') ; ax.set_ylim(ax.get_ylim()[::-1]) 643 644 #ax.set_xticks(np.arange(-180,181,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 645 #ax.set_yticks(np.arange(-90,91,30)) ; ax.set_ybound(lower=self.lats, upper=self.late) 683 684 if self.zkey == 4: 685 ax.set_yscale('log') ; ax.set_ylim(ax.get_ylim()[::-1]) 686 else: 687 #ax.set_yticks(np.arange(self.xzs,self.xze,10000.)) ; 688 ax.set_ybound(lower=self.xzs, upper=self.xze) 689 690 if self.lons is not None: ax.set_xticks(np.arange(-360,361,45)) ; ax.set_xbound(lower=self.lons, upper=self.lone) 691 elif self.lats is not None: ax.set_xticks(np.arange(-90,91,30)) ; ax.set_xbound(lower=self.lats, upper=self.late) 646 692 647 693 self.gettitle()
Note: See TracChangeset
for help on using the changeset viewer.