pytesprocess 0.1.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.
- pytesprocess-0.1.1/LICENSE +21 -0
- pytesprocess-0.1.1/PKG-INFO +211 -0
- pytesprocess-0.1.1/README.md +161 -0
- pytesprocess-0.1.1/pyproject.toml +49 -0
- pytesprocess-0.1.1/pytesprocess/__init__.py +9 -0
- pytesprocess-0.1.1/pytesprocess/_version.py +2 -0
- pytesprocess-0.1.1/pytesprocess/cli/__init__.py +1 -0
- pytesprocess-0.1.1/pytesprocess/cli/commands/__init__.py +5 -0
- pytesprocess-0.1.1/pytesprocess/cli/commands/event.py +66 -0
- pytesprocess-0.1.1/pytesprocess/cli/commands/filter.py +17 -0
- pytesprocess-0.1.1/pytesprocess/cli/commands/ivsweep.py +29 -0
- pytesprocess-0.1.1/pytesprocess/cli/common.py +86 -0
- pytesprocess-0.1.1/pytesprocess/cli/main.py +81 -0
- pytesprocess-0.1.1/pytesprocess/config/__init__.py +4 -0
- pytesprocess-0.1.1/pytesprocess/config/loader.py +94 -0
- pytesprocess-0.1.1/pytesprocess/config/manager.py +297 -0
- pytesprocess-0.1.1/pytesprocess/config/resolvers/__init__.py +5 -0
- pytesprocess-0.1.1/pytesprocess/config/resolvers/common.py +56 -0
- pytesprocess-0.1.1/pytesprocess/config/resolvers/feature.py +293 -0
- pytesprocess-0.1.1/pytesprocess/config/resolvers/salting.py +86 -0
- pytesprocess-0.1.1/pytesprocess/config/resolvers/trigger.py +84 -0
- pytesprocess-0.1.1/pytesprocess/config/selectors.py +108 -0
- pytesprocess-0.1.1/pytesprocess/config/validation.py +314 -0
- pytesprocess-0.1.1/pytesprocess/config/warnings.py +2 -0
- pytesprocess-0.1.1/pytesprocess/core/__init__.py +10 -0
- pytesprocess-0.1.1/pytesprocess/core/algorithms.py +1455 -0
- pytesprocess-0.1.1/pytesprocess/core/didv.py +1648 -0
- pytesprocess-0.1.1/pytesprocess/core/eventbuilder.py +495 -0
- pytesprocess-0.1.1/pytesprocess/core/filterbuilder.py +81 -0
- pytesprocess-0.1.1/pytesprocess/core/filterdata.py +1849 -0
- pytesprocess-0.1.1/pytesprocess/core/ivsweep.py +2072 -0
- pytesprocess-0.1.1/pytesprocess/core/noise.py +923 -0
- pytesprocess-0.1.1/pytesprocess/core/noisemodel.py +1408 -0
- pytesprocess-0.1.1/pytesprocess/core/oftrigger.py +1035 -0
- pytesprocess-0.1.1/pytesprocess/core/template.py +450 -0
- pytesprocess-0.1.1/pytesprocess/process/__init__.py +6 -0
- pytesprocess-0.1.1/pytesprocess/process/data_source.py +185 -0
- pytesprocess-0.1.1/pytesprocess/process/event_context.py +35 -0
- pytesprocess-0.1.1/pytesprocess/process/feature_plan.py +186 -0
- pytesprocess-0.1.1/pytesprocess/process/feature_resources.py +267 -0
- pytesprocess-0.1.1/pytesprocess/process/features.py +1024 -0
- pytesprocess-0.1.1/pytesprocess/process/filterprocess.py +1176 -0
- pytesprocess-0.1.1/pytesprocess/process/ivprocess.py +1380 -0
- pytesprocess-0.1.1/pytesprocess/process/processing_data.py +967 -0
- pytesprocess-0.1.1/pytesprocess/process/randoms.py +921 -0
- pytesprocess-0.1.1/pytesprocess/process/triggers.py +1011 -0
- pytesprocess-0.1.1/pytesprocess/salting/__init__.py +7 -0
- pytesprocess-0.1.1/pytesprocess/salting/generator.py +364 -0
- pytesprocess-0.1.1/pytesprocess/salting/injector.py +329 -0
- pytesprocess-0.1.1/pytesprocess/salting/sampling.py +84 -0
- pytesprocess-0.1.1/pytesprocess/utils/__init__.py +5 -0
- pytesprocess-0.1.1/pytesprocess/utils/arg_utils.py +122 -0
- pytesprocess-0.1.1/pytesprocess/utils/dataframe_output.py +120 -0
- pytesprocess-0.1.1/pytesprocess/utils/filter_hdf5.py +594 -0
- pytesprocess-0.1.1/pytesprocess/utils/utils.py +701 -0
- pytesprocess-0.1.1/pytesprocess/workflows/__init__.py +3 -0
- pytesprocess-0.1.1/pytesprocess/workflows/processing.py +317 -0
- pytesprocess-0.1.1/pytesprocess/workflows/salting.py +133 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/PKG-INFO +211 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/SOURCES.txt +65 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/dependency_links.txt +1 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/entry_points.txt +2 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/requires.txt +16 -0
- pytesprocess-0.1.1/pytesprocess.egg-info/top_level.txt +1 -0
- pytesprocess-0.1.1/setup.cfg +4 -0
- pytesprocess-0.1.1/tests/test_cli_steps_v16.py +27 -0
- pytesprocess-0.1.1/tests/test_processing_data_v15.py +78 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Samuel Watkins
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytesprocess
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Detector data processing for pytesdaqx acquisitions
|
|
5
|
+
Author-email: Bruno Serfass <serfass@berkeley.edu>, Samuel Watkins <samwatkins@berkeley.edu>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2022 Samuel Watkins
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/spice-herald/pytesprocess
|
|
29
|
+
Project-URL: Repository, https://github.com/spice-herald/pytesprocess
|
|
30
|
+
Keywords: detector,TES,DAQ,signal processing
|
|
31
|
+
Requires-Python: >=3.11
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Requires-Dist: numpy>=1.26
|
|
35
|
+
Requires-Dist: scipy
|
|
36
|
+
Requires-Dist: matplotlib
|
|
37
|
+
Requires-Dist: PyYAML
|
|
38
|
+
Requires-Dist: qetpy>=1.8.6
|
|
39
|
+
Requires-Dist: pandas
|
|
40
|
+
Requires-Dist: pytesdaqx
|
|
41
|
+
Requires-Dist: humanfriendly
|
|
42
|
+
Requires-Dist: vaex
|
|
43
|
+
Requires-Dist: pyarrow
|
|
44
|
+
Requires-Dist: lmfit
|
|
45
|
+
Requires-Dist: cloudpickle
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: build; extra == "dev"
|
|
48
|
+
Requires-Dist: pytest; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# pytesprocess
|
|
52
|
+
|
|
53
|
+
`pytesprocess` is the detector-processing layer used with raw acquisitions written
|
|
54
|
+
by `pytesdaqx`. It provides random-event selection, software triggering,
|
|
55
|
+
feature extraction, salting, IV/dIdV processing, noise/filter generation, and
|
|
56
|
+
persistence of processed event products as Vaex HDF5 dataframes.
|
|
57
|
+
|
|
58
|
+
The current code targets Python 3.11+ and the modern `pytesdaqx` acquisition
|
|
59
|
+
model (`acquisition` + `stream`).
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
For a development checkout:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Runtime dependencies and the installed CLI entry point are defined entirely in
|
|
70
|
+
`pyproject.toml`.
|
|
71
|
+
|
|
72
|
+
## Command-line interface
|
|
73
|
+
|
|
74
|
+
Installing the package provides:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pytesprocess --help
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The normal event-processing workflow is selected directly from the top-level
|
|
81
|
+
command:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pytesprocess ACQUISITION \
|
|
85
|
+
--config processing.yaml \
|
|
86
|
+
--steps randoms trigger feature
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`--steps` is mandatory. It accepts either whitespace-separated or
|
|
90
|
+
comma-separated values, including mixed input:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
--steps randoms trigger feature
|
|
94
|
+
--steps randoms,trigger,feature
|
|
95
|
+
--steps randoms,trigger feature
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
All are equivalent. The execution order is normalized internally to:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
randoms -> salting -> trigger -> feature
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The separate detector-characterization/filter workflows remain explicit:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pytesprocess filter ACQUISITION --config processing.yaml
|
|
108
|
+
pytesprocess ivsweep ACQUISITION
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pytesprocess acquisition_I2_D20260807_T170432.zarr \
|
|
115
|
+
--config continuous_data_processing_v2.yaml \
|
|
116
|
+
--steps randoms,trigger,feature \
|
|
117
|
+
--nrandoms 300 \
|
|
118
|
+
--nevents 300 \
|
|
119
|
+
--ncores 4
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
See [docs/user/cli.md](docs/user/cli.md) for the current CLI behavior.
|
|
123
|
+
|
|
124
|
+
## Configuration
|
|
125
|
+
|
|
126
|
+
New processing configuration uses `config_version: 2` and separates workflow
|
|
127
|
+
sections explicitly:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
config_version: 2
|
|
131
|
+
|
|
132
|
+
resources:
|
|
133
|
+
filter_file: /path/to/filterdata.hdf5
|
|
134
|
+
|
|
135
|
+
trigger:
|
|
136
|
+
global: {}
|
|
137
|
+
channels: {}
|
|
138
|
+
|
|
139
|
+
feature:
|
|
140
|
+
global:
|
|
141
|
+
trace_length_msec: 20
|
|
142
|
+
pretrigger_length_msec: 10
|
|
143
|
+
presets: {}
|
|
144
|
+
channels: {}
|
|
145
|
+
|
|
146
|
+
salting:
|
|
147
|
+
global: {}
|
|
148
|
+
channels: {}
|
|
149
|
+
|
|
150
|
+
filter: {}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Feature trace lengths are specified in milliseconds in v2 configuration. The
|
|
154
|
+
resolver converts them to samples using the selected acquisition sample rate.
|
|
155
|
+
Channel selectors include `all`, shell-style globs such as `Z1P*`, comma groups
|
|
156
|
+
for applying one block to several independent channels, and explicit
|
|
157
|
+
multi-channel expressions such as `A|B`.
|
|
158
|
+
|
|
159
|
+
See [docs/user/configuration.md](docs/user/configuration.md).
|
|
160
|
+
|
|
161
|
+
## Processed dataframe identity
|
|
162
|
+
|
|
163
|
+
Each Vaex processing product has one dataframe-group identity:
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
dataframe_group_name
|
|
167
|
+
dataframe_group_id
|
|
168
|
+
dataframe_group_number
|
|
169
|
+
dataframe_file_index
|
|
170
|
+
processing_label
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
For example:
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
trigger_I2_D20260908_T123456/
|
|
177
|
+
trigger_I2_D20260908_T123456_F0001.hdf5
|
|
178
|
+
trigger_I2_D20260908_T123456_F0002.hdf5
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`F####` is a processing task/output shard index, not a second stream or series
|
|
182
|
+
identifier. Raw provenance uses canonical stream fields such as `stream_id`,
|
|
183
|
+
`stream_number`, and `stream_trigger_index`.
|
|
184
|
+
|
|
185
|
+
See [docs/user/outputs.md](docs/user/outputs.md).
|
|
186
|
+
|
|
187
|
+
## Package structure
|
|
188
|
+
|
|
189
|
+
The current package layout intentionally separates reusable analysis objects
|
|
190
|
+
from acquisition-processing workflows:
|
|
191
|
+
|
|
192
|
+
```text
|
|
193
|
+
pytesprocess/
|
|
194
|
+
core/ reusable analysis/data objects and algorithms
|
|
195
|
+
process/ raw/dataframe processing executors
|
|
196
|
+
config/ YAML loading, selection, resolution, validation
|
|
197
|
+
salting/ salt metadata generation and waveform injection
|
|
198
|
+
workflows/ multi-step orchestration used by the CLI
|
|
199
|
+
cli/ command-line parsing and dispatch
|
|
200
|
+
utils/ shared utilities and HDF5/dataframe helpers
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
See [docs/developer/architecture.md](docs/developer/architecture.md) for the
|
|
204
|
+
current developer-oriented architecture.
|
|
205
|
+
|
|
206
|
+
## Notes on multiprocessing
|
|
207
|
+
|
|
208
|
+
The existing Vaex/PyArrow and numerical-library thread limits are intentional.
|
|
209
|
+
They were introduced to avoid thread oversubscription and unstable/slower
|
|
210
|
+
multicore processing. They should not be removed or relocated without dedicated
|
|
211
|
+
multicore benchmarking.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# pytesprocess
|
|
2
|
+
|
|
3
|
+
`pytesprocess` is the detector-processing layer used with raw acquisitions written
|
|
4
|
+
by `pytesdaqx`. It provides random-event selection, software triggering,
|
|
5
|
+
feature extraction, salting, IV/dIdV processing, noise/filter generation, and
|
|
6
|
+
persistence of processed event products as Vaex HDF5 dataframes.
|
|
7
|
+
|
|
8
|
+
The current code targets Python 3.11+ and the modern `pytesdaqx` acquisition
|
|
9
|
+
model (`acquisition` + `stream`).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
For a development checkout:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install -e .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Runtime dependencies and the installed CLI entry point are defined entirely in
|
|
20
|
+
`pyproject.toml`.
|
|
21
|
+
|
|
22
|
+
## Command-line interface
|
|
23
|
+
|
|
24
|
+
Installing the package provides:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pytesprocess --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The normal event-processing workflow is selected directly from the top-level
|
|
31
|
+
command:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pytesprocess ACQUISITION \
|
|
35
|
+
--config processing.yaml \
|
|
36
|
+
--steps randoms trigger feature
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`--steps` is mandatory. It accepts either whitespace-separated or
|
|
40
|
+
comma-separated values, including mixed input:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
--steps randoms trigger feature
|
|
44
|
+
--steps randoms,trigger,feature
|
|
45
|
+
--steps randoms,trigger feature
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
All are equivalent. The execution order is normalized internally to:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
randoms -> salting -> trigger -> feature
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The separate detector-characterization/filter workflows remain explicit:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pytesprocess filter ACQUISITION --config processing.yaml
|
|
58
|
+
pytesprocess ivsweep ACQUISITION
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Example:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pytesprocess acquisition_I2_D20260807_T170432.zarr \
|
|
65
|
+
--config continuous_data_processing_v2.yaml \
|
|
66
|
+
--steps randoms,trigger,feature \
|
|
67
|
+
--nrandoms 300 \
|
|
68
|
+
--nevents 300 \
|
|
69
|
+
--ncores 4
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
See [docs/user/cli.md](docs/user/cli.md) for the current CLI behavior.
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
New processing configuration uses `config_version: 2` and separates workflow
|
|
77
|
+
sections explicitly:
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
config_version: 2
|
|
81
|
+
|
|
82
|
+
resources:
|
|
83
|
+
filter_file: /path/to/filterdata.hdf5
|
|
84
|
+
|
|
85
|
+
trigger:
|
|
86
|
+
global: {}
|
|
87
|
+
channels: {}
|
|
88
|
+
|
|
89
|
+
feature:
|
|
90
|
+
global:
|
|
91
|
+
trace_length_msec: 20
|
|
92
|
+
pretrigger_length_msec: 10
|
|
93
|
+
presets: {}
|
|
94
|
+
channels: {}
|
|
95
|
+
|
|
96
|
+
salting:
|
|
97
|
+
global: {}
|
|
98
|
+
channels: {}
|
|
99
|
+
|
|
100
|
+
filter: {}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Feature trace lengths are specified in milliseconds in v2 configuration. The
|
|
104
|
+
resolver converts them to samples using the selected acquisition sample rate.
|
|
105
|
+
Channel selectors include `all`, shell-style globs such as `Z1P*`, comma groups
|
|
106
|
+
for applying one block to several independent channels, and explicit
|
|
107
|
+
multi-channel expressions such as `A|B`.
|
|
108
|
+
|
|
109
|
+
See [docs/user/configuration.md](docs/user/configuration.md).
|
|
110
|
+
|
|
111
|
+
## Processed dataframe identity
|
|
112
|
+
|
|
113
|
+
Each Vaex processing product has one dataframe-group identity:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
dataframe_group_name
|
|
117
|
+
dataframe_group_id
|
|
118
|
+
dataframe_group_number
|
|
119
|
+
dataframe_file_index
|
|
120
|
+
processing_label
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
For example:
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
trigger_I2_D20260908_T123456/
|
|
127
|
+
trigger_I2_D20260908_T123456_F0001.hdf5
|
|
128
|
+
trigger_I2_D20260908_T123456_F0002.hdf5
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`F####` is a processing task/output shard index, not a second stream or series
|
|
132
|
+
identifier. Raw provenance uses canonical stream fields such as `stream_id`,
|
|
133
|
+
`stream_number`, and `stream_trigger_index`.
|
|
134
|
+
|
|
135
|
+
See [docs/user/outputs.md](docs/user/outputs.md).
|
|
136
|
+
|
|
137
|
+
## Package structure
|
|
138
|
+
|
|
139
|
+
The current package layout intentionally separates reusable analysis objects
|
|
140
|
+
from acquisition-processing workflows:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
pytesprocess/
|
|
144
|
+
core/ reusable analysis/data objects and algorithms
|
|
145
|
+
process/ raw/dataframe processing executors
|
|
146
|
+
config/ YAML loading, selection, resolution, validation
|
|
147
|
+
salting/ salt metadata generation and waveform injection
|
|
148
|
+
workflows/ multi-step orchestration used by the CLI
|
|
149
|
+
cli/ command-line parsing and dispatch
|
|
150
|
+
utils/ shared utilities and HDF5/dataframe helpers
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
See [docs/developer/architecture.md](docs/developer/architecture.md) for the
|
|
154
|
+
current developer-oriented architecture.
|
|
155
|
+
|
|
156
|
+
## Notes on multiprocessing
|
|
157
|
+
|
|
158
|
+
The existing Vaex/PyArrow and numerical-library thread limits are intentional.
|
|
159
|
+
They were introduced to avoid thread oversubscription and unstable/slower
|
|
160
|
+
multicore processing. They should not be removed or relocated without dedicated
|
|
161
|
+
multicore benchmarking.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pytesprocess"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Detector data processing for pytesdaqx acquisitions"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Bruno Serfass", email = "serfass@berkeley.edu"},
|
|
14
|
+
{name = "Samuel Watkins", email = "samwatkins@berkeley.edu"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["detector", "TES", "DAQ", "signal processing"]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"numpy>=1.26",
|
|
19
|
+
"scipy",
|
|
20
|
+
"matplotlib",
|
|
21
|
+
"PyYAML",
|
|
22
|
+
"qetpy>=1.8.6",
|
|
23
|
+
"pandas",
|
|
24
|
+
"pytesdaqx",
|
|
25
|
+
"humanfriendly",
|
|
26
|
+
"vaex",
|
|
27
|
+
"pyarrow",
|
|
28
|
+
"lmfit",
|
|
29
|
+
"cloudpickle",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"build",
|
|
35
|
+
"pytest",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/spice-herald/pytesprocess"
|
|
40
|
+
Repository = "https://github.com/spice-herald/pytesprocess"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
pytesprocess = "pytesprocess.cli.main:main"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.dynamic]
|
|
46
|
+
version = {attr = "pytesprocess._version.__version__"}
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.packages.find]
|
|
49
|
+
include = ["pytesprocess*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .main import main
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Default event-processing CLI arguments."""
|
|
2
|
+
|
|
3
|
+
from pytesprocess.workflows.processing import run_processing_workflow
|
|
4
|
+
|
|
5
|
+
_PROCESS_STEPS = ("randoms", "salting", "trigger", "feature")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def configure(parser):
|
|
9
|
+
parser.add_argument(
|
|
10
|
+
"--steps",
|
|
11
|
+
nargs="+",
|
|
12
|
+
required=True,
|
|
13
|
+
metavar="STEP[,STEP...]",
|
|
14
|
+
help=(
|
|
15
|
+
"Processing steps to run. Values may be space-separated, "
|
|
16
|
+
"comma-separated, or mixed (for example '--steps randoms trigger "
|
|
17
|
+
"feature' or '--steps randoms,trigger,feature'). User order is "
|
|
18
|
+
"ignored; execution order is always randoms -> salting -> trigger "
|
|
19
|
+
"-> feature. Valid steps: " + ", ".join(_PROCESS_STEPS) + "."
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Trigger/feature options
|
|
24
|
+
parser.add_argument("--ntriggers", type=int, default=-1)
|
|
25
|
+
parser.add_argument("--nevents", type=int, default=-1)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"--measurement-type",
|
|
28
|
+
default="background",
|
|
29
|
+
choices=["background", "calibration", "threshold"],
|
|
30
|
+
help=(
|
|
31
|
+
"Raw measurement type for trigger/feature processing. Threshold "
|
|
32
|
+
"data may be processed directly by the feature step without a "
|
|
33
|
+
"trigger dataframe."
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"--trigger-dataframe",
|
|
38
|
+
help="Existing trigger dataframe group/file for feature processing.",
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"--salting-dataframe",
|
|
42
|
+
help=(
|
|
43
|
+
"Existing salting dataframe to inject during trigger/feature "
|
|
44
|
+
"processing. Do not combine with the salting generation step."
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument("--external-features")
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"--partition-duration",
|
|
50
|
+
type=float,
|
|
51
|
+
default=10.0,
|
|
52
|
+
dest="partition_duration",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Random-generation options. They are validated only when randoms is
|
|
56
|
+
# requested, so the same top-level command works for other step sets.
|
|
57
|
+
count = parser.add_mutually_exclusive_group(required=False)
|
|
58
|
+
count.add_argument("--nrandoms", type=int)
|
|
59
|
+
count.add_argument("--random-rate", type=float)
|
|
60
|
+
parser.add_argument("--min-separation-msec", type=float, default=0.0)
|
|
61
|
+
parser.add_argument("--edge-exclusion-msec", type=float, default=0.0)
|
|
62
|
+
parser.add_argument("--random-seed", type=int)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def run(args):
|
|
66
|
+
return run_processing_workflow(args)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from pytesprocess.process import FilterDataProcessing
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def configure(parser):
|
|
5
|
+
parser.add_argument("--channels", nargs="+")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def run(args):
|
|
9
|
+
proc = FilterDataProcessing(
|
|
10
|
+
args.acquisition, streams=args.streams, restricted=args.restricted,
|
|
11
|
+
config_file=args.config, verbose=not args.quiet,
|
|
12
|
+
)
|
|
13
|
+
proc.process(
|
|
14
|
+
channels=args.channels, processing_label=args.processing_label,
|
|
15
|
+
lgc_output=False, lgc_save=True,
|
|
16
|
+
save_file_path=args.output, ncores=args.ncores,
|
|
17
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pytesprocess.process import IVSweepProcessing
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def configure(parser):
|
|
5
|
+
parser.add_argument("--channels", nargs="+")
|
|
6
|
+
parser.add_argument("--iv-only", action="store_true")
|
|
7
|
+
parser.add_argument("--didv-only", action="store_true")
|
|
8
|
+
parser.add_argument("--trace-length-msec", type=float, default=100.0)
|
|
9
|
+
parser.add_argument("--nrandoms-iv", type=int)
|
|
10
|
+
parser.add_argument("--random-seed", type=int)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run(args):
|
|
14
|
+
if args.iv_only and args.didv_only:
|
|
15
|
+
raise ValueError("Use only one of --iv-only or --didv-only")
|
|
16
|
+
proc = IVSweepProcessing(
|
|
17
|
+
args.acquisition, processing_label=args.processing_label,
|
|
18
|
+
verbose=not args.quiet,
|
|
19
|
+
)
|
|
20
|
+
proc.process(
|
|
21
|
+
channels=args.channels,
|
|
22
|
+
enable_iv=not args.didv_only,
|
|
23
|
+
enable_didv=not args.iv_only,
|
|
24
|
+
trace_length_iv_msec=args.trace_length_msec,
|
|
25
|
+
nrandoms_iv=args.nrandoms_iv,
|
|
26
|
+
random_seed=args.random_seed,
|
|
27
|
+
lgc_output=False, lgc_save=True,
|
|
28
|
+
save_path=args.output, ncores=args.ncores,
|
|
29
|
+
)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Shared helpers for the pytesprocess command-line interface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from pytesdaqx.io import AcquisitionCatalog
|
|
8
|
+
|
|
9
|
+
from pytesprocess.config import ProcessingConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def add_common_acquisition_args(parser, *, config=False, ncores=True):
|
|
13
|
+
parser.add_argument("acquisition", help="Raw pytesdaqx acquisition path")
|
|
14
|
+
if config:
|
|
15
|
+
parser.add_argument("--config", required=True, help="Processing YAML file")
|
|
16
|
+
parser.add_argument("--streams", nargs="+", help="Optional stream IDs")
|
|
17
|
+
parser.add_argument("--output", help="Base output directory")
|
|
18
|
+
parser.add_argument("--processing-label", help="Optional human-readable processing label")
|
|
19
|
+
if ncores:
|
|
20
|
+
parser.add_argument("--ncores", type=int, default=1, help="Number of local worker processes")
|
|
21
|
+
parser.add_argument("--restricted", action="store_true", help="Process restricted background data only")
|
|
22
|
+
parser.add_argument("--quiet", action="store_true", help="Reduce informational output")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def catalog_for(args, measurement_types=None):
|
|
26
|
+
measurement = measurement_types
|
|
27
|
+
if isinstance(measurement, (list, tuple, set)):
|
|
28
|
+
unique = {str(item) for item in measurement}
|
|
29
|
+
background_only = unique == {"background"}
|
|
30
|
+
else:
|
|
31
|
+
background_only = (measurement is None or str(measurement) == "background")
|
|
32
|
+
|
|
33
|
+
if args.restricted and not background_only:
|
|
34
|
+
raise ValueError(
|
|
35
|
+
"--restricted is only valid for background data. It selects "
|
|
36
|
+
"restricted background data only, not open + restricted data."
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
catalog = AcquisitionCatalog(args.acquisition, verbose=not args.quiet)
|
|
40
|
+
return catalog.filter(
|
|
41
|
+
streams=args.streams,
|
|
42
|
+
measurement_types=measurement_types,
|
|
43
|
+
restricted=bool(args.restricted) if background_only else False,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def processing_config(args, *, workflows, measurement_types="background", check_resources=True):
|
|
48
|
+
catalog = catalog_for(args, measurement_types=measurement_types)
|
|
49
|
+
config = ProcessingConfig(
|
|
50
|
+
args.config,
|
|
51
|
+
catalog.record_channels,
|
|
52
|
+
sample_rate=catalog.sample_rate_hz,
|
|
53
|
+
verbose=not args.quiet,
|
|
54
|
+
)
|
|
55
|
+
config.validate(workflows, check_resources=check_resources, display=not args.quiet)
|
|
56
|
+
return config, catalog
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def default_output_base(acquisition):
|
|
60
|
+
path = Path(acquisition)
|
|
61
|
+
parent = path.parent
|
|
62
|
+
if parent.name == "raw":
|
|
63
|
+
return str(parent.parent / "processed")
|
|
64
|
+
return str(parent / "processed")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def output_base(args):
|
|
68
|
+
return args.output or default_output_base(args.acquisition)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def trigger_edge_parameters(config, catalog):
|
|
72
|
+
"""Return trigger edge exclusion and legacy-HDF5 livetime."""
|
|
73
|
+
from pytesprocess.core import FilterData
|
|
74
|
+
from pytesprocess.utils import get_trigger_template_info
|
|
75
|
+
|
|
76
|
+
trigger_config = config.get_config("trigger")
|
|
77
|
+
filter_file = trigger_config["overall"]["filter_file"]
|
|
78
|
+
filter_data = FilterData()
|
|
79
|
+
filter_data.load_hdf5(filter_file, overwrite=True)
|
|
80
|
+
info = get_trigger_template_info(trigger_config, filter_data)
|
|
81
|
+
edge_msec = float(info["max_edge_exclusion"])
|
|
82
|
+
livetime = None
|
|
83
|
+
if catalog.storage_format == "hdf5":
|
|
84
|
+
nsegments = sum(int(entry.get("n_segments") or 0) for entry in catalog.entries)
|
|
85
|
+
livetime = float(catalog.get_duration()) - nsegments * 2.0 * edge_msec * 1e-3
|
|
86
|
+
return edge_msec, livetime
|