You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementation of diffuse flux in the background (#449)
* make SoB splines class
* 1. add bkg spatial into SoB_splines class
2. remove kwargs from class init, instead takes a dict where name, smoothing order, and gamma precision should be in. NO default vals! The latter 2 can be of str type.
3. bkg_weights class method returns NotImplementedError instead of array of 1s
4. remove obsolete environment smoothing & precision keys
5. remove redundant if clauses pertaining to making smoothing order an int & environment key in make_2d_spline_from_hist method
6. type annotate smoothing order to int where needed
7. remove kwargs from methods, use the class params instead
8. change the plot paths in make_individual_spline_set method to include a suffix with the subclass name if not "no_difffuse". The sig, SoB hist & splines plots will now be under the <gamma>/precision<float>_smoothing<int> dir
9. change the SoB_spline_path func args to include the sob dict as kwargs in make_splines & load_spline methods
10. BugFix: use per-flavour fluxes for SPL & BPL subclasses
11. BugFix: make the diffuse + atm weights an np.array
12. BPL subclass get_diffuse_flux method returns fluxes and respective masks for the 2 energy ranges. That accommodates the subclass bkg_weights method to comply with returning a single weights array
_Note to self: commit more oft!_
* import SoB_splines class to use its staticmethod make_plot
* add SoB class name in the spline paths if it's NOT the default "no_difffuse" (ie atm-only). Adds extra arg in the smoothing_precision_string, llh_energy_hash_pickles, and bkg_spline_path func
* add simulate_bkg_with_diffuse method in the NTSeason. Same as the simulate_background(), but takes a bkg_weights func as an arg, so that the diffuse + atm weights are calculated for given MC
* 1. add simulate_bkg_with_diffuse() in Season, which raises NotImplementedError (only for NT!!)
2. add SoB arg in make_background_spatial(). The SoB_splines.mmake_background_spline() is then called
3. change imports
* Add an optional SoB arg when creating SpatialPDF. This is only relevant for the BackgroundSpatialPDF, particularly for the ZenithSpline where SoB_splines class is needed for the create_background_function method. For UniformSolidAngle bkg spatial pdf the SoB = None
* Changes in BaseInjector:
1. when initializing, make sob dict with default vals for bkg_model_name, smoothing_order, and gamma_precision and instantiate SoB_splines.
2. pass the SoB class when creating the spatial_pdf if the "bkg_spatial_pdf" DOES NOT exist in the injection_spatial_pdf dict (BackgroundSpatialPDF defaults to ZenithSpline), otherwise is None
NOTE: not optimal and subject to change, since it depends on BackgroundSpatialPDF.create method!!!
3. when creating the dataset, call season.simulate_bkg_with_diffuse() w/ Sob_splines.bkg_weights as its Callable arg if sob_name isn't "no_difffuse", otherwise use the regular simulate_background()
* BUGFIX: when creating dataset in BaseInjector and SoB spline name isn't "no_difffuse", have a try except clause to catch cases when datasets other than NT are used. If that's the case a NotImplementedError is raised and simulate_background() is used instead.
Note: currently simulate_bkg_with_diffuse() is only implemented for NTSeason but can be extended to all datasets w/ MC
* changes to LLH
1. when initializing LLH
a) make sob dict with default vals for smoothing, precision, and SoB name. If sob dict isn't passed in the llh dict, then it's created with smoothing and precision vals taken from the llh dict for backwards compatibility. Create SoB spline and pass its smoothing_order and gamma_precision properties to the respective LLH ones.
b) when creating the SpatialPDF, pass SoB instance if bkg spatial is not specified in the llh spatial dict, otherwise pass None.
!!Hacky method, dependent on the hardcoded default "zenith spline" for the bkg spatial. Prone to error if that changes!!!!
2. BUGFIX: update return val in SpatialLLH create_energy_function. Calls self.spatial_pdf.background_spatial instead of obsolete property
3. changes in FixedEnergyLLH:
a) delete redundant smoothing order and precision properties assignment when initializing
b) update llh_energy_hash_pickles()
c) replace old methods to SoB class methods where needed
d) BUGFIX: dump proper sinDEC bins from season when making SoB pickle in create_energy_weighting_function()
4. changes in StandardLLH
a) replace old methods to SoB class methods where needed
b) update SoB_spline_path()
5. BUGFIX: in generate_dynamic_flare_class() raise NotImplementedError if mh_name is either "spatial", or "fixed_energy" since there is no SoB energy cache in these 2
* add warning logging when initializing minimizer if the SoB dicts in the llh & inj dicts are different
* delete redundant warning log in the minimizer for when running fixed gamma trials with different gamma in the llh dict than the one in inj dict
* BUGFIX: have a try except clause in the submit method of Submitter for when LowMemoryInjector is used and the make_band_mask needs to be called. Fixes cases when you submit jobs on the cluster that don't include inj dict
* BUGFIX: change MockUnblindedInjector to return scrambled data for all seasons. Substitute load_background_model() with use_data_for_trials() so the exp data are correctly loaded when initializing. Bypass the season's simulate_background() in create_dataset() by basically copying the Season.simulate_background() method before applying the angular_error_modifier (bad practice but can't think of sth better)
* update public all_sky_3_year module used in tests. Make default SoB class (no_difffuse, flarestack smoothing order and precision) to call make_individual_spline_set method
* fix linter: BPLDiffuseSpline inherits from base class and not SPLDiffuseSpline; return correct types for masks in its get_diffuse_flux method
* isort fix
* exit ResultsHandler after making TS and params plots if only bkg trials
0 commit comments