コード例 #1
0
 def GtCcube(self):
     """Run gtbin with the CCUBE option"""
     if (self.clobber == "no" and os.path.isfile(self.ccube)):
         #print("File exists and clobber is False")
         return (0)
     Nbdecade = log10(self.Emax) - log10(
         self.Emin)  #Compute the number of decade
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.ccube
     evtbin['algorithm'] = "CCUBE"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin['ebinalg'] = "LOG"
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj']  #"AIT"
     #The number of bin is the number of decade * the number of bin
     #per decade (given by the users). The +0.5 rounds it properly
     evtbin["enumbins"] = max(
         2,
         int(Nbdecade *
             self.Configuration['energy']['enumbins_per_decade'] + 0.5))
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #2
0
def Crab_cmap(useWorkAround=False):
    evtbin['algorithm'] = 'CMAP'
    evtbin['evfile'] = 'Crab_events_filtered.fits'
    evtbin['outfile'] = 'Crab.fits'
    evtbin['scfile'] = 'Crab_scData_0000.fits'
    evtbin['tbinalg'] = 'LIN'
    evtbin['tstart'] = 0.
    evtbin['tstop'] = 86400.
    evtbin['dtime'] = 1000.0
    evtbin['tbinfile'] = 'numxpix=100'
    evtbin['nxpix'] = 100
    evtbin['nypix'] = 100
    evtbin['binsz'] = 0.5
    evtbin['coordsys'] = 'CEL'
    evtbin['xref'] = 83.0
    evtbin['yref'] = 22.0
    evtbin['axisrot'] = 0.0
    evtbin['ebinalg'] = 'LOG'
    evtbin['emin'] = 30.0
    evtbin['emax'] = 200000.0
    evtbin['enumbins'] = 20
    evtbin['denergy'] = 0.0
    evtbin['proj'] = 'CAR'
    evtbin['snratio'] = 1
    evtbin['lcemin'] = 0
    evtbin['lcemax'] = 0
    if useWorkAround:
        evtbin.write()
    evtbin.run()
コード例 #3
0
 def GtCcube(self):
     """Run gtbin with the CCUBE option"""
     Nbdecade = log10(self.Emax) - log10(
         self.Emin)  #Compute the number of decade
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.ccube
     evtbin['algorithm'] = "CCUBE"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin['ebinalg'] = "LOG"
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj']  #"AIT"
     #The number of bin is the number of decade * the number of bin per decade (given by the users)
     evtbin["enumbins"] = int(
         Nbdecade * self.Configuration['energy']['enumbins_per_decade'])
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #4
0
ファイル: gtfunction.py プロジェクト: mireianievas/enrico
 def GtCcube(self):
     """Run gtbin with the CCUBE option"""
     if (self.clobber=="no" and os.path.isfile(self.ccube)):
         #print("File exists and clobber is False")
         return(0)
     Nbdecade = log10(self.Emax)-log10(self.Emin)#Compute the number of decade
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.ccube
     evtbin['algorithm'] = "CCUBE"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin['ebinalg'] = "LOG"
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj'] #"AIT"
     #The number of bin is the number of decade * the number of bin 
     #per decade (given by the users). The +0.5 rounds it properly
     evtbin["enumbins"] = max(2,int(Nbdecade*self.Configuration['energy']['enumbins_per_decade']+0.5))
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #5
0
def Crab_lc():
    evtbin['algorithm'] = 'LC'
    evtbin['outfile'] = 'Crab.lc'
    evtbin['tstart'] = 0
    evtbin['tstop'] = 8.64e4
    evtbin['dtime'] = 1e3
    evtbin.write()
    evtbin.run()
コード例 #6
0
def run_gtsrcmaps(square):

    '''This is the atomic function that actually runs in the seperate
    threads.  The input is an array with two elements, the first describes
    the energy binning and the second lists all of the progromatic
    options.  This function runs evtbin to generate a counts cube for the
    sub-energy range and then gtsrcmaps.  It returns the bin number and
    the output filename of the srcmaps file for the sub-energy range.'''


    idx = square[0][0][0]
    emin = square[0][0][1]*0.001
    emax = square[0][-1][2]*0.001
    enumbins = len(square[0])
    options = square[1]

    ccubehandle,ccubefilename = tempfile.mkstemp(suffix=".fits")
    evtbin['evfile'] = options['evfile']
    evtbin['outfile'] = ccubefilename
    evtbin['algorithm'] = 'CCUBE'
    evtbin['nxpix'] = options['nxpix']
    evtbin['nypix'] = options['nypix']
    evtbin['binsz'] = options['binsz']
    evtbin['coordsys'] = options['coordsys']
    evtbin['xref'] = options['xref']
    evtbin['yref'] = options['yref']
    evtbin['axisrot'] = options['axisrot']
    evtbin['proj'] = options['proj']
    evtbin['ebinalg'] = options['ebinalg']
    evtbin['emin'] = emin
    evtbin['emax'] = emax
    evtbin['enumbins'] = enumbins
    evtbin['scfile'] = options['scfile']
    evtbin.run(print_command=False)

    srcmaphandle,srcmapfilename = tempfile.mkstemp(suffix=".fits")
    srcMaps['scfile'] = options['scfile']
    srcMaps['expcube'] = options['expcube']
    srcMaps['cmap'] = ccubefilename
    srcMaps['srcmdl'] = options['srcmdl']
    srcMaps['bexpmap'] = options['bexpmap']
    srcMaps['outfile'] = srcmapfilename
    srcMaps['irfs'] = options['irfs']
    srcMaps['chatter'] = 2
    srcMaps['emapbnds'] = "no"
    srcMaps.run(print_command=False)

    return idx,srcmapfilename
コード例 #7
0
ファイル: gtsrcmaps_mp.py プロジェクト: eclipsia/gtapps_mp
def run_gtsrcmaps(square):

    '''This is the atomic function that actually runs in the seperate
    threads.  The input is an array with two elements, the first describes
    the energy binning and the second lists all of the progromatic
    options.  This function runs evtbin to generate a counts cube for the
    sub-energy range and then gtsrcmaps.  It returns the bin number and
    the output filename of the srcmaps file for the sub-energy range.'''


    idx = square[0][0][0]
    emin = square[0][0][1]*0.001
    emax = square[0][-1][2]*0.001
    enumbins = len(square[0])
    options = square[1]

    ccubehandle,ccubefilename = tempfile.mkstemp(suffix=".fits")
    evtbin['evfile'] = options['evfile']
    evtbin['outfile'] = ccubefilename
    evtbin['algorithm'] = 'CCUBE'
    evtbin['nxpix'] = options['nxpix']
    evtbin['nypix'] = options['nypix']
    evtbin['binsz'] = options['binsz']
    evtbin['coordsys'] = options['coordsys']
    evtbin['xref'] = options['xref']
    evtbin['yref'] = options['yref']
    evtbin['axisrot'] = options['axisrot']
    evtbin['proj'] = options['proj']
    evtbin['ebinalg'] = options['ebinalg']
    evtbin['emin'] = emin
    evtbin['emax'] = emax
    evtbin['enumbins'] = enumbins
    evtbin['scfile'] = options['scfile']
    evtbin.run(print_command=False)

    srcmaphandle,srcmapfilename = tempfile.mkstemp(suffix=".fits")
    srcMaps['scfile'] = options['scfile']
    srcMaps['expcube'] = options['expcube']
    srcMaps['cmap'] = ccubefilename
    srcMaps['srcmdl'] = options['srcmdl']
    srcMaps['bexpmap'] = options['bexpmap']
    srcMaps['outfile'] = srcmapfilename
    srcMaps['irfs'] = options['irfs']
    srcMaps['chatter'] = 2
    srcMaps['emapbnds'] = "no"
    srcMaps.run(print_command=False)

    return idx,srcmapfilename
コード例 #8
0
ファイル: gtfunction.py プロジェクト: zblz/enrico
 def GtLCbin(self, dt=60):
     """Run gtbin with the LC option. the default dt is 60 sec and data can be rebinned after.
       Can also take a file as input to define the time bins"""
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.lcfile
     evtbin['algorithm'] = "LC"
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin["dtime"] = dt
     if dt > 0:
         evtbin["tbinalg"] = "LIN"
     else:
         evtbin["tbinalg"] = "FILE"
         evtbin["tbinfile"] = self.BinDef
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #9
0
ファイル: survey.py プロジェクト: cdeil/enrico
 def _count_map(self):
     """Run gtbin"""
     from gt_apps import evtbin as tool
     self._set_common_tool_options(tool)
     tool['evfile'] = os.path.join(self.input_dir, 'gtmktime.fits')
     tool['scfile'] = 'NONE'
     tool['outfile'] = 'map.fits'
     tool['algorithm'] = 'CMAP'
     tool['nxpix'] = self.nxpix
     tool['nypix'] = self.nypix
     tool['binsz'] = self.binsz
     tool['coordsys'] = self.coordsys
     tool['xref'] = self.xref
     tool['yref'] = self.yref
     tool['axisrot'] = 0
     tool['proj'] = self.proj
     tool.run()
コード例 #10
0
ファイル: gtfunction.py プロジェクト: jlenain/enrico
 def GtLCbin(self,dt=60):
     """Run gtbin with the LC option. the default dt is 60 sec and data can be rebinned after.
       Can also take a file as input to define the time bins"""
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.lcfile
     evtbin['algorithm'] = "LC"
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin["dtime"] = dt
     if dt > 0 :
         evtbin["tbinalg"] = "LIN"
     else :
         evtbin["tbinalg"] = "FILE"
         evtbin["tbinfile"] = self.BinDef
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #11
0
 def _count_map(self):
     """Run gtbin"""
     from gt_apps import evtbin as tool
     self._set_common_tool_options(tool)
     tool['evfile'] = os.path.join(self.input_dir, 'gtmktime.fits')
     tool['scfile'] = 'NONE'
     tool['outfile'] = 'map.fits'
     tool['algorithm'] = 'CMAP'
     tool['nxpix'] = self.nxpix
     tool['nypix'] = self.nypix
     tool['binsz'] = self.binsz
     tool['coordsys'] = self.coordsys
     tool['xref'] = self.xref
     tool['yref'] = self.yref
     tool['axisrot'] = 0
     tool['proj'] = self.proj
     tool.run()
コード例 #12
0
ファイル: gtfunction.py プロジェクト: zblz/enrico
 def Gtbin(self):
     """Run gtbin with the CMAP option. A count map is produced"""
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.cmapfile
     evtbin['algorithm'] = "CMAP"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = 'CEL'
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj']
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #13
0
ファイル: gtfunction.py プロジェクト: jlenain/enrico
 def Gtbin(self):
     """Run gtbin with the CMAP option. A count map is produced"""
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.cmapfile
     evtbin['algorithm'] = "CMAP"
     evtbin['nxpix'] = self.npix 
     evtbin['nypix'] = self.npix 
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin['xref'] = self.ra 
     evtbin['yref'] = self.dec
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj'] 
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #14
0
 def GtLCbin(self, dt=60):
     """Run gtbin with the LC option. the default dt is 60 sec and data can be rebinned after.
       Can also take a file as input to define the time bins"""
     if (self.clobber == "no" and os.path.isfile(self.lcfile)):
         #print("File exists and clobber is False")
         return (0)
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.lcfile
     evtbin['algorithm'] = "LC"
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin["dtime"] = dt
     if dt > 0:
         evtbin["tbinalg"] = "LIN"
     else:
         evtbin["tbinalg"] = "FILE"
         evtbin["tbinfile"] = self.BinDef
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #15
0
ファイル: gtfunction.py プロジェクト: mireianievas/enrico
 def GtLCbin(self,dt=60):
     """Run gtbin with the LC option. the default dt is 60 sec and data can be rebinned after.
       Can also take a file as input to define the time bins"""
     if (self.clobber=="no" and os.path.isfile(self.lcfile)):
         #print("File exists and clobber is False")
         return(0)
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.lcfile
     evtbin['algorithm'] = "LC"
     evtbin["tstart"] = self.t1
     evtbin["tstop"] = self.t2
     evtbin["dtime"] = dt
     if dt > 0 :
         evtbin["tbinalg"] = "LIN"
     else :
         evtbin["tbinalg"] = "FILE"
         evtbin["tbinfile"] = self.BinDef
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #16
0
 def Gtbin(self):
     """Run gtbin with the CMAP option. A count map is produced"""
     if (self.clobber == "no" and os.path.isfile(self.cmapfile)):
         #print("File exists and clobber is False")
         return (0)
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.cmapfile
     evtbin['algorithm'] = "CMAP"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj']
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #17
0
ファイル: gtfunction.py プロジェクト: mireianievas/enrico
 def Gtbin(self):
     """Run gtbin with the CMAP option. A count map is produced"""
     if (self.clobber=="no" and os.path.isfile(self.cmapfile)):
         #print("File exists and clobber is False")
         return(0)
     evtbin['evfile'] = self.mktimefile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.cmapfile
     evtbin['algorithm'] = "CMAP"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin['xref'] = self.ra
     evtbin['yref'] = self.dec
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj']
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #18
0
ファイル: gtfunction.py プロジェクト: jlenain/enrico
 def GtCcube(self):
     """Run gtbin with the CCUBE option"""
     Nbdecade = log10(self.Emax)-log10(self.Emin)#Compute the number of decade
     evtbin['evfile'] = self.eventfile
     evtbin['scfile'] = self.ft2
     evtbin['outfile'] = self.ccube
     evtbin['algorithm'] = "CCUBE"
     evtbin['nxpix'] = self.npix
     evtbin['nypix'] = self.npix
     evtbin['binsz'] = self.binsz
     evtbin['coordsys'] = self.Configuration['space']['coordsys']
     evtbin['xref'] = self.ra 
     evtbin['yref'] = self.dec
     evtbin["emin"] = self.Emin
     evtbin["emax"] = self.Emax
     evtbin['ebinalg'] = "LOG"
     evtbin['axisrot'] = 0
     evtbin['proj'] = self.Configuration['space']['proj'] #"AIT"
     #The number of bin is the number of decade * the number of bin per decade (given by the users)
     evtbin["enumbins"] = int(Nbdecade*self.Configuration['energy']['enumbins_per_decade'])
     evtbin['clobber'] = self.clobber
     evtbin.run()
コード例 #19
0
        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
        evtbin['axisrot'] = 0
        evtbin['coordsys'] = 'CEL'
        evtbin['proj'] = 'AIT'
        evtbin['algorithm'] = 'CMAP'
        evtbin['evfile'] = gti_file
        cmap_file = 'JUPITER_binned_cmap_' + str(i) + '.fits'
        evtbin['outfile'] = cmap_file
        evtbin['xref'] = ra
        evtbin['yref'] = dec
        evtbin.run()

        #stack each cmap
        total_cmap_data += fits.getdata(cmap_file)

cmap_outfile = 'stacked_cmap.fits'
hdu = fits.PrimaryHDU(total_cmap_data)
hdu.writeto(cmap_outfile, overwrite=True)

plt.imshow(total_cmap_data, cmap='gray')
plt.colorbar()
plt.show()
コード例 #20
0
def Crab_pha():
    evtbin['algorithm'] = 'PHA1'
    evtbin['outfile'] = 'Crab.pha'
    evtbin.write()
    evtbin.run()