Changeset 817
- Timestamp:
- Oct 25, 2012, 11:24:38 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r796 r817 65 65 def check_localtime(time): 66 66 a=-1 67 print time68 67 for i in range(len(time)-1): 69 68 if (time[i] > time[i+1]): a=i … … 452 451 453 452 ## Author: AS + TN 454 def definesubplot ( numplot, fig 453 def definesubplot ( numplot, fig, ipreferline=False): 455 454 from matplotlib.pyplot import rcParams 456 455 rcParams['font.size'] = 12. ## default (important for multiple calls) … … 470 469 subh = 1 471 470 fig.subplots_adjust(hspace = 0.5) 471 if ipreferline: subv = 1 ; subh = 3 ; fig.subplots_adjust(wspace = 0.35) 472 472 rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. ) 473 473 elif numplot == 4: … … 883 883 h = 50. ## en km 884 884 radius = 3397200. 885 #print meanlat, meanlon886 885 if char == "cyl": m = Basemap(rsphere=radius,projection='cyl',\ 887 886 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) … … 900 899 elif char == "merc": m = Basemap(rsphere=radius,projection='merc',lat_ts=0.,\ 901 900 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 901 elif char == "geos": m = Basemap(rsphere=radius,projection='geos',lon_0=meanlon) 902 elif char == "robin": m = Basemap(rsphere=radius,projection='robin',lon_0=0) 903 elif char == "cass": 904 if zewidth > 60000.: ## approx. more than one degree 905 m = Basemap(rsphere=radius,projection='cass',\ 906 lon_0=meanlon,lat_0=meanlat,\ 907 width=zewidth,height=zeheight) 908 else: 909 m = Basemap(rsphere=radius,projection='cass',\ 910 lon_0=meanlon,lat_0=meanlat,\ 911 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 912 else: errormess("projection not supported.") 902 913 fontsizemer = int(mpl.rcParams['font.size']*3./4.) 903 if char in ["cyl","lcc","merc","nsper","laea"]: step = findstep(wlon) 904 else: step = 10. 905 steplon = step*2. 914 if zewidth > 60000.: 915 if char in ["cyl","lcc","merc","nsper","laea"]: step = findstep(wlon) 916 else: step = 10. 917 steplon = step*2. 918 else: 919 print "very small domain !" 920 steplon = 0.5 921 step = 0.5 906 922 zecolor ='grey' 907 923 zelinewidth = 1 908 zelatmax = 80 909 if meanlat > 75.: zelatmax = 90. ; step = step/2.924 zelatmax = 80. 925 if meanlat > 75.: zelatmax = 90. ; step = step/2. ; steplon = steplon*2. 910 926 # to show gcm grid: 911 927 #zecolor = 'r' … … 914 930 #steplon = 360./64. 915 931 #zelatmax = 90. - step/3 916 if char not in ["moll" ]:932 if char not in ["moll","robin"]: 917 933 if wlon[1]-wlon[0] < 2.: ## LOCAL MODE 918 934 m.drawmeridians(np.r_[-1.:1.:0.05], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, fmt='%5.2f') … … 1041 1057 "TPOT": "%.0f",\ 1042 1058 "TSURF": "%.0f",\ 1059 "TSK": "%.0f",\ 1043 1060 "U_OUT1": "%.0f",\ 1044 1061 "T_OUT1": "%.0f",\ … … 1092 1109 "TPOT": "Paired",\ 1093 1110 "TSURF": "RdBu_r",\ 1111 "TSK": "RdBu_r",\ 1094 1112 "QH2O": "PuBu",\ 1095 1113 "USTM": "YlOrRd",\ … … 1350 1368 else: y = lat 1351 1369 count = count+1 1352 if indexvert is None and ((dim0 == 4) or (y is None)):1370 if indexvert is None and len(vert) > 1 and ((dim0 == 4) or (y is None)): 1353 1371 print "AXIS is vert" 1354 1372 if vertmode == 0: # vertical axis is as is (GCM grid) -
trunk/UTIL/PYTHON/myscript.py
r792 r817 31 31 parser.add_option('-c', '--color', action='store',dest='clb', type="string", default=None, help='change colormapS (also: nobar,onebar,def)') 32 32 parser.add_option('--trycol', action='store_true',dest='trycol', default=False, help='try 9 typical color palette') 33 parser.add_option('--nocolorb', action='store_true',dest='nocolorb', default=False, help='no color bar please') 33 34 parser.add_option('--div', action='store',dest='ndiv', type="int", default=10, help='number of divisions in colorbar [10]') 34 35 parser.add_option('--title', action='store',dest='zetitle', type="string", default="fill",help='customize the whole title') -
trunk/UTIL/PYTHON/planetoplot.py
r792 r817 76 76 trycol=False,\ 77 77 streamflag=False,\ 78 nocolorb=False,\ 78 79 analysis=None): 79 80 … … 429 430 ### Open a figure and set subplots 430 431 fig = figure() 431 subv,subh = definesubplot( numplot, fig )432 subv,subh = definesubplot( numplot, fig, ipreferline = (mapmode == 1) ) 432 433 if ope in ['-','-%','-_histo'] and len(namefiles) ==1 : subv,subh = 2,2 433 434 elif ope in ['-','-%'] and len(namefiles)>1 : subv, subh = len(namefiles), 3 … … 464 465 ltst = None 465 466 if typefile in ['meso'] and indextime is not None and len(indextime) < 2: ltst = localtime ( indextime, slon , all_namefile[index_f]) 467 468 469 #if mapmode == 0: 470 # if xlab is None: 471 # if indexlon is None: xlab = "Longitude" 472 # elif indexlat is None: xlab = "Latitude" 473 # if ylab is None: 474 # if indexvert is None: ylab = "Altitude" 475 476 466 477 print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime 467 478 ##var = nc.variables["phisinit"][:,:] … … 547 558 else: palette = get_cmap(name=colorb) 548 559 #palette = cm.GMT_split 560 #palette = cm.GMT_globe 549 561 ##### 1. ELIMINATE 0D or >3D CASES 550 562 if len(what_I_plot.shape) == 0: … … 618 630 if indextime is None and axtime is not None and xlab is None: xlabel(axtime.upper()) ## define the right label 619 631 if save == 'txt': writeascii(np.transpose([x,np.transpose(what_I_plot)]),'profile'+str(nplot*1000+imov)+'.txt') 620 632 if axtime == "lt": 633 ax = mpl.pyplot.gca() 634 # set ticks where your images will be 635 ax.get_xaxis().set_ticks(np.arange(0,48,2)) 636 # rename tick labels 637 ax.get_xaxis().set_ticklabels(["0","2","4","6","8","10","12","14","16","18","20","22",\ 638 "0","2","4","6","8","10","12","14","16","18","20","22"]) 639 ## rebound everyone 640 ax.set_xbound(lower=min(x), upper=max(x)) 621 641 elif which == "xy": 622 642 if lbls is not None: lbl=lbls[index_f] … … 707 727 mpl.pyplot.plot([idx],[idy],'+k',mew=0.5,ms=18) 708 728 709 if colorb not in ['nobar','onebar']: 729 if not nocolorb: 730 if colorb not in ['nobar','onebar']: 710 731 if (fileref is not None) and ((index_f+1)%3 == 0): daformat = "%.3f" 711 732 elif mult != 1: daformat = "%.1f" -
trunk/UTIL/PYTHON/pp.py
r792 r817 177 177 redope=opt.redope,seevar=opt.seevar,xlab=opt.xlab,ylab=opt.ylab,lbls=separatenames(opt.labels),\ 178 178 lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark),markdevil=opt.mdevil,facwind=opt.facwind,\ 179 trycol=opt.trycol,streamflag=opt.stream, analysis=opt.analysis)179 trycol=opt.trycol,streamflag=opt.stream,nocolorb=opt.nocolorb,analysis=opt.analysis) 180 180 print 'DONE: '+name 181 181 system("rm -f to_be_erased")
Note: See TracChangeset
for help on using the changeset viewer.