Changeset 20472
- Timestamp:
- Oct 30, 2008, 5:07:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20459 r20472 64 64 65 65 plotcol_1frame_tlist = [ 66 (['d_sky'],['d_mag'],'scatter') 66 (['x_psf','objc_colc'],['y_psf','objc_rowc'],'scatter') 67 ,(['psfinstmag_sdss'],['d_mag'],'scatter') 68 ,(['psfinstmag_sdss'],['d_sky'],'scatter') 67 69 ,(['d_x'],['d_y'],'scatter') 68 70 ,(['sky_ps1'],['d_mag'],'scatter') 69 ,([' psfinstmag_sdss'],['d_mag'],'scatter')70 ,([' psfinstmag_sdss'],['d_sky'],'scatter')71 ,(['d_sky'],['d_mag'],'scatter') 72 ,(['x_psf'],['objc_colc'],'histogram') 71 73 ,(['m_rr_cc_psf'],['d_mag'],'scatter') 72 74 ,(['sky_sdss'],['sky_ps1'],'scatter') 75 ,(['y_psf'],['objc_rowc'],'histogram') 76 ,(['sky_sdss'],['sky_ps1'],'histogram') 73 77 ,(['psfinstmag_sdss'],['psf_inst_mag'],'histogram') 74 ,(['sky_sdss'],['sky_ps1'],'histogram')75 ,(['x_psf'],['objc_colc'],'histogram')76 ,(['y_psf'],['objc_rowc'],'histogram')77 ,(['x_psf','objc_colc'],['y_psf','objc_rowc'],'scatter')78 78 ] 79 79 … … 81 81 (['d_mag_median'],['d_sky_median'],'scatter') 82 82 ,(['d_x_median'],['d_y_median'],'scatter') 83 ,(['d_x_median'],['d_y_median'],'histogram') 83 84 ,(['d_mag_median'],['N_SDSS'],'scatter') 85 ,(['N_PS1'],['N_SDSS'],'scatter') 84 86 ,(['field','field'],['d_mag_median','d_mag_mean'],'scatter') 85 87 ] 86 88 87 def mergePlots( plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=['u','g','r','i','z'],workdir='/IPP/data/SDSS/stripe82/coadd/compare'):89 def mergePlots(summaryTable,plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=['u','g','r','i','z'],workdir='/IPP/data/SDSS/stripe82/coadd/compare'): 88 90 from subprocess import call 89 91 from glob import glob 92 import re 90 93 import os 91 94 os.chdir(workdir) 95 outroot = re.sub('(\.[sc]mf|\.fits?)$','',summaryTable) 92 96 for tup in plotcol_1frame_tlist: 93 97 t1,t2,t3=tup … … 95 99 globstr = getOutnameStatsOnefile("match_%s_*"%(filt),t3,t1,t2) 96 100 filelist = glob(globstr) 97 outname = getOutnameStatsOnefile("merged_%s " %(filt),t3,t1,t2)101 outname = getOutnameStatsOnefile("merged_%s_%s" %(outroot,filt),t3,t1,t2) 98 102 cmdstr = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(outname,' '.join(filelist)) 99 103 print "Making %s" %(outname) 100 104 call(cmdstr,shell=True) 101 call("gzip %s" %(outname),shell=True) 105 print "gzipping %s" %(outname) 106 call("gzip -f %s" %(outname),shell=True) 102 107 103 108 def compIPPphoto(summaryTable,mode,plotcol_1frame_tlist=plotcol_1frame_tlist,\ … … 144 149 vallist,keylist = valuesKeysSortedByKeys(stats_hash) 145 150 rowtuple_list.append(vallist) 146 plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex )151 plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex,bandid=filter_name) 147 152 # return column_hash,goodrow_hash 148 153 newrows = numpy.rec.array(rowtuple_list,names=keylist) … … 159 164 sumgoodrows_hash = summaryhash.fromkeys(summaryhash.keys(),numpy.ones((nrows,),bool)) 160 165 for filt in filters: 166 print bandindex_hash[filt], filt 161 167 plotStatsOnefile(summaryhash,sumgoodrows_hash,summaryTable,plotcol_summary_tlist,bandindex_hash[filt],bandid=filt) 162 mergePlots( plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=filters)168 mergePlots(summaryTable,plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=filters) 163 169 return column_hash,goodrow_hash 164 170 … … 175 181 return outhash 176 182 177 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps',bandid='' ):183 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps',bandid='',useBandid=False): 178 184 import re 179 185 # Construct output filename 180 186 root = re.sub('(\.[sc]mf|\.fits?)$','',matchtable) 181 if bandid != '':187 if useBandid and bandid != '': 182 188 root = "%s_%s" %(root,bandid) 183 189 if isNone(col2_l): … … 191 197 192 198 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps',bandid=''): 193 """Make diagnostic plots for a single table, based on values 194 in values_hash""" 199 """Make diagnostic plots for a single table, based on values in 200 values_hash""" 201 from subprocess import call 195 202 from numpy import concatenate 196 203 from sm import cvar,angle … … 201 208 angle_l = [0,45,0,45,0,90] 202 209 ptype_l = [ 41, 41, 40, 40, 30,30] 210 outname_l = [] 211 nplots = 0 203 212 for troika in plotcol_tlist: 204 213 col1name_l = troika[0] … … 206 215 plottype = troika[2] 207 216 outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format,bandid=bandid) 217 outname_l.append(outname) 208 218 smOpenPlot(outname,format=format) 209 219 firstplot = True … … 259 269 firstplot = False 260 270 i+=1 261 smClosePlot() 271 smClosePlot() 272 nplots += 1 273 all_outname = "nup_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps" 274 tmp_outname = "tmp_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps" 275 print "creating ", all_outname 276 mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l)) 277 call(mergecmd,shell=True) 278 psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname) 279 print "calling ", psnupcmd 280 call(psnupcmd,shell=True) 281 os.remove(tmp_outname) 282 return all_outname 283 262 284 263 285 def valuesKeysSortedByKeys(hash): … … 513 535 return array(good1_l),array(good2_l),array(good3_l) 514 536 515 def makePlan(lastcamcol= 6):537 def makePlan(lastcamcol=1): 516 538 """Make paired list of which fpObjc file to compare to which IPP 517 539 .cmf file. Could also think about constructing the fpObjc filename … … 598 620 # Filtering out objects that can't be primary, i.e. 599 621 # !BRIGHT && (!BLENDED || NODEBLEND || nchild == 0) 600 sdssfilt += ';select !((flags[%s]&1<<1)!=0)&&(!((flags[%s]&1<<3)!=0)||((flags[%s]&1<<6)!=0)||nchild==0)' % \ 601 (bandindex,bandindex,bandindex) 602 # add check for BINNED1 !!! bit28 in flags1 603 622 # Get flag values by left-shifting a 1 by the correct number of bits. Bit N needs to be left-shifted N times. 623 bright = 1<<1 624 blended = 1<<3 625 nodeblend = 1<<6 626 binned1 = 1<<28 627 sdssfilt += ';select ((flags[%s]&%s)==0)&&(!((flags[%s]&%s)!=0)||((flags[%s]&%s)!=0)||nchild==0)&&((flags[%s]&%s)!=0)' % \ 628 (bandindex,bright,bandindex,blended,bandindex,nodeblend,bandindex,binned1) 604 629 # Check flag 0x4000 (extended) to compare against prob_psf in SDSS 605 630 # - for some reason, 'flags' and the other integer columns get
Note:
See TracChangeset
for help on using the changeset viewer.
