Changeset 23263
- Timestamp:
- Mar 11, 2009, 7:08:37 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sj_branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py
r20560 r23263 68 68 69 69 # Look at extended flag in PS1 vs. SDSS!!! 70 71 # os.chdir('/disk1/jester/IPP/data/SDSS/stripe82/coadd/compare') 72 # execfile('/disk1/jester/usrdevel/ipp_sj/ippTests/compIPPphoto.py') 73 # h1,h2=compIPPphoto('test.fits','new',workdir='/IPP/data/SDSS/stripe82/coadd/compare',runlist=[1056,1755]) 70 74 71 75 plotcol_1frame_tlist = [ … … 167 171 plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex,bandid=filter_name) 168 172 # return column_hash,goodrow_hash 173 # Herre, need to check that keylist is filled i.e. files were found 169 174 newrows = numpy.rec.array(rowtuple_list,names=keylist) 170 175 tabhdu = tabHDUfromRecArray(newrows) … … 269 274 if not re.search('objc',col2name): 270 275 try: 271 [xmin,xmax] = stats_med(values1[goodrows],[histo_min_ntile,histo_max_ntile]) 276 r = stats_med(values1[goodrows],[histo_min_ntile,histo_max_ntile]) 277 [xmin,xmax] = r 272 278 [ymin,ymax] = stats_med(values2[goodrows],[histo_min_ntile,histo_max_ntile]) 273 except IndexError: 279 except ValueError: 280 print "Pffrz! ",r 274 281 print col1name, goodrows, type(goodrows), len(goodrows), len(values1) 275 282 # print "Huhu", outname, min(values1),max(values2),xmin,xmax … … 448 455 # "reference columns" 449 456 outhash = {} 450 #print "Looking for FWHM_MAJ in table %s" %(tablename)451 if 'FWHM_MAJ' in copyfields_list and 'FWHM_MAJ' not in h.ascardlist().keys():452 copyfields_list.remove('FWHM_MAJ')453 copyfields_list.remove('FWHM_MIN')454 copyfields_list.append('FWHM_X')455 copyfields_list.append('FWHM_Y')456 457 for f in copyfields_list: 457 458 outhash[f] = h[f] … … 477 478 # Maybe I want to keep track of these number of "good" rows? 478 479 479 # XXX:Count number of objects in a) SDSS, b) PS1, c) both, by480 # Count number of objects in a) SDSS, b) PS1, c) both, by 480 481 # counting number of a) entries > 0 in 'id', b) non-nan entries 481 482 # in IPP_IDET, c) both (Later pass the following as parameters to … … 617 618 file.""" 618 619 import pyfits 620 from numpy import nan 619 621 620 622 def getOutname(SDSSfile,PS1file,sdssbandstr): … … 631 633 632 634 filters = ['u','g','r','i','z'] 633 # Read primary header of PS1 file to work out band 634 try: 635 ps1copyfields_hash = headerfieldHash(['FWHM_MAJ','FWHM_MIN','FILTER'],PS1cmf,HDU=0) 636 except KeyError: 637 ps1copyfields_hash = headerfieldHash(['FWHM_X','FWHM_Y','FILTER'],PS1cmf,HDU=0) 635 # Read primary header of PS1 file to work out band and copy other 636 # interesting fields. These include FHWM_MAJ,MIN which used to be 637 # called FWHM_X,Y, but are missing in some cases if the camera 638 # stage failed. In the latter case, we can still read IQ_FW1,2. So 639 # we first update the .cmf file to be sure that FWHM_MAJ,MIN is 640 # present for later analysis. 641 ensureFHWMheaderfields(PS1cmf) 642 ps1copyfields_hash = headerfieldHash(['FWHM_MAJ','FWHM_MIN','FILTER'],PS1cmf,HDU=0) 643 sdsscopyfields_hash = headerfieldHash(['RUN','RERUN','CAMCOL','FIELD'],SDSSfpObjc,0) 638 644 sdssbandstr = ps1copyfields_hash['FILTER'] 639 645 bandindex = filters.index(sdssbandstr) … … 642 648 return outname,sdssbandstr,bandindex 643 649 644 sdsscopyfields_hash = headerfieldHash(['RUN','RERUN','CAMCOL','FIELD'],SDSSfpObjc,0)645 650 646 651 # Note position offset - y_sdss-y_psf1 ~ 0.6, x_sdss-x_ps1 ~ 0.35 (in 1056-r1-0192) … … 682 687 return outname,sdssbandstr,bandindex 683 688 689 def ensureFHWMheaderfields(PS1cmf): 690 import pyfits 691 PS1handle = pyfits.open(PS1cmf,mode='update') 692 PS1primhead = PS1handle[0].header 693 headfields = PS1primhead.ascardlist().keys() 694 if not ('FWHM_MAJ' in headfields and 'FWHM_MIN' in headfields): 695 if ('FWHM_X' in headfields and 'FWHM_Y' in headfields): 696 PS1primhead.update('FWHM_MAJ',PS1primhead['FWHM_X']) 697 PS1primhead.update('FWHM_MIN',PS1primhead['FWHM_Y']) 698 else: 699 PS1primhead.update('FWHM_MAJ',PS1primhead['IQ_FW1']) 700 PS1primhead.update('FWHM_MIN',PS1primhead['IQ_FW2']) 701 PS1handle.close() 702 703 704 684 705 def updateHeaderFromHash(header,hash): 685 706 """Add fields in hash to header""" … … 698 719 for field in fieldlist: 699 720 outhash[field] = h[field] 721 f.close() 700 722 return outhash 701 723 … … 1018 1040 # For testing: 1019 1041 # return ['1056-0192.421/1056-0192.421.ch.421.CHIP1.cmf'],['1056-0192.421/fpObjc-001056-1-0192.fit'] 1042 # return ['1056-0192.1/1056-0192.1.ch.1.CHIP21.cmf'],['1056-0192.1/fpObjc-001056-1-0192.fit'] 1020 1043 1021 1044 from glob import glob
Note:
See TracChangeset
for help on using the changeset viewer.
