legend-dataflow-scripts 0.1.8__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {legend_dataflow_scripts-0.1.8/src/legend_dataflow_scripts.egg-info → legend_dataflow_scripts-0.2.1}/PKG-INFO +1 -1
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1/src/legend_dataflow_scripts.egg-info}/PKG-INFO +1 -1
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/_version.py +3 -3
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/dplms.py +19 -15
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/eopt.py +17 -16
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/evtsel.py +57 -20
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/nopt.py +18 -17
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/pz.py +19 -15
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/svm_build.py +4 -8
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/hit/aoe.py +18 -22
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/hit/ecal.py +47 -59
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/hit/lq.py +17 -13
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/hit/qc.py +11 -13
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/log.py +2 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/plot_dict.py +1 -1
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/workflow/utils.py +7 -5
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/LICENSE +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/README.md +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/pyproject.toml +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/setup.cfg +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/SOURCES.txt +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/dependency_links.txt +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/entry_points.txt +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/not-zip-safe +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/requires.txt +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legend_dataflow_scripts.egg-info/top_level.txt +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/dsp/svm.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/par/geds/hit/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/tier/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/tier/dsp.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/tier/hit.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/alias_table.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/cfgtools.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/convert_np.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/utils/pulser_removal.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/workflow/__init__.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/workflow/execenv.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/workflow/filedb.py +0 -0
- {legend_dataflow_scripts-0.1.8 → legend_dataflow_scripts-0.2.1}/src/legenddataflowscripts/workflow/pre_compile_catalog.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: legend-dataflow-scripts
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Python package for the processing scripts for LEGEND-200 data
|
|
5
5
|
Author-email: George Marshall <ggmarsh@uw.edu>, Luigi Pertoldi <gipert@pm.me>
|
|
6
6
|
Maintainer: The LEGEND Collaboration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: legend-dataflow-scripts
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Python package for the processing scripts for LEGEND-200 data
|
|
5
5
|
Author-email: George Marshall <ggmarsh@uw.edu>, Luigi Pertoldi <gipert@pm.me>
|
|
6
6
|
Maintainer: The LEGEND Collaboration
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.1
|
|
32
|
-
__version_tuple__ = version_tuple = (0,
|
|
31
|
+
__version__ = version = '0.2.1'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 1)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g68aa434fe'
|
|
@@ -7,7 +7,6 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
import pygama.math.distributions as pmd # noqa: F401
|
|
10
|
-
from dbetto import TextDB
|
|
11
10
|
from dbetto.catalog import Props
|
|
12
11
|
from lgdo import Array, Table, lh5
|
|
13
12
|
from pygama.pargen.dplms_ge_dict import dplms_ge_dict
|
|
@@ -23,11 +22,21 @@ def par_geds_dsp_dplms() -> None:
|
|
|
23
22
|
argparser.add_argument("--database", help="database", type=str, required=True)
|
|
24
23
|
|
|
25
24
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
26
|
-
argparser.add_argument(
|
|
25
|
+
argparser.add_argument(
|
|
26
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
argparser.add_argument(
|
|
30
|
+
"--processing-chain",
|
|
31
|
+
help="Processing chain config",
|
|
32
|
+
type=str,
|
|
33
|
+
nargs="*",
|
|
34
|
+
required=True,
|
|
35
|
+
)
|
|
36
|
+
argparser.add_argument(
|
|
37
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
38
|
+
)
|
|
27
39
|
|
|
28
|
-
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
|
|
29
|
-
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
|
|
30
|
-
argparser.add_argument("--channel", help="Channel", type=str, required=True)
|
|
31
40
|
argparser.add_argument(
|
|
32
41
|
"--raw-table-name", help="raw table name", type=str, required=True
|
|
33
42
|
)
|
|
@@ -38,18 +47,13 @@ def par_geds_dsp_dplms() -> None:
|
|
|
38
47
|
|
|
39
48
|
args = argparser.parse_args()
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
log = build_log(config_dict, args.log)
|
|
45
|
-
|
|
46
|
-
configs = TextDB(args.configs).on(args.timestamp, system=args.datatype)
|
|
47
|
-
dsp_config = config_dict["inputs"]["proc_chain"][args.channel]
|
|
50
|
+
dsp_config = Props.read_from(args.processing_chain)
|
|
51
|
+
log = build_log(args.log_config, args.log)
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
dplms_dict = Props.read_from(dplms_json)
|
|
53
|
+
t0 = time.time()
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
dplms_dict = Props.read_from(args.config_file)
|
|
56
|
+
db_dict = Props.read_from(args.decay_const)
|
|
53
57
|
|
|
54
58
|
if dplms_dict["run_dplms"] is True:
|
|
55
59
|
with Path(args.fft_raw_filelist).open() as f:
|
|
@@ -9,7 +9,6 @@ from pathlib import Path
|
|
|
9
9
|
import numpy as np
|
|
10
10
|
import pygama.pargen.energy_optimisation as om # noqa: F401
|
|
11
11
|
import sklearn.gaussian_process.kernels as ker
|
|
12
|
-
from dbetto import TextDB
|
|
13
12
|
from dbetto.catalog import Props
|
|
14
13
|
from dspeed.units import unit_registry as ureg
|
|
15
14
|
from lgdo import lh5
|
|
@@ -37,11 +36,21 @@ def par_geds_dsp_eopt() -> None:
|
|
|
37
36
|
argparser.add_argument("--inplots", help="in_plot_path", type=str)
|
|
38
37
|
|
|
39
38
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
40
|
-
argparser.add_argument("--configs", help="configs", type=str, required=True)
|
|
41
39
|
|
|
42
|
-
argparser.add_argument(
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
argparser.add_argument(
|
|
41
|
+
"--processing-chain",
|
|
42
|
+
help="Processing chain config",
|
|
43
|
+
type=str,
|
|
44
|
+
nargs="*",
|
|
45
|
+
required=True,
|
|
46
|
+
)
|
|
47
|
+
argparser.add_argument(
|
|
48
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
49
|
+
)
|
|
50
|
+
argparser.add_argument(
|
|
51
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
52
|
+
)
|
|
53
|
+
|
|
45
54
|
argparser.add_argument(
|
|
46
55
|
"--raw-table-name", help="raw table name", type=str, required=True
|
|
47
56
|
)
|
|
@@ -57,17 +66,12 @@ def par_geds_dsp_eopt() -> None:
|
|
|
57
66
|
)
|
|
58
67
|
args = argparser.parse_args()
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
log = build_log(config_dict, args.log)
|
|
69
|
+
dsp_config = Props.read_from(args.processing_chain)
|
|
70
|
+
log = build_log(args.log_config, args.log)
|
|
64
71
|
|
|
65
72
|
t0 = time.time()
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
opt_json = config_dict["inputs"]["optimiser_config"][args.channel]
|
|
69
|
-
|
|
70
|
-
opt_dict = Props.read_from(opt_json)
|
|
74
|
+
opt_dict = Props.read_from(args.config_file)
|
|
71
75
|
db_dict = Props.read_from(args.decay_const)
|
|
72
76
|
|
|
73
77
|
if opt_dict.pop("run_eopt") is True:
|
|
@@ -121,9 +125,6 @@ def par_geds_dsp_eopt() -> None:
|
|
|
121
125
|
msg = f"Data Loaded in {(t1 - t0) / 60} minutes"
|
|
122
126
|
log.info(msg)
|
|
123
127
|
|
|
124
|
-
if isinstance(dsp_config, str | list):
|
|
125
|
-
dsp_config = Props.read_from(dsp_config)
|
|
126
|
-
|
|
127
128
|
dsp_config["outputs"] = ["tp_99", "tp_0_est", "dt_eff"]
|
|
128
129
|
|
|
129
130
|
init_data = run_one_dsp(tb_data, dsp_config, db_dict=db_dict, verbosity=0)
|
|
@@ -11,7 +11,6 @@ import lgdo
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
import pygama.math.histogram as pgh
|
|
13
13
|
import pygama.pargen.energy_cal as pgc
|
|
14
|
-
from dbetto import TextDB
|
|
15
14
|
from dbetto.catalog import Props
|
|
16
15
|
from lgdo import lh5
|
|
17
16
|
from pygama.pargen.data_cleaning import generate_cuts, get_keys
|
|
@@ -83,7 +82,7 @@ def get_out_data(
|
|
|
83
82
|
|
|
84
83
|
def par_geds_dsp_evtsel() -> None:
|
|
85
84
|
argparser = argparse.ArgumentParser()
|
|
86
|
-
argparser.add_argument("--raw-filelist", help="raw_filelist", type=str)
|
|
85
|
+
argparser.add_argument("--raw-filelist", help="raw_filelist", type=str, nargs="*")
|
|
87
86
|
argparser.add_argument(
|
|
88
87
|
"--pulser-file", help="pulser-file", type=str, required=False
|
|
89
88
|
)
|
|
@@ -97,15 +96,25 @@ def par_geds_dsp_evtsel() -> None:
|
|
|
97
96
|
help="raw calibration curve file(s)",
|
|
98
97
|
type=str,
|
|
99
98
|
nargs="*",
|
|
100
|
-
required=
|
|
99
|
+
required=False,
|
|
101
100
|
)
|
|
102
101
|
|
|
103
102
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
104
|
-
argparser.add_argument("--configs", help="configs", type=str, required=True)
|
|
105
103
|
|
|
106
|
-
argparser.add_argument(
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
argparser.add_argument(
|
|
105
|
+
"--processing-chain",
|
|
106
|
+
help="Processing chain config",
|
|
107
|
+
type=str,
|
|
108
|
+
nargs="*",
|
|
109
|
+
required=True,
|
|
110
|
+
)
|
|
111
|
+
argparser.add_argument(
|
|
112
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
113
|
+
)
|
|
114
|
+
argparser.add_argument(
|
|
115
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
116
|
+
)
|
|
117
|
+
|
|
109
118
|
argparser.add_argument(
|
|
110
119
|
"--raw-table-name", help="raw table name", type=str, required=True
|
|
111
120
|
)
|
|
@@ -113,18 +122,14 @@ def par_geds_dsp_evtsel() -> None:
|
|
|
113
122
|
argparser.add_argument("--peak-file", help="peak_file", type=str, required=True)
|
|
114
123
|
args = argparser.parse_args()
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
config_dict = configs["snakemake_rules"]["pars_dsp_peak_selection"]
|
|
118
|
-
|
|
119
|
-
log = build_log(config_dict, args.log)
|
|
125
|
+
log = build_log(args.log_config, args.log)
|
|
120
126
|
|
|
121
127
|
sto = lh5.LH5Store()
|
|
122
128
|
t0 = time.time()
|
|
123
129
|
|
|
124
|
-
dsp_config =
|
|
125
|
-
peak_json = config_dict["inputs"]["peak_config"][args.channel]
|
|
130
|
+
dsp_config = Props.read_from(args.processing_chain)
|
|
126
131
|
|
|
127
|
-
peak_dict = Props.read_from(
|
|
132
|
+
peak_dict = Props.read_from(args.config_file)
|
|
128
133
|
db_dict = Props.read_from(args.decay_const)
|
|
129
134
|
|
|
130
135
|
Path(args.peak_file).parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -134,13 +139,17 @@ def par_geds_dsp_evtsel() -> None:
|
|
|
134
139
|
if peak_dict.pop("run_selection") is True:
|
|
135
140
|
log.debug("Starting peak selection")
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
if (
|
|
143
|
+
isinstance(args.raw_filelist, list)
|
|
144
|
+
and args.raw_filelist[0].split(".")[-1] == "filelist"
|
|
145
|
+
):
|
|
146
|
+
files = args.raw_filelist[0]
|
|
147
|
+
with Path(files).open() as f:
|
|
148
|
+
files = f.read().splitlines()
|
|
149
|
+
else:
|
|
150
|
+
files = args.raw_filelist
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
"operations"
|
|
143
|
-
]
|
|
152
|
+
raw_files = sorted(files)
|
|
144
153
|
|
|
145
154
|
peaks_kev = peak_dict["peaks"]
|
|
146
155
|
kev_widths = peak_dict["kev_widths"]
|
|
@@ -181,6 +190,34 @@ def par_geds_dsp_evtsel() -> None:
|
|
|
181
190
|
False,
|
|
182
191
|
)
|
|
183
192
|
|
|
193
|
+
if args.raw_cal_curve:
|
|
194
|
+
raw_dict = Props.read_from(args.raw_cal_curve)[args.channel]["pars"][
|
|
195
|
+
"operations"
|
|
196
|
+
]
|
|
197
|
+
else:
|
|
198
|
+
E_uncal = tb.daqenergy.nda
|
|
199
|
+
E_uncal = E_uncal[E_uncal > 200]
|
|
200
|
+
guess_keV = 2620 / np.nanpercentile(E_uncal, 99) # usual simple guess
|
|
201
|
+
|
|
202
|
+
# daqenergy is an int so use integer binning (dx used to be bugged as output so switched to nbins)
|
|
203
|
+
|
|
204
|
+
hpge_cal = pgc.HPGeCalibration(
|
|
205
|
+
"daqenergy",
|
|
206
|
+
peaks_kev,
|
|
207
|
+
guess_keV,
|
|
208
|
+
0,
|
|
209
|
+
uncal_is_int=True,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
hpge_cal.hpge_find_energy_peaks(E_uncal, etol_kev=5)
|
|
213
|
+
roughpars = hpge_cal.pars
|
|
214
|
+
raw_dict = {
|
|
215
|
+
"daqenergy_cal": {
|
|
216
|
+
"expression": "daqenergy*a",
|
|
217
|
+
"parameters": {"a": round(float(roughpars[1]), 5)},
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
184
221
|
for outname, info in raw_dict.items():
|
|
185
222
|
outcol = tb.eval(info["expression"], info.get("parameters", None))
|
|
186
223
|
tb.add_column(outname, outcol)
|
|
@@ -7,7 +7,6 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
import pygama.pargen.noise_optimization as pno
|
|
10
|
-
from dbetto import TextDB
|
|
11
10
|
from dbetto.catalog import Props
|
|
12
11
|
from lgdo import lh5
|
|
13
12
|
from pygama.pargen.data_cleaning import generate_cuts, get_cut_indexes
|
|
@@ -22,12 +21,22 @@ def par_geds_dsp_nopt() -> None:
|
|
|
22
21
|
argparser.add_argument("--database", help="database", type=str, required=True)
|
|
23
22
|
argparser.add_argument("--inplots", help="inplots", type=str)
|
|
24
23
|
|
|
25
|
-
argparser.add_argument("--configs", help="configs", type=str, required=True)
|
|
26
24
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
27
25
|
|
|
28
|
-
argparser.add_argument(
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
argparser.add_argument(
|
|
27
|
+
"--processing-chain",
|
|
28
|
+
help="Processing chain config",
|
|
29
|
+
type=str,
|
|
30
|
+
nargs="*",
|
|
31
|
+
required=True,
|
|
32
|
+
)
|
|
33
|
+
argparser.add_argument(
|
|
34
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
35
|
+
)
|
|
36
|
+
argparser.add_argument(
|
|
37
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
38
|
+
)
|
|
39
|
+
|
|
31
40
|
argparser.add_argument(
|
|
32
41
|
"--raw-table-name", help="raw table name", type=str, required=True
|
|
33
42
|
)
|
|
@@ -37,18 +46,13 @@ def par_geds_dsp_nopt() -> None:
|
|
|
37
46
|
|
|
38
47
|
args = argparser.parse_args()
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
log = build_log(config_dict, args.log)
|
|
49
|
+
dsp_config = Props.read_from(args.processing_chain)
|
|
50
|
+
log = build_log(args.log_config, args.log)
|
|
44
51
|
|
|
45
52
|
t0 = time.time()
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
opt_dict = Props.read_from(opt_json)
|
|
51
|
-
db_dict = Props.read_from(args.database)
|
|
54
|
+
opt_dict = Props.read_from(args.config_file)
|
|
55
|
+
db_dict = Props.read_from(args.decay_const)
|
|
52
56
|
|
|
53
57
|
if opt_dict.pop("run_nopt") is True:
|
|
54
58
|
with Path(args.raw_filelist).open() as f:
|
|
@@ -81,9 +85,6 @@ def par_geds_dsp_nopt() -> None:
|
|
|
81
85
|
msg = f"... {len(tb_data)} baselines after cuts"
|
|
82
86
|
log.info(msg)
|
|
83
87
|
|
|
84
|
-
if isinstance(dsp_config, str | list):
|
|
85
|
-
dsp_config = Props.read_from(dsp_config)
|
|
86
|
-
|
|
87
88
|
if args.plot_path:
|
|
88
89
|
out_dict, plot_dict = pno.noise_optimization(
|
|
89
90
|
tb_data,
|
|
@@ -6,7 +6,6 @@ import pickle as pkl
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
|
-
from dbetto import TextDB
|
|
10
9
|
from dbetto.catalog import Props
|
|
11
10
|
from lgdo import lh5
|
|
12
11
|
from pygama.pargen.data_cleaning import get_cut_indexes
|
|
@@ -28,9 +27,20 @@ def par_geds_dsp_pz() -> None:
|
|
|
28
27
|
"-p", "--no-pulse", help="no pulser present", action="store_true"
|
|
29
28
|
)
|
|
30
29
|
|
|
31
|
-
argparser.add_argument(
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
argparser.add_argument(
|
|
31
|
+
"--processing-chain",
|
|
32
|
+
help="Processing chain config",
|
|
33
|
+
type=str,
|
|
34
|
+
nargs="*",
|
|
35
|
+
required=True,
|
|
36
|
+
)
|
|
37
|
+
argparser.add_argument(
|
|
38
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
39
|
+
)
|
|
40
|
+
argparser.add_argument(
|
|
41
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
42
|
+
)
|
|
43
|
+
|
|
34
44
|
argparser.add_argument(
|
|
35
45
|
"--raw-table-name", help="raw table name", type=str, required=True
|
|
36
46
|
)
|
|
@@ -46,19 +56,13 @@ def par_geds_dsp_pz() -> None:
|
|
|
46
56
|
argparser.add_argument("--pz-files", help="input files", nargs="*", type=str)
|
|
47
57
|
args = argparser.parse_args()
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
log = build_log(config_dict, args.log)
|
|
53
|
-
|
|
54
|
-
channel_dict = config_dict["inputs"]["processing_chain"][args.channel]
|
|
55
|
-
kwarg_dict = config_dict["inputs"]["tau_config"][args.channel]
|
|
56
|
-
|
|
57
|
-
kwarg_dict = Props.read_from(kwarg_dict)
|
|
59
|
+
log = build_log(args.log_config, args.log)
|
|
60
|
+
kwarg_dict = Props.read_from(args.config_file)
|
|
58
61
|
|
|
59
62
|
if kwarg_dict["run_tau"] is True:
|
|
60
|
-
dsp_config = Props.read_from(
|
|
63
|
+
dsp_config = Props.read_from(args.processing_chain)
|
|
61
64
|
kwarg_dict.pop("run_tau")
|
|
65
|
+
input_file = []
|
|
62
66
|
if args.pz_files is not None and len(args.pz_files) > 0:
|
|
63
67
|
if (
|
|
64
68
|
isinstance(args.pz_files, list)
|
|
@@ -156,7 +160,7 @@ def par_geds_dsp_pz() -> None:
|
|
|
156
160
|
tau.get_single_decay_constant(
|
|
157
161
|
tb_data, kwarg_dict.get("slope_param", "tail_slope")
|
|
158
162
|
)
|
|
159
|
-
msg = f"Found tau: {tau.output_dict['pz']['
|
|
163
|
+
msg = f"Found tau: {tau.output_dict['pz']['tau1']}+- {tau.output_dict['pz']['tau1_err']}"
|
|
160
164
|
log.debug(msg)
|
|
161
165
|
elif kwarg_dict["mode"] == "double":
|
|
162
166
|
tau.get_dpz_decay_constants(
|
|
@@ -4,7 +4,6 @@ import argparse
|
|
|
4
4
|
import pickle as pkl
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
-
from dbetto import TextDB
|
|
8
7
|
from dbetto.catalog import Props
|
|
9
8
|
from lgdo import lh5
|
|
10
9
|
from sklearn.svm import SVC
|
|
@@ -15,10 +14,10 @@ from ....utils import build_log
|
|
|
15
14
|
def par_geds_dsp_svm_build() -> None:
|
|
16
15
|
argparser = argparse.ArgumentParser()
|
|
17
16
|
argparser.add_argument("--log", help="log file", type=str)
|
|
18
|
-
argparser.add_argument("--configs", help="config file", type=str)
|
|
19
17
|
|
|
20
|
-
argparser.add_argument(
|
|
21
|
-
|
|
18
|
+
argparser.add_argument(
|
|
19
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
20
|
+
)
|
|
22
21
|
|
|
23
22
|
argparser.add_argument(
|
|
24
23
|
"--output-file", help="output SVM file", type=str, required=True
|
|
@@ -31,10 +30,7 @@ def par_geds_dsp_svm_build() -> None:
|
|
|
31
30
|
)
|
|
32
31
|
args = argparser.parse_args()
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
config_dict = configs["snakemake_rules"]["pars_dsp_build_svm"]
|
|
36
|
-
|
|
37
|
-
log = build_log(config_dict, args.log)
|
|
33
|
+
log = build_log(args.log_config, args.log)
|
|
38
34
|
|
|
39
35
|
if args.train_data is not None and len(args.train_data) > 0:
|
|
40
36
|
# Load files
|
|
@@ -10,7 +10,6 @@ import warnings
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
|
-
from dbetto import TextDB
|
|
14
13
|
from dbetto.catalog import Props
|
|
15
14
|
from pygama.pargen.AoE_cal import * # noqa: F403
|
|
16
15
|
from pygama.pargen.AoE_cal import CalAoE
|
|
@@ -195,12 +194,23 @@ def par_geds_hit_aoe() -> None:
|
|
|
195
194
|
argparser.add_argument("--eres-file", help="eres_file", type=str, required=True)
|
|
196
195
|
argparser.add_argument("--inplots", help="in_plot_path", type=str, required=False)
|
|
197
196
|
|
|
198
|
-
argparser.add_argument(
|
|
197
|
+
argparser.add_argument(
|
|
198
|
+
"--timestamp",
|
|
199
|
+
help="timestamp",
|
|
200
|
+
type=str,
|
|
201
|
+
required=False,
|
|
202
|
+
default="20000101T000000Z",
|
|
203
|
+
)
|
|
204
|
+
|
|
199
205
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
206
|
+
argparser.add_argument(
|
|
207
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
argparser.add_argument(
|
|
211
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
212
|
+
)
|
|
200
213
|
|
|
201
|
-
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
|
|
202
|
-
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
|
|
203
|
-
argparser.add_argument("--channel", help="Channel", type=str, required=True)
|
|
204
214
|
argparser.add_argument("--table-name", help="table name", type=str, required=True)
|
|
205
215
|
|
|
206
216
|
argparser.add_argument("--plot-file", help="plot_file", type=str, required=False)
|
|
@@ -210,13 +220,8 @@ def par_geds_hit_aoe() -> None:
|
|
|
210
220
|
argparser.add_argument("-d", "--debug", help="debug_mode", action="store_true")
|
|
211
221
|
args = argparser.parse_args()
|
|
212
222
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
build_log(config_dict, args.log)
|
|
217
|
-
|
|
218
|
-
channel_dict = config_dict["inputs"]["aoecal_config"][args.channel]
|
|
219
|
-
kwarg_dict = Props.read_from(channel_dict)
|
|
223
|
+
log = build_log(args.log_config, args.log)
|
|
224
|
+
kwarg_dict = Props.read_from(args.config_file)
|
|
220
225
|
|
|
221
226
|
ecal_dict = Props.read_from(args.ecal_file)
|
|
222
227
|
cal_dict = ecal_dict["pars"]
|
|
@@ -298,19 +303,10 @@ def par_geds_hit_aoe() -> None:
|
|
|
298
303
|
aoe = None
|
|
299
304
|
plot_dict = out_plot_dict
|
|
300
305
|
results_dict = {}
|
|
301
|
-
|
|
302
306
|
if args.plot_file:
|
|
303
|
-
common_dict = plot_dict.pop("common") if "common" in list(plot_dict) else None
|
|
304
|
-
out_plot_dict.update({"aoe": plot_dict})
|
|
305
|
-
|
|
306
|
-
if "common" in list(out_plot_dict) and common_dict is not None:
|
|
307
|
-
out_plot_dict["common"].update(common_dict)
|
|
308
|
-
elif common_dict is not None:
|
|
309
|
-
out_plot_dict["common"] = common_dict
|
|
310
|
-
|
|
311
307
|
Path(args.plot_file).parent.mkdir(parents=True, exist_ok=True)
|
|
312
308
|
with Path(args.plot_file).open("wb") as w:
|
|
313
|
-
pkl.dump(
|
|
309
|
+
pkl.dump(plot_dict, w, protocol=pkl.HIGHEST_PROTOCOL)
|
|
314
310
|
|
|
315
311
|
Path(args.hit_pars).parent.mkdir(parents=True, exist_ok=True)
|
|
316
312
|
final_hit_dict = {
|
|
@@ -12,9 +12,7 @@ import matplotlib.pyplot as plt
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pygama.math.distributions as pgf
|
|
14
14
|
import pygama.math.histogram as pgh
|
|
15
|
-
from dbetto import TextDB
|
|
16
15
|
from dbetto.catalog import Props
|
|
17
|
-
from legendmeta import LegendMetadata
|
|
18
16
|
from lgdo import lh5
|
|
19
17
|
from matplotlib.colors import LogNorm
|
|
20
18
|
from pygama.math.distributions import nb_poly
|
|
@@ -460,16 +458,21 @@ def par_geds_hit_ecal() -> None:
|
|
|
460
458
|
argparser.add_argument("--in-hit-dict", help="in_hit_dict", required=False)
|
|
461
459
|
argparser.add_argument("--inplot-dict", help="inplot_dict", required=False)
|
|
462
460
|
|
|
463
|
-
argparser.add_argument("--
|
|
464
|
-
argparser.add_argument(
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
argparser.add_argument("--log", help="log_file", type=str)
|
|
462
|
+
argparser.add_argument(
|
|
463
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
464
|
+
)
|
|
467
465
|
|
|
468
|
-
argparser.add_argument(
|
|
469
|
-
|
|
470
|
-
|
|
466
|
+
argparser.add_argument(
|
|
467
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
468
|
+
)
|
|
471
469
|
|
|
472
|
-
argparser.add_argument(
|
|
470
|
+
argparser.add_argument(
|
|
471
|
+
"--det-status", help="detector status", type=str, default="on", required=False
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
argparser.add_argument("--table-name", help="table name", type=str, required=True)
|
|
475
|
+
argparser.add_argument("--channel", help="channel", type=str)
|
|
473
476
|
|
|
474
477
|
argparser.add_argument("--plot-path", help="plot_path", type=str, required=False)
|
|
475
478
|
argparser.add_argument("--save-path", help="save_path", type=str)
|
|
@@ -478,22 +481,7 @@ def par_geds_hit_ecal() -> None:
|
|
|
478
481
|
argparser.add_argument("-d", "--debug", help="debug_mode", action="store_true")
|
|
479
482
|
args = argparser.parse_args()
|
|
480
483
|
|
|
481
|
-
|
|
482
|
-
config_dict = configs["snakemake_rules"]
|
|
483
|
-
if args.tier == "hit":
|
|
484
|
-
config_dict = config_dict["pars_hit_ecal"]
|
|
485
|
-
elif args.tier == "pht":
|
|
486
|
-
config_dict = config_dict["pars_pht_ecal"]
|
|
487
|
-
else:
|
|
488
|
-
msg = "invalid tier"
|
|
489
|
-
raise ValueError(msg)
|
|
490
|
-
|
|
491
|
-
log = build_log(config_dict, args.log)
|
|
492
|
-
|
|
493
|
-
chmap = LegendMetadata(args.metadata).channelmap(
|
|
494
|
-
args.timestamp, system=args.datatype
|
|
495
|
-
)
|
|
496
|
-
det_status = chmap[args.channel]["analysis"]["usability"]
|
|
484
|
+
log = build_log(args.log_config, args.log)
|
|
497
485
|
|
|
498
486
|
if args.in_hit_dict:
|
|
499
487
|
hit_dict = Props.read_from(args.in_hit_dict)
|
|
@@ -508,10 +496,12 @@ def par_geds_hit_ecal() -> None:
|
|
|
508
496
|
|
|
509
497
|
database_dic = Props.read_from(db_files)
|
|
510
498
|
|
|
511
|
-
|
|
499
|
+
if args.channel and args.channel in database_dic:
|
|
500
|
+
database_dic = database_dic[args.channel]
|
|
512
501
|
|
|
513
|
-
|
|
514
|
-
|
|
502
|
+
hit_dict.update(database_dic["ctc_params"])
|
|
503
|
+
|
|
504
|
+
kwarg_dict = Props.read_from(args.config_file)
|
|
515
505
|
|
|
516
506
|
# convert plot functions from strings to functions and split off baseline and common plots
|
|
517
507
|
for field, item in kwarg_dict["plot_options"].items():
|
|
@@ -605,7 +595,7 @@ def par_geds_hit_ecal() -> None:
|
|
|
605
595
|
debug_mode=kwarg_dict.get("debug_mode", False) | args.debug,
|
|
606
596
|
)
|
|
607
597
|
full_object_dict[cal_energy_param].hpge_get_energy_peaks(
|
|
608
|
-
e_uncal, etol_kev=5 if det_status == "on" else 20
|
|
598
|
+
e_uncal, etol_kev=5 if args.det_status == "on" else 20
|
|
609
599
|
)
|
|
610
600
|
if 2614.511 not in full_object_dict[cal_energy_param].peaks_kev:
|
|
611
601
|
full_object_dict[cal_energy_param] = HPGeCalibration(
|
|
@@ -616,10 +606,10 @@ def par_geds_hit_ecal() -> None:
|
|
|
616
606
|
debug_mode=kwarg_dict.get("debug_mode", False),
|
|
617
607
|
)
|
|
618
608
|
full_object_dict[cal_energy_param].hpge_get_energy_peaks(
|
|
619
|
-
e_uncal, etol_kev=5 if det_status == "on" else 30, n_sigma=2
|
|
609
|
+
e_uncal, etol_kev=5 if args.det_status == "on" else 30, n_sigma=2
|
|
620
610
|
)
|
|
621
611
|
got_peaks_kev = full_object_dict[cal_energy_param].peaks_kev.copy()
|
|
622
|
-
if det_status != "on":
|
|
612
|
+
if args.det_status != "on":
|
|
623
613
|
full_object_dict[cal_energy_param].hpge_cal_energy_peak_tops(
|
|
624
614
|
e_uncal,
|
|
625
615
|
peaks_kev=got_peaks_kev,
|
|
@@ -633,7 +623,7 @@ def par_geds_hit_ecal() -> None:
|
|
|
633
623
|
tail_weight=kwarg_dict.get("tail_weight", 0),
|
|
634
624
|
n_events=kwarg_dict.get("n_events", None),
|
|
635
625
|
allowed_p_val=kwarg_dict.get("p_val", 0),
|
|
636
|
-
update_cal_pars=bool(det_status == "on"),
|
|
626
|
+
update_cal_pars=bool(args.det_status == "on"),
|
|
637
627
|
bin_width_kev=0.5,
|
|
638
628
|
)
|
|
639
629
|
full_object_dict[cal_energy_param].hpge_fit_energy_peaks(
|
|
@@ -680,31 +670,6 @@ def par_geds_hit_ecal() -> None:
|
|
|
680
670
|
hit_dict.update(
|
|
681
671
|
{cal_energy_param: full_object_dict[cal_energy_param].gen_pars_dict()}
|
|
682
672
|
)
|
|
683
|
-
if "copy_calibration" in kwarg_dict:
|
|
684
|
-
for copy_cal_param, _copy_to_cal_param in kwarg_dict[
|
|
685
|
-
"copy_calibration"
|
|
686
|
-
].items():
|
|
687
|
-
if copy_cal_param not in full_object_dict:
|
|
688
|
-
msg = f"copy_calibration parameter {copy_cal_param} not found in full_object_dict"
|
|
689
|
-
raise ValueError(msg)
|
|
690
|
-
if isinstance(_copy_to_cal_param, str):
|
|
691
|
-
copy_to_cal_param = [_copy_to_cal_param]
|
|
692
|
-
else:
|
|
693
|
-
copy_to_cal_param = _copy_to_cal_param
|
|
694
|
-
for cal_par in copy_to_cal_param:
|
|
695
|
-
if cal_par in full_object_dict:
|
|
696
|
-
msg = f"copy_calibration parameter {cal_par} already exists in full_object_dict"
|
|
697
|
-
raise ValueError(msg)
|
|
698
|
-
copy_dict = {cal_par: full_object_dict[cal_par].gen_pars_dict()}
|
|
699
|
-
copy_dict["expression"] = copy_dict[cal_par]["expression"].replace(
|
|
700
|
-
copy_cal_param, cal_par
|
|
701
|
-
)
|
|
702
|
-
hit_dict.update({cal_par: copy_dict[cal_par]})
|
|
703
|
-
if "extra_blocks" in kwarg_dict:
|
|
704
|
-
if isinstance(kwarg_dict["extra_blocks"], dict):
|
|
705
|
-
kwarg_dict["extra_blocks"] = [kwarg_dict["extra_blocks"]]
|
|
706
|
-
for extra_block in kwarg_dict["extra_blocks"]:
|
|
707
|
-
hit_dict.update(extra_block)
|
|
708
673
|
|
|
709
674
|
if args.plot_path:
|
|
710
675
|
param_plot_dict = {}
|
|
@@ -753,7 +718,7 @@ def par_geds_hit_ecal() -> None:
|
|
|
753
718
|
peak_dict["parameters"] = peak_dict["parameters"].to_dict()
|
|
754
719
|
peak_dict["uncertainties"] = peak_dict["uncertainties"].to_dict()
|
|
755
720
|
|
|
756
|
-
if det_status != "on":
|
|
721
|
+
if args.det_status != "on":
|
|
757
722
|
for peak_dict in (
|
|
758
723
|
full_object_dict[cal_energy_param]
|
|
759
724
|
.results["hpge_cal_energy_peak_tops"]["peak_parameters"]
|
|
@@ -763,6 +728,29 @@ def par_geds_hit_ecal() -> None:
|
|
|
763
728
|
peak_dict["parameters"] = peak_dict["parameters"].to_dict()
|
|
764
729
|
peak_dict["uncertainties"] = peak_dict["uncertainties"].to_dict()
|
|
765
730
|
|
|
731
|
+
if "copy_calibration" in kwarg_dict:
|
|
732
|
+
for cal_par, copy_dict in kwarg_dict["copy_calibration"].items():
|
|
733
|
+
copy_cal_param = copy_dict["copy_param"]
|
|
734
|
+
new_input_param = copy_dict["new_input_param"]
|
|
735
|
+
old_input_param = copy_dict["old_input_param"]
|
|
736
|
+
if copy_cal_param not in full_object_dict:
|
|
737
|
+
msg = f"copy_calibration parameter {copy_cal_param} not found in full_object_dict"
|
|
738
|
+
raise ValueError(msg)
|
|
739
|
+
if cal_par in full_object_dict:
|
|
740
|
+
msg = f"copy_calibration parameter {cal_par} already exists in full_object_dict"
|
|
741
|
+
raise ValueError(msg)
|
|
742
|
+
new_dict = {cal_par: copy.deepcopy(hit_dict[copy_cal_param])}
|
|
743
|
+
new_dict[cal_par]["expression"] = new_dict[cal_par]["expression"].replace(
|
|
744
|
+
old_input_param, new_input_param
|
|
745
|
+
)
|
|
746
|
+
hit_dict.update({cal_par: new_dict[cal_par]})
|
|
747
|
+
|
|
748
|
+
if "extra_blocks" in kwarg_dict:
|
|
749
|
+
if isinstance(kwarg_dict["extra_blocks"], dict):
|
|
750
|
+
kwarg_dict["extra_blocks"] = [kwarg_dict["extra_blocks"]]
|
|
751
|
+
for extra_block in kwarg_dict["extra_blocks"]:
|
|
752
|
+
hit_dict.update(extra_block)
|
|
753
|
+
|
|
766
754
|
if "monitoring_parameters" in kwarg_dict:
|
|
767
755
|
monitor_dict = monitor_parameters(
|
|
768
756
|
files, args.table_name, kwarg_dict["monitoring_parameters"]
|
|
@@ -10,7 +10,6 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
import pandas as pd
|
|
13
|
-
from dbetto import TextDB
|
|
14
13
|
from dbetto.catalog import Props
|
|
15
14
|
from pygama.math.distributions import gaussian
|
|
16
15
|
from pygama.pargen.AoE_cal import * # noqa: F403
|
|
@@ -222,13 +221,23 @@ def par_geds_hit_lq() -> None:
|
|
|
222
221
|
argparser.add_argument("--eres-file", help="eres_file", type=str, required=True)
|
|
223
222
|
argparser.add_argument("--inplots", help="in_plot_path", type=str, required=False)
|
|
224
223
|
|
|
225
|
-
argparser.add_argument("--configs", help="configs", type=str, required=True)
|
|
226
224
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
225
|
+
argparser.add_argument(
|
|
226
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
argparser.add_argument(
|
|
230
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
231
|
+
)
|
|
227
232
|
|
|
228
|
-
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
|
|
229
|
-
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
|
|
230
|
-
argparser.add_argument("--channel", help="Channel", type=str, required=True)
|
|
231
233
|
argparser.add_argument("--table-name", help="table name", type=str, required=True)
|
|
234
|
+
argparser.add_argument(
|
|
235
|
+
"--timestamp",
|
|
236
|
+
help="timestamp",
|
|
237
|
+
type=str,
|
|
238
|
+
required=False,
|
|
239
|
+
default="20000101T000000Z",
|
|
240
|
+
)
|
|
232
241
|
|
|
233
242
|
argparser.add_argument("--plot-file", help="plot_file", type=str, required=False)
|
|
234
243
|
argparser.add_argument("--hit-pars", help="hit_pars", type=str)
|
|
@@ -237,13 +246,8 @@ def par_geds_hit_lq() -> None:
|
|
|
237
246
|
argparser.add_argument("-d", "--debug", help="debug_mode", action="store_true")
|
|
238
247
|
args = argparser.parse_args()
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
build_log(config_dict, args.log)
|
|
244
|
-
|
|
245
|
-
channel_dict = config_dict["inputs"]["lqcal_config"][args.channel]
|
|
246
|
-
kwarg_dict = Props.read_from(channel_dict)
|
|
249
|
+
build_log(args.log_config, args.log)
|
|
250
|
+
kwarg_dict = Props.read_from(args.config_file)
|
|
247
251
|
|
|
248
252
|
ecal_dict = Props.read_from(args.ecal_file)
|
|
249
253
|
cal_dict = ecal_dict["pars"]["operations"]
|
|
@@ -295,7 +299,7 @@ def par_geds_hit_lq() -> None:
|
|
|
295
299
|
|
|
296
300
|
data["run_timestamp"] = args.timestamp
|
|
297
301
|
|
|
298
|
-
out_dicts, results_dicts,
|
|
302
|
+
out_dicts, results_dicts, lq_dict, plot_dicts = run_lq_calibration(
|
|
299
303
|
data,
|
|
300
304
|
cal_dicts={args.timestamp: cal_dict},
|
|
301
305
|
results_dicts={args.timestamp: eres_dict},
|
|
@@ -10,7 +10,6 @@ import warnings
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
|
-
from dbetto import TextDB
|
|
14
13
|
from dbetto.catalog import Props
|
|
15
14
|
from lgdo.lh5 import ls
|
|
16
15
|
from pygama.pargen.data_cleaning import (
|
|
@@ -305,28 +304,27 @@ def par_geds_hit_qc() -> None:
|
|
|
305
304
|
required=False,
|
|
306
305
|
nargs="*",
|
|
307
306
|
)
|
|
307
|
+
argparser.add_argument("--channel", help="channel", type=str)
|
|
308
308
|
|
|
309
|
-
argparser.add_argument("--configs", help="config", type=str, required=True)
|
|
310
309
|
argparser.add_argument("--log", help="log_file", type=str)
|
|
310
|
+
argparser.add_argument(
|
|
311
|
+
"--log-config", help="Log config file", type=str, required=False, default={}
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
argparser.add_argument(
|
|
315
|
+
"--config-file", help="Config file", type=str, nargs="*", required=True
|
|
316
|
+
)
|
|
311
317
|
|
|
312
|
-
argparser.add_argument("--datatype", help="Datatype", type=str, required=True)
|
|
313
|
-
argparser.add_argument("--timestamp", help="Timestamp", type=str, required=True)
|
|
314
|
-
argparser.add_argument("--channel", help="Channel", type=str, required=True)
|
|
315
318
|
argparser.add_argument("--table-name", help="table name", type=str, required=True)
|
|
316
|
-
argparser.add_argument("--tier", help="tier", type=str, default="hit")
|
|
317
319
|
|
|
318
320
|
argparser.add_argument("--plot-path", help="plot_path", type=str, required=False)
|
|
319
321
|
argparser.add_argument("--save-path", help="save_path", type=str)
|
|
320
322
|
args = argparser.parse_args()
|
|
321
323
|
|
|
322
|
-
|
|
323
|
-
config_dict = configs["snakemake_rules"]["pars_hit_qc"]
|
|
324
|
-
|
|
325
|
-
build_log(config_dict, args.log)
|
|
324
|
+
build_log(args.log_config, args.log)
|
|
326
325
|
|
|
327
326
|
# get metadata dictionary
|
|
328
|
-
|
|
329
|
-
kwarg_dict = Props.read_from(channel_dict)
|
|
327
|
+
kwarg_dict = Props.read_from(args.config_file)
|
|
330
328
|
|
|
331
329
|
if args.overwrite_files:
|
|
332
330
|
overwrite = Props.read_from(args.overwrite_files)
|
|
@@ -347,7 +345,7 @@ def par_geds_hit_qc() -> None:
|
|
|
347
345
|
with Path(args.cal_files[0]).open() as f:
|
|
348
346
|
cal_files = f.read().splitlines()
|
|
349
347
|
else:
|
|
350
|
-
cal_files = args.
|
|
348
|
+
cal_files = args.cal_files
|
|
351
349
|
|
|
352
350
|
start = time.time()
|
|
353
351
|
log.info("starting qc")
|
|
@@ -39,6 +39,8 @@ def build_log(
|
|
|
39
39
|
log_file
|
|
40
40
|
The path to the log file.
|
|
41
41
|
"""
|
|
42
|
+
if isinstance(config_dict, str):
|
|
43
|
+
config_dict = {"options": {"logging": config_dict}}
|
|
42
44
|
if "logging" in config_dict["options"]:
|
|
43
45
|
log_config = config_dict["options"]["logging"]
|
|
44
46
|
log_config = Props.read_from(log_config)
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
def fill_plot_dict(plot_class, data, plot_options, plot_dict=None):
|
|
5
5
|
if plot_dict is None:
|
|
6
6
|
plot_dict = {}
|
|
7
|
-
|
|
7
|
+
if plot_options is not None:
|
|
8
8
|
for key, item in plot_options.items():
|
|
9
9
|
if item["options"] is not None:
|
|
10
10
|
plot_dict[key] = item["function"](plot_class, data, **item["options"])
|
|
@@ -49,7 +49,8 @@ def subst_vars(
|
|
|
49
49
|
if use_env:
|
|
50
50
|
combined_var_values = dict(iter(os.environ.items()))
|
|
51
51
|
combined_var_values.update(copy.copy(var_values))
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
return subst_vars_impl(props, combined_var_values, ignore_missing)
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
def subst_vars_in_snakemake_config(workflow, config):
|
|
@@ -65,10 +66,11 @@ def subst_vars_in_snakemake_config(workflow, config):
|
|
|
65
66
|
use_env=True,
|
|
66
67
|
ignore_missing=False,
|
|
67
68
|
)
|
|
68
|
-
if "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if "execenv" in config:
|
|
70
|
+
if "system" in config:
|
|
71
|
+
config["execenv"] = config["execenv"][config["system"]]
|
|
72
|
+
else:
|
|
73
|
+
config["execenv"] = config["execenv"]["bare"]
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
def set_last_rule_name(workflow, new_name):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|