Changeset 721
- Timestamp:
- Jul 12, 2012, 8:02:52 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r717 r721 58 58 if 'controle' in nc.variables: typefile = 'gcm' 59 59 elif 'phisinit' in nc.variables: typefile = 'gcm' 60 elif 'phis' in nc.variables: typefile = 'gcm' 60 61 elif 'time_counter' in nc.variables: typefile = 'earthgcm' 61 62 elif hasattr(nc,'START_DATE'): typefile = 'meso' … … 744 745 elif 'U' in varinfile: [uchar,vchar] = ['U','V'] #; print "this is RAW meso file" 745 746 elif 'u' in varinfile: [uchar,vchar] = ['u','v'] #; print "this is GCM file" 747 elif 'vitu' in varinfile: [uchar,vchar] = ['vitu','vitv'] #; print "this is GCM v5 file" 746 748 ### you can add choices here ! 747 749 else: [uchar,vchar] = ['not found','not found'] … … 1068 1070 "gray": "red",\ 1069 1071 "PuBu": "black",\ 1072 "titan": "red",\ 1070 1073 } 1071 1074 if whichone not in whichcolor: … … 1105 1108 "blueclouds": "http://eoimages.gsfc.nasa.gov/ve/2431/land_ocean_ice_cloud_2048.jpg",\ 1106 1109 "justclouds": "http://eoimages.gsfc.nasa.gov/ve/2432/cloud_combined_2048.jpg",\ 1110 "pluto": "http://www.boulder.swri.edu/~buie/pluto/pluto_all.png",\ 1111 "triton": "http://laps.noaa.gov/albers/sos/neptune/triton/triton_rgb_cyl_www.jpg",\ 1112 "titan": "http://laps.noaa.gov/albers/sos/saturn/titan/titan_rgb_cyl_www.jpg",\ 1113 #"titan": "http://laps.noaa.gov/albers/sos/celestia/titan_50.jpg",\ 1114 "titanuni": "http://maps.jpl.nasa.gov/pix/sat6fss1.jpg",\ 1115 "venus": "http://laps.noaa.gov/albers/sos/venus/venus4/venus4_rgb_cyl_www.jpg",\ 1116 "cosmic": "http://laps.noaa.gov/albers/sos/universe/wmap/wmap_rgb_cyl_www.jpg",\ 1107 1117 } 1108 1118 ### see http://www.mmedia.is/~bjj/planetary_maps.html … … 1138 1148 "Sirenum_Crater_small": [[-36.,-26.],[-168.,-156.]],\ 1139 1149 "Rupes": [[ 72., 90.],[-120.,- 20.]],\ 1150 "Xanadu": [[-40., 20.],[ 40., 120.]],\ 1140 1151 } 1141 1152 if area not in list: area = "Whole" -
trunk/UTIL/PYTHON/myscript.py
r647 r721 42 42 43 43 ### SPECIFIC FOR MAPPING [MAPMODE 1] 44 parser.add_option('-p', '--proj', action='store',dest='proj', type="string", default=None, help='projection') 45 parser.add_option('-b', '--back', action='store',dest='back', type="string", default=None, help='background image [None]') 46 parser.add_option('-W', '--winds', action='store_true',dest='winds', default=False, help='wind vectors [False]') 47 parser.add_option('-s', '--stride', action='store',dest='ste', type="int", default=3, help='stride vectors [3]') 48 parser.add_option('-z', '--zoom', action='store',dest='zoom', type="float", default=None, help='zoom factor in %') 49 parser.add_option('--blat', action='store',dest='blat', type="int", default=None, help='reference lat (or bounding lat for stere) [computed]') 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 lon,lat [None]') 44 parser.add_option('-p', '--proj', action='store',dest='proj', type="string", default=None, help='projection') 45 parser.add_option('-b', '--back', action='store',dest='back', type="string", default=None, help='background image [None]') 46 parser.add_option('-W', '--winds', action='store_true',dest='winds', default=False, help='wind vectors [False]') 47 parser.add_option('--facwind', action='store',dest='facwind', type="float", default=1, help='wind vectors magnifying factor [1]') 48 parser.add_option('-s', '--stride', action='store',dest='ste', type="int", default=3, help='stride vectors [3]') 49 parser.add_option('-z', '--zoom', action='store',dest='zoom', type="float", default=None, help='zoom factor in %') 50 parser.add_option('--blat', action='store',dest='blat', type="int", default=None, help='reference lat (or bounding lat for stere) [computed]') 51 parser.add_option('--blon', action='store',dest='blon', type="int", default=None, help='reference lon [computed]') 52 parser.add_option('--mark', action='append',dest='mark', type="string", default=None, help='superimpose a crossmark at given lon,lat [None]') 52 53 53 54 ### SPECIFIC FOR SLICING [MAPMODE 0] … … 66 67 67 68 ### OPERATIONS BETWEEN FILES 68 parser.add_option('--operation', action='store',dest='operat', type="string", default=None, help='operation to perform on input files given through -f. "+" or "-" acts on each input file by adding or substracting the ref file specified through --fref. "cat" acts on all input files in-a-row. "add_var" "sub_var" "mul_var" "div_var" acts on two variables .')69 parser.add_option('--operation', action='store',dest='operat', type="string", default=None, help='operation to perform on input files given through -f. "+" or "-" acts on each input file by adding or substracting the ref file specified through --fref. "cat" acts on all input files in-a-row. "add_var" "sub_var" "mul_var" "div_var" acts on two variables (add _only to get only operation plot).') 69 70 parser.add_option('--fref', action='store',dest='fref', type="string", default=None, help='reference namefile for the --operation option.') 70 71 parser.add_option('--mope', action='store',dest='vminope', type="float", default=0., help='bounding minimum value for inter-file operation') -
trunk/UTIL/PYTHON/planetoplot.py
r718 r721 67 67 lstyle=None,\ 68 68 cross=None,\ 69 facwind=1.,\ 69 70 streamflag=False): 70 71 … … 190 191 elif "lon" in nc.variables: lon = nc.variables["lon"][:] 191 192 ### ALT 192 if "altitude" in nc.variables: vert = nc.variables["altitude"][:] 193 elif "Alt" in nc.variables: vert = nc.variables["Alt"][:] 194 elif "lev" in nc.variables: vert = nc.variables["lev"][:] 195 else: vert = [0.] 193 if "altitude" in nc.variables: vert = nc.variables["altitude"][:] 194 elif "Alt" in nc.variables: vert = nc.variables["Alt"][:] 195 elif "lev" in nc.variables: vert = nc.variables["lev"][:] 196 elif "presnivs" in nc.variables: vert = nc.variables["presnivs"][:] 197 else: vert = [0.] 196 198 ### AIRE (to weight means with the area) 197 199 if "aire" in nc.variables: area = nc.variables["aire"][:,:] … … 364 366 if len(namefiles) > 1: errormess("for this operation... please set only one file !") 365 367 if len(var) > 2: errormess("not sure this works for more than 2 vars... please check.") 366 if ope in ["div_var"]: all_var[k] = all_var[k-2] / all_var[k-1] ; insert = '_div_'367 elif ope in ["mul_var"]: all_var[k] = all_var[k-2] * all_var[k-1] ; insert = '_mul_'368 elif ope in ["add_var"]: all_var[k] = all_var[k-2] + all_var[k-1] ; insert = '_add_'369 elif ope in ["sub_var"]: all_var[k] = all_var[k-2] - all_var[k-1] ; insert = '_sub_'368 if "div_var" in ope: all_var[k] = all_var[k-2] / all_var[k-1] ; insert = '_div_' 369 elif "mul_var" in ope: all_var[k] = all_var[k-2] * all_var[k-1] ; insert = '_mul_' 370 elif "add_var" in ope: all_var[k] = all_var[k-2] + all_var[k-1] ; insert = '_add_' 371 elif "sub_var" in ope: all_var[k] = all_var[k-2] - all_var[k-1] ; insert = '_sub_' 370 372 else: errormess(ope+" : non-implemented operation. Check pp.py --help") 371 373 numplot = numplot + 1 ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] 372 374 all_varname[k] = all_varname[k-2] + insert + all_varname[k-1] 375 ### only the operation plot 376 if "only" in ope: 377 numplot = 1 ; all_var[0] = all_var[k] 378 all_time[0] = all_time[k] ; all_namefile[0] = all_namefile[k] 379 all_varname[0] = all_varname[k-2] + insert + all_varname[k-1] 380 381 373 382 ################################## 374 383 ### Open a figure and set subplots … … 604 613 key = False 605 614 if metwind and mapmode == 1: [vecx_frame,vecy_frame] = m.rotate_vector(vecx_frame, vecy_frame, lon2d, lat2d) 606 if var:colorvec = definecolorvec(colorb)607 else: colorvec = definecolorvec(back)615 if trans != 0.0: colorvec = definecolorvec(colorb) 616 else: colorvec = definecolorvec(back) 608 617 vectorfield(vecx_frame, vecy_frame, x, y, stride=stride, csmooth=2,\ 609 618 #scale=15., factor=300., color=colorvec, key=key) 610 scale=20., factor=250. , color=colorvec, key=key)619 scale=20., factor=250./facwind, color=colorvec, key=key) 611 620 #200. ## or csmooth=stride 621 ### THIS IS A QUITE SPECIFIC PIECE (does not work for mesoscale files) 612 622 if ope == '-' and nplot == numplot: # this should work as long as ope is '-' guarantees 3 plots for 4 panels without contour 613 623 subplot(subv,subh,nplot+1) … … 616 626 latmin = -50.; latmax = 50. # latitude range for histogram of difference 617 627 zeindexlat = (lat<latmax)*(lat>latmin) 628 if typefile in ['meso']: zeindexlat = 10 618 629 # this follows the define_axis logic in myplot.py: 619 630 if indextime is None or indexlon is None: what_I_plot_frame = what_I_plot_frame[zeindexlat,:] … … 633 644 zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame)) 634 645 zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20) 635 if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,1000.) 636 elif var2 == 'tpot': zelevels = np.arange(270,370,5) 637 elif var2 == 'tk': zelevels = np.arange(150,250,5) 646 ### another dirty specific stuff in the wall 647 if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,1000.) 648 elif var2 == 'tpot': zelevels = np.arange(270,370,5) 649 elif var2 == 'tk': zelevels = np.arange(150,250,5) 650 elif var2 == 'wstar': zelevels = np.arange(0,10,1.0) 651 elif var2 == 'zmax_th': zelevels = np.arange(0,10,2.0) ; what_I_plot_frame = what_I_plot_frame / 1000. 652 ### 638 653 if mapmode == 0: 639 654 what_I_plot_frame, x, y = define_axis( lonyeah,latyeah,vert,time,indexlon,indexlat,indexvert,\ … … 641 656 ## is this needed? only if len(all_var2[index_f].shape) != len(all_var[index_f].shape) 642 657 cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33)#, alpha=0.5, linestyles='solid') 658 #cs = contour( x,y,what_I_plot_frame, zelevels, colors='w', linewidths = 0.5)#, alpha=0.5, linestyles='solid') 643 659 clabel(cs, inline=1, fontsize = 4.*rcParams['font.size']/5., fmt=fmtvar(var2.upper())) 644 elif mapmode == 1: cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33)#, alpha=0.5, linestyles='solid') 660 elif mapmode == 1: 661 cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33)#, alpha=0.5, linestyles='solid') 662 #clabel(cs, inline=0, fontsize = rcParams['font.size'], fmt="%.0f") #fmtvar(var2.upper())) 645 663 if which in ["regular","unidim"]: 646 664 … … 738 756 ### 739 757 zeplot = prefix + basename 758 if zoom: zeplot = zeplot + "zoom"+str(abs(zoom)) 740 759 if addchar: zeplot = zeplot + addchar 741 760 if numplot <= 0: zeplot = zeplot + "_LT"+str(abs(numplot)) -
trunk/UTIL/PYTHON/pp.py
r647 r721 23 23 ### Get options and variables 24 24 parser = OptionParser() ; getparseroptions(parser) ; (opt,args) = parser.parse_args() 25 if opt.file is None: errormess("I want to eat one file at least ! Use winds.py -f name_of_my_file. Or type winds.py -h")25 if opt.file is None: errormess("I want to eat one file at least ! Use pp.py -f name_of_my_file. Or type pp.py -h") 26 26 if opt.var is None and opt.anomaly is True: errormess("Cannot ask to compute anomaly if no variable is set") 27 27 if opt.fref is not None and opt.operat is None: errormess("you must specify an operation when using a reference file") … … 61 61 else: 62 62 [lschar,zehour,zehourin] = ["",0,0] 63 if opt.var is None: opt.var = ["phisinit"] ; opt.clb = "nobar" 63 if opt.var is None: 64 opt.var = ["phisinit"] ; opt.clb = "nobar" 65 ### temporaire... en attendant mieux. 66 if opt.back == "titan": opt.var = ["phis"] ; opt.clb = "nobar" 64 67 65 68 if opt.vmin is not None : zevmin = opt.vmin[min(i,len(opt.vmin)-1)] … … 172 175 mrate=opt.rate,mquality=opt.quality,trans=opt.trans,zarea=opt.area,axtime=opt.axtime,\ 173 176 redope=opt.redope,seevar=opt.seevar,xlab=opt.xlab,ylab=opt.ylab,lbls=separatenames(opt.labels),\ 174 lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark), streamflag=opt.stream)177 lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark),facwind=opt.facwind,streamflag=opt.stream) 175 178 print 'DONE: '+name 176 179 system("rm -f to_be_erased")
Note: See TracChangeset
for help on using the changeset viewer.