Changeset 20528
- Timestamp:
- Nov 4, 2008, 5:03:53 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20527 r20528 67 67 # (and that's probably quite enough anyway). 68 68 69 # Look at extended flag in PS1 vs. SDSS!!! 69 70 70 71 plotcol_1frame_tlist = [ … … 75 76 ,(['sky_ps1'],['d_mag'],'scatter') 76 77 ,(['d_sky'],['d_mag'],'scatter') 77 ,([' x_psf'],['objc_colc'],'histogram')78 ,(['d_x'],['d_y'],'histogram') 78 79 ,(['m_rr_cc_psf'],['d_mag'],'scatter') 79 80 ,(['sky_sdss'],['sky_ps1'],'scatter') … … 100 101 outroot = re.sub('(\.[sc]mf|\.fits?)$','',summaryTable) 101 102 for filt in filtlist: 102 rootstr = " nup_match_%s"%(filt)103 rootstr = "win_match_%s"%(filt) 103 104 globstr = "%s_*.eps"%(rootstr) 104 105 filelist = glob(globstr) … … 203 204 return outname 204 205 205 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps',bandid=''): 206 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,\ 207 format='epsport',bandid='',expand=0.8): 206 208 """Make diagnostic plots for a single table, based on values in 207 209 values_hash""" … … 218 220 ptype_l = [ 41, 41, 40, 40, 30,30] 219 221 outname_l = [] 220 nplots = 0 222 nplots = len(plotcol_tlist) 223 all_outname = "win_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps" 224 smOpenPlot(all_outname,format=format) 225 # all the explict sm. and smLib. calls should be wrapped into 226 # functions that can be called for other plotting packages 227 sm.window(1,1,1,1) 228 sm.frelocate(0.5,1.05) 229 sm.putlabel(5,re.sub('(\.[sc]mf|\.fits?)$','',re.sub('_','\_',matchtable))) 230 i=0 221 231 for troika in plotcol_tlist: 232 i+=1 233 Nx,Ny,winx,winy = setWindow(i,nplots) 234 smLib.window(Nx,Ny,winx,winy) 222 235 col1name_l = troika[0] 223 236 col2name_l = troika[1] … … 225 238 outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format,bandid=bandid) 226 239 outname_l.append(outname) 227 smOpenPlot(outname,format=format)228 240 firstplot = True 229 i = 0230 241 for col1name,col2name in zip(col1name_l,col2name_l): 231 242 values1 = values_hash[col1name.lower()] … … 255 266 smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name,\ 256 267 # xrange=(xmin,xmax),yrange=(ymin,ymax)) 257 xrange=None,yrange=None )268 xrange=None,yrange=None,expand=expand) 258 269 else: 259 270 smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name) 260 271 else: 261 272 angle(angle_l[i%len(angle_l)]) 262 smScatterPlot(values1,values2,ptype=ptype_l[i%len(ptype_l)],logical=goodrows,append=True) 273 smScatterPlot(values1,values2,ptype=ptype_l[i%len(ptype_l)],\ 274 logical=goodrows,append=True,expand=expand) 263 275 angle(0) 264 276 if plottype == 'histogram': … … 273 285 minbin=None 274 286 maxbin=None 275 smHistoPlot(values2,ltype=0,nbins=Nbins,minbin=minbin,maxbin=maxbin,xlab=col2name,ylab="N") 287 smHistoPlot(values2,ltype=0,nbins=Nbins,minbin=minbin,maxbin=maxbin,\ 288 xlab=col2name,ylab="N",expand=expand) 276 289 smHistoPlot(values1,append=True,minbin=minbin,maxbin=maxbin,nbins=Nbins,\ 277 ltype=2 )290 ltype=2,expand=expand) 278 291 firstplot = False 279 i+=1 280 smClosePlot() 281 nplots += 1 292 smClosePlot() 282 293 all_outname = "nup_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps" 283 294 tmp_outname = "tmp_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps" 284 print "creating ", all_outname285 mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l))286 call(mergecmd,shell=True)287 psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname)288 print "calling ", psnupcmd289 call(psnupcmd,shell=True)290 os.remove(tmp_outname)295 # print "creating ", all_outname 296 # mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l)) 297 # call(mergecmd,shell=True) 298 # psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname) 299 # print "calling ", psnupcmd 300 # call(psnupcmd,shell=True) 301 # os.remove(tmp_outname) 291 302 return all_outname 292 303 293 def setWindow(i,Nplots ):304 def setWindow(i,Nplots,portrait=True): 294 305 """Set sm window for plotting the i-th out of Nplots. The logic is 295 306 that N_x * N_y >= Nplots and N_y-N_x is 0 or 1. So Ny is the sqrt … … 318 329 if int(i/Nx) == i/float(Nx): 319 330 winy -= 1 331 if not portrait: 332 tmp = Nx 333 Nx = Ny 334 Ny = tmp 335 tmp = winx 336 winx = winy 337 winy = tmp 320 338 return Nx,Ny,winx,winy 321 339 … … 697 715 """Issue sm device command for file of given format: 698 716 eps -> postfile 717 epsland -> postlandfile 718 epsport -> postportfile 699 719 else just use given format as 'device'""" 700 720 from sm import device, erase … … 703 723 elif format == 'eps': 704 724 device('postfile '+filename) 725 elif format == 'epsland': 726 device('postlandfile '+filename) 727 elif format == 'epsport': 728 device('postportfile '+filename) 705 729 else: 706 730 device(format +' '+filename) … … 717 741 xlab=None,ylab=None,xrange=None,yrange=None,\ 718 742 box1=None,box2=None,box3=None,box4=None,\ 719 ltype=0,append=False ):743 ltype=0,append=False,expand=1.8): 720 744 """Plot a histogram, intelligently deriving bins from the given 721 745 parameters if they are given intelligently. Otherwise, silently … … 735 759 bincenters = leftbinedges + 0.5*(leftbinedges[1]-leftbinedges[0]) 736 760 761 sm.expand(expand) 737 762 sm.ltype(ltype) 738 763 if not append: … … 764 789 def smScatterPlot(x,y,logical=None,ptype=41,xlab=None,ylab=None,xrange=None,yrange=None,\ 765 790 box1=None,box2=None,box3=None,box4=None,\ 766 append=False ):791 append=False,expand=1.8): 767 792 """Make an sm scatter plot on current device. If append=True, 768 793 overplot with current limits. Otherwise, draw box box1 box2 box3 box4""" 769 794 import sm 770 sm.expand( 1.8)795 sm.expand(expand) 771 796 sm.lweight(5) 772 797 # Silently ignore any problems with plot generation … … 779 804 pass 780 805 806 # May need to add erase option here which defaults to True 781 807 def smSetup(x,y,logical,xrange,yrange,xlab,ylab,box1,box2,box3,box4): 782 808 import sm,re
Note:
See TracChangeset
for help on using the changeset viewer.
