Changeset 20142
- Timestamp:
- Oct 14, 2008, 2:51:21 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20086 r20142 27 27 # + magdiff vs. sky 28 28 # + magdiff vs. skydiff 29 # + magdiff vs. stellar density30 # + magdiff vs. presence of bright stars31 29 # + something about PSF sizes; use Michigan moments for photo - 32 30 # M_rr_cc_psf is the size of the reconstructed PSF, and m_rr_cc is the size of the object … … 38 36 # + histograms of everything - recovery fractions, means, medians, quartiles 39 37 # + Trends with field number, seeing etc. 40 38 # + magdiff vs. stellar density 39 # + magdiff vs. presence of bright stars (e.g. number of bright 40 # stars above some typical S/N or counts threshold - 50% 41 # saturation?) 42 # 43 # XXX Todo: 44 # 45 # - Merge identical plots into single .eps file 46 # 47 # - Make html page with jpeg/gif versions of plots 48 # 49 # - Need mechanism to specify default plotting ranges, since outliers 50 # mess up axis ranges. Different quantities need different 51 # ranges. Comparing different plots is also easier if the plot 52 # ranges are the same. 53 # 54 # - second tlist for summary plots (same or different plot routine?) 55 # 56 # - towards generality, want to read these things and colname_hash and 57 # label_l from config files 58 # 41 59 # Convention: for scatter, plot second against first; for histogram, plot both histograms 42 # 43 # XXX: Need mechanism to specify default plotting ranges, since 44 # outliers mess up axis ranges. E.g. 0.1 and 0.9 percentiles? 45 plotcol_tlist = [ 60 plotcol_1frame_tlist = [ 46 61 (['d_sky'],['d_mag'],'scatter') 47 62 ,(['d_x'],['d_y'],'scatter') … … 56 71 ] 57 72 58 def compIPPphoto(summaryTable,mode,plotcol_tlist=plotcol_tlist,skip=False): 73 plotcol_summary_tlist = [ 74 (['d_mag_median'],['d_sky_median'],'scatter') 75 ,(['d_x_median'],['d_y_median'],'scatter') 76 ,(['d_mag_median'],['N_SDSS'],'scatter') 77 ,(['d_mag_median','d_mag_mean'],['field','field'],'scatter') 78 ] 79 80 81 def compIPPphoto(summaryTable,mode,plotcol_1frame_tlist=plotcol_1frame_tlist,\ 82 plotcol_summary_tlist=plotcol_summary_tlist,skip=True): 59 83 """summaryTable: .fits table for output 60 84 mode: new or append for creating summaryTable new or appending current run's output to it. … … 93 117 vallist,keylist = valuesKeysSortedByKeys(stats_hash) 94 118 rowtuple_list.append(vallist) 95 plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_ tlist,bandindex)119 plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex) 96 120 # return column_hash,goodrow_hash 97 121 newrows = numpy.rec.array(rowtuple_list,names=keylist) … … 99 123 if mode == 'new': 100 124 tabhdu.writeto(summaryTable,clobber=True) 125 nrows = tabhdu.header['NAXIS2'] 126 summaryhash = hashFromPyfitsTable(tabhdu) 101 127 else: 102 appendFitsTable(summaryTable,tabhdu) 128 newtabhdu = appendFitsTable(summaryTable,tabhdu) 129 nrows = newtabhdu.header['NAXIS2'] 130 summaryhash = hashFromPyfitsTable(newtabhdu) 131 # Fake a goodrows hash 132 sumgoodrows_hash = summaryhash.fromkeys(summaryhash.keys(),numpy.ones((nrows,),bool)) 133 plotStatsOnefile(summaryhash,sumgoodrows_hash,summaryTable,plotcol_summary_tlist,bandindex) 103 134 return column_hash,goodrow_hash 135 136 def hashFromPyfitsTable(pyfitsTableHDU): 137 """Return a hash wrapping the table data so a column can be 138 addressed as hash[colname] instead of tabledata.field(colname)""" 139 from numpy import array 140 outhash = {} 141 for col in pyfitsTableHDU.columns.names: 142 # Column names are uppercase, we want lowercase hash keys 143 outhash[col.lower()] = array(pyfitsTableHDU.data.field(col)) 144 return outhash 104 145 105 146 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps'): … … 124 165 histo_min_ntile = 0.03 125 166 histo_max_ntile = 1-histo_min_ntile 167 angle_l = [0,45,0,45,0,90] 168 ptype_l = [ 41, 41, 40, 40, 30,30] 126 169 for troika in plotcol_tlist: 127 170 col1name_l = troika[0] … … 131 174 smOpenPlot(outname,format=format) 132 175 firstplot = True 176 i = 0 133 177 for col1name,col2name in zip(col1name_l,col2name_l): 134 values1 = values_hash[col1name ]135 goodrows1 = goodrow_hash[col1name ]136 values2 = values_hash[col2name ]137 goodrows2 = goodrow_hash[col2name ]178 values1 = values_hash[col1name.lower()] 179 goodrows1 = goodrow_hash[col1name.lower()] 180 values2 = values_hash[col2name.lower()] 181 goodrows2 = goodrow_hash[col2name.lower()] 138 182 # Slice out depth for current filter if necessary 139 183 if len(values1.shape) > 1: … … 150 194 # Avoid plotting outliers 151 195 if not re.search('objc',col2name): 152 [xmin,xmax] = stats_med(values1[goodrows],[histo_min_ntile,histo_max_ntile]) 153 [ymin,ymax] = stats_med(values2[goodrows],[histo_min_ntile,histo_max_ntile]) 196 try: 197 [xmin,xmax] = stats_med(values1[goodrows],[histo_min_ntile,histo_max_ntile]) 198 [ymin,ymax] = stats_med(values2[goodrows],[histo_min_ntile,histo_max_ntile]) 199 except IndexError: 200 print col1name, goodrows, type(goodrows), len(goodrows), len(values1) 154 201 # print "Huhu", outname, min(values1),max(values2),xmin,xmax 155 202 smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name,\ … … 159 206 smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name) 160 207 else: 161 angle( 45)162 smScatterPlot(values1,values2, logical=goodrows,append=True)208 angle(angle_l[i%len(angle_l)]) 209 smScatterPlot(values1,values2,ptype=ptype_l[i%len(ptype_l)],logical=goodrows,append=True) 163 210 angle(0) 164 211 if plottype == 'histogram': … … 177 224 ltype=2) 178 225 firstplot = False 226 i+=1 179 227 smClosePlot() 180 228 … … 196 244 newtabhdu.data.field(col)[nrows_old:] = tabHDU.data.field(col) 197 245 oldtabhdulist.close() 198 return newtabhdu.writeto(fitsfile,clobber=True) 246 newtabhdu.writeto(fitsfile,clobber=True) 247 return newtabhdu 199 248 200 249 … … 247 296 outl = [] 248 297 for ntile in ntiles: 249 outl.append(sortarr[ntile*(l-1)]) 298 idx = max(int(ntile*(l-1)),0) 299 outl.append(sortarr[idx]) 250 300 return outl 251 301
Note:
See TracChangeset
for help on using the changeset viewer.
