arrayprobe 0.1.0__py3-none-any.whl
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.
- arrayprobe/__init__.py +219 -0
- arrayprobe/__main__.py +19 -0
- arrayprobe/_v314_lazy.py +48 -0
- arrayprobe/ai_ready.py +212 -0
- arrayprobe/attributed_export.py +1333 -0
- arrayprobe/authordefaults.py +267 -0
- arrayprobe/cli.py +3510 -0
- arrayprobe/combine.py +12 -0
- arrayprobe/compare.py +950 -0
- arrayprobe/config.py +1239 -0
- arrayprobe/constants.py +12 -0
- arrayprobe/count_closure.py +204 -0
- arrayprobe/diagnostic_views.py +769 -0
- arrayprobe/diode_report.py +265 -0
- arrayprobe/driver/__init__.py +5 -0
- arrayprobe/driver/_load_record.py +331 -0
- arrayprobe/driver/preflight_inputs.py +250 -0
- arrayprobe/driver/reprocess.py +553 -0
- arrayprobe/driver/run_flight.py +8166 -0
- arrayprobe/driver/tas_from_probe_housekeeping.py +124 -0
- arrayprobe/dropsize.py +519 -0
- arrayprobe/friendly.py +206 -0
- arrayprobe/geometry/__init__.py +77 -0
- arrayprobe/geometry/min_rectangle.py +92 -0
- arrayprobe/intarr.py +12 -0
- arrayprobe/intarr_analysis.py +16 -0
- arrayprobe/intarr_plots.py +12 -0
- arrayprobe/inventory.py +129 -0
- arrayprobe/jit_kernels.py +344 -0
- arrayprobe/lwc.py +44 -0
- arrayprobe/masks.py +349 -0
- arrayprobe/matio.py +410 -0
- arrayprobe/matlab_compat.py +13 -0
- arrayprobe/ncio.py +26 -0
- arrayprobe/particle.py +55 -0
- arrayprobe/particle_perimeter.py +12 -0
- arrayprobe/products.py +78 -0
- arrayprobe/profiles.py +179 -0
- arrayprobe/provenance.py +21 -0
- arrayprobe/py.typed +11 -0
- arrayprobe/readers/__init__.py +9 -0
- arrayprobe/readers/dmt.py +603 -0
- arrayprobe/readers/mask_csv.py +12 -0
- arrayprobe/readers/pms.py +12 -0
- arrayprobe/readers/sea.py +433 -0
- arrayprobe/readers/tasinfo.py +12 -0
- arrayprobe/regimes.py +507 -0
- arrayprobe/render.py +728 -0
- arrayprobe/reproduce_report.py +149 -0
- arrayprobe/review_agreement.py +135 -0
- arrayprobe/review_sampling.py +327 -0
- arrayprobe/run_page.py +624 -0
- arrayprobe/sample_area.py +12 -0
- arrayprobe/selector.py +206 -0
- arrayprobe/sizing.py +151 -0
- arrayprobe/time_convert.py +12 -0
- arrayprobe/timing_closure.py +141 -0
- arrayprobe/tools/__init__.py +27 -0
- arrayprobe/tools/make_demo_flight.py +1089 -0
- arrayprobe/tools/make_tas_file.py +760 -0
- arrayprobe/tools/probe_comparison.py +569 -0
- arrayprobe/tools/synthetic_truth.py +698 -0
- arrayprobe/tools/tas_sources.py +705 -0
- arrayprobe/triage_context.py +488 -0
- arrayprobe/triage_server.py +5215 -0
- arrayprobe/tune/__init__.py +15 -0
- arrayprobe/tune/diodes.py +400 -0
- arrayprobe/tune/distributions.py +300 -0
- arrayprobe/tune/sample.py +243 -0
- arrayprobe/tune/score.py +230 -0
- arrayprobe/tune/settings.py +354 -0
- arrayprobe/validate_by_condition.py +208 -0
- arrayprobe/validation_report.py +166 -0
- arrayprobe-0.1.0.dist-info/METADATA +260 -0
- arrayprobe-0.1.0.dist-info/RECORD +189 -0
- arrayprobe-0.1.0.dist-info/WHEEL +5 -0
- arrayprobe-0.1.0.dist-info/entry_points.txt +2 -0
- arrayprobe-0.1.0.dist-info/licenses/LICENSE +31 -0
- arrayprobe-0.1.0.dist-info/licenses/LICENSES/BSD-3-Clause.txt +47 -0
- arrayprobe-0.1.0.dist-info/licenses/NOTICE.md +369 -0
- arrayprobe-0.1.0.dist-info/top_level.txt +4 -0
- arrayprobe_soda2/__init__.py +131 -0
- arrayprobe_soda2/angles.py +143 -0
- arrayprobe_soda2/aspect_ratio.py +541 -0
- arrayprobe_soda2/backfill.py +100 -0
- arrayprobe_soda2/binary_dof.py +181 -0
- arrayprobe_soda2/buildindex.py +113 -0
- arrayprobe_soda2/decompress_dmt.py +285 -0
- arrayprobe_soda2/enhancement_hooks.py +275 -0
- arrayprobe_soda2/export_ascii.py +732 -0
- arrayprobe_soda2/export_ncdf.py +683 -0
- arrayprobe_soda2/export_ncdf_raf.py +396 -0
- arrayprobe_soda2/fillholes.py +161 -0
- arrayprobe_soda2/find_radius.py +105 -0
- arrayprobe_soda2/findsize.py +407 -0
- arrayprobe_soda2/fit_poisson.py +170 -0
- arrayprobe_soda2/fix2dimage.py +63 -0
- arrayprobe_soda2/fixraking.py +162 -0
- arrayprobe_soda2/fixstuckbits.py +146 -0
- arrayprobe_soda2/hvps4_read_frame.py +121 -0
- arrayprobe_soda2/jit_kernels.py +152 -0
- arrayprobe_soda2/label_blobs.py +177 -0
- arrayprobe_soda2/min_circle_fast.py +320 -0
- arrayprobe_soda2/particlesort.py +703 -0
- arrayprobe_soda2/pbp_writer.py +558 -0
- arrayprobe_soda2/poisson_spot_correct.py +183 -0
- arrayprobe_soda2/princomp.py +107 -0
- arrayprobe_soda2/probespecs.py +361 -0
- arrayprobe_soda2/process_2d.py +1364 -0
- arrayprobe_soda2/process_2d_parallel.py +626 -0
- arrayprobe_soda2/process_hk.py +512 -0
- arrayprobe_soda2/processbuffer_2dc.py +155 -0
- arrayprobe_soda2/processbuffer_cip.py +213 -0
- arrayprobe_soda2/processbuffer_f2dc.py +139 -0
- arrayprobe_soda2/processbuffer_spec.py +441 -0
- arrayprobe_soda2/processbuffer_tail.py +350 -0
- arrayprobe_soda2/pth_readers.py +245 -0
- arrayprobe_soda2/py.typed +11 -0
- arrayprobe_soda2/read2dbuffer.py +371 -0
- arrayprobe_soda2/reject.py +246 -0
- arrayprobe_soda2/reprocess_pbp.py +156 -0
- arrayprobe_soda2/sample_area.py +264 -0
- arrayprobe_soda2/save_writer.py +480 -0
- arrayprobe_soda2/sea.py +324 -0
- arrayprobe_soda2/spec_absolutepointers.py +109 -0
- arrayprobe_soda2/spec_decompress.py +203 -0
- arrayprobe_soda2/spec_index.py +476 -0
- arrayprobe_soda2/spec_read_frame.py +286 -0
- arrayprobe_soda2/spec_read_hk.py +301 -0
- arrayprobe_soda2/spec_readint.py +127 -0
- arrayprobe_soda2/timeconv.py +77 -0
- arrayprobe_soda2/update_op.py +101 -0
- arrayprobe_uiops/__init__.py +45 -0
- arrayprobe_uiops/combine.py +192 -0
- arrayprobe_uiops/combine_fork.py +359 -0
- arrayprobe_uiops/constants.py +830 -0
- arrayprobe_uiops/decode_naming.py +113 -0
- arrayprobe_uiops/diode_mask.py +250 -0
- arrayprobe_uiops/engine_absence.py +41 -0
- arrayprobe_uiops/export_oap.py +325 -0
- arrayprobe_uiops/geometry_core.py +366 -0
- arrayprobe_uiops/habit.py +749 -0
- arrayprobe_uiops/habit_core.py +248 -0
- arrayprobe_uiops/hollow_size_rule.py +376 -0
- arrayprobe_uiops/imgproc.py +2081 -0
- arrayprobe_uiops/imgproc_core.py +275 -0
- arrayprobe_uiops/intarr.py +167 -0
- arrayprobe_uiops/intarr_analysis.py +569 -0
- arrayprobe_uiops/intarr_plots.py +119 -0
- arrayprobe_uiops/jit_kernels.py +430 -0
- arrayprobe_uiops/lwc.py +70 -0
- arrayprobe_uiops/matlab_compat.py +860 -0
- arrayprobe_uiops/measure.py +346 -0
- arrayprobe_uiops/min_circle.py +204 -0
- arrayprobe_uiops/min_ellipse.py +161 -0
- arrayprobe_uiops/min_rectangle.py +200 -0
- arrayprobe_uiops/ncar_2dc_timing.py +100 -0
- arrayprobe_uiops/ncio.py +810 -0
- arrayprobe_uiops/oap_read.py +228 -0
- arrayprobe_uiops/particle.py +51 -0
- arrayprobe_uiops/particle_perimeter.py +94 -0
- arrayprobe_uiops/particle_physics.py +199 -0
- arrayprobe_uiops/pecan_params.py +134 -0
- arrayprobe_uiops/probe_cases.py +298 -0
- arrayprobe_uiops/product_sanity.py +337 -0
- arrayprobe_uiops/profile.py +71 -0
- arrayprobe_uiops/profiles.py +756 -0
- arrayprobe_uiops/provenance.py +804 -0
- arrayprobe_uiops/py.typed +11 -0
- arrayprobe_uiops/qc.py +169 -0
- arrayprobe_uiops/readers/__init__.py +8 -0
- arrayprobe_uiops/readers/mask_csv.py +74 -0
- arrayprobe_uiops/readers/pms.py +239 -0
- arrayprobe_uiops/readers/tasinfo.py +57 -0
- arrayprobe_uiops/rect_ellipse.py +129 -0
- arrayprobe_uiops/register_image_assisted.py +25 -0
- arrayprobe_uiops/reject.py +501 -0
- arrayprobe_uiops/reject_core.py +220 -0
- arrayprobe_uiops/sample_area.py +93 -0
- arrayprobe_uiops/sizedist.py +1923 -0
- arrayprobe_uiops/sizedist_core.py +814 -0
- arrayprobe_uiops/sizedist_tables.py +642 -0
- arrayprobe_uiops/spec.py +1094 -0
- arrayprobe_uiops/spec_core.py +703 -0
- arrayprobe_uiops/stray_pixel.py +103 -0
- arrayprobe_uiops/tas.py +191 -0
- arrayprobe_uiops/time_convert.py +41 -0
- uiops/__init__.py +402 -0
- uiops/py.typed +11 -0
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""Probe- and project-specific configuration tables, transcribed from UIOOPS.
|
|
3
|
+
|
|
4
|
+
Two independent switch statements in the MATLAB source decide everything about a
|
|
5
|
+
run. This module transcribes both, verbatim, so that no later stage re-derives a
|
|
6
|
+
literal from memory:
|
|
7
|
+
|
|
8
|
+
* ``imgProc_sm.m:117-193`` -- keyed on **probe name alone**. Supplies the image
|
|
9
|
+
boundary word, the boundary-time marker, diode size and diode count.
|
|
10
|
+
* ``sizeDist.m:107-511`` -- keyed on **(project, probe)**. Supplies diode size
|
|
11
|
+
and count again (they do NOT always agree -- see :data:`DIODESIZE_DISAGREEMENTS`),
|
|
12
|
+
plus arm distance, the size-bin edges, probe type, the airspeed ceiling, and the
|
|
13
|
+
inter-arrival / shattering-reacceptance parameters.
|
|
14
|
+
|
|
15
|
+
Fidelity doctrine: preserve bugs, do not fix them. Three upstream defects are
|
|
16
|
+
transcribed rather than repaired, each with a named test:
|
|
17
|
+
|
|
18
|
+
1. ``('otherwise', '2DP')`` never assigns ``tasMax``. MATLAB therefore raises an
|
|
19
|
+
undefined-variable error the first time ``sizeDist.m:968`` compares against it.
|
|
20
|
+
Here :attr:`ProbeConfig.tas_max` is ``None`` and reading
|
|
21
|
+
:attr:`ProbeConfig.tasMax` raises :class:`MatlabUndefinedVariable`.
|
|
22
|
+
2. ``('GPM', '2DS')``, ``('GPM', 'CIP')`` and ``('GPM', 'HVPS')`` never assign
|
|
23
|
+
``intar_threshold``, though the first two switch inter-arrival thresholding ON.
|
|
24
|
+
:attr:`ProbeConfig.sets_intar_threshold` records this; ``sizeDist.m:1135`` would
|
|
25
|
+
fail on the undefined variable.
|
|
26
|
+
3. The 2DC diode size is ``0.025`` mm in ``imgProc_sm.m:123`` but ``0.030`` mm in
|
|
27
|
+
``sizeDist.m:186``. Both are kept, in their own tables.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
MATLAB source of truth: ``UIOPS-v3.1.4/joefinlon-UIOPS-ba5e67c/``.
|
|
31
|
+
|
|
32
|
+
Vocabulary note: this module says "particle", never "drop". The package must work
|
|
33
|
+
for ice as well as liquid; a liquid noun in a public name is a design commitment we
|
|
34
|
+
do not want to make.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
from __future__ import annotations
|
|
38
|
+
|
|
39
|
+
from dataclasses import dataclass
|
|
40
|
+
from types import MappingProxyType
|
|
41
|
+
from typing import TypedDict
|
|
42
|
+
|
|
43
|
+
import numpy as np
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"MatlabUndefinedVariable",
|
|
47
|
+
"ImgProcConfig",
|
|
48
|
+
"ProbeConfig",
|
|
49
|
+
"IMGPROC_CONFIG",
|
|
50
|
+
"SIZEDIST_CONFIG",
|
|
51
|
+
"PROBE_TYPES",
|
|
52
|
+
"DIODESIZE_DISAGREEMENTS",
|
|
53
|
+
"PROJECTS",
|
|
54
|
+
"imgproc_config",
|
|
55
|
+
"sizedist_config",
|
|
56
|
+
"bin_edges",
|
|
57
|
+
"bin_width",
|
|
58
|
+
"resolution_um",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class MatlabUndefinedVariable(NameError):
|
|
63
|
+
"""Raised where MATLAB would raise ``Undefined function or variable``.
|
|
64
|
+
|
|
65
|
+
Transcribing an upstream omission as a Python default (``0``, ``inf``,
|
|
66
|
+
``None`` used silently) would turn a MATLAB *crash* into a Python *number*,
|
|
67
|
+
which is a behaviour change. So the omission is preserved as an error at the
|
|
68
|
+
moment of use.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# --------------------------------------------------------------------------
|
|
73
|
+
# Probe type codes -- sizeDist.m:627,774,791,796,802,811,852,923,938,945
|
|
74
|
+
# --------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
PROBE_TYPES = MappingProxyType({
|
|
77
|
+
0: "2DC/2DP (PMS, 32 diodes, 4-byte boundary)",
|
|
78
|
+
1: "CIP/PIP (DMT, 64 diodes)",
|
|
79
|
+
2: "2DS/HVPS (SPEC, 128 diodes)",
|
|
80
|
+
3: "Fast2DC/F2DC (64 diodes, 12 MHz clock)",
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# --------------------------------------------------------------------------
|
|
85
|
+
# imgProc_sm.m:117-193 -- keyed on probe name alone
|
|
86
|
+
# --------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
@dataclass(frozen=True)
|
|
89
|
+
class ImgProcConfig:
|
|
90
|
+
"""One case of the ``imgProc_sm.m`` probe switch.
|
|
91
|
+
|
|
92
|
+
Attributes mirror the MATLAB variable names one-for-one so a transliterated
|
|
93
|
+
call site reads the same as its source line.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
probename: str
|
|
97
|
+
boundary: tuple[int, ...]
|
|
98
|
+
"""The inter-particle marker word repeated across a full slice.
|
|
99
|
+
|
|
100
|
+
``imgProc_sm.m:119,129`` (2DC/2DP), ``:139,149`` (CIP/PIP), ``:159,174``
|
|
101
|
+
(HVPS/2DS), ``:189`` (Fast2DC). The 2DS/HVPS value 43690 is ``0xAAAA``; the
|
|
102
|
+
CIP/PIP/Fast2DC value 170 is ``0xAA``; the 2DC/2DP value 255 is ``0xFF``.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
boundarytime: float
|
|
106
|
+
"""Marker following the boundary word. ``NaN`` for the DMT probes."""
|
|
107
|
+
|
|
108
|
+
ds: float
|
|
109
|
+
"""Diode size in millimetres (``imgProc_sm.m:123`` etc.)."""
|
|
110
|
+
|
|
111
|
+
diodenum: int
|
|
112
|
+
"""Diode count (``imgProc_sm.m:125`` etc.)."""
|
|
113
|
+
|
|
114
|
+
probetype: int
|
|
115
|
+
"""See :data:`PROBE_TYPES`."""
|
|
116
|
+
|
|
117
|
+
needs_tas_file: bool = False
|
|
118
|
+
"""2DS and HVPS read TAS from ``varargin{1}`` (``imgProc_sm.m:167-170,180-185``)."""
|
|
119
|
+
|
|
120
|
+
read_width: int = 8
|
|
121
|
+
"""Column count of the raw ``data`` read (``imgProc_sm.m:488-494``).
|
|
122
|
+
|
|
123
|
+
NOT always ``len(boundary)`` -- Fast2DC reads 8 columns wide but has a
|
|
124
|
+
THREE-word boundary (``:189``), so the two must be kept apart.
|
|
125
|
+
Conflating them (deriving the read width from ``len(boundary)``) was a
|
|
126
|
+
real port bug found while triaging (``imgproc.py:640``): it happens
|
|
127
|
+
to coincide for probetypes 0, 1 and 2, so S3's probetype-2 path never
|
|
128
|
+
exposed it."""
|
|
129
|
+
|
|
130
|
+
read_slices: int = 1700
|
|
131
|
+
"""Slice count of the raw ``data`` read (``imgProc_sm.m:488-494``): 1024 for
|
|
132
|
+
probetype 0, 512 for Fast2DC, 1700 otherwise.
|
|
133
|
+
|
|
134
|
+
A **literal per probetype in all three MATLAB trees**, and the port used
|
|
135
|
+
the input file's dimension-2 length instead until 2026-09-10. MATLAB reads
|
|
136
|
+
that dimension (``:205-207``) and assigns ``size_mat = dimlen`` -- and then
|
|
137
|
+
never mentions ``size_mat`` again. It is a dead store, and the port had
|
|
138
|
+
quietly promoted it to the read count. The two coincide on every file the
|
|
139
|
+
port's own writer produces (``ImgBlocklen`` == 1700), which is why nothing
|
|
140
|
+
caught it; on the OLYMPEX distribution's own stitched file, whose second
|
|
141
|
+
dimension is not the block length, they do not. The `inq_dim` call itself
|
|
142
|
+
is kept, because MATLAB makes it and a file with fewer than three
|
|
143
|
+
dimensions must fail the same way."""
|
|
144
|
+
|
|
145
|
+
start_first: int = 1
|
|
146
|
+
"""Initial ``start`` before any particle is found (``:524-529``).
|
|
147
|
+
|
|
148
|
+
2 for probetypes 0, 1, 3; 1 for probetype 2."""
|
|
149
|
+
|
|
150
|
+
boundary_needs_time: bool = True
|
|
151
|
+
"""Whether the boundary test's second clause (``:523``) checks
|
|
152
|
+
``data(j+1,1)==boundarytime``.
|
|
153
|
+
|
|
154
|
+
False for probetypes 1 and 3: their ``boundarytime`` is NaN and
|
|
155
|
+
``isequal(NaN,NaN)`` is false in MATLAB, so ``:523``'s
|
|
156
|
+
``|| probetype==1 || probetype==3`` disjunct exists purely to bypass a
|
|
157
|
+
check that would otherwise never pass. Do not "fix" this into a
|
|
158
|
+
NaN-tolerant comparison."""
|
|
159
|
+
|
|
160
|
+
image_slice_offset: int = 0
|
|
161
|
+
"""Extra offset on the image slice's start index (``:534,:541,:555,:558``).
|
|
162
|
+
|
|
163
|
+
1 for probetype 0 (``data(start+1:j-1,:)``), 0 otherwise
|
|
164
|
+
(``data(start:j-1,:)``). The SAME value also offsets the corrupt/zero-image
|
|
165
|
+
guard test, which reads ``start+offset > (j-1)`` -- not a coincidence:
|
|
166
|
+
probetype 0's guard is exactly the emptiness of that offset slice."""
|
|
167
|
+
|
|
168
|
+
image_invert: bool = False
|
|
169
|
+
"""Whether the image is built as ``65535 - data`` (``:562``, probetype 2
|
|
170
|
+
only) or used as-is (``:556,:559`` -- the PMS/DMT raw formats already
|
|
171
|
+
store 1 = illuminated, so no inversion is needed or applied)."""
|
|
172
|
+
|
|
173
|
+
image_word_bits: int = 16
|
|
174
|
+
"""Bits per ``dec2bin`` word in the image construction (``:556-564``).
|
|
175
|
+
|
|
176
|
+
8 for probetypes 0, 1, 3; 16 for probetype 2."""
|
|
177
|
+
|
|
178
|
+
timing: str = "spec"
|
|
179
|
+
"""Which particle-timing branch (``:580-778``) this probe takes:
|
|
180
|
+
``'pms'`` (0), ``'dmt'`` (1), ``'spec'`` (2, ported), ``'fast2dc'`` (3)."""
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def byteperslice(self) -> int:
|
|
184
|
+
"""``imgProc_sm.m:200`` -- ``byteperslice = diodenum/8``."""
|
|
185
|
+
return self.diodenum // 8
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
IMGPROC_CONFIG: MappingProxyType[str, ImgProcConfig] = MappingProxyType({
|
|
189
|
+
cfg.probename: cfg
|
|
190
|
+
for cfg in (
|
|
191
|
+
# imgProc_sm.m:118-126
|
|
192
|
+
ImgProcConfig("2DC", (255, 255, 255, 255), 85.0, 0.025, 32, 0,
|
|
193
|
+
read_slices=1024, read_width=4, start_first=2, boundary_needs_time=True,
|
|
194
|
+
image_slice_offset=1, image_invert=False,
|
|
195
|
+
image_word_bits=8, timing="pms"),
|
|
196
|
+
# imgProc_sm.m:128-136
|
|
197
|
+
ImgProcConfig("2DP", (255, 255, 255, 255), 85.0, 0.200, 32, 0,
|
|
198
|
+
read_slices=1024, read_width=4, start_first=2, boundary_needs_time=True,
|
|
199
|
+
image_slice_offset=1, image_invert=False,
|
|
200
|
+
image_word_bits=8, timing="pms"),
|
|
201
|
+
# imgProc_sm.m:138-146
|
|
202
|
+
ImgProcConfig("CIP", (170,) * 8, float("nan"), 0.025, 64, 1,
|
|
203
|
+
read_width=8, start_first=2, boundary_needs_time=False,
|
|
204
|
+
image_slice_offset=0, image_invert=False,
|
|
205
|
+
image_word_bits=8, timing="dmt"),
|
|
206
|
+
# imgProc_sm.m:148-156
|
|
207
|
+
ImgProcConfig("PIP", (170,) * 8, float("nan"), 0.100, 64, 1,
|
|
208
|
+
read_width=8, start_first=2, boundary_needs_time=False,
|
|
209
|
+
image_slice_offset=0, image_invert=False,
|
|
210
|
+
image_word_bits=8, timing="dmt"),
|
|
211
|
+
# imgProc_sm.m:158-172
|
|
212
|
+
ImgProcConfig("HVPS", (43690,) * 8, 0.0, 0.150, 128, 2, needs_tas_file=True,
|
|
213
|
+
read_width=8, start_first=1, boundary_needs_time=True,
|
|
214
|
+
image_slice_offset=0, image_invert=True,
|
|
215
|
+
image_word_bits=16, timing="spec"),
|
|
216
|
+
# imgProc_sm.m:173-187
|
|
217
|
+
ImgProcConfig("2DS", (43690,) * 8, 0.0, 0.010, 128, 2, needs_tas_file=True,
|
|
218
|
+
read_width=8, start_first=1, boundary_needs_time=True,
|
|
219
|
+
image_slice_offset=0, image_invert=True,
|
|
220
|
+
image_word_bits=16, timing="spec"),
|
|
221
|
+
# imgProc_sm.m:188-197 -- note the boundary is THREE words, not four or eight
|
|
222
|
+
ImgProcConfig("Fast2DC", (170, 170, 170), float("nan"), 0.025, 64, 3,
|
|
223
|
+
read_slices=512, read_width=8, start_first=2, boundary_needs_time=False,
|
|
224
|
+
image_slice_offset=0, image_invert=False,
|
|
225
|
+
image_word_bits=8, timing="fast2dc"),
|
|
226
|
+
)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
# --------------------------------------------------------------------------
|
|
231
|
+
# sizeDist.m:107-511 -- keyed on (project, probe)
|
|
232
|
+
# --------------------------------------------------------------------------
|
|
233
|
+
|
|
234
|
+
@dataclass(frozen=True)
|
|
235
|
+
class ProbeConfig:
|
|
236
|
+
"""One case of the ``sizeDist.m`` project/probe switch.
|
|
237
|
+
|
|
238
|
+
``kk`` is stored in millimetres, already divided (or multiplied) as the source
|
|
239
|
+
line does, so the literal here equals the MATLAB value at the end of its own
|
|
240
|
+
assignment.
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
project: str
|
|
244
|
+
probename: str
|
|
245
|
+
num_diodes: int
|
|
246
|
+
diodesize: float
|
|
247
|
+
"""Millimetres. Disagrees with :attr:`ImgProcConfig.ds` for the 2DC."""
|
|
248
|
+
|
|
249
|
+
armdst: float
|
|
250
|
+
"""Arm separation in millimetres (sample-area geometry)."""
|
|
251
|
+
|
|
252
|
+
num_bins: int
|
|
253
|
+
kk: np.ndarray
|
|
254
|
+
"""Size-bin **edges** in millimetres. ``len(kk) == num_bins + 1`` in every case."""
|
|
255
|
+
|
|
256
|
+
probetype: int
|
|
257
|
+
tas_max: float | None
|
|
258
|
+
"""``None`` where MATLAB leaves ``tasMax`` unassigned -- see :attr:`tasMax`."""
|
|
259
|
+
|
|
260
|
+
apply_int_arr_thresh: bool
|
|
261
|
+
default_int_arr_thresh: float
|
|
262
|
+
reaccpt_shatrs: bool
|
|
263
|
+
reaccpt_d: float
|
|
264
|
+
"""Minimum particle diameter (mm) eligible for shattering reacceptance."""
|
|
265
|
+
|
|
266
|
+
reaccpt_max_ia: float
|
|
267
|
+
"""Maximum inter-arrival time (s) eligible for shattering reacceptance."""
|
|
268
|
+
|
|
269
|
+
sets_intar_threshold: bool
|
|
270
|
+
"""False where the case never assigns ``intar_threshold`` (upstream omission)."""
|
|
271
|
+
|
|
272
|
+
needs_pecan_params: bool = False
|
|
273
|
+
"""PECAN cases call ``getPECANparams``, which does not exist in the repo."""
|
|
274
|
+
|
|
275
|
+
source_line: str = ""
|
|
276
|
+
"""``file:line`` of the case, so a reader can check the transcription."""
|
|
277
|
+
|
|
278
|
+
kk_octave: np.ndarray | None = None
|
|
279
|
+
"""The ladder **Octave** would build, where that differs from MATLAB's.
|
|
280
|
+
|
|
281
|
+
Only the three colon-built cases differ (see :func:`_colon`); every ladder
|
|
282
|
+
written as an explicit literal is identical in both. This exists solely so
|
|
283
|
+
an Octave golden can be compared bit-for-bit -- it is never what the port
|
|
284
|
+
computes by default. ``None`` means "the same as :attr:`kk`", and
|
|
285
|
+
:meth:`__post_init__` fills it in so callers need no special case.
|
|
286
|
+
"""
|
|
287
|
+
|
|
288
|
+
def __post_init__(self) -> None:
|
|
289
|
+
object.__setattr__(self, "kk", np.asarray(self.kk, dtype=np.float64))
|
|
290
|
+
oct_kk = self.kk if self.kk_octave is None else np.asarray(
|
|
291
|
+
self.kk_octave, dtype=np.float64)
|
|
292
|
+
if oct_kk.shape != self.kk.shape:
|
|
293
|
+
raise ValueError(
|
|
294
|
+
f"kk_octave has {oct_kk.size} edges but kk has {self.kk.size}; "
|
|
295
|
+
"the two ladders must differ only in rounding, never in length"
|
|
296
|
+
)
|
|
297
|
+
object.__setattr__(self, "kk_octave", oct_kk)
|
|
298
|
+
|
|
299
|
+
@property
|
|
300
|
+
def tasMax(self) -> float: # noqa: N802 -- MATLAB name, deliberately
|
|
301
|
+
"""``tasMax``, raising where MATLAB would.
|
|
302
|
+
|
|
303
|
+
``('otherwise', '2DP')`` (``sizeDist.m:465-489``) never assigns it, so
|
|
304
|
+
``sizeDist.m:640`` and ``:968`` fail there. Preserved, not defaulted.
|
|
305
|
+
"""
|
|
306
|
+
if self.tas_max is None:
|
|
307
|
+
raise MatlabUndefinedVariable(
|
|
308
|
+
f"tasMax is not assigned for project={self.project!r} "
|
|
309
|
+
f"probename={self.probename!r} (sizeDist.m:465-489 omits it); "
|
|
310
|
+
"MATLAB raises 'Undefined function or variable' at sizeDist.m:968. No "
|
|
311
|
+
"default exists: tasMax is the fastest airspeed the probe's clock samples "
|
|
312
|
+
"without skewed images, a property of the instrument no release states for "
|
|
313
|
+
"the 2DP. Pass tas_max=<m/s> with your probe's value."
|
|
314
|
+
)
|
|
315
|
+
return self.tas_max
|
|
316
|
+
|
|
317
|
+
@property
|
|
318
|
+
def res(self) -> float:
|
|
319
|
+
"""``sizeDist.m:522`` -- ``res = diodesize*1000``, i.e. microns."""
|
|
320
|
+
return self.diodesize * 1000.0
|
|
321
|
+
|
|
322
|
+
@property
|
|
323
|
+
def binwidth(self) -> np.ndarray:
|
|
324
|
+
"""``sizeDist.m:523`` -- ``binwidth = diff(kk)``, length ``num_bins``."""
|
|
325
|
+
return np.diff(self.kk)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def _colon(start: float, step: float, stop: float, *,
|
|
329
|
+
matlab: bool = True) -> np.ndarray:
|
|
330
|
+
"""MATLAB ``start:step:stop``, for the eight cases that build ``kk`` this way.
|
|
331
|
+
|
|
332
|
+
``sizeDist.m:143`` (PECAN/PIP), ``:388`` (otherwise/2DS), ``:420``
|
|
333
|
+
(otherwise/PIP) and their ORACLES-variant counterparts, plus the
|
|
334
|
+
production tree's ``otherwise`` HVPS and CIP cases. MATLAB's colon
|
|
335
|
+
operator is inclusive of ``stop`` when it
|
|
336
|
+
lands on a grid point and is computed to avoid accumulated rounding, which is
|
|
337
|
+
what ``np.arange`` does not guarantee -- so the count is derived first.
|
|
338
|
+
|
|
339
|
+
**MATLAB fills the result from both ends toward the middle**, and this is
|
|
340
|
+
not a detail that can be skipped. Elements in the lower half are computed
|
|
341
|
+
as ``start + k*step``; those in the upper half as ``last - (m-k)*step``,
|
|
342
|
+
where ``m`` is the number of steps and ``last = start + m*step``. The two
|
|
343
|
+
routes disagree in the last bit, so a naive ``start + k*step`` throughout
|
|
344
|
+
gets the upper half wrong by one ULP.
|
|
345
|
+
|
|
346
|
+
Measured 2026-09-03: for the ORACLES 2D-S ladder
|
|
347
|
+
(``0.005:0.010:128.6*0.010``, 129 points) the naive form differs from the
|
|
348
|
+
archived MATLAB product's own ``Bin Minimum``/``Bin Maximum`` bytes in
|
|
349
|
+
**34 of 129 edges**, each by 2.2e-16 mm, all in the upper half; the
|
|
350
|
+
two-sided form reproduces all 129 exactly.
|
|
351
|
+
``tests/test_bin_ladder.py`` pins that against the product.
|
|
352
|
+
|
|
353
|
+
**Octave is not an oracle for this.** Octave's colon computes
|
|
354
|
+
``start + k*step`` throughout and agrees with the naive form, so the
|
|
355
|
+
project's usual differential oracle would have confirmed the wrong answer
|
|
356
|
+
here -- the archived product's bytes are what settled it. Pass
|
|
357
|
+
``matlab=False`` to get Octave's construction, which exists **only** so an
|
|
358
|
+
Octave golden can still be compared bit-for-bit; it is never the port's
|
|
359
|
+
default, because the port targets MATLAB.
|
|
360
|
+
"""
|
|
361
|
+
m = int(np.floor((stop - start) / step + 1e-10))
|
|
362
|
+
k = np.arange(m + 1, dtype=np.float64)
|
|
363
|
+
out = start + step * k
|
|
364
|
+
if not matlab:
|
|
365
|
+
return out
|
|
366
|
+
last = start + step * m
|
|
367
|
+
upper = k > m // 2
|
|
368
|
+
out[upper] = last - step * (m - k[upper])
|
|
369
|
+
return out
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
class _ColonPair(TypedDict):
|
|
373
|
+
"""The two ladders a colon-built case needs, named for keyword expansion."""
|
|
374
|
+
|
|
375
|
+
kk: np.ndarray
|
|
376
|
+
kk_octave: np.ndarray
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _colon_pair(start: float, step: float, stop: float) -> _ColonPair:
|
|
380
|
+
"""Both ladders for a colon-built case, from one set of parameters.
|
|
381
|
+
|
|
382
|
+
Expanded into a :class:`ProbeConfig` as ``**_colon_pair(...)``, so ``kk``
|
|
383
|
+
and ``kk_octave`` can never drift apart or be transcribed differently --
|
|
384
|
+
the failure mode of writing the same three numbers twice. The
|
|
385
|
+
:class:`TypedDict` return is what lets the expansion keep its types.
|
|
386
|
+
"""
|
|
387
|
+
return {
|
|
388
|
+
"kk": _colon(start, step, stop),
|
|
389
|
+
"kk_octave": _colon(start, step, stop, matlab=False),
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
# The nineteen-bin ladder shared by CIP, 2DC, F2DC and 2DP (the last scaled by 8).
|
|
394
|
+
_KK19_UM = np.array([
|
|
395
|
+
50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 475.0, 550.0, 625.0,
|
|
396
|
+
700.0, 800.0, 900.0, 1000.0, 1200.0, 1400.0, 1600.0, 1800.0, 2000.0,
|
|
397
|
+
])
|
|
398
|
+
|
|
399
|
+
_KK_HVPS_UM = np.array([
|
|
400
|
+
200.0, 400.0, 600.0, 800.0, 1000.0, 1200.0, 1400.0, 1600.0, 1800.0, 2200.0,
|
|
401
|
+
2600.0, 3000.0, 3400.0, 3800.0, 4200.0, 4600.0, 5000.0, 6000.0, 7000.0,
|
|
402
|
+
8000.0, 9000.0, 10000.0, 12000.0, 14000.0, 16000.0, 18000.0, 20000.0,
|
|
403
|
+
25000.0, 30000.0,
|
|
404
|
+
])
|
|
405
|
+
|
|
406
|
+
_KK_GPM_2DS_UM = np.array([
|
|
407
|
+
40.0, 60.0, 80.0, 100.0, 125.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0,
|
|
408
|
+
475.0, 550.0, 625.0, 700.0, 800.0, 900.0, 1000.0, 1200.0, 1400.0, 1600.0,
|
|
409
|
+
1800.0, 2000.0,
|
|
410
|
+
])
|
|
411
|
+
|
|
412
|
+
_KK_SOCRATES_2DS_UM = np.array([
|
|
413
|
+
50.0, 75.0, 100.0, 125.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 475.0,
|
|
414
|
+
550.0, 625.0, 700.0, 800.0, 900.0, 1000.0, 1200.0, 1400.0, 1600.0, 1800.0,
|
|
415
|
+
2000.0,
|
|
416
|
+
])
|
|
417
|
+
|
|
418
|
+
_KK_SOCRATES_FAST2DC_UM = np.array([
|
|
419
|
+
150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 475.0, 550.0, 625.0, 700.0, 800.0,
|
|
420
|
+
900.0, 1000.0, 1200.0, 1400.0, 1600.0, 1800.0, 2000.0,
|
|
421
|
+
])
|
|
422
|
+
|
|
423
|
+
_KK_SOCRATES_PIP_UM = np.array([
|
|
424
|
+
150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 475.0, 550.0, 625.0, 700.0, 800.0,
|
|
425
|
+
900.0, 1000.0, 1200.0, 1400.0, 1600.0, 1800.0, 2000.0, 2400.0, 2800.0,
|
|
426
|
+
3200.0, 3600.0, 4000.0, 4800.0, 5600.0, 6400.0, 7200.0, 8000.0,
|
|
427
|
+
])
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
_CONFIGS: tuple[ProbeConfig, ...] = (
|
|
431
|
+
# ---- PECAN (sizeDist.m:108-160) --------------------------------------
|
|
432
|
+
ProbeConfig(
|
|
433
|
+
project="PECAN", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
434
|
+
armdst=100.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=1,
|
|
435
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-5,
|
|
436
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=2.5e-7,
|
|
437
|
+
sets_intar_threshold=True, needs_pecan_params=True,
|
|
438
|
+
source_line="sizeDist.m:110-146",
|
|
439
|
+
),
|
|
440
|
+
ProbeConfig(
|
|
441
|
+
project="PECAN", probename="PIP", num_diodes=64, diodesize=0.1,
|
|
442
|
+
armdst=260.0, num_bins=64, **_colon_pair(0.05, 0.1, 64.6 * 0.1), probetype=1,
|
|
443
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-5,
|
|
444
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
445
|
+
sets_intar_threshold=True, needs_pecan_params=True,
|
|
446
|
+
source_line="sizeDist.m:147-176",
|
|
447
|
+
),
|
|
448
|
+
|
|
449
|
+
# ---- GPM (sizeDist.m:177-254) ----------------------------------------
|
|
450
|
+
# NOTE: none of the GPM 2DS/CIP/HVPS cases assign intar_threshold.
|
|
451
|
+
ProbeConfig(
|
|
452
|
+
project="GPM", probename="2DS", num_diodes=128, diodesize=0.010,
|
|
453
|
+
armdst=63.0, num_bins=22, kk=_KK_GPM_2DS_UM / 1000.0, probetype=2,
|
|
454
|
+
tas_max=170.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-6,
|
|
455
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
456
|
+
sets_intar_threshold=False,
|
|
457
|
+
source_line="sizeDist.m:179-196",
|
|
458
|
+
),
|
|
459
|
+
ProbeConfig(
|
|
460
|
+
project="GPM", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
461
|
+
armdst=100.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=1,
|
|
462
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-6,
|
|
463
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=2.5e-7,
|
|
464
|
+
sets_intar_threshold=False,
|
|
465
|
+
source_line="sizeDist.m:197-214",
|
|
466
|
+
),
|
|
467
|
+
ProbeConfig(
|
|
468
|
+
project="GPM", probename="2DC", num_diodes=32, diodesize=0.03,
|
|
469
|
+
armdst=61.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=0,
|
|
470
|
+
tas_max=125.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-5,
|
|
471
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
472
|
+
sets_intar_threshold=True,
|
|
473
|
+
source_line="sizeDist.m:215-236",
|
|
474
|
+
),
|
|
475
|
+
ProbeConfig(
|
|
476
|
+
project="GPM", probename="HVPS", num_diodes=128, diodesize=0.150,
|
|
477
|
+
armdst=161.0, num_bins=28, kk=_KK_HVPS_UM / 1000.0, probetype=2,
|
|
478
|
+
tas_max=170.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-6,
|
|
479
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
480
|
+
sets_intar_threshold=False,
|
|
481
|
+
source_line="sizeDist.m:237-253",
|
|
482
|
+
),
|
|
483
|
+
|
|
484
|
+
# ---- SOCRATES (sizeDist.m:255-338) -----------------------------------
|
|
485
|
+
ProbeConfig(
|
|
486
|
+
project="SOCRATES", probename="2DS", num_diodes=128, diodesize=0.010,
|
|
487
|
+
armdst=63.0, num_bins=21, kk=_KK_SOCRATES_2DS_UM / 1000.0, probetype=2,
|
|
488
|
+
tas_max=170.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-6,
|
|
489
|
+
reaccpt_shatrs=True, reaccpt_d=0.05, reaccpt_max_ia=1e-6,
|
|
490
|
+
sets_intar_threshold=True,
|
|
491
|
+
source_line="sizeDist.m:262-284",
|
|
492
|
+
),
|
|
493
|
+
ProbeConfig(
|
|
494
|
+
project="SOCRATES", probename="Fast2DC", num_diodes=64, diodesize=0.025,
|
|
495
|
+
armdst=61.0, num_bins=17, kk=_KK_SOCRATES_FAST2DC_UM / 1000.0,
|
|
496
|
+
probetype=3, tas_max=300.0, apply_int_arr_thresh=True,
|
|
497
|
+
default_int_arr_thresh=4e-6, reaccpt_shatrs=True, reaccpt_d=0.15,
|
|
498
|
+
reaccpt_max_ia=2.5e-6, sets_intar_threshold=True,
|
|
499
|
+
source_line="sizeDist.m:285-308",
|
|
500
|
+
),
|
|
501
|
+
ProbeConfig(
|
|
502
|
+
project="SOCRATES", probename="PIP", num_diodes=64, diodesize=0.1,
|
|
503
|
+
armdst=260.0, num_bins=27, kk=_KK_SOCRATES_PIP_UM / 1000.0, probetype=1,
|
|
504
|
+
tas_max=200.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-5,
|
|
505
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
506
|
+
sets_intar_threshold=True,
|
|
507
|
+
source_line="sizeDist.m:309-337",
|
|
508
|
+
),
|
|
509
|
+
|
|
510
|
+
# ---- otherwise: any project name not listed above (sizeDist.m:339-511)
|
|
511
|
+
ProbeConfig(
|
|
512
|
+
project="otherwise", probename="HVPS", num_diodes=128, diodesize=0.150,
|
|
513
|
+
armdst=161.0, num_bins=28, kk=_KK_HVPS_UM / 1000.0, probetype=2,
|
|
514
|
+
tas_max=170.0, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
515
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
516
|
+
sets_intar_threshold=True,
|
|
517
|
+
source_line="sizeDist.m:341-364",
|
|
518
|
+
),
|
|
519
|
+
ProbeConfig(
|
|
520
|
+
project="otherwise", probename="2DS", num_diodes=128, diodesize=0.010,
|
|
521
|
+
armdst=63.0, num_bins=128, **_colon_pair(0.005, 0.010, 128.6 * 0.010),
|
|
522
|
+
probetype=2, tas_max=170.0, apply_int_arr_thresh=False,
|
|
523
|
+
default_int_arr_thresh=4e-6, reaccpt_shatrs=False, reaccpt_d=0.5,
|
|
524
|
+
reaccpt_max_ia=1e-6, sets_intar_threshold=True,
|
|
525
|
+
source_line="sizeDist.m:365-390",
|
|
526
|
+
),
|
|
527
|
+
ProbeConfig(
|
|
528
|
+
project="otherwise", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
529
|
+
armdst=100.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=1,
|
|
530
|
+
tas_max=200.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-5,
|
|
531
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
532
|
+
sets_intar_threshold=True,
|
|
533
|
+
source_line="sizeDist.m:391-414",
|
|
534
|
+
),
|
|
535
|
+
ProbeConfig(
|
|
536
|
+
project="otherwise", probename="PIP", num_diodes=64, diodesize=0.1,
|
|
537
|
+
armdst=260.0, num_bins=64, **_colon_pair(0.05, 0.1, 64.6 * 0.1), probetype=1,
|
|
538
|
+
tas_max=200.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-5,
|
|
539
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
540
|
+
sets_intar_threshold=True,
|
|
541
|
+
source_line="sizeDist.m:415-440",
|
|
542
|
+
),
|
|
543
|
+
ProbeConfig(
|
|
544
|
+
project="otherwise", probename="2DC", num_diodes=32, diodesize=0.03,
|
|
545
|
+
armdst=61.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=0,
|
|
546
|
+
tas_max=125.0, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
547
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
548
|
+
sets_intar_threshold=True,
|
|
549
|
+
source_line="sizeDist.m:441-464",
|
|
550
|
+
),
|
|
551
|
+
# tasMax is NEVER assigned in this case -- preserved as an error.
|
|
552
|
+
ProbeConfig(
|
|
553
|
+
project="otherwise", probename="2DP", num_diodes=32, diodesize=0.200,
|
|
554
|
+
armdst=260.0, num_bins=19, kk=_KK19_UM * 8.0 / 1000.0, probetype=0,
|
|
555
|
+
tas_max=None, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
556
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
557
|
+
sets_intar_threshold=True,
|
|
558
|
+
source_line="sizeDist.m:465-489",
|
|
559
|
+
),
|
|
560
|
+
ProbeConfig(
|
|
561
|
+
project="otherwise", probename="F2DC", num_diodes=64, diodesize=0.025,
|
|
562
|
+
armdst=61.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=3,
|
|
563
|
+
tas_max=300.0, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
564
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
565
|
+
sets_intar_threshold=True,
|
|
566
|
+
source_line="sizeDist.m:490-510",
|
|
567
|
+
),
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
SIZEDIST_CONFIG: MappingProxyType[tuple[str, str], ProbeConfig] = MappingProxyType({
|
|
572
|
+
(cfg.project, cfg.probename): cfg for cfg in _CONFIGS
|
|
573
|
+
})
|
|
574
|
+
"""The **stock v3.1.4** table. Not what ORACLES ran -- see
|
|
575
|
+
:data:`SIZEDIST_CONFIG_PRODUCTION`."""
|
|
576
|
+
|
|
577
|
+
PROJECTS: tuple[str, ...] = ("PECAN", "GPM", "SOCRATES")
|
|
578
|
+
"""Projects with their own switch case. Anything else falls to ``otherwise``."""
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
# --------------------------------------------------------------------------
|
|
582
|
+
# the ORACLES-variant sizeDist.m:92-395 -- the ORACLES PRODUCTION table
|
|
583
|
+
# --------------------------------------------------------------------------
|
|
584
|
+
#
|
|
585
|
+
# WHY THERE ARE TWO TABLES. The block above was transcribed at S0 from stock
|
|
586
|
+
# v3.1.4. S4 established that the
|
|
587
|
+
# ORACLES products were made by the ORACLES-variant `sizeDist.m`, a different lineage
|
|
588
|
+
# whose project/probe switch is NOT the same file's -- 12 cases against stock's
|
|
589
|
+
# 16, and four of the shared cases carry different numbers. Two of those
|
|
590
|
+
# differences decide output on the ORACLES 2D-S chain:
|
|
591
|
+
#
|
|
592
|
+
# applyIntArrThresh 0 -> 1 (:268) gates the WHOLE shattering block
|
|
593
|
+
# defaultIntArrThresh 4e-6 -> 6e-6 (:269) "Changed from 1e-6 to 6e-6 for ORACLES"
|
|
594
|
+
#
|
|
595
|
+
# Running the port against the stock row would skip shatter identification
|
|
596
|
+
# entirely and silently produce a different size distribution. This is the same
|
|
597
|
+
# shape of error four times over now -- S3 ported the wrong `imgProc_sm`, the reject port
|
|
598
|
+
# checked the reject constants in the wrong tree, S4's design found the `.5`
|
|
599
|
+
# area-ratio threshold -- so the answer is a SECOND TABLE, never a patch to the
|
|
600
|
+
# first. `tests/test_reference_data.py` already said so in 2026-08-19:
|
|
601
|
+
# "the divergence is real, and it belongs in a FidelityProfile, not in a patched
|
|
602
|
+
# shared table."
|
|
603
|
+
#
|
|
604
|
+
# The full diff of the two switches, measured rather than argued:
|
|
605
|
+
#
|
|
606
|
+
# GPM/2DC present in stock, ABSENT in production
|
|
607
|
+
# SOCRATES/* three cases in stock, the whole branch ABSENT in production
|
|
608
|
+
# otherwise/HVPS 28 hand-written bins -> 70 uniform 0.15 mm (reproduces the
|
|
609
|
+
# archived ORACLES HVPS ladder, which is how the file was
|
|
610
|
+
# identified in the first place); applyIntArrThresh 0 -> 1;
|
|
611
|
+
# defaultIntArrThresh 4e-6 -> 1e-6
|
|
612
|
+
# otherwise/2DS applyIntArrThresh 0 -> 1; defaultIntArrThresh 4e-6 -> 6e-6
|
|
613
|
+
# otherwise/CIP 19 hand-written bins -> 64 uniform 0.025 mm;
|
|
614
|
+
# applyIntArrThresh 0 -> 1; defaultIntArrThresh 1e-5 -> 1e-6
|
|
615
|
+
# otherwise/F2DC probetype 3 -> 0, and **tasMax is never assigned** -- so F2DC
|
|
616
|
+
# joins 2DP as a case that kills MATLAB at :968. Stock had
|
|
617
|
+
# repaired it (Joe Finlon, 01/09/17); this lineage predates that.
|
|
618
|
+
#
|
|
619
|
+
# Everything else is whitespace.
|
|
620
|
+
|
|
621
|
+
_CONFIGS_PRODUCTION: tuple[ProbeConfig, ...] = (
|
|
622
|
+
# ---- PECAN (ORACLES-variant sizeDist.m:93-159) -- identical to stock ----
|
|
623
|
+
ProbeConfig(
|
|
624
|
+
project="PECAN", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
625
|
+
armdst=100.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=1,
|
|
626
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-5,
|
|
627
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=2.5e-7,
|
|
628
|
+
sets_intar_threshold=True, needs_pecan_params=True,
|
|
629
|
+
source_line="sizeDist.m (campaign-configured copy):95-127",
|
|
630
|
+
),
|
|
631
|
+
ProbeConfig(
|
|
632
|
+
project="PECAN", probename="PIP", num_diodes=64, diodesize=0.1,
|
|
633
|
+
armdst=260.0, num_bins=64, **_colon_pair(0.05, 0.1, 64.6 * 0.1), probetype=1,
|
|
634
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-5,
|
|
635
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
636
|
+
sets_intar_threshold=True, needs_pecan_params=True,
|
|
637
|
+
source_line="sizeDist.m (campaign-configured copy):128-159",
|
|
638
|
+
),
|
|
639
|
+
|
|
640
|
+
# ---- GPM (ORACLES-variant sizeDist.m:160-222) -- NO 2DC case here
|
|
641
|
+
ProbeConfig(
|
|
642
|
+
project="GPM", probename="2DS", num_diodes=128, diodesize=0.010,
|
|
643
|
+
armdst=63.0, num_bins=22, kk=_KK_GPM_2DS_UM / 1000.0, probetype=2,
|
|
644
|
+
tas_max=170.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-6,
|
|
645
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
646
|
+
sets_intar_threshold=False,
|
|
647
|
+
source_line="sizeDist.m (campaign-configured copy):162-181",
|
|
648
|
+
),
|
|
649
|
+
ProbeConfig(
|
|
650
|
+
project="GPM", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
651
|
+
armdst=100.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=1,
|
|
652
|
+
tas_max=200.0, apply_int_arr_thresh=True, default_int_arr_thresh=1e-6,
|
|
653
|
+
reaccpt_shatrs=True, reaccpt_d=0.5, reaccpt_max_ia=2.5e-7,
|
|
654
|
+
sets_intar_threshold=False,
|
|
655
|
+
source_line="sizeDist.m (campaign-configured copy):182-199",
|
|
656
|
+
),
|
|
657
|
+
ProbeConfig(
|
|
658
|
+
project="GPM", probename="HVPS", num_diodes=128, diodesize=0.150,
|
|
659
|
+
armdst=161.0, num_bins=28, kk=_KK_HVPS_UM / 1000.0, probetype=2,
|
|
660
|
+
tas_max=170.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-6,
|
|
661
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
662
|
+
sets_intar_threshold=False,
|
|
663
|
+
source_line="sizeDist.m (campaign-configured copy):200-222",
|
|
664
|
+
),
|
|
665
|
+
|
|
666
|
+
# ---- otherwise (ORACLES-variant sizeDist.m:223-394) -------------------
|
|
667
|
+
# This is the branch ORACLES lands in: 'ORACLES' is not one of the named
|
|
668
|
+
# projects, so `switch projectname` falls to `otherwise` at :223.
|
|
669
|
+
ProbeConfig(
|
|
670
|
+
project="otherwise", probename="HVPS", num_diodes=128, diodesize=0.150,
|
|
671
|
+
armdst=161.0, num_bins=70, **_colon_pair(0.075, 0.15, 70.5 * 0.15),
|
|
672
|
+
probetype=2, tas_max=170.0, apply_int_arr_thresh=True,
|
|
673
|
+
default_int_arr_thresh=1e-6, reaccpt_shatrs=False, reaccpt_d=0.5,
|
|
674
|
+
reaccpt_max_ia=1e-6, sets_intar_threshold=True,
|
|
675
|
+
source_line="sizeDist.m (campaign-configured copy):225-249",
|
|
676
|
+
),
|
|
677
|
+
ProbeConfig(
|
|
678
|
+
project="otherwise", probename="2DS", num_diodes=128, diodesize=0.010,
|
|
679
|
+
armdst=63.0, num_bins=128, **_colon_pair(0.005, 0.010, 128.6 * 0.010),
|
|
680
|
+
probetype=2, tas_max=170.0, apply_int_arr_thresh=True,
|
|
681
|
+
default_int_arr_thresh=6e-6, reaccpt_shatrs=False, reaccpt_d=0.5,
|
|
682
|
+
reaccpt_max_ia=1e-6, sets_intar_threshold=True,
|
|
683
|
+
source_line="sizeDist.m (campaign-configured copy):250-274",
|
|
684
|
+
),
|
|
685
|
+
ProbeConfig(
|
|
686
|
+
project="otherwise", probename="CIP", num_diodes=64, diodesize=0.025,
|
|
687
|
+
armdst=100.0, num_bins=64, **_colon_pair(0.0125, 0.025, 64.5 * 0.025),
|
|
688
|
+
probetype=1, tas_max=200.0, apply_int_arr_thresh=True,
|
|
689
|
+
default_int_arr_thresh=1e-6, reaccpt_shatrs=False, reaccpt_d=0.5,
|
|
690
|
+
reaccpt_max_ia=1e-6, sets_intar_threshold=True,
|
|
691
|
+
source_line="sizeDist.m (campaign-configured copy):276-298",
|
|
692
|
+
),
|
|
693
|
+
ProbeConfig(
|
|
694
|
+
project="otherwise", probename="PIP", num_diodes=64, diodesize=0.1,
|
|
695
|
+
armdst=260.0, num_bins=64, **_colon_pair(0.05, 0.1, 64.6 * 0.1), probetype=1,
|
|
696
|
+
tas_max=200.0, apply_int_arr_thresh=False, default_int_arr_thresh=1e-5,
|
|
697
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
698
|
+
sets_intar_threshold=True,
|
|
699
|
+
source_line="sizeDist.m (campaign-configured copy):300-322",
|
|
700
|
+
),
|
|
701
|
+
ProbeConfig(
|
|
702
|
+
project="otherwise", probename="2DC", num_diodes=32, diodesize=0.03,
|
|
703
|
+
armdst=61.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=0,
|
|
704
|
+
tas_max=125.0, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
705
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
706
|
+
sets_intar_threshold=True,
|
|
707
|
+
source_line="sizeDist.m (campaign-configured copy):325-347",
|
|
708
|
+
),
|
|
709
|
+
# tasMax is NEVER assigned in this case -- preserved as an error.
|
|
710
|
+
ProbeConfig(
|
|
711
|
+
project="otherwise", probename="2DP", num_diodes=32, diodesize=0.200,
|
|
712
|
+
armdst=260.0, num_bins=19, kk=_KK19_UM * 8.0 / 1000.0, probetype=0,
|
|
713
|
+
tas_max=None, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
714
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
715
|
+
sets_intar_threshold=True,
|
|
716
|
+
source_line="sizeDist.m (campaign-configured copy):349-370",
|
|
717
|
+
),
|
|
718
|
+
# ...and neither is it here, which stock had already fixed.
|
|
719
|
+
ProbeConfig(
|
|
720
|
+
project="otherwise", probename="F2DC", num_diodes=64, diodesize=0.025,
|
|
721
|
+
armdst=61.0, num_bins=19, kk=_KK19_UM / 1000.0, probetype=0,
|
|
722
|
+
tas_max=None, apply_int_arr_thresh=False, default_int_arr_thresh=4e-6,
|
|
723
|
+
reaccpt_shatrs=False, reaccpt_d=0.5, reaccpt_max_ia=1e-6,
|
|
724
|
+
sets_intar_threshold=True,
|
|
725
|
+
source_line="sizeDist.m (campaign-configured copy):372-393",
|
|
726
|
+
),
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
SIZEDIST_CONFIG_PRODUCTION: MappingProxyType[tuple[str, str], ProbeConfig] = (
|
|
730
|
+
MappingProxyType({
|
|
731
|
+
(cfg.project, cfg.probename): cfg for cfg in _CONFIGS_PRODUCTION
|
|
732
|
+
})
|
|
733
|
+
)
|
|
734
|
+
"""The **ORACLES production** table, from the ORACLES-variant ``sizeDist.m``."""
|
|
735
|
+
|
|
736
|
+
PROJECTS_PRODUCTION: tuple[str, ...] = ("PECAN", "GPM")
|
|
737
|
+
"""Production has no ``SOCRATES`` case, so SOCRATES falls to ``otherwise`` there."""
|
|
738
|
+
|
|
739
|
+
SIZEDIST_TREES: MappingProxyType[str, tuple[MappingProxyType, tuple[str, ...]]] = (
|
|
740
|
+
MappingProxyType({
|
|
741
|
+
"stock": (SIZEDIST_CONFIG, PROJECTS),
|
|
742
|
+
"production": (SIZEDIST_CONFIG_PRODUCTION, PROJECTS_PRODUCTION),
|
|
743
|
+
})
|
|
744
|
+
)
|
|
745
|
+
"""The two switch tables, by tree name. ``sizedist_config`` selects between them."""
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
DIODESIZE_DISAGREEMENTS: MappingProxyType[str, tuple[float, float]] = MappingProxyType({
|
|
749
|
+
# probe: (imgProc_sm.m ds, sizeDist.m diodesize)
|
|
750
|
+
"2DC": (0.025, 0.03),
|
|
751
|
+
})
|
|
752
|
+
"""Probes whose two switches disagree on diode size. Both values are preserved.
|
|
753
|
+
|
|
754
|
+
``imgProc_sm.m:123`` sizes 2DC images with 0.025 mm; ``sizeDist.m:186,344,443``
|
|
755
|
+
bins them with 0.030 mm. Whichever is right, a faithful port reproduces both, so
|
|
756
|
+
the modules must each read their own table rather than a merged one.
|
|
757
|
+
"""
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
# --------------------------------------------------------------------------
|
|
761
|
+
# Lookup helpers
|
|
762
|
+
# --------------------------------------------------------------------------
|
|
763
|
+
|
|
764
|
+
def imgproc_config(probename: str) -> ImgProcConfig:
|
|
765
|
+
"""Look up the ``imgProc_sm.m`` probe case.
|
|
766
|
+
|
|
767
|
+
Unlike ``sizeDist.m``, ``imgProc_sm.m:117`` has **no** ``otherwise`` branch:
|
|
768
|
+
an unrecognized probe leaves every variable unassigned and MATLAB fails at
|
|
769
|
+
``imgProc_sm.m:195``. Preserved as an error.
|
|
770
|
+
"""
|
|
771
|
+
try:
|
|
772
|
+
return IMGPROC_CONFIG[probename]
|
|
773
|
+
except KeyError:
|
|
774
|
+
raise MatlabUndefinedVariable(
|
|
775
|
+
f"imgProc_sm.m:117 has no case for probename={probename!r} and no "
|
|
776
|
+
"otherwise branch; MATLAB fails at imgProc_sm.m:195 (diodenum unset). "
|
|
777
|
+
f"Known probes: {sorted(IMGPROC_CONFIG)}"
|
|
778
|
+
) from None
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
def sizedist_config(projectname: str, probename: str,
|
|
782
|
+
tree: str = "stock") -> ProbeConfig:
|
|
783
|
+
"""Look up the ``sizeDist.m`` (project, probe) case in one of the two trees.
|
|
784
|
+
|
|
785
|
+
An unknown *project* falls through to the ``otherwise`` branch, exactly as
|
|
786
|
+
``sizeDist.m:339`` (stock) / ``:223`` (production) does. An unknown *probe*
|
|
787
|
+
within a branch matches no inner case, leaving everything unassigned --
|
|
788
|
+
preserved as an error.
|
|
789
|
+
|
|
790
|
+
``tree`` selects the switch table: ``"stock"`` (v3.1.4) or ``"production"``
|
|
791
|
+
(the campaign-configured ``sizeDist.m``, the file that made the archived products).
|
|
792
|
+
The default is ``"stock"`` because every caller written before the size-distribution
|
|
793
|
+
stage was ported meant
|
|
794
|
+
stock and their tests assert stock numbers -- but a *pipeline* must name the
|
|
795
|
+
tree, so the earlier translation's ``sizedist.run`` takes ``tree`` with no default at
|
|
796
|
+
all. Getting this wrong is not a rounding difference: production switches
|
|
797
|
+
shattering identification **on** for the 2D-S and stock does not.
|
|
798
|
+
"""
|
|
799
|
+
try:
|
|
800
|
+
table, projects = SIZEDIST_TREES[tree]
|
|
801
|
+
except KeyError:
|
|
802
|
+
raise ValueError(
|
|
803
|
+
f"unknown sizeDist tree {tree!r}; known: {sorted(SIZEDIST_TREES)}"
|
|
804
|
+
) from None
|
|
805
|
+
key_project = projectname if projectname in projects else "otherwise"
|
|
806
|
+
try:
|
|
807
|
+
return table[(key_project, probename)]
|
|
808
|
+
except KeyError:
|
|
809
|
+
available = sorted(p for (proj, p) in table if proj == key_project)
|
|
810
|
+
raise MatlabUndefinedVariable(
|
|
811
|
+
f"sizeDist.m ({tree}) has no case for probename={probename!r} under "
|
|
812
|
+
f"project branch {key_project!r} (from projectname={projectname!r}); "
|
|
813
|
+
"MATLAB leaves num_diodes/diodesize/kk unassigned and fails at "
|
|
814
|
+
f"sizeDist.m:522. Available probes in that branch: {available}"
|
|
815
|
+
) from None
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
def bin_edges(projectname: str, probename: str) -> np.ndarray:
|
|
819
|
+
"""``kk`` in millimetres for a run -- ``num_bins + 1`` edges."""
|
|
820
|
+
return sizedist_config(projectname, probename).kk
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
def bin_width(projectname: str, probename: str) -> np.ndarray:
|
|
824
|
+
"""``binwidth = diff(kk)`` -- ``sizeDist.m:523``."""
|
|
825
|
+
return sizedist_config(projectname, probename).binwidth
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
def resolution_um(projectname: str, probename: str) -> float:
|
|
829
|
+
"""``res = diodesize*1000`` -- ``sizeDist.m:522``."""
|
|
830
|
+
return sizedist_config(projectname, probename).res
|