def test_ogip_rebinner(): with within_directory(__example_dir): ogip = OGIPLike("test_ogip", observation="test.pha{1}") n_data_points = 128 ogip.set_active_measurements("all") assert ogip.n_data_points == n_data_points ogip.rebin_on_background(min_number_of_counts=100) assert ogip.n_data_points < 128 with pytest.raises(AssertionError): ogip.set_active_measurements("all") ogip.remove_rebinning() assert ogip._rebinner is None assert ogip.n_data_points == n_data_points ogip.view_count_spectrum()
def test_swift_gbm(): with within_directory(__example_dir): gbm_dir = "gbm" bat_dir = "bat" bat = OGIPLike( "BAT", observation=os.path.join(bat_dir, "gbm_bat_joint_BAT.pha"), response=os.path.join(bat_dir, "gbm_bat_joint_BAT.rsp"), ) bat.set_active_measurements("15-150") bat.view_count_spectrum() nai6 = OGIPLike( "n6", os.path.join(gbm_dir, "gbm_bat_joint_NAI_06.pha"), os.path.join(gbm_dir, "gbm_bat_joint_NAI_06.bak"), os.path.join(gbm_dir, "gbm_bat_joint_NAI_06.rsp"), spectrum_number=1, ) nai6.set_active_measurements("8-900") nai6.view_count_spectrum() bgo0 = OGIPLike( "b0", os.path.join(gbm_dir, "gbm_bat_joint_BGO_00.pha"), os.path.join(gbm_dir, "gbm_bat_joint_BGO_00.bak"), os.path.join(gbm_dir, "gbm_bat_joint_BGO_00.rsp"), spectrum_number=1, ) bgo0.set_active_measurements("250-10000") bgo0.view_count_spectrum() bat.use_effective_area_correction(0.2, 1.5) bat.fix_effective_area_correction(0.6) bat.use_effective_area_correction(0.2, 1.5) band = Band() model = Model(PointSource("joint_fit", 0, 0, spectral_shape=band)) band.K = 0.04 band.xp = 300.0 data_list = DataList(bat, nai6, bgo0) jl = JointLikelihood(model, data_list) _ = jl.fit() _ = display_spectrum_model_counts(jl, step=False)
def test_swift_gbm(): with within_directory(__example_dir): gbm_dir = "gbm" bat_dir = "bat" bat = OGIPLike('BAT', observation=os.path.join(bat_dir, 'gbm_bat_joint_BAT.pha'), response=os.path.join(bat_dir, 'gbm_bat_joint_BAT.rsp')) bat.set_active_measurements('15-150') bat.view_count_spectrum() nai6 = OGIPLike('n6', os.path.join(gbm_dir, 'gbm_bat_joint_NAI_06.pha'), os.path.join(gbm_dir, 'gbm_bat_joint_NAI_06.bak'), os.path.join(gbm_dir, 'gbm_bat_joint_NAI_06.rsp'), spectrum_number=1) nai6.set_active_measurements('8-900') nai6.view_count_spectrum() bgo0 = OGIPLike('b0', os.path.join(gbm_dir, 'gbm_bat_joint_BGO_00.pha'), os.path.join(gbm_dir, 'gbm_bat_joint_BGO_00.bak'), os.path.join(gbm_dir, 'gbm_bat_joint_BGO_00.rsp'), spectrum_number=1) bgo0.set_active_measurements('250-10000') bgo0.view_count_spectrum() bat.use_effective_area_correction(.2, 1.5) bat.fix_effective_area_correction(.6) bat.use_effective_area_correction(.2, 1.5) band = Band() model = Model(PointSource('joint_fit', 0, 0, spectral_shape=band)) band.K = .04 band.xp = 300. data_list = DataList(bat, nai6, bgo0) jl = JointLikelihood(model, data_list) _ = jl.fit() _ = display_spectrum_model_counts(jl, step=False)