Changeset 20459
- Timestamp:
- Oct 29, 2008, 6:35:57 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20285 r20459 58 58 # 59 59 # Convention: for scatter, plot second against first; for histogram, plot both histograms 60 61 62 # XXX Todo: labels! group by runs? different colours for different 63 # bands; include seeing? plot things against seeing? 64 60 65 plotcol_1frame_tlist = [ 61 66 (['d_sky'],['d_mag'],'scatter') … … 63 68 ,(['sky_ps1'],['d_mag'],'scatter') 64 69 ,(['psfinstmag_sdss'],['d_mag'],'scatter') 70 ,(['psfinstmag_sdss'],['d_sky'],'scatter') 65 71 ,(['m_rr_cc_psf'],['d_mag'],'scatter') 72 ,(['sky_sdss'],['sky_ps1'],'scatter') 66 73 ,(['psfinstmag_sdss'],['psf_inst_mag'],'histogram') 67 74 ,(['sky_sdss'],['sky_ps1'],'histogram') … … 75 82 ,(['d_x_median'],['d_y_median'],'scatter') 76 83 ,(['d_mag_median'],['N_SDSS'],'scatter') 77 ,([' d_mag_median','d_mag_mean'],['field','field'],'scatter')84 ,(['field','field'],['d_mag_median','d_mag_mean'],'scatter') 78 85 ] 79 86 87 def mergePlots(plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=['u','g','r','i','z'],workdir='/IPP/data/SDSS/stripe82/coadd/compare'): 88 from subprocess import call 89 from glob import glob 90 import os 91 os.chdir(workdir) 92 for tup in plotcol_1frame_tlist: 93 t1,t2,t3=tup 94 for filt in filtlist: 95 globstr = getOutnameStatsOnefile("match_%s_*"%(filt),t3,t1,t2) 96 filelist = glob(globstr) 97 outname = getOutnameStatsOnefile("merged_%s" %(filt),t3,t1,t2) 98 cmdstr = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(outname,' '.join(filelist)) 99 print "Making %s" %(outname) 100 call(cmdstr,shell=True) 101 call("gzip %s" %(outname),shell=True) 80 102 81 103 def compIPPphoto(summaryTable,mode,plotcol_1frame_tlist=plotcol_1frame_tlist,\ … … 109 131 stats_hash={} 110 132 chipfile_l,fpObjc_l = makePlan() 133 filters = [] 134 bandindex_hash = {} 111 135 for chipfile,fpObjc in zip(chipfile_l,fpObjc_l): 112 136 matchtable,filter_name,bandindex = matchSdssPs1(fpObjc,chipfile,skip=skip) 137 if filter_name not in filters: 138 filters.append(filter_name) 139 bandindex_hash[filter_name] = bandindex 113 140 stats_hash, column_hash, goodrow_hash = computeStatistics(matchtable) 114 141 # Sort res_hash by its column names to make sure order is … … 131 158 # Fake a goodrows hash 132 159 sumgoodrows_hash = summaryhash.fromkeys(summaryhash.keys(),numpy.ones((nrows,),bool)) 133 plotStatsOnefile(summaryhash,sumgoodrows_hash,summaryTable,plotcol_summary_tlist,bandindex) 160 for filt in filters: 161 plotStatsOnefile(summaryhash,sumgoodrows_hash,summaryTable,plotcol_summary_tlist,bandindex_hash[filt],bandid=filt) 162 mergePlots(plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=filters) 134 163 return column_hash,goodrow_hash 164 165 # XXX Todo: check histogram axis scaling! 135 166 136 167 def hashFromPyfitsTable(pyfitsTableHDU): … … 144 175 return outhash 145 176 146 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps' ):177 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps',bandid=''): 147 178 import re 148 179 # Construct output filename 149 180 root = re.sub('(\.[sc]mf|\.fits?)$','',matchtable) 181 if bandid != '': 182 root = "%s_%s" %(root,bandid) 150 183 if isNone(col2_l): 151 184 outname = '%s_%s_%s.%s' % (root,kind,col1[0],format) … … 157 190 return outname 158 191 159 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps' ):192 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps',bandid=''): 160 193 """Make diagnostic plots for a single table, based on values 161 194 in values_hash""" 162 195 from numpy import concatenate 163 196 from sm import cvar,angle 197 import re 164 198 # In histograms, only plot core of distribution within these percentiles: 165 199 histo_min_ntile = 0.03 … … 171 205 col2name_l = troika[1] 172 206 plottype = troika[2] 173 outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format )207 outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format,bandid=bandid) 174 208 smOpenPlot(outname,format=format) 175 209 firstplot = True … … 238 272 def appendFitsTable(fitsfile,tabHDU,HDU=1): 239 273 """Append rows in tabHDU to existing fits table file""" 274 import pyfits 240 275 oldtabhdulist = pyfits.open(fitsfile) 241 276 nrows_old = len(oldtabhdulist[HDU].data) … … 370 405 ,'d_skyerr':['skyErr','SKY_SIGMA'] 371 406 ,'d_pointsource':['prob_psf','pointsource_ps1'] 372 # ,'d_mag':['psfcounts','PSF_INST_MAG ']373 # ,'d_magerr':['psfcountserr','PSF_INST_MAG_SIG']374 407 ,'d_mag':['psfinstmag_sdss','PSF_INST_MAG'] 375 408 ,'d_magerr':['psfinstmagerr_sdss','PSF_INST_MAG_SIG'] … … 480 513 return array(good1_l),array(good2_l),array(good3_l) 481 514 482 def makePlan( ):515 def makePlan(lastcamcol=6): 483 516 """Make paired list of which fpObjc file to compare to which IPP 484 517 .cmf file. Could also think about constructing the fpObjc filename … … 487 520 488 521 # For testing: 489 return ['1056-0192.421/1056-0192.421.ch.421.CHIP1.cmf'],['1056-0192.421/fpObjc-001056-1-0192.fit']522 # return ['1056-0192.421/1056-0192.421.ch.421.CHIP1.cmf'],['1056-0192.421/fpObjc-001056-1-0192.fit'] 490 523 491 524 from glob import glob … … 507 540 } 508 541 Nfields = 18 509 camcollist = range(1, 6+1)542 camcollist = range(1,lastcamcol+1) 510 543 sdsslist = [] 511 544 ps1list = [] … … 567 600 sdssfilt += ';select !((flags[%s]&1<<1)!=0)&&(!((flags[%s]&1<<3)!=0)||((flags[%s]&1<<6)!=0)||nchild==0)' % \ 568 601 (bandindex,bandindex,bandindex) 602 # add check for BINNED1 !!! bit28 in flags1 603 569 604 # Check flag 0x4000 (extended) to compare against prob_psf in SDSS 570 605 # - for some reason, 'flags' and the other integer columns get … … 823 858 img = f_handle[HDU].data 824 859 resid_img = 1e-7*ones(img.shape,Float32) 825 print resid_img.shape,type(resid_img),img.shape,type(img)826 860 fitlist = [] 827 861 for initialGuessTuple in initialGuessList: … … 846 880 win.showArray(res) 847 881 resid_img[int(y0)-halfwinsize:int(y0)+halfwinsize+1,int(x0)-halfwinsize:int(x0)+halfwinsize+1] = res 848 print initialGuessTuple, scale,x,xsig,y,ysig,theta882 # print initialGuessTuple, scale,x,xsig,y,ysig,theta 849 883 fitlist.append(par) 850 884 f_handle.close()
Note:
See TracChangeset
for help on using the changeset viewer.
