Changeset 637
- Timestamp:
- Apr 30, 2012, 11:09:59 AM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r613 r637 290 290 from mymath import max,mean 291 291 from scipy import integrate 292 import numpy as np 292 293 if yint and vert is not None and indice is not None: 293 294 if type(input).__name__=='MaskedArray': … … 320 321 fig.subplots_adjust(hspace = 0.5) 321 322 rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. ) 322 elif 323 elif numplot == 4: 323 324 subv = 2 324 325 subh = 2 … … 534 535 [lon2d,lat2d] = np.meshgrid(falselon,falselat) ## dummy coordinates 535 536 print "WARNING: domain plot artificially centered on lat,lon 0,0" 536 elif typefile in ['gcm']: 537 [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True) 538 elif typefile in ['earthgcm','ecmwf']: 539 [lon2d,lat2d] = getcoord2d(nc,nlat="lat",nlon="lon",is1d=True) 537 elif typefile in ['gcm','earthgcm','ecmwf']: 538 if "longitude" in nc.dimensions: dalon = "longitude" 539 elif "lon" in nc.dimensions: dalon = "lon" 540 if "latitude" in nc.dimensions: dalat = "latitude" 541 elif "lat" in nc.dimensions: dalat = "lat" 542 [lon2d,lat2d] = getcoord2d(nc,nlat=dalat,nlon=dalon,is1d=True) 540 543 elif typefile in ['geo']: 541 544 [lon2d,lat2d] = getcoord2d(nc,nlat='XLAT_M',nlon='XLONG_M') … … 692 695 meanlon = 0.5*(wlon[0]+wlon[1]) 693 696 meanlat = 0.5*(wlat[0]+wlat[1]) 697 zewidth = np.abs(wlon[0]-wlon[1])*60000.*np.cos(3.14*meanlat/180.) 698 zeheight = np.abs(wlat[0]-wlat[1])*60000. 694 699 if blat is None: 695 700 ortholat=meanlat … … 703 708 h = 50. ## en km 704 709 radius = 3397200. 710 #print meanlat, meanlon 705 711 if char == "cyl": m = Basemap(rsphere=radius,projection='cyl',\ 706 712 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) … … 708 714 elif char == "ortho": m = Basemap(rsphere=radius,projection='ortho',lon_0=ortholon,lat_0=ortholat) 709 715 elif char == "lcc": m = Basemap(rsphere=radius,projection='lcc',lat_1=meanlat,lat_0=meanlat,lon_0=meanlon,\ 710 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 716 width=zewidth,height=zeheight) 717 #llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 711 718 elif char == "npstere": m = Basemap(rsphere=radius,projection='npstere', boundinglat=blat, lon_0=0.) 712 719 elif char == "spstere": m = Basemap(rsphere=radius,projection='spstere', boundinglat=blat, lon_0=180.) 713 720 elif char == "nplaea": m = Basemap(rsphere=radius,projection='nplaea', boundinglat=wlat[0], lon_0=meanlon) 714 721 elif char == "laea": m = Basemap(rsphere=radius,projection='laea',lon_0=meanlon,lat_0=meanlat,lat_ts=meanlat,\ 715 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 722 width=zewidth,height=zeheight) 723 #llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 716 724 elif char == "nsper": m = Basemap(rsphere=radius,projection='nsper',lon_0=meanlon,lat_0=meanlat,satellite_height=h*1000.) 717 725 elif char == "merc": m = Basemap(rsphere=radius,projection='merc',lat_ts=0.,\ … … 724 732 zelinewidth = 1 725 733 zelatmax = 80 734 if meanlat > 75.: zelatmax = 90. ; step = step/2. 726 735 # to show gcm grid: 727 736 #zecolor = 'r' … … 833 842 "DOWNDRAFT": "%.0f",\ 834 843 "TK": "%.0f",\ 844 "T": "%.0f",\ 835 845 #"ZMAX_TH": "%.0f",\ 836 846 #"WSTAR": "%.0f",\ … … 1014 1024 "South_Pole": [[-90.,-50.],[-180., 180.]],\ 1015 1025 "Close_South_Pole": [[-90.,-75.],[-180., 180.]],\ 1016 "Sirenum_Crater_large": [[-46.,-34.],[-166., 1017 "Sirenum_Crater_small": [[-36.,-26.],[-168., 1018 1026 "Sirenum_Crater_large": [[-46.,-34.],[-166.,-151.]],\ 1027 "Sirenum_Crater_small": [[-36.,-26.],[-168.,-156.]],\ 1028 "Rupes": [[ 72., 90.],[-120.,- 20.]],\ 1019 1029 } 1020 1030 if area not in list: area = "Whole" -
trunk/UTIL/PYTHON/myscript.py
r612 r637 39 39 parser.add_option('--ylabel', action='store',dest='ylab', type="string", default=None, help='customize the y-axis label') 40 40 parser.add_option('--labels', action='store',dest='labels', type="string", default=None, help='customize 1D curve labels. Str comma-separated. [None]') 41 parser.add_option('--lstyle', action='store',dest='linestyle', type="string", default=None, help='customize 1D curve linestyles. Str ing separated by commas. [None]')41 parser.add_option('--lstyle', action='store',dest='linestyle', type="string", default=None, help='customize 1D curve linestyles. Str comma-separ. [None]') 42 42 43 43 ### SPECIFIC FOR MAPPING [MAPMODE 1] … … 49 49 parser.add_option('--blat', action='store',dest='blat', type="int", default=None, help='reference lat (or bounding lat for stere) [computed]') 50 50 parser.add_option('--blon', action='store',dest='blon', type="int", default=None, help='reference lon [computed]') 51 parser.add_option('--mark', action='append',dest='mark', type="string", default=None, help='superimpose a crossmark at given coords. lon,lat float separated by commas.[None]')51 parser.add_option('--mark', action='append',dest='mark', type="string", default=None, help='superimpose a crossmark at given lon,lat [None]') 52 52 53 53 ### SPECIFIC FOR SLICING [MAPMODE 0] -
trunk/UTIL/PYTHON/planetoplot.py
r614 r637 81 81 from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img 82 82 import matplotlib as mpl 83 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel, subplots_adjust, axes 83 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel, subplots_adjust, axes, clabel 84 84 from matplotlib.cm import get_cmap 85 85 #from mpl_toolkits.basemap import cm … … 141 141 elif typefile != typefile0: errormess("Not the same kind of files !", [typefile0, typefile]) 142 142 ### we care for input file being 1D simulations 143 if typefile in ['gcm'] and len(nc.variables["longitude"][:]) is 1 and len(nc.variables["latitude"][:]) is 1: mapmode=0 ; winds=False 144 elif typefile in ['earthgcm'] and len(nc.variables["lon"][:]) is 1 and len(nc.variables["lat"][:]) is 1: mapmode=0 ; winds=False 143 if "longitude" in nc.dimensions and "latitude" in nc.dimensions: is1d = len(nc.variables["longitude"][:])*len(nc.variables["latitude"][:]) 144 elif "lon" in nc.dimensions and "lat" in nc.dimensions: is1d = len(nc.variables["lon"][:])*len(nc.variables["lat"][:]) 145 if typefile in ['gcm','earthgcm'] and is1d == 1: mapmode=0 ; winds=False 145 146 ### we create default vert and time prescriptions if not here in case mapping mode is on (lat/lon maps) 146 147 if redope is None and mapmode == 1: … … 282 283 all_time[k] = time 283 284 if var2: 285 all_var2[k] = getfield(nc,var2) 284 286 if ((var2 in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (var2 not in nc.variables)): all_var2[k] = slopeamplitude(nc) 285 else: all_var2[k] = getfield(nc,var2)286 287 if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar) 287 288 ##################### … … 561 562 [vecx_frame,vecy_frame] = [dumpbdy(vecx_frame,6,stag=uchar,condition=True), dumpbdy(vecy_frame,6,stag=vchar,condition=True)] 562 563 key = True 564 if fvar in ['UV','uv','uvmet']: key = False 563 565 elif typefile in ['gcm']: 564 566 key = False … … 573 575 zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame)) 574 576 zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20) 575 if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,1000.) 577 if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,1000.) 578 elif var2 == 'tpot': zelevels = np.arange(270,370,5) 579 elif var2 == 'tk': zelevels = np.arange(150,250,5) 576 580 if mapmode == 0: 577 what_I_plot_frame, x, y = define_axis( lon ,lat,vert,time,indexlon,indexlat,indexvert,\581 what_I_plot_frame, x, y = define_axis( lonyeah,latyeah,vert,time,indexlon,indexlat,indexvert,\ 578 582 itime,what_I_plot_frame, len(all_var2[index_f].shape),vertmode ) 579 cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33, alpha=0.5, linestyles='solid') 580 elif mapmode == 1: cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33, alpha=0.5, linestyles='solid') 583 ## is this needed? only if len(all_var2[index_f].shape) != len(all_var[index_f].shape) 584 cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33)#, alpha=0.5, linestyles='solid') 585 clabel(cs, inline=1, fontsize = 4.*rcParams['font.size']/5., fmt=fmtvar(var2.upper())) 586 elif mapmode == 1: cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33)#, alpha=0.5, linestyles='solid') 581 587 if which in ["regular","unidim"]: 582 588
Note: See TracChangeset
for help on using the changeset viewer.