示例#1
0
    def test_write_sources_on_file(self):

        test_out_dir = self.set_outputfolder("test_write_sources_on_file")


        ag = AGAnalysis(self.agilepyConf)

        sources_subset = ag.loadSourcesFromCatalog("2AGL", rangeDist=(0, 30))

        self.assertRaises(SourceModelFormatNotSupported, ag.writeSourcesOnFile, "regfile", "notsupportedformat", None)

        #reg
        regfile = ag.writeSourcesOnFile("regfile", "reg", sources_subset)    
        with open(regfile) as f:
            linesNum = sum(1 for line in f)
        assert 1 == linesNum
        
        """
        ag.generateMaps()
        ag.mle()
        regfile = ag.writeSourcesOnFile("regfile", "reg", sources_subset)    
        with open(regfile) as f:
            linesNum = sum(1 for line in f)
        self.assertEqual(len(sources_subset)+1, linesNum)
        """

        ag.generateMaps()
        ag.freeSources(lambda name: name == self.VELA, "pos", True)
        ag.mle()
        regfile = ag.writeSourcesOnFile("regfile", "reg", sources_subset)    
        with open(regfile) as f:
            linesNum = sum(1 for line in f)
        self.assertEqual(len(sources_subset)+1, linesNum)
示例#2
0
    def test_fixed_parameters(self):

        test_out_dir = self.set_outputfolder("test_fixed_parameters")


        ag = AGAnalysis(self.agilepyConf)

        ag.setOptions(
            energybins=[[100, 1000]], tmin=434279000,
            tmax=434289532,
            timetype="TT")

        sources = ag.loadSourcesFromCatalog("2AGL", rangeDist=(0, 25))
        
        assert len(sources) == 9

        source = ag.selectSources('name == "2AGLJ0835-4514"').pop()

        flux0 = source.spectrum.getVal("flux")
        
        sources = ag.freeSources(
            'name == "2AGLJ0835-4514"', "flux", False, show=True)

        _ = ag.generateMaps()

        _ = ag.mle()
        
        flux1 = source.get("multiFlux")["value"]

        assert flux0 == flux1

        ag.destroy()
示例#3
0
    def test_analysis_pipeline(self):
        test_out_dir = self.set_outputfolder("test_analysis_pipeline")
        ag = AGAnalysis(self.agilepyConf, self.sourcesConfTxt)

        ag.setOptions(tmin = 433857532, tmax = 434289532, timetype = "TT", glon = 263.55, glat = -2.78)
        maplistFilePath = ag.generateMaps()
        self.assertEqual(True, os.path.isfile(maplistFilePath))

        sources = ag.loadSourcesFromCatalog("2AGL", rangeDist = (0, 21))
        sources = ag.freeSources('name == "2AGLJ0835-4514"', "flux", True, show=True)

        products_1 = ag.mle()

        for p in products_1:
            self.assertEqual(True, os.path.isfile(p))

        products_2 = ag.mle()
        for p in products_2:
            self.assertEqual(True, os.path.isfile(p))

        ag.setOptions(tmin = 433857532, tmax = 433907532, timetype = "TT", glon = 263.55, glat = -2.78)

        maplistfile = ag.generateMaps()
        
        products_3 = ag.mle()
        for p in products_3:
            self.assertEqual(True, os.path.isfile(p))
        
        ag.destroy()