コード例 #1
0
ファイル: convolution.py プロジェクト: Areustle/fermi-glast
 def rot_lon_lat(self, lon, lat):
     """ Rotate the specified lon/lat to the equatorial grid. """
     v1 = DoubleVector()
     v2 = DoubleVector()
     Background.rot_grid(v1, v2, DoubleVector([lon]), DoubleVector([lat]),
                         self.center)
     return v1[0], v2[0]
コード例 #2
0
ファイル: roi_diffuse.py プロジェクト: tburnett/pointlike
 def setup(self):
     SkyIntegrator.set_tolerance(self.tolerance)
     exp = self.sa.exposure.exposure
     psf = self.sa.psf
     if len(self.dmodel) == 1:
         self.bgs = [Background(self.dmodel[0], exp[0], exp[1])]
     else:
         self.bgs = map(Background, self.dmodel, exp)
コード例 #3
0
ファイル: pointfit.py プロジェクト: tburnett/pointlike
def set_diffuse(diffusefilename='galdiffuse', exposure=1e10):
    if 'GLAST_EXT' in os.environ and diffusefilename == 'galdiffuse':
        diffusefilename = os.path.join(os.environ['GLAST_EXT'], 'extFiles',
                                       'v0r7', 'galdiffuse', 'GP_gamma.fits')
    diffuse = DiffuseFunction(diffusefilename)
    background = Background(diffuse, exposure)
    PointSourceLikelihood.set_diffuse(background)
    return (diffuse, background)  # return to keep references
コード例 #4
0
ファイル: roi_managers.py プロジェクト: Areustle/fermi-glast
    def reload_data(self,bands):

        exp = self.sa.exposure.exposure
        ns  = self.nsimps
        nm  = len(self.models)
        rd  = self.roi_dir

        front_bgs = [Background(model.get_dmodel(0),exp[0]) for model in self.bgmodels]
        back_bgs  = [Background(model.get_dmodel(1),exp[1]) for model in self.bgmodels]

        for nband,band in enumerate(bands):

            if not band.has_pixels:
                band.pi_evals = 0
                band.bg_pix_counts = 0
                continue

            #for bg in bgs: bg.set_event_class(band.ec)
            bgs = back_bgs if band.ec else front_bgs
            
            band.pi_evals  = N.empty([len(band.wsdl),nm,ns + 1])
                        
            for ne,e in enumerate(band.bg_points):
                for nbg,bg in enumerate(bgs):
                    bg.setEnergy(e)
                    band.pi_evals[:,nbg,ne] = N.asarray(bg.wsdl_vector_value(band.wsdl))

            #there really needs to be a reconciliation between generated and updating
            band.mo_evals = N.empty([nm,ns + 1])
            for n,m in enumerate(self.models):
                band.mo_evals[n,:] = m(band.bg_points)
                        
            band.bg_counts      = (band.ap_evals * band.mo_evals).sum(axis = 1)
            band.bg_all_counts = band.bg_counts.sum()
            band.pi_evals *= (band.b.pixelArea() * band.bg_vector)
            band.bg_pix_counts = (band.pi_evals * band.mo_evals).sum(axis = 2)
            band.bg_all_pix_counts = band.bg_pix_counts.sum(axis=1)
コード例 #5
0
ファイル: roi_diffuse.py プロジェクト: tburnett/pointlike
 def setup(self):
     exp = self.sa.exposure.exposure
     psf = self.sa.psf
     if len(self.dmodel) == 1:
         self.bg = [Background(self.dmodel[0], exp[0], exp[1])]
         self.bgc = [
             BackgroundConvolution(self.roi_dir,
                                   self.bg[0],
                                   psf,
                                   npix=self.npix,
                                   pixelsize=self.pixelsize)
         ]
     else:
         self.bg = map(Background, self.dmodel, exp)
         self.bgc = [
             BackgroundConvolution(self.roi_dir,
                                   bg,
                                   psf,
                                   npix=self.npix,
                                   pixelsize=self.pixelsize)
             for bg in self.bg
         ]