Ejemplo n.º 1
0
    def time_selection(self):
        """
        Do a GTI selection based on a file of time spans

        CFITSIO won't allow filenames (including filter expression) longer than
        ~1100 chars, so for selections that require very long filters (i.e.,
        more than ~30 time spans covered) we split the gtmktime calls into
        chunks of ~20 time spans.
        """
        eventlist = []
        last = False
        numbin = None
        while not last:
            selstr, numbin, last = utils.time_selection_string(
                self.Configuration, numbin)
            outfile = self.eventfile.replace('.fits', '_{}'.format(numbin))
            self._RunMktime(selstr, outfile, 'no')
            eventlist.append(outfile + '\n')
            maketime['outfile'] = outfile
            maketime.run()

        evlist_filename = self.eventfile.replace('.fits', '.list')
        with open(evlist_filename, 'w') as evlistfile:
            evlistfile.writelines(eventlist)

        # Redo first-cut to consolidate into single fits file (gtmktime does not accept lists!)
        ft1 = self.ft1  # Store FT1 to restore it later
        self.ft1 = evlist_filename
        self.FirstCut()
        self.ft1 = ft1

        # Clean cruft: all temp event files and event file list
        os.unlink(evlist_filename)
        for file in eventlist:
            os.unlink(file.strip())  # strip of endline char
Ejemplo n.º 2
0
    def time_selection(self):
        """
        Do a GTI selection based on a file of time spans

        CFITSIO won't allow filenames (including filter expression) longer than
        ~1100 chars, so for selections that require very long filters (i.e.,
        more than ~30 time spans covered) we split the gtmktime calls into
        chunks of ~20 time spans.
        """
        eventlist = []
        last = False
        numbin = None
        while not last:
            selstr,numbin,last = utils.time_selection_string(self.Configuration,numbin)
            outfile = self.eventfile.replace('.fits','_{}'.format(numbin))
            self._RunMktime(selstr,outfile,'no')
            eventlist.append(outfile+'\n')
            maketime['outfile'] = outfile
            maketime.run()

        evlist_filename = self.eventfile.replace('.fits','.list')
        with open(evlist_filename,'w') as evlistfile:
            evlistfile.writelines(eventlist)

        # Redo first-cut to consolidate into single fits file (gtmktime does not accept lists!)
        ft1 = self.ft1 # Store FT1 to restore it later
        self.ft1 = evlist_filename
        self.FirstCut()
        self.ft1 = ft1

        # Clean cruft: all temp event files and event file list
        os.unlink(evlist_filename)
        for file in eventlist:
            os.unlink(file.strip()) # strip of endline char
Ejemplo n.º 3
0
    def time_selection(self):
        """
        Do a GTI selection based on a file of time spans

        CFITSIO won't allow filenames (including filter expression) longer than
        ~1100 chars, so for selections that require very long filters (i.e.,
        more than ~30 time spans covered) we split the gtmktime calls into
        chunks of ~20 time spans.
        """
        eventlist = []
        last = False
        numbin = None
        while not last:
            selstr,numbin,last = utils.time_selection_string(self.Configuration,numbin)
            outfile = self.eventfile.replace('.fits','_{}'.format(numbin))
            self._RunMktime(selstr,outfile,'no')
            eventlist.append(outfile+'\n')

        evlist_filename = self.eventfile.replace('.fits','.list')
        with open(evlist_filename,'w') as evlistfile:
            evlistfile.writelines(eventlist)

        # Redo SelectEvents to consolidate into single fits file (gtmktime does not accept lists!)
        eventcoarse = self.eventcoarse # Store eventcoarse to restore it later
        clobber = self.clobber         # Store clobber settings, we will force clobber at this step
        self.eventcoarse = evlist_filename
        self.clobber = True
        self.SelectEvents()
        self.eventcoarse = eventcoarse
        self.clobber = clobber

        # Clean cruft: all temp event files and event file list
        os.unlink(evlist_filename)
        for file in eventlist:
            os.unlink(file.strip()) # strip of endline char
Ejemplo n.º 4
0
    def time_selection(self):
        """
        Do a GTI selection based on a file of time spans

        CFITSIO won't allow filenames (including filter expression) longer than
        ~1100 chars, so for selections that require very long filters (i.e.,
        more than ~30 time spans covered) we split the gtmktime calls into
        chunks of ~20 time spans.
        """
        eventlist = []
        last = False
        numbin = None
        while not last:
            selstr, numbin, last = utils.time_selection_string(
                self.Configuration, numbin)
            outfile = self.eventfile.replace('.fits', '_{}'.format(numbin))
            self._RunMktime(selstr, outfile, 'no')
            eventlist.append(outfile + '\n')

        evlist_filename = self.eventfile.replace('.fits', '.list')
        with open(evlist_filename, 'w') as evlistfile:
            evlistfile.writelines(eventlist)

        # Redo SelectEvents to consolidate into single fits file (gtmktime does not accept lists!)
        eventcoarse = self.eventcoarse  # Store eventcoarse to restore it later
        clobber = self.clobber  # Store clobber settings, we will force clobber at this step
        self.eventcoarse = evlist_filename
        self.clobber = True
        self.SelectEvents()
        self.eventcoarse = eventcoarse
        self.clobber = clobber

        # Clean cruft: all temp event files and event file list
        os.unlink(evlist_filename)
        for file in eventlist:
            os.unlink(file.strip())  # strip of endline char