예제 #1
0
 def FirstCut(self):
     """Run gtselect tool"""
     if (self.clobber == "no" and os.path.isfile(self.eventcoarse)):
         #print("File exists and clobber is False")
         return (0)
     filter['infile'] = self.ft1
     filter['outfile'] = self.eventcoarse
     if (self.roicuts == True):
         filter['ra'] = self.ra
         filter['dec'] = self.dec
         filter['rad'] = self.roi
     else:
         filter['ra'] = 0
         filter['dec'] = 0
         filter['rad'] = 180
     if (self.timecuts == True):
         filter['tmin'] = self.t1
         filter['tmax'] = self.t2
     else:
         filter['tmin'] = "INDEF"
         filter['tmax'] = "INDEF"
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['zmax'] = self.Configuration['analysis']['zmax']
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = "INDEF"
     filter['clobber'] = self.clobber
     filter.run()
예제 #2
0
 def FirstCut(self):
     """Run gtselect tool"""
     if (self.clobber=="no" and os.path.isfile(self.eventcoarse)):
         #print("File exists and clobber is False")
         return(0)
     filter['infile'] = self.ft1
     filter['outfile'] = self.eventcoarse
     if (self.roicuts == True):
         filter['ra'] = self.ra
         filter['dec'] = self.dec
         filter['rad'] = self.roi
     else:
         filter['ra']  = 0
         filter['dec'] = 0
         filter['rad'] = 180
     if (self.timecuts == True):
         filter['tmin'] = self.t1
         filter['tmax'] = self.t2
     else:
         filter['tmin'] = "INDEF"
         filter['tmax'] = "INDEF"
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['zmax'] = self.Configuration['analysis']['zmax']
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = "INDEF"
     filter['clobber'] = self.clobber
     filter.run()
예제 #3
0
def Crab_filter():
    filter['infile'] = 'Crab_events_0000.fits'
    filter['outfile'] = 'Crab_events_filtered.fits'
    filter['ra'] = 83.57
    filter['dec'] = 22.01
    filter['rad'] = 20
    filter['tmin'] = 0
    filter['tmax'] = 0
    #    filter['eventClass'] = 0
    filter.run()
예제 #4
0
def ltcube(times):
    '''This is the atomic function that actually runs in the seperate
    threads.  It takes a list as input where the first element is
    tmin, second is tmax, third is spacecraft file, fourth is the
    event file and fifth is the zmax parameter.  It first uses
    gtselect with wide open cuts to divide up the event file then it
    runs gtltcube on that event file.  The temporary event file is
    deleted automatically.  The function returns the name of the
    created ltcube file which can be combined with other files and/or
    deleted later.'''

    print "Starting calculation on interval {} to {}".format(
        times[0], times[1])
    if times[3] != '':
        evfile = tempfile.NamedTemporaryFile(suffix=".fits")
        filter['ra'] = "INDEF"
        filter['dec'] = "INDEF"
        filter['rad'] = "INDEF"
        filter['evclass'] = 0
        filter['evtype'] = "INDEF"
        filter['infile'] = times[3]
        filter['outfile'] = evfile.name
        filter['ra'] = "INDEF"
        filter['dec'] = "INDEF"
        filter['tmin'] = times[0]
        filter['tmax'] = times[1]
        filter['emin'] = 0.0
        filter['emax'] = 1000000.0
        filter['zmin'] = 0
        filter['zmax'] = 180
        filter['convtype'] = -1
        filter['chatter'] = 0
        filter.run(print_command=True)

    osfilehandle, outfilename = tempfile.mkstemp(suffix=".fits")
    if times[3] != '':
        expCube['evfile'] = evfile.name
    else:
        expCube['evfile'] = ""
    expCube['scfile'] = times[2]
    expCube['outfile'] = outfilename
    expCube['tmin'] = times[0]
    expCube['tmax'] = times[1]
    expCube['dcostheta'] = 0.025
    expCube['binsz'] = 1
    expCube['phibins'] = 0
    expCube['zmax'] = times[4]
    expCube['chatter'] = 0
    expCube.run(print_command=True)
    print "Completed calculation on interval {} to {}".format(
        times[0], times[1])
    return outfilename
예제 #5
0
def ltcube(times):

    '''This is the atomic function that actually runs in the seperate
    threads.  It takes a list as input where the first element is
    tmin, second is tmax, third is spacecraft file, fourth is the
    event file and fifth is the zmax parameter.  It first uses
    gtselect with wide open cuts to divide up the event file then it
    runs gtltcube on that event file.  The temporary event file is
    deleted automatically.  The function returns the name of the
    created ltcube file which can be combined with other files and/or
    deleted later.'''

    print "Starting calculation on interval {} to {}".format(times[0],times[1])
    if times[3] != '':
        evfile = tempfile.NamedTemporaryFile(suffix=".fits")
        filter['ra']="INDEF" 
        filter['dec']="INDEF"
        filter['rad'] = "INDEF"
        filter['evclass'] = 0
        filter['evtype'] = "INDEF"
        filter['infile'] = times[3]
        filter['outfile'] = evfile.name
        filter['ra'] = "INDEF"
        filter['dec'] = "INDEF"
        filter['tmin'] = times[0]
        filter['tmax'] = times[1]
        filter['emin'] = 0.0 
        filter['emax'] = 1000000.0
        filter['zmin'] = 0
        filter['zmax'] = 180
        filter['convtype'] = -1
        filter['chatter'] = 0
        filter.run(print_command=True)

    osfilehandle,outfilename = tempfile.mkstemp(suffix=".fits")
    if times[3] != '':
        expCube['evfile'] = evfile.name
    else:
        expCube['evfile'] = ""
    expCube['scfile'] =  times[2]
    expCube['outfile'] = outfilename
    expCube['tmin'] = times[0]
    expCube['tmax'] = times[1]
    expCube['dcostheta'] = 0.025
    expCube['binsz'] = 1
    expCube['phibins'] = 0
    expCube['zmax'] = times[4]
    expCube['chatter'] = 0
    expCube.run(print_command=True)
    print "Completed calculation on interval {} to {}".format(times[0],times[1])
    return outfilename
예제 #6
0
 def FirstCut(self):
     """Run gtselect tool"""
     filter['infile'] = self.ft1
     filter['outfile'] = self.eventfile
     filter['ra'] = self.ra 
     filter['dec'] = self.dec 
     filter['rad'] = self.roi
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['tmin'] = self.t1
     filter['tmax'] = self.t2
     filter['zmax'] = self.Configuration['analysis']['zmax'] 
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = self.Configuration['event']['evtype']
     filter['clobber'] = self.clobber
     filter.run()
예제 #7
0
파일: data.py 프로젝트: cdeil/enrico
 def _preprocess_gtmktime(self):
     """Run gtmktime"""
     from gt_apps import maketime as tool
     self._set_common_tool_options(tool)
     tool['scfile'] = join(DOWNLOAD_DIR, SPACECRAFT)
     tool['sctable'] = 'SC_DATA'
     tool['filter'] = default_filter
     tool['roicut'] = 'no'
     tool['evfile'] = 'gtselect.fits'
     tool['evtable'] = 'EVENTS'
     tool['outfile'] = 'gtmktime.fits'
     tool['apply_filter'] = 'yes'
     tool['overwrite'] = 'no'
     tool['header_obstimes'] = 'yes'
     tool['gtifile'] = 'default'
     tool.run()
예제 #8
0
 def FirstCut(self):
     """Run gtselect tool"""
     filter['infile'] = self.ft1
     filter['outfile'] = self.eventfile
     filter['ra'] = self.ra
     filter['dec'] = self.dec
     filter['rad'] = self.roi
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['tmin'] = self.t1
     filter['tmax'] = self.t2
     filter['zmax'] = self.Configuration['analysis']['zmax']
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = self.Configuration['event']['evtype']
     filter['clobber'] = self.clobber
     filter.run()
예제 #9
0
 def _preprocess_gtmktime(self):
     """Run gtmktime"""
     from gt_apps import maketime as tool
     self._set_common_tool_options(tool)
     tool['scfile'] = join(DOWNLOAD_DIR, SPACECRAFT)
     tool['sctable'] = 'SC_DATA'
     tool['filter'] = default_filter
     tool['roicut'] = 'no'
     tool['evfile'] = 'gtselect.fits'
     tool['evtable'] = 'EVENTS'
     tool['outfile'] = 'gtmktime.fits'
     tool['apply_filter'] = 'yes'
     tool['overwrite'] = 'no'
     tool['header_obstimes'] = 'yes'
     tool['gtifile'] = 'default'
     tool.run()
예제 #10
0
 def _preprocess_gtltcube(self):
     """Run gtltcube"""
     from gt_apps import GtApp
     tool = GtApp('gtltcube')
     self._set_common_tool_options(tool)
     tool['evfile'] = 'gtmktime.fits'
     tool['evtable'] = 'EVENTS'
     tool['scfile'] = join(DOWNLOAD_DIR, SPACECRAFT)
     tool['sctable'] = 'SC_DATA'
     tool['outfile'] = 'gtltcube.fits'
     tool['dcostheta'] = 0.025
     tool['binsz'] = 1
     tool['phibins'] = 0
     tool['tmin'] = 0
     tool['tmax'] = 0
     tool['file_version'] = 1
     tool['zmax'] = 180
     tool.run()
예제 #11
0
파일: data.py 프로젝트: cdeil/enrico
 def _preprocess_gtltcube(self):
     """Run gtltcube"""
     from gt_apps import GtApp
     tool = GtApp('gtltcube')
     self._set_common_tool_options(tool)
     tool['evfile'] = 'gtmktime.fits'
     tool['evtable'] = 'EVENTS'
     tool['scfile'] = join(DOWNLOAD_DIR, SPACECRAFT)
     tool['sctable'] = 'SC_DATA'
     tool['outfile'] = 'gtltcube.fits'
     tool['dcostheta'] = 0.025
     tool['binsz'] = 1
     tool['phibins'] = 0
     tool['tmin'] = 0
     tool['tmax'] = 0
     tool['file_version'] = 1
     tool['zmax'] = 180
     tool.run()
예제 #12
0
 def SelectEvents(self):
     """Run gtselect tool"""
     if (self.clobber == "no" and os.path.isfile(self.eventfile)):
         #print("File exists and clobber is False")
         return (0)
     filter['infile'] = self.eventcoarse
     filter['outfile'] = self.eventfile
     filter['ra'] = 0  #self.ra
     filter['dec'] = 0  #self.dec
     filter['rad'] = 180  #self.roi
     filter['tmin'] = "INDEF"  #self.t1
     filter['tmax'] = "INDEF"  #self.t2
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['zmax'] = self.Configuration['analysis']['zmax']
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = self.Configuration['event']['evtype']
     filter['clobber'] = self.clobber
     filter.run()
예제 #13
0
 def SelectEvents(self):
     """Run gtselect tool"""
     if (self.clobber=="no" and os.path.isfile(self.eventfile)):
         #print("File exists and clobber is False")
         return(0)
     filter['infile'] = self.eventcoarse
     filter['outfile'] = self.eventfile
     filter['ra'] =   0            #self.ra
     filter['dec'] =  0            #self.dec
     filter['rad'] =  180          #self.roi
     filter['tmin'] = "INDEF"      #self.t1
     filter['tmax'] = "INDEF"      #self.t2
     filter['emin'] = self.Emin
     filter['emax'] = self.Emax
     filter['zmax'] = self.Configuration['analysis']['zmax']
     filter['evclass'] = self.Configuration['event']['evclass']
     filter['evtype'] = self.Configuration['event']['evtype']
     filter['clobber'] = self.clobber
     filter.run()
예제 #14
0
 def _preprocess_gtselect(self, evclass, emin):
     """Run gtselect"""
     from gt_apps import filter as tool
     self._set_common_tool_options(tool)
     tool['infile'] = '@weeks.lis'
     tool['outfile'] = 'gtselect.fits'
     tool['ra'] = 'INDEF'
     tool['dec'] = 'INDEF'
     tool['rad'] = 'INDEF'
     tool['tmin'] = 'INDEF'
     tool['tmax'] = 'INDEF'
     tool['emin'] = emin
     tool['emax'] = int(1e10)
     tool['zmax'] = 100
     tool['evclass'] = evclass
     tool['convtype'] = -1
     tool['phasemin'] = 0
     tool['phasemax'] = 1
     tool['evtable'] = 'EVENTS'
     tool.run()
예제 #15
0
파일: data.py 프로젝트: mireianievas/enrico
 def _preprocess_gtselect(self, evclass, emin):
     """Run gtselect"""
     from gt_apps import filter as tool
     self._set_common_tool_options(tool)
     tool['infile'] = '@weeks.lis'
     tool['outfile'] = 'gtselect.fits'
     tool['ra'] = 'INDEF'
     tool['dec'] = 'INDEF'
     tool['rad'] = 'INDEF'
     tool['tmin'] = 'INDEF'
     tool['tmax'] = 'INDEF'
     tool['emin'] = emin
     tool['emax'] = int(1e10)
     tool['zmax'] = 100
     tool['evclass'] = evclass
     tool['convtype'] = -1
     tool['phasemin'] = 0
     tool['phasemax'] = 1
     tool['evtable'] = 'EVENTS'
     tool.run()
예제 #16
0
def diffrsp(times):
    '''This is the atomic function that actually runs in the seperate
    threads.  It takes a list as input where the first element is
    tmin, second is tmax, third is the spacecraft file, fourth is the
    event file, fifth is the source model and sixth is the IRF.  It
    first uses gtselect with wide open cuts to divide up the event
    file then it runs gtdiffrsp on that event file.  The temporary
    event file is deleted automatically.  The function returns the
    name of the created event file which can be combined with other
    files and/or deleted later.'''

    print "Starting calculation on interval {} to {}".format(
        times[0], times[1])

    osfilehandle, outfilename = tempfile.mkstemp(suffix=".fits")
    filter['rad'] = "INDEF"
    filter['evclass'] = 0
    filter['evclsmin'] = 0
    filter['evclsmax'] = 10
    filter['infile'] = times[3]
    filter['outfile'] = outfilename
    filter['ra'] = "INDEF"
    filter['dec'] = "INDEF"
    filter['tmin'] = times[0]
    filter['tmax'] = times[1]
    filter['emin'] = 0
    filter['emax'] = 400000
    filter['zmax'] = 180
    filter['convtype'] = -1
    filter['chatter'] = 0
    filter.run(print_command=False)

    diffResps['evfile'] = outfilename
    diffResps['scfile'] = times[2]
    diffResps['srcmdl'] = times[4]
    diffResps['irfs'] = times[5]
    diffResps['chatter'] = 0
    diffResps.run(print_command=False)
    print "Completed calculation of interval {} to {}".format(
        times[0], times[1])
    return outfilename
예제 #17
0
def diffrsp(times):

    '''This is the atomic function that actually runs in the seperate
    threads.  It takes a list as input where the first element is
    tmin, second is tmax, third is the spacecraft file, fourth is the
    event file, fifth is the source model and sixth is the IRF.  It
    first uses gtselect with wide open cuts to divide up the event
    file then it runs gtdiffrsp on that event file.  The temporary
    event file is deleted automatically.  The function returns the
    name of the created event file which can be combined with other
    files and/or deleted later.'''

    print "Starting calculation on interval {} to {}".format(times[0],times[1])

    osfilehandle,outfilename = tempfile.mkstemp(suffix=".fits")
    filter['rad'] = "INDEF"
    filter['evclass'] = 0
    filter['evclsmin'] = 0
    filter['evclsmax'] = 10
    filter['infile'] = times[3]
    filter['outfile'] = outfilename
    filter['ra'] = "INDEF"
    filter['dec'] = "INDEF"
    filter['tmin'] = times[0]
    filter['tmax'] = times[1]
    filter['emin'] = 0
    filter['emax'] = 400000
    filter['zmax'] = 180
    filter['convtype'] = -1
    filter['chatter'] = 0
    filter.run(print_command=False)

    diffResps['evfile'] = outfilename
    diffResps['scfile'] =  times[2]
    diffResps['srcmdl'] = times[4]
    diffResps['irfs'] = times[5]
    diffResps['chatter'] = 0
    diffResps.run(print_command=False)
    print "Completed calculation of interval {} to {}".format(times[0],times[1])
    return outfilename
예제 #18
0
def eventsum(filenames, Outfile, SaveTemp):

    '''This function takes a list of event files and sums them up using
    gtselect.  It first checks to see if there's only one temporary
    file.  If so, it just copies that to the output file.  If not, it
    creates a temporary file that lists the individual event files
    and operates gtselect on them.'''

    if len(filenames) <= 1:
        subprocess.call(["cp", filenames[0], Outfile])
    else:
        fileListfile = tempfile.NamedTemporaryFile()
        for filename in filenames:
            fileListfile.file.write(filename + "\n")
        fileListfile.flush()
        filter['rad'] = "INDEF"
        filter['evclass'] = 0
        filter['evclsmin'] = 0
        filter['evclsmax'] = 10
        filter['infile'] = "@"+fileListfile.name
        filter['outfile'] = Outfile
        filter['ra'] = "INDEF"
        filter['dec'] = "INDEF"
        filter['tmin'] = "INDEF"
        filter['tmax'] = "INDEF"
        filter['emin'] = 0
        filter['emax'] = 400000
        filter['zmax'] = 180
        filter['convtype'] = -1
        filter['chatter'] = 0
        filter.run(print_command=False)

    if SaveTemp:
        print "Did not delete the following temporary files:"
        print filenames
    else:
        print "Deleting temporary files..."
        for filename in filenames:
            os.remove(filename)
예제 #19
0
    else:
        #gtselect
        filter['evclass'] = 128
        filter['evtype'] = 3
        filter['rad'] = 'INDEF'
        filter['emin'] = emin
        filter['emax'] = emax
        filter['zmax'] = zmax
        filter['infile'] = data_file
        filter['ra'] = ra
        filter['dec'] = dec
        filter['tmin'] = times[i - 1]  #must be in MET (s)
        filter['tmax'] = times[i]
        outfile = 'JUPITER_binned_filtered_' + str(i) + '.fits'
        filter['outfile'] = outfile
        filter.run()

        #gtmktime
        maketime['scfile'] = sc_file
        maketime['filter'] = '(DATA_QUAL==1)&&(LAT_CONFIG==1)'
        maketime['roicut'] = 'yes'
        maketime['evfile'] = outfile
        gti_file = 'JUPITER_binned_gti_' + str(i) + '.fits'
        maketime['outfile'] = gti_file
        maketime.run()

        #counts map
        evtbin['scfile'] = sc_file
        evtbin['nxpix'] = int(dim)
        evtbin['nypix'] = int(dim)
        evtbin['binsz'] = bin_size