Skip to content

Commit 809d8c4

Browse files
committed
Produce and look for calibration files with lstcam_calib version
1 parent fd1eac7 commit 809d8c4

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/osa/configs/sequencer.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SOURCE_CATALOG: %(OSA_DIR)s/Catalog
3636
SEQUENCER_WEB_DIR: %(OSA_DIR)s/SequencerWeb
3737
GAIN_SELECTION_FLAG_DIR: %(OSA_DIR)s/GainSel
3838
GAIN_SELECTION_WEB_DIR: %(OSA_DIR)s/GainSelWeb
39+
CALIB_ENV: /fefs/aswg/software/conda/envs/lstcam-env
3940

4041
# To be set by the user. Using PROD-ID will overcome the automatic
4142
# fetching of lstchain version. Otherwise leave it empty (and without the colon symbol).

src/osa/paths.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ def get_drs4_pedestal_filename(run_id: int, prod_id: str) -> Path:
103103
return files[-1] # Get the latest production among the major lstchain version
104104

105105
date = utils.date_to_dir(get_run_date(run_id))
106+
lstcam_env = Path(cfg.get("LST1", "CALIB_ENV"))
107+
lstcam_calib_version = utils.get_lstcam_calib_version(lstcam_env)
106108
return (
107109
DRS4_PEDESTAL_BASEDIR
108110
/ date
109-
/ f"v{lstchain.__version__}/drs4_pedestal.Run{run_id:05d}.0000.h5"
111+
/ f"v{lstcam_calib_version}/drs4_pedestal.Run{run_id:05d}.0000.h5"
110112
).resolve()
111113

112114

@@ -138,10 +140,12 @@ def get_calibration_filename(run_id: int, prod_id: str) -> Path:
138140
date = utils.date_to_dir(get_run_date(run_id))
139141
options.filters = utils.get_calib_filters(run_id)
140142

143+
lstcam_env = Path(cfg.get("LST1", "CALIB_ENV"))
144+
lstcam_calib_version = utils.get_lstcam_calib_version(lstcam_env)
141145
return (
142146
CALIB_BASEDIR
143147
/ date
144-
/ f"v{lstchain.__version__}/calibration_filters_{options.filters}.Run{run_id:05d}.0000.h5"
148+
/ f"v{lstcam_calib_version}/calibration_filters_{options.filters}.Run{run_id:05d}.0000.h5"
145149
).resolve()
146150

147151

src/osa/scripts/calibration_pipeline.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from osa.utils.cliopts import calibration_pipeline_cliparsing
2121
from osa.utils.logging import myLogger
2222
from osa.workflow.stages import DRS4PedestalStage, ChargeCalibrationStage
23-
from osa.utils.utils import get_lstchain_version
2423

2524
__all__ = [
2625
"calibration_sequence",
@@ -47,30 +46,25 @@ def drs4_pedestal_command(drs4_pedestal_run_id: int) -> list:
4746
base_dir = Path(cfg.get("LST1", "BASE")).resolve()
4847
r0_dir = Path(cfg.get("LST1", "R0_DIR")).resolve()
4948
command = cfg.get("lstchain", "drs4_baseline")
50-
prod_id = get_lstchain_version()
5149
return [
5250
command,
5351
"-r", str(drs4_pedestal_run_id),
5452
"-b", base_dir,
5553
f"--r0-dir={r0_dir}",
5654
"--no-progress",
57-
"-v",prod_id,
5855
]
5956

6057
def calibration_file_command(drs4_pedestal_run_id: int, pedcal_run_id: int) -> list:
6158
"""Build the create_calibration_file command."""
6259
base_dir = Path(cfg.get("LST1", "BASE")).resolve()
6360
r0_dir = Path(cfg.get("LST1", "R0_DIR")).resolve()
6461
command = cfg.get("lstchain", "charge_calibration")
65-
prod_id = get_lstchain_version()
6662
cmd = [
6763
command,
6864
"-p", str(drs4_pedestal_run_id),
6965
"-r", str(pedcal_run_id),
7066
"-b", base_dir,
7167
f"--r0-dir={r0_dir}",
72-
"-v",prod_id,
73-
7468
]
7569
# In case of problems with trigger tagging:
7670
if cfg.getboolean("lstchain", "use_ff_heuristic_id"):

src/osa/utils/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from datetime import datetime, timedelta
1212
from pathlib import Path
1313
from socket import gethostname
14+
import subprocess as sp
1415
from gammapy.data import observatory_locations
1516
from astropy import units as u
1617
from astropy.table import Table
@@ -402,3 +403,13 @@ def get_RF_model(run_id: int) -> Path:
402403
rf_model_path = rf_models_dir / declination_str
403404

404405
return rf_model_path.resolve()
406+
407+
408+
def get_lstcam_calib_version(env_path: Path) -> str:
409+
"""Get the version of the lstcam_calib package installed in the given environment."""
410+
python_exe = f"{str(env_path)}/bin/python"
411+
cmd = [python_exe, "-m", "pip", "show", "lstcam_calib"]
412+
result = sp.run(cmd, capture_output=True, text=True, check=True)
413+
for line in result.stdout.split('\n'):
414+
if line.startswith('Version:'):
415+
return line.split(':', 1)[1].strip()

0 commit comments

Comments
 (0)