Skip to content

Commit

Permalink
get closest NSB among those with the same cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
marialainez committed Feb 10, 2025
1 parent 7658bfe commit e6ea503
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/osa/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def get_mc_nsb_dir(run_id: int, rf_models_dir: Path) -> Path:
closest to that of the data for a given run.
"""
analysis_dir = options.directory
_, additional_nsb, _ = find_tailcuts(analysis_dir, run_id)
additional_nsb = get_nsb_level(analysis_dir, run_id)

rf_models_prefix = cfg.get("lstchain", "mc_prod")
nsb_dict = get_nsb_dict(rf_models_dir, rf_models_prefix)
Expand All @@ -373,6 +373,20 @@ def get_mc_nsb_dir(run_id: int, rf_models_dir: Path) -> Path:
return nsb_dict[closest_nsb_value]


def get_nsb_level(analysis_dir, run_id):
"""Choose the closest NSB among those that are processed with the same cleaning level."""
analysis_dir = options.directory
_, nsb, config = find_tailcuts(analysis_dir, run_id)
picture_th = config["picture_thresh"]

nsb_levels = np.array([0.00, 0.07, 0.14, 0.22, 0.38, 0.50, 0.81, 1.25, 1.76, 2.34])
pth = np.array([8, 8, 8, 8, 10, 10, 12, 14, 16, 18])
candidate_nsbs = nsb_levels[pth==picture_th]

diff = abs(candidate_nsbs - nsb)
return candidate_nsbs[np.argsort(diff)][0]


def get_RF_model(run_id: int) -> Path:
"""Get the path of the RF models to be used in the DL2 production for a given run.
Expand Down

0 comments on commit e6ea503

Please sign in to comment.