Skip to content

Commit 3bb42f3

Browse files
committed
bugfixes round1
1 parent 2d95161 commit 3bb42f3

22 files changed

+60
-74
lines changed

workflow/Snakefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import logging
2020

2121
from dbetto import AttrsDict
2222
from legendmeta import LegendMetadata
23-
from legenddataflow import CalGrouping
24-
from legenddataflow import utils
23+
from legenddataflow import CalGrouping, execenv, utils
2524

2625
utils.subst_vars_in_snakemake_config(workflow, config)
2726
config = AttrsDict(config)
@@ -38,6 +37,8 @@ time = datetime.now().strftime("%Y%m%dT%H%M%SZ")
3837
if not Path(meta).exists():
3938
LegendMetadata(meta).checkout(config.legend_metadata_version)
4039

40+
metadata = LegendMetadata(meta, lazy=True)
41+
4142
part = CalGrouping(config, Path(det_status) / "cal_groupings.yaml")
4243

4344

@@ -80,7 +81,7 @@ onstart:
8081

8182
# Make sure some packages are initialized before we begin to avoid race conditions
8283
for pkg in ["dspeed", "lgdo", "matplotlib"]:
83-
shell(execenv.execenv_pyexe(config, "python") + f" -c 'import {pkg}'")
84+
shell(execenv.execenv_pyexe(config, "python") + "-c 'import " + pkg + "'")
8485

8586
# Log parameter catalogs in validity.jsonl files
8687
hit_par_cat_file = Path(utils.pars_path(config)) / "hit" / "validity.yaml"
@@ -123,9 +124,11 @@ onstart:
123124
onsuccess:
124125
from snakemake.report import auto_report
125126

127+
126128
rep_dir = f"{log_path(config)}/report-{datetime.strftime(datetime.utcnow(), '%Y%m%dT%H%M%SZ')}"
127129
Path(rep_dir).mkdir(parents=True, exist_ok=True)
128130
# auto_report(workflow.persistence.dag, f"{rep_dir}/report.html")
131+
auto_report(workflow.persistence.dag, report_plugin, report_settings)
129132

130133
with open(os.path.join(rep_dir, "dag.txt"), "w") as f:
131134
f.writelines(str(workflow.persistence.dag))

workflow/profiles/lngs/config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
cores: 125
22
restart-times: 2
3-
max-jobs-per-second: 1
43
resources:
54
- mem_swap=3500
65
configfile: config-lngs.yaml

workflow/src/legenddataflow/scripts/par/geds/dsp/dplms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from lgdo import Array, Table
1111
from pygama.pargen.dplms_ge_dict import dplms_ge_dict
1212

13-
from ....log import build_log
14-
from ...table_name import get_table_name
13+
from .....log import build_log
14+
from ....table_name import get_table_name
1515

1616

1717
def par_geds_dsp_dplms() -> None:

workflow/src/legenddataflow/scripts/par/geds/dsp/eopt.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
run_one_dsp,
1919
)
2020

21-
from ....log import build_log
22-
from ...table_name import get_table_name
21+
from .....log import build_log
22+
from ....table_name import get_table_name
2323

2424
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2525
warnings.filterwarnings(action="ignore", category=np.RankWarning)

workflow/src/legenddataflow/scripts/par/geds/dsp/evtsel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from pygama.pargen.data_cleaning import generate_cuts, get_keys
1616
from pygama.pargen.dsp_optimize import run_one_dsp
1717

18-
from ....log import build_log
19-
from ...pulser_removal import get_pulser_mask
20-
from ...table_name import get_table_name
18+
from .....log import build_log
19+
from ....pulser_removal import get_pulser_mask
20+
from ....table_name import get_table_name
2121

2222
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2323

workflow/src/legenddataflow/scripts/par/geds/dsp/nopt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pygama.pargen.data_cleaning import generate_cuts, get_cut_indexes
1313
from pygama.pargen.dsp_optimize import run_one_dsp
1414

15-
from ....log import build_log
15+
from .....log import build_log
1616

1717

1818
def par_geds_dsp_nopt() -> None:

workflow/src/legenddataflow/scripts/par/geds/dsp/svm_build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from lgdo import lh5
88
from sklearn.svm import SVC
99

10-
from ....log import build_log
10+
from .....log import build_log
1111

1212

1313
def par_geds_dsp_svm_build() -> None:

workflow/src/legenddataflow/scripts/par/geds/dsp/tau.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from pygama.pargen.dsp_optimize import run_one_dsp
1111
from pygama.pargen.extract_tau import ExtractTau
1212

13-
from ....log import build_log
14-
from ...pulser_removal import get_pulser_mask
15-
from ...table_name import get_table_name
13+
from .....log import build_log
14+
from ....pulser_removal import get_pulser_mask
15+
from ....table_name import get_table_name
1616

1717

1818
def par_geds_dsp_tau() -> None:

workflow/src/legenddataflow/scripts/par/geds/hit/aoe.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from pygama.pargen.AoE_cal import CalAoE, Pol1, SigmaFit, aoe_peak
1313
from pygama.pargen.utils import load_data
1414

15+
from .....log import build_log
1516
from ....convert_np import convert_dict_np_to_float
16-
from ....log import build_log
17-
from ...pulser_removal import get_pulser_mask
18-
from ...table_name import get_table_name
17+
from ....pulser_removal import get_pulser_mask
18+
from ....table_name import get_table_name
1919

2020
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2121

workflow/src/legenddataflow/scripts/par/geds/hit/ecal.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
from pygama.pargen.utils import load_data
2424
from scipy.stats import binned_statistic
2525

26+
from .....log import build_log
2627
from ....convert_np import convert_dict_np_to_float
27-
from ....log import build_log
28-
from ...pulser_removal import get_pulser_mask
29-
from ...table_name import get_table_name
28+
from ....pulser_removal import get_pulser_mask
29+
from ....table_name import get_table_name
3030

3131
mpl.use("agg")
3232
sto = lh5.LH5Store()

workflow/src/legenddataflow/scripts/par/geds/hit/lq.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
from pygama.pargen.lq_cal import LQCal
1515
from pygama.pargen.utils import load_data
1616

17+
from .....log import build_log
1718
from ....convert_np import convert_dict_np_to_float
18-
from ....log import build_log
19-
from ...pulser_removal import get_pulser_mask
20-
from ...table_name import get_table_name
19+
from ....pulser_removal import get_pulser_mask
20+
from ....table_name import get_table_name
2121

2222
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2323

workflow/src/legenddataflow/scripts/par/geds/hit/qc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
)
1818
from pygama.pargen.utils import load_data
1919

20+
from .....log import build_log
2021
from ....convert_np import convert_dict_np_to_float
21-
from ....log import build_log
22-
from ...pulser_removal import get_pulser_mask
23-
from ...table_name import get_table_name
22+
from ....pulser_removal import get_pulser_mask
23+
from ....table_name import get_table_name
2424

2525
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2626

workflow/src/legenddataflow/scripts/par/geds/pht/aoe.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from pygama.pargen.AoE_cal import CalAoE, Pol1, SigmaFit, aoe_peak
1717
from pygama.pargen.utils import load_data
1818

19+
from .....log import build_log
1920
from ....FileKey import ChannelProcKey, ProcessingFileKey
20-
from ....log import build_log
21-
from ...pulser_removal import get_pulser_mask
22-
from ...table_name import get_table_name
21+
from ....pulser_removal import get_pulser_mask
22+
from ....table_name import get_table_name
2323

2424
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2525

workflow/src/legenddataflow/scripts/par/geds/pht/ecal_part.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from pygama.pargen.energy_cal import FWHMLinear, FWHMQuadratic, HPGeCalibration
1919
from pygama.pargen.utils import load_data
2020

21+
from .....log import build_log
2122
from ....FileKey import ChannelProcKey, ProcessingFileKey
22-
from ....log import build_log
23-
from ...pulser_removal import get_pulser_mask
24-
from ...table_name import get_table_name
23+
from ....pulser_removal import get_pulser_mask
24+
from ....table_name import get_table_name
2525

2626
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2727
warnings.filterwarnings(action="ignore", category=np.RankWarning)

workflow/src/legenddataflow/scripts/par/geds/pht/fast.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from workflow.src.legenddataflow.scripts.par.geds.pht.lq import run_lq_calibration
1717
from workflow.src.legenddataflow.scripts.par.geds.pht.partcal import calibrate_partition
1818

19+
from .....log import build_log
1920
from ....FileKey import ChannelProcKey, ProcessingFileKey
20-
from ....log import build_log
21-
from ...pulser_removal import get_pulser_mask
22-
from ...table_name import get_table_name
21+
from ....pulser_removal import get_pulser_mask
22+
from ....table_name import get_table_name
2323

2424
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2525
warnings.filterwarnings(action="ignore", category=np.RankWarning)

workflow/src/legenddataflow/scripts/par/geds/pht/lq.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from pygama.pargen.lq_cal import LQCal
1919
from pygama.pargen.utils import load_data
2020

21+
from .....log import build_log
2122
from ....FileKey import ChannelProcKey, ProcessingFileKey
22-
from ....log import build_log
23-
from ...pulser_removal import get_pulser_mask
24-
from ...table_name import get_table_name
23+
from ....pulser_removal import get_pulser_mask
24+
from ....table_name import get_table_name
2525

2626
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2727

workflow/src/legenddataflow/scripts/par/geds/pht/qc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
)
1818
from pygama.pargen.utils import load_data
1919

20+
from .....log import build_log
2021
from ....convert_np import convert_dict_np_to_float
21-
from ....log import build_log
22-
from ...pulser_removal import get_pulser_mask
23-
from ...table_name import get_table_name
22+
from ....pulser_removal import get_pulser_mask
23+
from ....table_name import get_table_name
2424

2525
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2626

workflow/src/legenddataflow/scripts/par/geds/pht/qc_phy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
get_keys,
1818
)
1919

20+
from .....log import build_log
2021
from ....convert_np import convert_dict_np_to_float
21-
from ....log import build_log
22-
from ...table_name import get_table_name
22+
from ....table_name import get_table_name
2323

2424
warnings.filterwarnings(action="ignore", category=RuntimeWarning)
2525

workflow/src/legenddataflow/scripts/par/geds/raw/blindcal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from lgdo import lh5
1717
from pygama.pargen.energy_cal import HPGeCalibration
1818

19-
from ...table_name import get_table_name
19+
from ....table_name import get_table_name
2020

2121
mpl.use("agg")
2222

workflow/src/legenddataflow/scripts/par/geds/raw/blindcheck.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
from pygama.math.histogram import get_hist
2222
from pygama.pargen.energy_cal import get_i_local_maxima
2323

24-
from ....log import build_log
25-
from ...table_name import get_table_name
24+
from .....log import build_log
25+
from ....table_name import get_table_name
2626

2727
mpl.use("Agg")
2828

workflow/src/legenddataflow/scripts/par/geds/tcm/pulser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from dbetto.catalog import Props
77
from pygama.pargen.data_cleaning import get_tcm_pulser_ids
88

9-
from ....log import build_log
10-
from ...table_name import get_table_name
9+
from .....log import build_log
10+
from ....table_name import get_table_name
1111

1212

1313
def par_geds_tcm_pulser() -> None:
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
from pathlib import Path
2-
31
import numpy as np
42
from dbetto.catalog import Props
5-
from pygama.pargen.data_cleaning import get_tcm_pulser_ids
6-
73

8-
def get_pulser_mask(
9-
pulser_file=None, tcm_filelist=None, channel=None, pulser_multiplicity_threshold=10
10-
):
11-
if pulser_file is not None:
12-
if not isinstance(pulser_file, list):
13-
pulser_file = [pulser_file]
14-
mask = np.array([], dtype=bool)
15-
for file in pulser_file:
16-
pulser_dict = Props.read_from(file)
17-
pulser_mask = np.array(pulser_dict["mask"])
18-
mask = np.append(mask, pulser_mask)
194

20-
elif tcm_filelist is not None:
21-
# get pulser mask from tcm files
22-
with Path(tcm_filelist).open() as f:
23-
tcm_files = f.read().splitlines()
24-
tcm_files = sorted(np.unique(tcm_files))
25-
_, mask = get_tcm_pulser_ids(tcm_files, channel, pulser_multiplicity_threshold)
26-
else:
27-
msg = "No pulser file or tcm filelist provided"
28-
raise ValueError(msg)
5+
def get_pulser_mask(pulser_file):
6+
if not isinstance(pulser_file, list):
7+
pulser_file = [pulser_file]
8+
mask = np.array([], dtype=bool)
9+
for file in pulser_file:
10+
pulser_dict = Props.read_from(file)
11+
pulser_mask = np.array(pulser_dict["mask"])
12+
mask = np.append(mask, pulser_mask)
2913

3014
return mask

0 commit comments

Comments
 (0)