Skip to content

Commit

Permalink
write the DL1b files in the corresponding tailcutXY directory
Browse files Browse the repository at this point in the history
  • Loading branch information
marialainez committed Feb 7, 2025
1 parent 42c46e1 commit 8070e23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
12 changes: 11 additions & 1 deletion src/osa/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import List
import subprocess
import time

import json
import lstchain
from astropy.table import Table
from lstchain.onsite import (find_systematics_correction_file,
Expand Down Expand Up @@ -416,3 +416,13 @@ def catB_calibration_file_exists(run_id: int) -> bool:
catB_calib_dir = catB_calib_base_dir / "calibration" / night_dir / prod_id
catB_calib_file = catB_calib_dir / f"cat_B_calibration_filters_{filters}.Run{run_id:05d}.h5"
return catB_calib_file.exists()


def get_dl1_prod_id(config_filename):
with open(config_filename) as json_file:
data = json.load(json_file)

picture_thresh = data["tailcuts_clean_with_pedestal_threshold"]["picture_thresh"]
boundary_thresh = data["tailcuts_clean_with_pedestal_threshold"]["boundary_thresh"]

return f"tailcut{picture_thresh}{boundary_thresh}"
19 changes: 11 additions & 8 deletions src/osa/scripts/datasequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from osa.utils.cliopts import data_sequence_cli_parsing
from osa.utils.logging import myLogger
from osa.utils.utils import date_to_dir
from osa.paths import catB_closed_file_exists
from osa.paths import catB_closed_file_exists, get_dl1_prod_id


__all__ = ["data_sequence", "r0_to_dl1", "dl1_to_dl2", "dl1ab", "dl1_datacheck"]
Expand Down Expand Up @@ -188,13 +188,6 @@ def dl1ab(run_str: str) -> int:
rc: int
Return code of the executed command.
"""
# Create a new subdirectory for the dl1ab output
dl1ab_subdirectory = Path(options.directory) / options.dl1_prod_id
dl1ab_subdirectory.mkdir(parents=True, exist_ok=True)
# DL1a input file from base running_analysis directory
input_dl1_datafile = Path(options.directory) / f"dl1_LST-1.Run{run_str}.h5"
# DL1b output file to be stored in the dl1ab subdirectory
output_dl1_datafile = dl1ab_subdirectory / f"dl1_LST-1.Run{run_str}.h5"

# Prepare and launch the actual lstchain script
command = cfg.get("lstchain", "dl1ab")
Expand All @@ -206,8 +199,18 @@ def dl1ab(run_str: str) -> int:
"Please try again later."
)
sys.exit(1)
else:
options.dl1_prod_id = get_dl1_prod_id(config_file)
else:
config_file = Path(cfg.get("lstchain", "dl1b_config"))

# Create a new subdirectory for the dl1ab output
dl1ab_subdirectory = Path(options.directory) / options.dl1_prod_id
dl1ab_subdirectory.mkdir(parents=True, exist_ok=True)
# DL1a input file from base running_analysis directory
input_dl1_datafile = Path(options.directory) / f"dl1_LST-1.Run{run_str}.h5"
# DL1b output file to be stored in the dl1ab subdirectory
output_dl1_datafile = dl1ab_subdirectory / f"dl1_LST-1.Run{run_str}.h5"

cmd = [
command,
Expand Down

0 comments on commit 8070e23

Please sign in to comment.