-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application of Cat-B calibration (option1) #302
base: main
Are you sure you want to change the base?
Changes from all commits
4915cc1
53d57b3
0b43696
95290da
0828b26
763ec64
a3f0e1a
9e9193c
5ac3770
889508c
2d3e2bd
eefba65
f483be3
34c8ab0
c67cdd5
c3f8608
ccf89db
f8b0edd
e94a15a
a9ebfdb
d8df805
37062cd
d220c81
805964b
48f13b2
cf7b610
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,15 +3,19 @@ | |||||||||
import logging | ||||||||||
import sys | ||||||||||
from pathlib import Path | ||||||||||
import time | ||||||||||
|
||||||||||
from osa.configs import options | ||||||||||
from osa.configs.config import cfg | ||||||||||
from osa.job import historylevel | ||||||||||
from osa.workflow.stages import AnalysisStage | ||||||||||
from osa.provenance.capture import trace | ||||||||||
from osa.paths import get_catB_calibration_filename | ||||||||||
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.utils.utils import date_to_dir, get_calib_filters | ||||||||||
from osa.nightsummary.extract import get_last_pedcalib | ||||||||||
|
||||||||||
|
||||||||||
__all__ = ["data_sequence", "r0_to_dl1", "dl1_to_dl2", "dl1ab", "dl1_datacheck"] | ||||||||||
|
||||||||||
|
@@ -68,13 +72,17 @@ def data_sequence( | |||||||||
log.info(f"Going to level {level}") | ||||||||||
|
||||||||||
if level == 3: | ||||||||||
rc = dl1ab(run_str) | ||||||||||
if cfg.getboolean("lstchain", "store_image_dl1ab"): | ||||||||||
level -= 1 | ||||||||||
log.info(f"Going to level {level}") | ||||||||||
else: | ||||||||||
level -= 2 | ||||||||||
log.info(f"No images stored in dl1ab. Producing DL2. Going to level {level}") | ||||||||||
if options.no_dl1ab: | ||||||||||
level = 0 | ||||||||||
log.info(f"No DL1B are going to be produced. Going to level {level}") | ||||||||||
else: | ||||||||||
rc = dl1ab(run_str) | ||||||||||
if cfg.getboolean("lstchain", "store_image_dl1ab"): | ||||||||||
level -= 1 | ||||||||||
log.info(f"Going to level {level}") | ||||||||||
else: | ||||||||||
level -= 2 | ||||||||||
log.info(f"No images stored in dl1ab. Producing DL2. Going to level {level}") | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
if level == 2: | ||||||||||
rc = dl1_datacheck(run_str) | ||||||||||
|
@@ -165,6 +173,55 @@ def r0_to_dl1( | |||||||||
return analysis_step.rc | ||||||||||
|
||||||||||
|
||||||||||
@trace | ||||||||||
def catB_calibration(run_str: str) -> int: | ||||||||||
""" | ||||||||||
Prepare and launch the lstchain script that creates the | ||||||||||
Category B calibration files. It should be executed runwise, | ||||||||||
so it is only launched for the first subrun of each run. | ||||||||||
|
||||||||||
Parameters | ||||||||||
---------- | ||||||||||
run_str: str | ||||||||||
|
||||||||||
Returns | ||||||||||
------- | ||||||||||
rc: int | ||||||||||
Return code of the executed command. | ||||||||||
""" | ||||||||||
if run_str[-4:] != "0000": | ||||||||||
log.debug(f"{run_str} is not the first subrun of the run, so the script " | ||||||||||
"onsite_create_cat_B_calibration_file will not be launched for this subrun.") | ||||||||||
|
||||||||||
catB_calibration_file = get_catB_calibration_filename(int(run_str[:5])) | ||||||||||
n = 0 | ||||||||||
n_max = 10 | ||||||||||
while not catB_calibration_file.exists() and n<=n_max: | ||||||||||
time.sleep(120) | ||||||||||
n += 1 | ||||||||||
return 0 | ||||||||||
Comment on lines
+192
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need the sleep part here if you plan to do it in two steps?
Comment on lines
+193
to
+202
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd simply return if subrun is not 0 |
||||||||||
|
||||||||||
command = cfg.get("lstchain", "catB_calibration") | ||||||||||
options.filters = get_calib_filters(int(run_str[:5])) | ||||||||||
base_dir = Path(cfg.get("LST1", "BASE")).resolve() | ||||||||||
r0_dir = Path(cfg.get("LST1", "R0_DIR")).resolve() | ||||||||||
catA_calib_run = get_last_pedcalib(options.date) | ||||||||||
cmd = [ | ||||||||||
command, | ||||||||||
f"--run_number={run_str[:5]}", | ||||||||||
f"--catA_calibration_run={catA_calib_run}", | ||||||||||
f"--base_dir={base_dir}", | ||||||||||
f"--r0-dir={r0_dir}", | ||||||||||
f"--filters={options.filters}", | ||||||||||
] | ||||||||||
if options.simulate: | ||||||||||
return 0 | ||||||||||
|
||||||||||
analysis_step = AnalysisStage(run=run_str, command_args=cmd) | ||||||||||
analysis_step.execute() | ||||||||||
return analysis_step.rc | ||||||||||
|
||||||||||
|
||||||||||
@trace | ||||||||||
def dl1ab(run_str: str) -> int: | ||||||||||
""" | ||||||||||
|
@@ -189,7 +246,7 @@ def dl1ab(run_str: str) -> int: | |||||||||
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") | ||||||||||
cmd = [ | ||||||||||
|
@@ -198,9 +255,14 @@ def dl1ab(run_str: str) -> int: | |||||||||
f"--output-file={output_dl1_datafile}", | ||||||||||
f"--config={dl1b_config}", | ||||||||||
] | ||||||||||
|
||||||||||
if not cfg.getboolean("lstchain", "store_image_dl1ab"): | ||||||||||
cmd.append("--no-image=True") | ||||||||||
|
||||||||||
if cfg.getboolean("lstchain", "apply_catB_calibration"): | ||||||||||
catB_calibration_file = get_catB_calibration_filename(int(run_str[:5])) | ||||||||||
cmd.append(f"--catB-calibration-file={catB_calibration_file}") | ||||||||||
|
||||||||||
if options.simulate: | ||||||||||
return 0 | ||||||||||
|
||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it commented? do you plan to include a new cat B calibration line in the history file?