Changeset 20527
- Timestamp:
- Nov 4, 2008, 3:42:28 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20511 r20527 62 62 # XXX Todo: labels! group by runs? different colours for different 63 63 # bands; include seeing? plot things against seeing? 64 65 # Also: the plotcol lists need to be grouped into things that are to 66 # appear on the same page. For the beginning, that's the entire list 67 # (and that's probably quite enough anyway). 68 64 69 65 70 plotcol_1frame_tlist = [ … … 107 112 def compIPPphoto(summaryTable,mode,plotcol_1frame_tlist=plotcol_1frame_tlist,\ 108 113 plotcol_summary_tlist=plotcol_summary_tlist,\ 109 cmfDir = '/IPP/data/SDSS/stripe82/coadd/prod/run_ipp_20080815/',\ 110 skip=True): 114 cmfDir = '/IPP/data/SDSS/stripe82/coadd/prod/run_ipp_20080815/',\ 115 copyfields_list = ['RUN','RERUN','CAMCOL','FIELD','FILTER','FWHM_MAJ','FWHM_MIN'],\ 116 skip=True): 111 117 """summaryTable: .fits table for output 112 118 mode: new or append for creating summaryTable new or appending current run's output to it. … … 144 150 filters.append(filter_name) 145 151 bandindex_hash[filter_name] = bandindex 146 stats_hash, column_hash, goodrow_hash = computeStatistics(matchtable )152 stats_hash, column_hash, goodrow_hash = computeStatistics(matchtable,copyfields_list = copyfields_list) 147 153 # Sort res_hash by its column names to make sure order is 148 154 # identical in all rows of the table, and output is more … … 284 290 os.remove(tmp_outname) 285 291 return all_outname 286 292 293 def setWindow(i,Nplots): 294 """Set sm window for plotting the i-th out of Nplots. The logic is 295 that N_x * N_y >= Nplots and N_y-N_x is 0 or 1. So Ny is the sqrt 296 of N or the next-greatest square; Nx is either the same or one 297 fewer if that's still enough.""" 298 299 from scipy import sqrt 300 if int(sqrt(Nplots))**2 == Nplots: 301 Ny = int(sqrt(Nplots)) 302 Nx = Ny 303 else: 304 Ny = int(sqrt(Nplots)+1) 305 Nx = Ny-1 306 if Nx * Ny < Nplots: 307 Nx+=1 308 309 # That's nx, ny; now count up to total Nx ny. This is like 310 # representing i in a number system where the y-window number is 311 # the 10s and the x-window number the 1s, but the 10s are base Ny 312 # and the 1s are base Nx, and counting starts at 1 not 0. I.e. x = 313 # (i % Nx) or Nx if that's 0; y = i / Nx + 1 314 winx = i% Nx 315 if winx == 0: 316 winx = Nx 317 winy = int(i/Nx)+1 318 if int(i/Nx) == i/float(Nx): 319 winy -= 1 320 return Nx,Ny,winx,winy 287 321 288 322 def valuesKeysSortedByKeys(hash): … … 379 413 # "reference columns" 380 414 outhash = {} 415 if 'FWHM_MAJ' in copyfields_list and 'FWHM_MAJ' not in h.ascardlist().keys(): 416 copyfields_list.remove('FWHM_MAJ') 417 copyfields_list.remove('FWHM_MIN') 418 copyfields_list.append('FWHM_X') 419 copyfields_list.append('FWHM_Y') 381 420 for f in copyfields_list: 382 421 outhash[f] = h[f] … … 557 596 filters = ['u','g','r','i','z'] 558 597 # Read primary header of PS1 file to work out band 559 ps1copyfields_hash = headerfieldHash(['FWHM_MAJ','FWHM_MIN','FILTER'],PS1cmf,HDU=0) 598 try: 599 ps1copyfields_hash = headerfieldHash(['FWHM_MAJ','FWHM_MIN','FILTER'],PS1cmf,HDU=0) 600 except KeyError: 601 ps1copyfields_hash = headerfieldHash(['FWHM_X','FWHM_Y','FILTER'],PS1cmf,HDU=0) 560 602 sdssbandstr = ps1copyfields_hash['FILTER'] 561 603 bandindex = filters.index(sdssbandstr) … … 832 874 """Fit Gaussians to image in infile's HDU near the 833 875 positions and with fluxes and sigmas given in initialGuessList""" 834 # XXX Todo: Make frame with residuals. Make blank array, then insert residuals.835 876 import pyfits 836 877 from numpy import nan … … 839 880 f_handle=pyfits.open(infile) 840 881 img = f_handle[HDU].data 841 resid_img = 1e-7*ones(img.shape,Float32)882 resid_img = zeros(img.shape,Float32) 842 883 fitlist = [] 843 884 for initialGuessTuple in initialGuessList: … … 860 901 res = subim 861 902 (scale,x,xsig,y,ysig,theta)=par 862 win.showArray(res)903 # win.showArray(res) 863 904 resid_img[int(y0)-halfwinsize:int(y0)+halfwinsize+1,int(x0)-halfwinsize:int(x0)+halfwinsize+1] = res 864 905 # print initialGuessTuple, scale,x,xsig,y,ysig,theta 865 906 fitlist.append(par) 866 907 f_handle.close() 867 outname = 'gaussfit_resid_ '+infile908 outname = 'gaussfit_resid_r%ipix_%s' % (blankrad,infile) 868 909 primHDU = pyfits.PrimaryHDU(resid_img) 869 910 hdulist = pyfits.HDUList([primHDU]) … … 871 912 return fitlist 872 913 873 def doEfbComparison(simfile='simtest.1.00a.fits',efbfile='efbsim.1.00a.fits',simtab='simtest.1.00a.cmf' ):914 def doEfbComparison(simfile='simtest.1.00a.fits',efbfile='efbsim.1.00a.fits',simtab='simtest.1.00a.cmf',blankrad=9): 874 915 import pyfits 875 916 from numpy import array, rec … … 886 927 initlist.append((counts[i],x[i],2.,y[i],2.,0.)) 887 928 inparlist.append((counts[i],x[i],y[i])) 888 efbparlist = doGaussPsfPhotometry(efbfile,initlist )889 simparlist = doGaussPsfPhotometry(simfile,initlist )929 efbparlist = doGaussPsfPhotometry(efbfile,initlist,blankrad=blankrad) 930 simparlist = doGaussPsfPhotometry(simfile,initlist,blankrad=blankrad) 890 931 891 932 savelist = [ inparlist[i] + efbparlist[i] + simparlist[i] for i in range(nrows)] … … 900 941 saveHDU = tabHDUfromRecArray(saverows) 901 942 fitsend = re.compile('(\.[sc]mf|\.fits?)$') 902 saveHDU.writeto('gaussfit_ '+fitsend.sub('',efbfile)+'___'+simfile,clobber=True)943 saveHDU.writeto('gaussfit_r%ipix_%s___%s' %(blankrad,fitsend.sub('',efbfile),simfile),clobber=True) 903 944 904 945 … … 931 972 fpObjcDir += '/' 932 973 # For testing: 933 #return ['1056-0192.421/1056-0192.421.ch.421.CHIP1.cmf'],['1056-0192.421/fpObjc-001056-1-0192.fit']974 return ['1056-0192.421/1056-0192.421.ch.421.CHIP1.cmf'],['1056-0192.421/fpObjc-001056-1-0192.fit'] 934 975 935 976 from glob import glob
Note:
See TracChangeset
for help on using the changeset viewer.
