示例#1
0
def main():
    allfiles = ['mo_flatdiv_biassub_trim_gN20091027S0133.fits','N20020214S059.fits','N20020606S0141.fits',
                'N20080927S0183.fits','N20091002S0219.fits','N20091027S0133.fits','rgN20031029S0132.fits',
                'rgS20031031S0035.fits','S20080922S0100.fits']
    
    files = allfiles
    files = ['N20091002S0219.fits']#['N20030427S0092.fits']#['mo_flatdiv_biassub_trim_gN20091027S0133.fits']
    
    
    paramset = [
                {'threshold':2, 'window':None, 'verbose':True, 'timing':True, 
                 'grid':False, 'rejection':None},
                ]
    labelStrs = pyraf.iraf.no
    time_dict = {}
    frameForDisplay = 1
    dispFrame = 0
    numtimes = 1
    drawWindows = True
    display = True
    tmpFilename = 'tmpfile.tmp'
    iraf.set(stdimage='imtgmos')
    
    pydisplay = pyDisplay.getDisplay()
    
    sfilt = starFilter.starFilter()
    for fil in files:
        ext = 1
        while ext < 2:
            indi = 0
            for param in paramset:
                
                indi += 1
                for i in range(numtimes):
                    ds9 = pydisplay.getDisplayTool( 'ds9', 'myds9' )
                    try:
                        print '-'*50
                        if display:
                            try:
                                iraf.display( fil+'['+str(ext)+']', frameForDisplay)
                            except:
                                break
                        else:
                            try:
                                pf.getdata( fil, ext )
                            except:
                                break
                        
                        if frameForDisplay > 0:
                            dispFrame = frameForDisplay - 1
                        
                        xyArray, filTime = ds.detSources( fil, dispFrame=dispFrame, drawWindows=drawWindows, exts=ext, **param  )
                        end_time = time.time()
                        
                        scidata = pf.getdata( fil, ext )
                        xyArray = sfilt.filterStars( scidata, xyArray)
                        key = fil +'['+str(ext)+'] P'+str(indi)
                        
                        if not time_dict.has_key(key):
                            time_dict[key] = []
                        
                        time_dict[key].append((filTime,len(xyArray)))
                        #print xyArray
                        if display:
                            tmpFile = open( tmpFilename, 'w' )
                            index = 0
                            toWrite = ''
                            for coords in xyArray:
                                toWrite += '%s %s %s\n' %(str(coords[0]), str(coords[1]), str(index))
                                index += 1
                            tmpFile.write( toWrite )
                            tmpFile.close()
                            
                            iraf.tvmark( frame=dispFrame,coords=tmpFilename, mark='point',
                                pointsize=1, color=204, label=labelStrs )
                        
                            #tutorExam( ds9, scidata, xyArray, ext)
                        
                    except:
                        print "'" + fil + "': Failed"
                        raise
                
                    
                
                #frameForDisplay += 1
            ext += 1
        
    timelisting = sorted(time_dict.keys())
    print timelisting
    print 'Number of Runs:', numtimes
    for entry in timelisting:
        sum = 0
        objsum = 0
        for val in time_dict[entry]:
            sum += val[0]
            objsum += val[1]
        
        print "'" + entry + "': Time was (" + str( sum/numtimes ) + ")\tsecs / Objects ("+str(objsum)+")"
示例#2
0
 def __init__(self):
     self.pydisp = pyDisplay.getDisplay()
     self.ds9 = None
     self.displayIDMap = {}