def test_update_gal_iso(self): test_out_dir = self.set_outputfolder("test_update_gal_iso") ag = AGAnalysis(self.agilepyConf, self.sourcesConfTxt) ag.setOptions(tmin=433857532, tmax=433858532, timetype="TT") outDir = Path(ag.getOption("outdir")) ag.config.setOptions(galcoeff=[0.6, 0.8, 0.6, 0.8]) ag.config.setOptions(isocoeff=[10, 15, 10, 15]) galcoeffs = ag.config.getOptionValue("galcoeff") isocoeffs = ag.config.getOptionValue("isocoeff") _ = ag.generateMaps() matrix = ag.parseMaplistFile() for idx, row in enumerate(matrix): self.assertEqual(str(galcoeffs[idx]), row[4]) self.assertEqual(str(isocoeffs[idx]), row[5]) ag.config.setOptions(galcoeff=[0,0,0,0]) ag.config.setOptions(isocoeff=[0,0,0,0]) galcoeffs = ag.config.getOptionValue("galcoeff") isocoeffs = ag.config.getOptionValue("isocoeff") matrix = ag.parseMaplistFile() for idx, row in enumerate(matrix): self.assertEqual(str(galcoeffs[idx]), row[4]) self.assertEqual(str(isocoeffs[idx]), row[5])
def test_parse_maplistfile(self): test_out_dir = self.set_outputfolder("test_parse_maplistfile") ag = AGAnalysis(self.agilepyConf, self.sourcesConfTxt) ag.setOptions(energybins=[[100,300],[300,1000]], fovbinnumber=2) maplistFilePath = ag.generateMaps() maplistRows1 = ag.parseMaplistFile() maplistRows2 = ag.parseMaplistFile(maplistFilePath) self.assertEqual(4, len(maplistRows1)) self.assertEqual(4, len(maplistRows2)) for i in range(4): for j in range(3): self.assertEqual(maplistRows1[i][j], maplistRows2[i][j]) for i in range(4): for j in range(3): self.assertEqual(True, os.path.isfile(maplistRows1[i][j])) ag.destroy()
def test_generate_maps(self): test_out_dir = self.set_outputfolder("test_generate_maps") ag = AGAnalysis(self.agilepyConf, self.sourcesConfTxt) ag.setOptions(tmin=433857532, tmax=433858532, timetype="TT") outDir = ag.getOption("outdir") maplistFilePath0 = ag.generateMaps() self.assert_maplistfile_lines_number(maplistFilePath0, 4) outDir0 = Path(outDir).joinpath("maps", "0") self.assertEqual(True, outDir0.is_dir()) self.assert_generated_maps_number(outDir0, 16) self.assert_generated_maps_exist(ag.parseMaplistFile(maplistFilePath0)) # second generation (same parameters) maplistFilePath1 = ag.generateMaps() self.assert_maplistfile_lines_number(maplistFilePath1, 4) outDir1 = Path(outDir).joinpath("maps", "1") self.assertEqual(True, outDir1.is_dir()) self.assert_generated_maps_number(outDir1, 16) self.assert_generated_maps_exist(ag.parseMaplistFile(maplistFilePath1)) # third generation with different time interval ag.setOptions(tmin=433957532, tmax=433957632, timetype="TT") maplistFilePath2 = ag.generateMaps() self.assert_maplistfile_lines_number(maplistFilePath2, 4) outDir2 = Path(outDir).joinpath("maps", "2") self.assertEqual(True, outDir2.is_dir()) self.assert_generated_maps_number(outDir2, 16) self.assert_generated_maps_exist(ag.parseMaplistFile(maplistFilePath2)) # fourth generation with different glon and glat ag.setOptions(glon=265, glat=-3, timetype="TT") maplistFilePath3 = ag.generateMaps() self.assert_maplistfile_lines_number(maplistFilePath3, 4) outDir3 = Path(outDir).joinpath("maps", "3") self.assertEqual(True, outDir3.is_dir()) self.assert_generated_maps_number(outDir3, 16) self.assert_generated_maps_exist(ag.parseMaplistFile(maplistFilePath3)) # fifth generation with different fovbinnumber, and energy range ag.setOptions(fovbinnumber=1, energybins=[[100,300]]) maplistFilePath4 = ag.generateMaps() self.assert_maplistfile_lines_number(maplistFilePath4, 1) outDir3 = Path(outDir).joinpath("maps", "4") self.assertEqual(True, outDir3.is_dir()) self.assert_generated_maps_number(outDir3, 4) self.assert_generated_maps_exist(ag.parseMaplistFile(maplistFilePath4)) ag.destroy()
def test_update_gal_iso(self): ag = AGAnalysis(self.agilepyconfPath, self.sourcesconfPath) outDir = Path(ag.getOption("outdir")) ag.config.setOptions(galcoeff=[0.6, 0.8, 0.6, 0.8]) ag.config.setOptions(isocoeff=[10, 15, 10, 15]) galcoeffs = ag.config.getOptionValue("galcoeff") isocoeffs = ag.config.getOptionValue("isocoeff") maplistFilePath = ag.generateMaps() matrix = ag.parseMaplistFile() for idx, row in enumerate(matrix): self.assertEqual(str(galcoeffs[idx]), row[4]) self.assertEqual(str(isocoeffs[idx]), row[5]) if outDir.joinpath("maps").exists() and outDir.joinpath( "maps").is_dir(): shutil.rmtree(outDir.joinpath("maps")) outDir.joinpath("maps").mkdir(parents=False, exist_ok=True) ag.config.setOptions(galcoeff=[0, 0, 0, 0]) ag.config.setOptions(isocoeff=[0, 0, 0, 0]) galcoeffs = ag.config.getOptionValue("galcoeff") isocoeffs = ag.config.getOptionValue("isocoeff") matrix = ag.parseMaplistFile() for idx, row in enumerate(matrix): self.assertEqual(str(galcoeffs[idx]), row[4]) self.assertEqual(str(isocoeffs[idx]), row[5]) ag.destroy()