Example #1
0
    def loadImageStack(self, fileName, wvlStart=None, wvlStop=None,
                       weighted=True, fluxWeighted=False,
                       getRawCount=False, scaleByEffInt=True,
                       deadTime=100.e-6, filterName=None):
                                      
        #print '\nMaking images:'
        #print str(wvlStart),'-',wvlStop,'A'
        #print 'weighted:',weighted
        #print 'fluxWeighted:',fluxWeighted
        #print 'getRawCount:',getRawCount
        #print 'scaleByEffInt:',scaleByEffInt
        print "N timeStamps = ", len(self.timeStamps)
        #If the file exists, read it out
        if os.path.isfile(fileName):
            return readImageStack(fileName)
        #if the file doesn't exists, make it
        else:
            images = []
            pixIntTimes = []
            startTimes = []
            endTimes = []
            intTimes = []
            for iFrame in range(len(self.frameIntervals)):
                print '\nStacking Frame:',iFrame, "of", len(self.frameIntervals),"..."
                im_dict = self.getPixelCountImageByFrame(iFrame,
                                                         wvlStart, wvlStop,
                                                         weighted,
                                                         fluxWeighted,
                                                         getRawCount,
                                                         scaleByEffInt,
                                                         deadTime, filterName)
                if im_dict is not None:
                    images.append(im_dict['image'])
                    pixIntTimes.append(im_dict['pixIntTime'])
                    startTimes.append(im_dict['startTime'])
                    endTimes.append(im_dict['endTime'])
                    intTimes.append(im_dict['intTime'])
                    #pop=PopUp(parent=None,title='JD: '+str(im_dict['startTime'])+' Image')
                    #pop.plotArray(image=im_dict['image'], title='Image')
                    #pop.show()
                    #plotArray(image=im_dict['image'], title='JD: '+str(im_dict['startTime'])+' Image')
                    #print '\n'

            writeImageStack(fileName, images, startTimes=startTimes,
                            endTimes=endTimes, intTimes=intTimes,
                            pixIntTimes=pixIntTimes, targetName=self.name,
                            run=self.run,
                            nFrames=len(images),
                            wvlLowerLimit=wvlStart,
                            wvlUpperLimit=wvlStop, weighted=weighted,
                            fluxWeighted=fluxWeighted,
                            hotPixelsApplied=self.hotPixelsApplied,
                            maxExposureTime=self.dt,
                            tStamps=self.timeStamps)
            #return {'images':images,'pixIntTimes':pixIntTimes,
            #'startTimes':startTimes,'endTimes':endTimes,'intTimes':intTimes}
            print "Saved %i frames out of %i (the rest were blank intervals)"%(len(images), len(self.frameIntervals))
            return readImageStack(fileName)
    def loadImageStack(self, fileName, wvlStart=None, wvlStop=None,
                       weighted=True, fluxWeighted=False,
                       getRawCount=False, scaleByEffInt=True,
                       deadTime=100.e-6):
        # If the file exists, read it out
        if os.path.isfile(fileName):
            return readImageStack(fileName)
        # if the file doesn't exists, make it
        else:
            images = []
            pixIntTimes = []
            startTimes = []
            endTimes = []
            intTimes = []
            for iFrame in range(len(self.frameIntervals)):
                im_dict = self.getPixelCountImageByFrame(iFrame,
                                                         wvlStart, wvlStop,
                                                         weighted,
                                                         fluxWeighted,
                                                         getRawCount,
                                                         scaleByEffInt,
                                                         deadTime)
                images.append(im_dict['image'])
                pixIntTimes.append(im_dict['pixIntTime'])
                startTimes.append(im_dict['startTime'])
                endTimes.append(im_dict['endTime'])
                intTimes.append(im_dict['intTime'])

            writeImageStack(fileName, images, startTimes=startTimes,
                            endTimes=endTimes, intTimes=intTimes,
                            pixIntTimes=pixIntTimes, targetName=self.name,
                            run=self.run,
                            nFrames=len(self.frameIntervals),
                            wvlLowerLimit=wvlStart,
                            wvlUpperLimit=wvlStop, weighted=weighted,
                            fluxWeighted=fluxWeighted,
                            hotPixelsApplied=self.hotPixelsApplied,
                            maxExposureTime=self.dt,
                            tStamps=self.timeStamps)
            # return {'images':images,'pixIntTimes':pixIntTimes,
            # 'startTimes':startTimes,'endTimes':endTimes,'intTimes':intTimes}
            return readImageStack(fileName)