Skip to content

Conversation

@sathanas31
Copy link
Collaborator

Up until now, the background model assumes only conventional atmospheric events. This implementation is constructed so that it allows the option of including an extra diffuse flux component in the background model, where the diffuse flux can follow a single or broken power-law model with user-defined parameters.

Major changes:

  1. Revamp make_SoB_splines module by introducing the SoB_splines base class, with subclasses including "no_difffuse", "spl_difffuse", and "bpl_difffuse". All the methods for creating the background spatial and SoB splines are now methods of this class. When diffuse is included in the background, the background spatial and energy pdfs are constructed by weighting the histograms with the atmospheric + diffuse event weights, with the latter being derived in the respective class from the input (per-flavour) flux model.
  2. ONLY for NTSeason, implement a new method to simulate the background, where the events are selected according to the atmospheric + diffuse weights.
  3. Since making background spatial spline is a method of the SoB class, the BackgroundSpatialPDF is created with an optional SoB arg, which is necessary for the ZenithSpline, thus reflected when creating SpatialPDF.
  4. In direct analogy with how the other classes are created, SoB_splines takes a dictionary with user-defined background model parameters: "bkg_model_name" for the subclass name, "phi0" for the (per-flavour) norm, "spl_gamma", "gamma1", "gamma2", and "logEbreak" (see the respective classes for default values). This sob_dict is passed in the inj_dict and llh_dict as the "sob_dict" key. If not explicitly passed, then it is created when initializing the injector and llh defaulting to "no_difffuse". The sob_dict must also have "smoothing_order" and "gamma_precision" keys to create the SoB splines, which they both default to "flarestack" if not explicitly set by the user.
  5. Change in injector's create_dataset to add diffuse flux component in the pseudo-dataset if "bkg_model_name" != "no_difffuse" & season == NTSeason.

BUGFIXES:

  1. MockUnblindedInjector should return scrambled data for all seasons.
  2. Fix in Submitter for when you submit jobs on the cluster that don't include inj_dict.

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!_
…fffuse" (ie atm-only). Adds extra arg in the smoothing_precision_string, llh_energy_hash_pickles, and bkg_spline_path func
…ulate_background(), but takes a bkg_weights func as an arg, so that the diffuse + atm weights are calculated for given MC
…ntedError (only for NT!!)

2. add SoB arg in make_background_spatial(). The SoB_splines.mmake_background_spline() is then called
3. change imports
…nt 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
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()
…'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
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
…gamma trials with different gamma in the llh dict than the one in inj dict
…r 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
… 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)
…lass (no_difffuse, flarestack smoothing order and precision) to call make_individual_spline_set method
…useSpline; return correct types for masks in its get_diffuse_flux method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants