"Fit Negative n_s?": False } cat_res = dict() # Inject for, at most, 100 days max_window = 100 lengths = np.logspace(-2, 0, 5) * max_window for cat in tde_catalogues: name = "analyses/tde/compare_fitting_weights/" + cat + "/" cat_path = tde_catalogue_name(cat) catalogue = np.load(cat_path) src_res = dict() closest_src = np.sort(catalogue, order="Distance (Mpc)")[0] for i, llh_kwargs in enumerate([ fixed_weights, fixed_weights_negative, fit_weights, flare ]): label = ["Fixed Weights", "Fixed Weights (Negative n_s)", "Fit Weights", "Flare Search", ][i] f_name = ["fixed_weights", "fixed_weights_neg",
from flarestack import MinimisationHandler, analyse # Initialise Injectors/LLHs llh_dict = { "llh_name": "standard", "llh_sig_time_pdf": {"time_pdf_name": "steady"}, "llh_bkg_time_pdf": { "time_pdf_name": "steady", }, "llh_energy_pdf": {"energy_pdf_name": "power_law"}, } true_parameters = [3.6400763376308523, 0.0, 0.0, 4.0] catalogue = tde_catalogue_name("jetted") class TestTimeIntegrated(unittest.TestCase): def setUp(self): pass def test_declination_sensitivity(self): logging.info("Testing 'fit_weight' MinimisationHandler class") mh_name = "fit_weights" # Test three declinations unblind_dict = {
if llh_name == "fixed_energy": llh_dict["LLH Energy PDF"]["Gamma"] = gamma inj_dict = { "Injection Time PDF": { "Name": "Steady" }, "Injection Energy PDF": { "Name": "Power Law", "Gamma": gamma, }, "fixed_n": 30 } mh_dict = { "name": name, "mh_name": "fixed_weights", "datasets": [IC86_1_dict], # "catalogue": ps_catalogue_name(sin_dec), "catalogue": tde_catalogue_name("jetted"), "llh_dict": llh_dict, "inj kwargs": inj_dict } scale = flux_to_k(reference_sensitivity( sin_dec, gamma)) * 125 * ([4.0, 1.0, 0.3, 10.0][j]) mh = MinimisationHandler.create(mh_dict) mh.iterate_run(scale=scale, n_steps=2, n_trials=100) rh = ResultsHandler(mh_dict)
# Initialise Injectors/LLHs llh_energy = {"Name": "Power Law"} llh_time = {"Name": "FixedEndBox"} llh_kwargs = { "LLH Energy PDF": llh_energy, "LLH Time PDF": llh_time, "Fit Gamma?": True, "Fit Weights?": True, } cat_path = tde_catalogue_name("jetted") # cat_path = individual_tde_cat("Swift J1644+57") catalogue = np.load(cat_path) name = "analyses/tde/test_model/" injection_length = 100.0 injection_time = llh_time = { "Name": "Box", "Pre-Window": 0.0, "Post-Window": injection_length, } # Inject a spline
name_root = "analyses/tde/unblind_stacked_TDEs/" bkg_ts_root = "analyses/tde/compare_spectral_indices/" cat_res = dict() res = [] for j, cat in enumerate(tde_catalogues): name = name_root + cat.replace(" ", "") + "/" logging.info(f"{name}") bkg_ts = bkg_ts_root + cat.replace(" ", "") + "/Fit Weights/" cat_path = tde_catalogue_name(cat) catalogue = load_catalogue(cat_path) unblind_dict = { "name": name, "mh_name": "fit_weights", "dataset": custom_dataset(txs_sample_v1, catalogue, llh_dict["llh_sig_time_pdf"]), "catalogue": cat_path, "llh_dict": llh_dict, "background_ts": bkg_ts