def test_declination_sensitivity(self): logging.info("Testing 'standard' LLH class") # Test three declinations for j, sindec in enumerate(sindecs): unblind_dict = { "name": "tests/test_llh_standard/", "mh_name": "fixed_weights", "dataset": icecube_ps_3_year.get_seasons("IC86-2011"), "catalogue": ps_catalogue_name(sindec), "llh_dict": llh_dict, } ub = create_unblinder(unblind_dict) key = [x for x in ub.res_dict.keys() if x != "TS"][0] res = ub.res_dict[key] logging.info("Best fit values {0}".format(list(res["x"]))) logging.info("Reference best fit {0}".format(true_parameters[j])) for i, x in enumerate(res["x"]): self.assertAlmostEqual(x, true_parameters[j][i], delta=0.1)
"llh_sig_time_pdf": llh_time, "llh_bkg_time_pdf": { "time_pdf_name": "steady" }, } name = "analyses/benchmarks/ps_sens_7yr" # sindecs = np.linspace(0.90, -0.90, 3) sindecs = np.linspace(0.90, -0.90, 9) # sindecs = np.linspace(0.5, -0.5, 3) analyses = [] for sindec in sindecs: cat_path = ps_catalogue_name(sindec) subname = name + "/sindec=" + "{0:.2f}".format(sindec) + "/" scale = flux_to_k(reference_sensitivity(sindec)) * 5 mh_dict = { "name": subname, "mh_name": "fixed_weights", "dataset": ps_v002_p01, "catalogue": cat_path, "inj_dict": inj_kwargs, "llh_dict": llh_kwargs, "scale": scale, "n_trials": 50, "n_steps": 10,
llh_dict = { "name": "standard_overlapping", "LLH Energy PDF": injection_energy, "LLH Time PDF": injection_time, "pull_name": pull_corrector, "floor_name": floor, } scale = flux_to_k(reference_sensitivity(sin_dec, gamma)) * 5 mh_dict = { "name": name, "mh_name": "fixed_weights", "datasets": [IC86_1_dict], "catalogue": ps_catalogue_name(sin_dec), "llh_dict": llh_dict, "inj kwargs": inj_dict, "n_trials": 20, "n_steps": 15, "scale": scale, } pkl_file = make_analysis_pickle(mh_dict) # rd.submit_to_cluster(pkl_file, n_jobs=150) # mh = MinimisationHandler.create(mh_dict) # mh.iterate_run(n_steps=2, n_trials=20, scale=scale) mh.run(10, scale=float(scale))
"spline_path": spline_save_path }, # Outdated style, test for backwards-compatibility { "Name": "PowerLaw", "Gamma": 3.0 }, { "Name": "Spline", "Spline Path": spline_save_path } ] true_parameters = [[1.35150508], [1.34119769], [1.35150508], [1.34119769]] catalogue = ps_catalogue_name(-0.5) class TestTimeIntegrated(unittest.TestCase): def setUp(self): pass def test_declination_sensitivity(self): logging.info("Testing 'fixed_weight' MinimisationHandler class") for i, e_pdf_dict in enumerate(energy_pdfs): llh_dict = { "llh_name": "fixed_energy", "llh_sig_time_pdf": {
"energy_pdf_name": "power_law", "gamma": 2.0, } llh_time = {"time_pdf_name": "custom_source_box"} unblind_llh = { "llh_name": "standard", "llh_sig_time_pdf": llh_time, "llh_bkg_time_pdf": { "time_pdf_name": "steady" }, "llh_energy_pdf": llh_energy, } cat_path = ps_catalogue_name(0.5) unblind_dict = { "name": "tests/test_flare_search/", "mh_name": "flare", "dataset": icecube_ps_3_year.get_seasons("IC86-2011"), "catalogue": cat_path, "llh_dict": unblind_llh, } # Inspecting the neutrino lightcurve for this fixed-seed scramble confirms # that the most significant flare is in a 14 day window. The best-fit # parameters are shown below. As both the scrambling and fitting is # deterministic, these values should be returned every time this test is run. true_parameters = [
llh_dict = { "name": "spatial", "LLH Energy PDF": injection_energy, "LLH Time PDF": injection_time, "pull_name": pull_corrector, "floor_name": floor } # scale = flux_to_k(reference_sensitivity(sin_dec, gamma)) * 10 mh_dict = { "name": name, "mh_name": "fixed_weights", "datasets": [IC86_1_dict], "catalogue": ps_catalogue_name(-0.2), "llh_dict": llh_dict, "inj kwargs": inj_dict, "n_trials": 50, "n_steps": 2, "scale": 1. } pkl_file = make_analysis_pickle(mh_dict) # rd.submit_to_cluster(pkl_file, n_jobs=50) # # mh = MinimisationHandler.create(mh_dict_power_law) # mh.iterate_run(n_steps=2, n_trials=10) config_mh.append(mh_dict)
import logging from flarestack.data.public import icecube_ps_3_year from flarestack.utils.prepare_catalogue import ps_catalogue_name from flarestack.core.unblinding import create_unblinder import unittest llh_dict = { "llh_name": "spatial", "llh_sig_time_pdf": {"time_pdf_name": "steady"}, "llh_bkg_time_pdf": {"time_pdf_name": "steady"}, } source = ps_catalogue_name(0.0) unblind_dict = { "name": "tests/test_llh_spatial/", "mh_name": "fixed_weights", "dataset": icecube_ps_3_year.get_seasons("IC86-2011"), "catalogue": ps_catalogue_name(0.5), "llh_dict": llh_dict, } true_parameters = [1.9587621795637824] class TestSpatialLikelihood(unittest.TestCase): def setUp(self): pass def test_spatial(self): logging.info("Testing 'spatial' LLH class")