Skip to content

Commit 80e1e1c

Browse files
authored
Merge pull request #337 from cta-observatory/calib-prod-id
Produce and look for calibration files with lstcam_calib version
2 parents fd1eac7 + 8e9ca9a commit 80e1e1c

File tree

8 files changed

+26
-15
lines changed

8 files changed

+26
-15
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/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from osa.scripts.tests.test_osa_scripts import run_program
2727
from osa.utils.utils import date_to_dir
2828
from datetime import datetime
29-
import lstchain
3029

3130
date = datetime.fromisoformat("2020-01-17")
3231
nightdir = date_to_dir(date)
@@ -87,14 +86,14 @@ def drive_log(monitoring_dir):
8786

8887
@pytest.fixture(scope="session")
8988
def calibration_dir(calibration_base_dir):
90-
directory = calibration_base_dir / "calibration" / nightdir / f"v{lstchain.__version__}"
89+
directory = calibration_base_dir / "calibration" / nightdir / "v0.1.1"
9190
directory.mkdir(parents=True, exist_ok=True)
9291
return directory
9392

9493

9594
@pytest.fixture(scope="session")
9695
def drs4_baseline_dir(calibration_base_dir):
97-
directory = calibration_base_dir / "drs4_baseline" / nightdir / f"v{lstchain.__version__}"
96+
directory = calibration_base_dir / "drs4_baseline" / nightdir / "v0.1.1"
9897
directory.mkdir(parents=True, exist_ok=True)
9998
return directory
10099

src/osa/high_level/significance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ def main(
206206
log.debug(f"Config: {config.resolve()}")
207207

208208
# Initial setup of global parameters
209+
if simulate:
210+
options.simulate = True
209211
options.date = date
210212
flat_date = date_to_dir(date)
211213
options.tel_id = telescope

src/osa/nightsummary/tests/test_extract.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from datetime import datetime
2+
from osa.configs import options
23

4+
options.test = True
35
obs_date = datetime.fromisoformat("2020-01-17")
46

57

src/osa/paths.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import subprocess
1010
import time
1111
import json
12-
import lstchain
1312
from astropy.table import Table
1413
from lstchain.onsite import (find_systematics_correction_file,
1514
find_time_calibration_file)
@@ -103,10 +102,12 @@ def get_drs4_pedestal_filename(run_id: int, prod_id: str) -> Path:
103102
return files[-1] # Get the latest production among the major lstchain version
104103

105104
date = utils.date_to_dir(get_run_date(run_id))
105+
lstcam_env = Path(cfg.get("LST1", "CALIB_ENV"))
106+
lstcam_calib_version = utils.get_lstcam_calib_version(lstcam_env)
106107
return (
107108
DRS4_PEDESTAL_BASEDIR
108109
/ date
109-
/ f"v{lstchain.__version__}/drs4_pedestal.Run{run_id:05d}.0000.h5"
110+
/ f"v{lstcam_calib_version}/drs4_pedestal.Run{run_id:05d}.0000.h5"
110111
).resolve()
111112

112113

@@ -138,10 +139,12 @@ def get_calibration_filename(run_id: int, prod_id: str) -> Path:
138139
date = utils.date_to_dir(get_run_date(run_id))
139140
options.filters = utils.get_calib_filters(run_id)
140141

142+
lstcam_env = Path(cfg.get("LST1", "CALIB_ENV"))
143+
lstcam_calib_version = utils.get_lstcam_calib_version(lstcam_env)
141144
return (
142145
CALIB_BASEDIR
143146
/ date
144-
/ f"v{lstchain.__version__}/calibration_filters_{options.filters}.Run{run_id:05d}.0000.h5"
147+
/ f"v{lstcam_calib_version}/calibration_filters_{options.filters}.Run{run_id:05d}.0000.h5"
145148
).resolve()
146149

147150

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/scripts/tests/test_osa_scripts.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,6 @@ def test_drs4_pedestal_cmd(base_test_dir):
350350
base_test_dir,
351351
f"--r0-dir={r0_dir}",
352352
"--no-progress",
353-
"-v","v0.11.0.post1"
354-
355353
]
356354
assert cmd == expected_command
357355

@@ -370,7 +368,6 @@ def test_calibration_file_cmd(base_test_dir):
370368
"-b",
371369
base_test_dir,
372370
f"--r0-dir={r0_dir}",
373-
"-v","v0.11.0.post1"
374371
]
375372
assert cmd == expected_command
376373

src/osa/utils/utils.py

Lines changed: 13 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,15 @@ 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+
if options.test or options.simulate:
411+
return "0.1.1"
412+
python_exe = f"{str(env_path)}/bin/python"
413+
cmd = [python_exe, "-m", "pip", "show", "lstcam_calib"]
414+
result = sp.run(cmd, capture_output=True, text=True, check=True)
415+
for line in result.stdout.split('\n'):
416+
if line.startswith('Version:'):
417+
return line.split(':', 1)[1].strip()

0 commit comments

Comments
 (0)