Skip to content

Commit 9f81260

Browse files
authored
Merge pull request #344 from cta-observatory/overwrite-catB
Add option to overwrite the existing Cat-B calibration files
2 parents 28e501a + 4e4b415 commit 9f81260

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/osa/scripts/reprocessing.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def run_script(
3232
simulate: bool,
3333
force: bool,
3434
overwrite_tailcuts: bool,
35+
overwrite_catB: bool,
3536
):
3637
"""Run the sequencer for a given date."""
3738
osa_config = Path(config).resolve()
@@ -58,6 +59,9 @@ def run_script(
5859

5960
if overwrite_tailcuts:
6061
cmd.append("--overwrite-tailcuts")
62+
63+
if overwrite_catB:
64+
cmd.append("--overwrite-catB")
6165

6266
# Append the telescope to the command in the last place
6367
cmd.append("LST1")
@@ -88,6 +92,7 @@ def get_list_of_dates(dates_file):
8892
@click.option("-s", "--simulate", is_flag=True, help="Activate simulation mode.")
8993
@click.option("-f", "--force", is_flag=True, help="Force the autocloser to close the day.")
9094
@click.option("--overwrite-tailcuts", is_flag=True, help="Overwrite the tailcuts config file if it already exists.")
95+
@click.option("--overwrite-catB", is_flag=True, help="Overwrite the Cat-B calibration files if they already exist.")
9196
@click.option(
9297
"-c",
9398
"--config",
@@ -110,6 +115,7 @@ def main(
110115
simulate: bool = False,
111116
force: bool = False,
112117
overwrite_tailcuts: bool = False,
118+
overwrite_catB: bool = False,
113119
):
114120
"""
115121
Loop over the dates listed in the input file and launch the script for each of them.
@@ -126,7 +132,19 @@ def main(
126132
# Avoid running jobs while it is still night time
127133
wait_for_daytime()
128134

129-
run_script(script, date, config, no_dl2, no_gainsel, no_calib, no_dl1ab, simulate, force, overwrite_tailcuts)
135+
run_script(
136+
script,
137+
date,
138+
config,
139+
no_dl2,
140+
no_gainsel,
141+
no_calib,
142+
no_dl1ab,
143+
simulate,
144+
force,
145+
overwrite_tailcuts,
146+
overwrite_catB,
147+
)
130148
log.info("Waiting 1 minute to launch the process for the next date...\n")
131149
time.sleep(60)
132150

src/osa/scripts/sequencer_catB_tailcuts.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
default=False,
5757
help="Overwrite the tailcuts config file if it already exists.",
5858
)
59+
parser.add_argument(
60+
"--overwrite-catB",
61+
action="store_true",
62+
default=False,
63+
help="Overwrite the Cat-B calibration files if they already exist.",
64+
)
5965
parser.add_argument(
6066
"tel_id",
6167
choices=["ST", "LST1", "LST2", "all"],
@@ -111,7 +117,7 @@ def launch_catB_calibration(run_id: int):
111117
before and it finished successfully, it creates a catB_{run}.closed file.
112118
"""
113119
job_id = get_catB_last_job_id(run_id)
114-
if job_id:
120+
if job_id and not options.overwrite_catB:
115121
job_status = get_sacct_output(run_sacct(job_id=job_id))["State"]
116122
if job_status.item() in ["RUNNING", "PENDING"]:
117123
log.debug(f"Job {job_id} (corresponding to run {run_id:05d}) is still running.")
@@ -129,8 +135,11 @@ def launch_catB_calibration(run_id: int):
129135

130136
else:
131137
if catB_calibration_file_exists(run_id):
132-
log.info(f"Cat-B calibration file already produced for run {run_id:05d}.")
133-
return
138+
if not options.overwrite_catB:
139+
log.info(f"Cat-B calibration file already produced for run {run_id:05d}.")
140+
return
141+
else:
142+
log.info(f"Cat-B calibration file already produced for run {run_id:05d}. Overwriting it.")
134143

135144
command = cfg.get("lstchain", "catB_calibration")
136145
if cfg.getboolean("lstchain", "use_lstcam_env_for_CatB_calib"):
@@ -162,6 +171,9 @@ def launch_catB_calibration(run_id: int):
162171
cmd.append(f"--dl1-dir={analysis_dir}")
163172
cmd.append(f"--lstchain-version={lstchain_version[1:]}")
164173

174+
if options.overwrite_catB:
175+
cmd.append("--yes")
176+
165177
if not options.simulate:
166178
job = sp.run(cmd, encoding="utf-8", capture_output=True, text=True, check=True)
167179
job_id = job.stdout.strip()
@@ -217,6 +229,7 @@ def main():
217229
options.tel_id = opts.tel_id
218230
options.simulate = opts.simulate
219231
options.overwrite_tailcuts = opts.overwrite_tailcuts
232+
options.overwrite_catB = opts.overwrite_catB
220233
options.date = opts.date
221234
options.date = set_default_date_if_needed()
222235
options.configfile = opts.config.resolve()

0 commit comments

Comments
 (0)