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,642 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""The self-contained pieces of v3.5's ``sizeDist.m``.
|
|
3
|
+
|
|
4
|
+
Three things, none of which needs the netCDF input the whole driver needs:
|
|
5
|
+
|
|
6
|
+
1. **The per-campaign / per-probe defaults** set by the ``switch projectname``
|
|
7
|
+
block (v3.5 ``sizeDist.m:139-642``; v3.1.4 ``:107-511``): ``num_bins``, the
|
|
8
|
+
bin-edge vector ``kk``, and the ten other per-probe constants assigned
|
|
9
|
+
alongside them. Both releases' tables are held here so the diff between
|
|
10
|
+
them is a computed fact (:func:`diff_tables`), not a sentence.
|
|
11
|
+
2. **The ``varargin`` block** (``:98-110``), which is where the new
|
|
12
|
+
``iaThreshType == 3`` (1-Hz threshold) mode enters, and the per-second
|
|
13
|
+
shatter-flagging / reacceptance block it drives (``:1383-1428``).
|
|
14
|
+
3. **``iNewHabit`` detection** (``:117-123``): the switch that the V1
|
|
15
|
+
``single_area`` / ``single_mass`` port consumes.
|
|
16
|
+
|
|
17
|
+
Every table and every branch below is asserted against a real Octave run of the
|
|
18
|
+
vendored source's own lines (``octave_oracle/run_v35_sizedist_tables_bank.py``,
|
|
19
|
+
fixture ``tests/data/v35_sizedist_tables_oracle.json``) in
|
|
20
|
+
``tests/test_v35_sizedist_tables.py``. **Oracle layer 2 only** -- no archived
|
|
21
|
+
product was ever produced by v3.5, so nothing here has layer-1 validation.
|
|
22
|
+
|
|
23
|
+
Where the two releases differ, the difference is a **science change** made by
|
|
24
|
+
the upstream authors, not a defect; neither side is "fixed" here. The largest:
|
|
25
|
+
the ``otherwise/2DS`` case -- the one an ORACLES run resolves to -- carries the
|
|
26
|
+
128-bin 10 um ladder in v3.1.4 and the **HVPS 28-bin 0.2-30 mm table** in v3.5.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
from collections.abc import Sequence
|
|
32
|
+
from dataclasses import dataclass
|
|
33
|
+
from typing import Any
|
|
34
|
+
|
|
35
|
+
import numpy as np
|
|
36
|
+
|
|
37
|
+
from arrayprobe_uiops.constants import _colon
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"BinLadder",
|
|
41
|
+
"BinLiteral",
|
|
42
|
+
"ProbeDefaults",
|
|
43
|
+
"UndefinedProbeCase",
|
|
44
|
+
"V314_TABLES",
|
|
45
|
+
"V35_TABLES",
|
|
46
|
+
"V35_CAMPAIGNS",
|
|
47
|
+
"V314_CAMPAIGNS",
|
|
48
|
+
"probe_defaults",
|
|
49
|
+
"diff_tables",
|
|
50
|
+
"InterarrivalThresholdSpec",
|
|
51
|
+
"select_interarrival_threshold",
|
|
52
|
+
"flag_shattered_1hz",
|
|
53
|
+
"reaccept_shattered_1hz",
|
|
54
|
+
"HABIT_ATTR_OLD",
|
|
55
|
+
"HABIT_ATTR_NEW",
|
|
56
|
+
"HABIT_SCHEME_SENTINEL_VARIABLE",
|
|
57
|
+
"detect_habit_scheme",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ---------------------------------------------------------------------------
|
|
62
|
+
# 1. The per-campaign / per-probe defaults
|
|
63
|
+
# ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True)
|
|
67
|
+
class BinLadder:
|
|
68
|
+
"""``kk = diodesize/2:diodesize:(num_bins+0.6)*diodesize`` -- a colon-built ladder.
|
|
69
|
+
|
|
70
|
+
Source: the ``switch projectname`` block of ``sizeDist.m:139-642`` (UIOOPS v3.5; v3.1.4
|
|
71
|
+
``:107-511``).
|
|
72
|
+
|
|
73
|
+
Built with :func:`arrayprobe.constants._colon`, which knows that MATLAB
|
|
74
|
+
fills a colon range from both ends and Octave does not (they differ by one
|
|
75
|
+
ULP in the upper half). ``octave_colon=True`` exists only so the Octave
|
|
76
|
+
fixture can be compared bit-for-bit; the port targets MATLAB.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def edges(self, diodesize: float, num_bins: int, *, octave_colon: bool = False) -> np.ndarray:
|
|
80
|
+
return _colon(
|
|
81
|
+
diodesize / 2, diodesize, (num_bins + 0.6) * diodesize, matlab=not octave_colon
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass(frozen=True)
|
|
86
|
+
class BinLiteral:
|
|
87
|
+
"""``kk = [microns ...] * times / 1000`` -- a literal table, in the source's
|
|
88
|
+
own operation order (``*8`` then ``/1000`` for 2DP; ``/1000`` alone otherwise).
|
|
89
|
+
|
|
90
|
+
Source: the ``switch projectname`` block of ``sizeDist.m:139-642`` (UIOOPS v3.5; v3.1.4
|
|
91
|
+
``:107-511``)."""
|
|
92
|
+
|
|
93
|
+
microns: tuple[float, ...]
|
|
94
|
+
times: float = 1.0
|
|
95
|
+
|
|
96
|
+
def edges(self, diodesize: float, num_bins: int, *, octave_colon: bool = False) -> np.ndarray:
|
|
97
|
+
arr = np.asarray(self.microns, dtype=np.float64)
|
|
98
|
+
if self.times != 1.0:
|
|
99
|
+
arr = arr * self.times
|
|
100
|
+
return arr / 1000
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass(frozen=True)
|
|
104
|
+
class ProbeDefaults:
|
|
105
|
+
"""Everything one ``case`` of the inner ``switch probename`` assigns.
|
|
106
|
+
|
|
107
|
+
Source: the ``switch projectname`` block of ``sizeDist.m:139-642`` (UIOOPS v3.5; v3.1.4
|
|
108
|
+
``:107-511``).
|
|
109
|
+
|
|
110
|
+
``tasMax`` is ``None`` for 2DP, which assigns none in either release (the
|
|
111
|
+
earlier translation already ships that crash). ``intar_threshold_defaulted`` records
|
|
112
|
+
whether the case runs ``intar_threshold = ones(size(tas_time))*defaultIntArrThresh``;
|
|
113
|
+
``calls_getPECANparams`` records the PECAN cases' call to a function that
|
|
114
|
+
exists in **neither** vendored tree (measured: both releases error there).
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
num_diodes: int
|
|
118
|
+
diodesize: float
|
|
119
|
+
armdst: float
|
|
120
|
+
num_bins: int
|
|
121
|
+
bins: BinLadder | BinLiteral
|
|
122
|
+
probetype: int
|
|
123
|
+
tasMax: float | None
|
|
124
|
+
applyIntArrThresh: int
|
|
125
|
+
defaultIntArrThresh: float
|
|
126
|
+
reaccptShatrs: int
|
|
127
|
+
reaccptD: float
|
|
128
|
+
reaccptMaxIA: float
|
|
129
|
+
intar_threshold_defaulted: bool
|
|
130
|
+
calls_getPECANparams: bool = False
|
|
131
|
+
|
|
132
|
+
def kk(self, *, octave_colon: bool = False) -> np.ndarray:
|
|
133
|
+
return self.bins.edges(self.diodesize, self.num_bins, octave_colon=octave_colon)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class UndefinedProbeCase(LookupError):
|
|
137
|
+
"""The inner ``switch probename`` has no ``otherwise``: an unlisted probe
|
|
138
|
+
leaves ``num_bins``/``kk`` (and everything else) unassigned, and the driver
|
|
139
|
+
fails later on the first use. The port refuses up front rather than invent
|
|
140
|
+
a table.
|
|
141
|
+
|
|
142
|
+
Source: the ``switch projectname`` block of ``sizeDist.m:139-642`` (UIOOPS v3.5; v3.1.4
|
|
143
|
+
``:107-511``)."""
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
_LADDER = BinLadder()
|
|
147
|
+
|
|
148
|
+
# Shared literal tables (microns), named for where they first appear.
|
|
149
|
+
_CIP19 = BinLiteral(
|
|
150
|
+
(
|
|
151
|
+
50.0,
|
|
152
|
+
100.0,
|
|
153
|
+
150.0,
|
|
154
|
+
200.0,
|
|
155
|
+
250.0,
|
|
156
|
+
300.0,
|
|
157
|
+
350.0,
|
|
158
|
+
400.0,
|
|
159
|
+
475.0,
|
|
160
|
+
550.0,
|
|
161
|
+
625.0,
|
|
162
|
+
700.0,
|
|
163
|
+
800.0,
|
|
164
|
+
900.0,
|
|
165
|
+
1000.0,
|
|
166
|
+
1200.0,
|
|
167
|
+
1400.0,
|
|
168
|
+
1600.0,
|
|
169
|
+
1800.0,
|
|
170
|
+
2000.0,
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
_2DP19 = BinLiteral(_CIP19.microns, times=8.0)
|
|
174
|
+
_HVPS28 = BinLiteral(
|
|
175
|
+
(
|
|
176
|
+
200.0,
|
|
177
|
+
400.0,
|
|
178
|
+
600.0,
|
|
179
|
+
800.0,
|
|
180
|
+
1000.0,
|
|
181
|
+
1200.0,
|
|
182
|
+
1400.0,
|
|
183
|
+
1600.0,
|
|
184
|
+
1800.0,
|
|
185
|
+
2200.0,
|
|
186
|
+
2600.0,
|
|
187
|
+
3000.0,
|
|
188
|
+
3400.0,
|
|
189
|
+
3800.0,
|
|
190
|
+
4200.0,
|
|
191
|
+
4600.0,
|
|
192
|
+
5000.0,
|
|
193
|
+
6000.0,
|
|
194
|
+
7000.0,
|
|
195
|
+
8000.0,
|
|
196
|
+
9000.0,
|
|
197
|
+
10000.0,
|
|
198
|
+
12000.0,
|
|
199
|
+
14000.0,
|
|
200
|
+
16000.0,
|
|
201
|
+
18000.0,
|
|
202
|
+
20000.0,
|
|
203
|
+
25000.0,
|
|
204
|
+
30000.0,
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
_GPM_2DS22 = BinLiteral(
|
|
208
|
+
(
|
|
209
|
+
40.0,
|
|
210
|
+
60.0,
|
|
211
|
+
80.0,
|
|
212
|
+
100.0,
|
|
213
|
+
125.0,
|
|
214
|
+
150.0,
|
|
215
|
+
200.0,
|
|
216
|
+
250.0,
|
|
217
|
+
300.0,
|
|
218
|
+
350.0,
|
|
219
|
+
400.0,
|
|
220
|
+
475.0,
|
|
221
|
+
550.0,
|
|
222
|
+
625.0,
|
|
223
|
+
700.0,
|
|
224
|
+
800.0,
|
|
225
|
+
900.0,
|
|
226
|
+
1000.0,
|
|
227
|
+
1200.0,
|
|
228
|
+
1400.0,
|
|
229
|
+
1600.0,
|
|
230
|
+
1800.0,
|
|
231
|
+
2000.0,
|
|
232
|
+
)
|
|
233
|
+
)
|
|
234
|
+
_SOC_2DS21 = BinLiteral(
|
|
235
|
+
(
|
|
236
|
+
50.0,
|
|
237
|
+
75.0,
|
|
238
|
+
100.0,
|
|
239
|
+
125.0,
|
|
240
|
+
150.0,
|
|
241
|
+
200.0,
|
|
242
|
+
250.0,
|
|
243
|
+
300.0,
|
|
244
|
+
350.0,
|
|
245
|
+
400.0,
|
|
246
|
+
475.0,
|
|
247
|
+
550.0,
|
|
248
|
+
625.0,
|
|
249
|
+
700.0,
|
|
250
|
+
800.0,
|
|
251
|
+
900.0,
|
|
252
|
+
1000.0,
|
|
253
|
+
1200.0,
|
|
254
|
+
1400.0,
|
|
255
|
+
1600.0,
|
|
256
|
+
1800.0,
|
|
257
|
+
2000.0,
|
|
258
|
+
)
|
|
259
|
+
)
|
|
260
|
+
_SOC_F2DC17 = BinLiteral(
|
|
261
|
+
(
|
|
262
|
+
150.0,
|
|
263
|
+
200.0,
|
|
264
|
+
250.0,
|
|
265
|
+
300.0,
|
|
266
|
+
350.0,
|
|
267
|
+
400.0,
|
|
268
|
+
475.0,
|
|
269
|
+
550.0,
|
|
270
|
+
625.0,
|
|
271
|
+
700.0,
|
|
272
|
+
800.0,
|
|
273
|
+
900.0,
|
|
274
|
+
1000.0,
|
|
275
|
+
1200.0,
|
|
276
|
+
1400.0,
|
|
277
|
+
1600.0,
|
|
278
|
+
1800.0,
|
|
279
|
+
2000.0,
|
|
280
|
+
)
|
|
281
|
+
)
|
|
282
|
+
_SOC_PIP27 = BinLiteral(
|
|
283
|
+
(
|
|
284
|
+
150.0,
|
|
285
|
+
200.0,
|
|
286
|
+
250.0,
|
|
287
|
+
300.0,
|
|
288
|
+
350.0,
|
|
289
|
+
400.0,
|
|
290
|
+
475.0,
|
|
291
|
+
550.0,
|
|
292
|
+
625.0,
|
|
293
|
+
700.0,
|
|
294
|
+
800.0,
|
|
295
|
+
900.0,
|
|
296
|
+
1000.0,
|
|
297
|
+
1200.0,
|
|
298
|
+
1400.0,
|
|
299
|
+
1600.0,
|
|
300
|
+
1800.0,
|
|
301
|
+
2000.0,
|
|
302
|
+
2400.0,
|
|
303
|
+
2800.0,
|
|
304
|
+
3200.0,
|
|
305
|
+
3600.0,
|
|
306
|
+
4000.0,
|
|
307
|
+
4800.0,
|
|
308
|
+
5600.0,
|
|
309
|
+
6400.0,
|
|
310
|
+
7200.0,
|
|
311
|
+
8000.0,
|
|
312
|
+
)
|
|
313
|
+
)
|
|
314
|
+
_IMP_2DS29 = BinLiteral(
|
|
315
|
+
(
|
|
316
|
+
20.0,
|
|
317
|
+
40.0,
|
|
318
|
+
60.0,
|
|
319
|
+
80.0,
|
|
320
|
+
100.0,
|
|
321
|
+
125.0,
|
|
322
|
+
150.0,
|
|
323
|
+
200.0,
|
|
324
|
+
250.0,
|
|
325
|
+
300.0,
|
|
326
|
+
350.0,
|
|
327
|
+
400.0,
|
|
328
|
+
475.0,
|
|
329
|
+
550.0,
|
|
330
|
+
625.0,
|
|
331
|
+
700.0,
|
|
332
|
+
800.0,
|
|
333
|
+
900.0,
|
|
334
|
+
1000.0,
|
|
335
|
+
1200.0,
|
|
336
|
+
1400.0,
|
|
337
|
+
1600.0,
|
|
338
|
+
1800.0,
|
|
339
|
+
2000.0,
|
|
340
|
+
2200.0,
|
|
341
|
+
2400.0,
|
|
342
|
+
2600.0,
|
|
343
|
+
2800.0,
|
|
344
|
+
3000.0,
|
|
345
|
+
3200.0,
|
|
346
|
+
)
|
|
347
|
+
)
|
|
348
|
+
_IMP_3VH25 = BinLiteral(
|
|
349
|
+
(
|
|
350
|
+
100.0,
|
|
351
|
+
125.0,
|
|
352
|
+
150.0,
|
|
353
|
+
200.0,
|
|
354
|
+
250.0,
|
|
355
|
+
300.0,
|
|
356
|
+
350.0,
|
|
357
|
+
400.0,
|
|
358
|
+
475.0,
|
|
359
|
+
550.0,
|
|
360
|
+
625.0,
|
|
361
|
+
700.0,
|
|
362
|
+
800.0,
|
|
363
|
+
900.0,
|
|
364
|
+
1000.0,
|
|
365
|
+
1200.0,
|
|
366
|
+
1400.0,
|
|
367
|
+
1600.0,
|
|
368
|
+
1800.0,
|
|
369
|
+
2000.0,
|
|
370
|
+
2200.0,
|
|
371
|
+
2400.0,
|
|
372
|
+
2600.0,
|
|
373
|
+
2800.0,
|
|
374
|
+
3000.0,
|
|
375
|
+
3200.0,
|
|
376
|
+
)
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _pd(nd: Any, ds: Any, arm: Any, nb: Any, bins: Any, pt: Any, tasmax: Any, a: Any, d: Any,
|
|
381
|
+
rs: Any, rd: Any, rmia: Any, itdef: Any, pecan: Any = False) -> ProbeDefaults:
|
|
382
|
+
return ProbeDefaults(nd, ds, arm, nb, bins, pt, tasmax, a, d, rs, rd, rmia, itdef, pecan)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
# The ``otherwise`` branch, keyed by the sentinel campaign name ``None``.
|
|
386
|
+
OTHERWISE = None
|
|
387
|
+
|
|
388
|
+
#: v3.1.4 ``sizeDist.m:107-511`` (measured under Octave, see module docstring).
|
|
389
|
+
V314_TABLES: dict[str | None, dict[str, ProbeDefaults]] = {
|
|
390
|
+
"PECAN": {
|
|
391
|
+
"CIP": _pd(
|
|
392
|
+
64, 0.025, 100.0, 19, _CIP19, 1, 200.0, 1, 1e-5, 1, 0.5, 2.5e-7, False, pecan=True
|
|
393
|
+
),
|
|
394
|
+
"PIP": _pd(64, 0.1, 260.0, 64, _LADDER, 1, 200.0, 1, 1e-5, 1, 0.5, 1e-6, False, pecan=True),
|
|
395
|
+
},
|
|
396
|
+
"GPM": {
|
|
397
|
+
"2DS": _pd(128, 0.010, 63.0, 22, _GPM_2DS22, 2, 170.0, 1, 1e-6, 1, 0.5, 1e-6, False),
|
|
398
|
+
"CIP": _pd(64, 0.025, 100.0, 19, _CIP19, 1, 200.0, 1, 1e-6, 1, 0.5, 2.5e-7, False),
|
|
399
|
+
"2DC": _pd(32, 0.03, 61.0, 19, _CIP19, 0, 125.0, 1, 1e-5, 0, 0.5, 1e-6, True),
|
|
400
|
+
"HVPS": _pd(128, 0.150, 161.0, 28, _HVPS28, 2, 170.0, 0, 1e-6, 0, 0.5, 1e-6, False),
|
|
401
|
+
},
|
|
402
|
+
"SOCRATES": {
|
|
403
|
+
"2DS": _pd(128, 0.010, 63.0, 21, _SOC_2DS21, 2, 170.0, 1, 1e-6, 1, 0.05, 1e-6, True),
|
|
404
|
+
"Fast2DC": _pd(64, 0.025, 61.0, 17, _SOC_F2DC17, 3, 300.0, 1, 4e-6, 1, 0.15, 2.5e-6, True),
|
|
405
|
+
"PIP": _pd(64, 0.1, 260.0, 27, _SOC_PIP27, 1, 200.0, 0, 1e-5, 0, 0.5, 1e-6, True),
|
|
406
|
+
},
|
|
407
|
+
OTHERWISE: {
|
|
408
|
+
"HVPS": _pd(128, 0.150, 161.0, 28, _HVPS28, 2, 170.0, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
409
|
+
"2DS": _pd(128, 0.010, 63.0, 128, _LADDER, 2, 170.0, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
410
|
+
"CIP": _pd(64, 0.025, 100.0, 19, _CIP19, 1, 200.0, 0, 1e-5, 0, 0.5, 1e-6, True),
|
|
411
|
+
"PIP": _pd(64, 0.1, 260.0, 64, _LADDER, 1, 200.0, 0, 1e-5, 0, 0.5, 1e-6, True),
|
|
412
|
+
"2DC": _pd(32, 0.03, 61.0, 19, _CIP19, 0, 125.0, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
413
|
+
"2DP": _pd(32, 0.200, 260.0, 19, _2DP19, 0, None, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
414
|
+
"F2DC": _pd(64, 0.025, 61.0, 19, _CIP19, 3, 300.0, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
415
|
+
},
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
#: v3.5 ``sizeDist.m:139-642``.
|
|
419
|
+
V35_TABLES: dict[str | None, dict[str, ProbeDefaults]] = {
|
|
420
|
+
"PECAN": V314_TABLES["PECAN"],
|
|
421
|
+
"GPM": {
|
|
422
|
+
"2DS": V314_TABLES["GPM"]["2DS"],
|
|
423
|
+
# applyIntArrThresh 1 -> 0 and reaccptShatrs 1 -> 0; bins unchanged.
|
|
424
|
+
"CIP": _pd(64, 0.025, 100.0, 19, _CIP19, 1, 200.0, 0, 1e-6, 0, 0.5, 2.5e-7, False),
|
|
425
|
+
"2DC": V314_TABLES["GPM"]["2DC"],
|
|
426
|
+
"HVPS": V314_TABLES["GPM"]["HVPS"],
|
|
427
|
+
},
|
|
428
|
+
"SOCRATES": {
|
|
429
|
+
# 21 literal bins (50 um - 2 mm) -> 256-bin 10 um ladder (5 um - 2.565 mm).
|
|
430
|
+
"2DS": _pd(128, 0.010, 63.0, 256, _LADDER, 2, 170.0, 1, 1e-6, 1, 0.05, 1e-6, True),
|
|
431
|
+
# 17 literal bins (150 um - 2 mm) -> 128-bin 25 um ladder (12.5 um - 3.2125 mm).
|
|
432
|
+
"Fast2DC": _pd(64, 0.025, 61.0, 128, _LADDER, 3, 300.0, 1, 4e-6, 1, 0.15, 2.5e-6, True),
|
|
433
|
+
"PIP": V314_TABLES["SOCRATES"]["PIP"],
|
|
434
|
+
},
|
|
435
|
+
"IMPACTS": {
|
|
436
|
+
"2DS": _pd(128, 0.010, 63.0, 29, _IMP_2DS29, 2, 170.0, 1, 1e-6, 1, 0.5, 1e-6, False),
|
|
437
|
+
"3VCPI_V": _pd(128, 0.010, 50.8, 29, _IMP_2DS29, 2, 170.0, 1, 1e-6, 1, 0.5, 1e-6, False),
|
|
438
|
+
"3VCPI_H": _pd(128, 0.050, 50.8, 25, _IMP_3VH25, 2, 170.0, 1, 1e-6, 1, 0.5, 2.5e-6, False),
|
|
439
|
+
"HVPS": _pd(128, 0.150, 161.0, 28, _HVPS28, 2, 170.0, 0, 1e-6, 0, 0.5, 1e-6, False),
|
|
440
|
+
},
|
|
441
|
+
OTHERWISE: {
|
|
442
|
+
"HVPS": V314_TABLES[OTHERWISE]["HVPS"],
|
|
443
|
+
# 128-bin 10 um ladder -> the HVPS 28-bin table (0.2 - 30 mm), verbatim.
|
|
444
|
+
"2DS": _pd(128, 0.010, 63.0, 28, _HVPS28, 2, 170.0, 0, 4e-6, 0, 0.5, 1e-6, True),
|
|
445
|
+
"CIP": V314_TABLES[OTHERWISE]["CIP"],
|
|
446
|
+
"PIP": V314_TABLES[OTHERWISE]["PIP"],
|
|
447
|
+
"2DC": V314_TABLES[OTHERWISE]["2DC"],
|
|
448
|
+
"2DP": V314_TABLES[OTHERWISE]["2DP"],
|
|
449
|
+
"F2DC": V314_TABLES[OTHERWISE]["F2DC"],
|
|
450
|
+
},
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
V314_CAMPAIGNS = tuple(k for k in V314_TABLES if k is not None)
|
|
454
|
+
V35_CAMPAIGNS = tuple(k for k in V35_TABLES if k is not None)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def probe_defaults(projectname: str, probename: str, *, version: str = "3.5") -> ProbeDefaults:
|
|
458
|
+
"""Resolve ``(projectname, probename)`` exactly as the ``switch`` does.
|
|
459
|
+
|
|
460
|
+
Source: the ``switch projectname`` block of ``sizeDist.m:139-642`` (UIOOPS v3.5; v3.1.4
|
|
461
|
+
``:107-511``).
|
|
462
|
+
|
|
463
|
+
An unlisted campaign takes the ``otherwise`` branch; an unlisted probe
|
|
464
|
+
*within* a branch raises :class:`UndefinedProbeCase` (the inner switch has
|
|
465
|
+
no ``otherwise``). Case-sensitive, as MATLAB's ``switch`` on strings is.
|
|
466
|
+
"""
|
|
467
|
+
tables = {"3.5": V35_TABLES, "3.1.4": V314_TABLES}[version]
|
|
468
|
+
branch = tables.get(projectname, tables[OTHERWISE])
|
|
469
|
+
try:
|
|
470
|
+
return branch[probename]
|
|
471
|
+
except KeyError:
|
|
472
|
+
raise UndefinedProbeCase(
|
|
473
|
+
f"sizeDist v{version}: no case for probe {probename!r} under "
|
|
474
|
+
+ ("campaign " + repr(projectname) if projectname in tables else "the otherwise branch")
|
|
475
|
+
) from None
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
@dataclass(frozen=True)
|
|
479
|
+
class TableDiff:
|
|
480
|
+
campaign: str
|
|
481
|
+
probe: str
|
|
482
|
+
status: str # "unchanged" | "changed" | "new" | "removed"
|
|
483
|
+
changed_fields: tuple[str, ...]
|
|
484
|
+
v314: ProbeDefaults | None
|
|
485
|
+
v35: ProbeDefaults | None
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
def diff_tables(
|
|
489
|
+
campaigns: Sequence[str] = ("PECAN", "GPM", "SOCRATES", "IMPACTS", "ORACLES"),
|
|
490
|
+
) -> list[TableDiff]:
|
|
491
|
+
"""The complete v3.1.4 -> v3.5 diff over ``campaigns`` x every probe either
|
|
492
|
+
release names. ``ORACLES`` (or any unlisted name) exercises ``otherwise``."""
|
|
493
|
+
probes = sorted({p for t in (V314_TABLES, V35_TABLES) for b in t.values() for p in b})
|
|
494
|
+
fields = [f for f in ProbeDefaults.__dataclass_fields__ if f != "bins"]
|
|
495
|
+
out = []
|
|
496
|
+
for c in campaigns:
|
|
497
|
+
for p in probes:
|
|
498
|
+
old = new = None
|
|
499
|
+
try:
|
|
500
|
+
old = probe_defaults(c, p, version="3.1.4")
|
|
501
|
+
except UndefinedProbeCase:
|
|
502
|
+
pass
|
|
503
|
+
try:
|
|
504
|
+
new = probe_defaults(c, p, version="3.5")
|
|
505
|
+
except UndefinedProbeCase:
|
|
506
|
+
pass
|
|
507
|
+
if old is None and new is None:
|
|
508
|
+
continue
|
|
509
|
+
if old is None:
|
|
510
|
+
out.append(TableDiff(c, p, "new", (), None, new))
|
|
511
|
+
elif new is None:
|
|
512
|
+
out.append(TableDiff(c, p, "removed", (), old, None))
|
|
513
|
+
else:
|
|
514
|
+
changed = [f for f in fields if getattr(old, f) != getattr(new, f)]
|
|
515
|
+
if not np.array_equal(old.kk(), new.kk()):
|
|
516
|
+
changed.append("kk")
|
|
517
|
+
out.append(
|
|
518
|
+
TableDiff(c, p, "changed" if changed else "unchanged", tuple(changed), old, new)
|
|
519
|
+
)
|
|
520
|
+
return out
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
# ---------------------------------------------------------------------------
|
|
524
|
+
# 2. iaThreshType: the varargin block and the 1-Hz (type 3) shatter block
|
|
525
|
+
# ---------------------------------------------------------------------------
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
@dataclass(frozen=True)
|
|
529
|
+
class InterarrivalThresholdSpec:
|
|
530
|
+
"""What v3.5 ``sizeDist.m:98-110`` leaves behind.
|
|
531
|
+
|
|
532
|
+
``ia_thresh_file`` is ``None`` where MATLAB leaves ``iaThreshFile``
|
|
533
|
+
**unassigned** -- one argument with ``iaThreshType`` 0 or 2 (v3.1.4 assigned
|
|
534
|
+
``varargin{1}`` unconditionally; v3.5's inner ``if/elseif`` has no ``else``).
|
|
535
|
+
Latent in v3.5 because the only later read, ``:1179``, is short-circuited
|
|
536
|
+
behind ``iaThreshType == 1``. ``iat_thresh`` is the per-second array, set
|
|
537
|
+
only for type 3 with exactly one argument.
|
|
538
|
+
"""
|
|
539
|
+
|
|
540
|
+
ia_thresh_file: str | object | None
|
|
541
|
+
iat_thresh: np.ndarray | None
|
|
542
|
+
too_many_inputs: bool
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
def select_interarrival_threshold(
|
|
546
|
+
ia_thresh_type: int, varargin: Sequence[object]
|
|
547
|
+
) -> InterarrivalThresholdSpec:
|
|
548
|
+
"""v3.5 ``sizeDist.m:98-110``, as a pure function of the call's inputs."""
|
|
549
|
+
n = len(varargin)
|
|
550
|
+
if n == 1:
|
|
551
|
+
if ia_thresh_type == 1:
|
|
552
|
+
return InterarrivalThresholdSpec(varargin[0], None, False)
|
|
553
|
+
if ia_thresh_type == 3:
|
|
554
|
+
return InterarrivalThresholdSpec(
|
|
555
|
+
"NONE", np.asarray(varargin[0], dtype=np.float64), False
|
|
556
|
+
)
|
|
557
|
+
return InterarrivalThresholdSpec(None, None, False)
|
|
558
|
+
if n > 1:
|
|
559
|
+
return InterarrivalThresholdSpec("NONE", None, True)
|
|
560
|
+
return InterarrivalThresholdSpec("NONE", None, False)
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
def flag_shattered_1hz(
|
|
564
|
+
int_arr: Sequence[float], thresh: float, auto_reject: Sequence[str] | None = None
|
|
565
|
+
) -> np.ndarray:
|
|
566
|
+
"""v3.5 ``sizeDist.m:1384-1396``: the type-3 shatter flagging for one second.
|
|
567
|
+
|
|
568
|
+
``thresh`` is ``iatThresh(i)`` for that second. A particle at or below the
|
|
569
|
+
threshold is ``'S'``, and so is the one immediately before it (``(ix-1):ix``).
|
|
570
|
+
Returns the per-particle reject codes (1-D ``<U1`` array).
|
|
571
|
+
"""
|
|
572
|
+
ia = np.asarray(int_arr, dtype=np.float64).ravel()
|
|
573
|
+
rej = np.array(["A"] * ia.size if auto_reject is None else list(auto_reject), dtype="<U1")
|
|
574
|
+
if ia.size == 0:
|
|
575
|
+
return rej
|
|
576
|
+
if ia.size == 1 and ia[0] <= thresh:
|
|
577
|
+
rej[0] = "S"
|
|
578
|
+
else:
|
|
579
|
+
if ia[0] <= thresh:
|
|
580
|
+
rej[0] = "S"
|
|
581
|
+
for ix in range(1, ia.size): # MATLAB ix = 2:length(int_arr)
|
|
582
|
+
if ia[ix] <= thresh:
|
|
583
|
+
rej[ix - 1 : ix + 1] = "S"
|
|
584
|
+
return rej
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def reaccept_shattered_1hz(
|
|
588
|
+
auto_reject: Sequence[str],
|
|
589
|
+
int_arr: Sequence[float],
|
|
590
|
+
int_arr3: Sequence[float],
|
|
591
|
+
particle_diameter_minR: Sequence[float],
|
|
592
|
+
thresh: float,
|
|
593
|
+
*,
|
|
594
|
+
reaccptD: float,
|
|
595
|
+
reaccptMaxIA: float,
|
|
596
|
+
) -> tuple[np.ndarray, int | None]:
|
|
597
|
+
"""v3.5 ``sizeDist.m:1398-1428``: the type-3 block's reacceptance.
|
|
598
|
+
|
|
599
|
+
**This is not the v3.1.4 reacceptance**, nor v3.5's own type-1/type-2 one.
|
|
600
|
+
Those iterate ``find(rBegin):find(rEnd)`` -- which, through MATLAB's
|
|
601
|
+
first-element colon rule, scans only the first shattering event (a preserved
|
|
602
|
+
v3.1.4 bug). v3.5 rewrites the type-3 block ("JF 11/5/25")
|
|
603
|
+
to scan ``find(rBegin,1,'first'):find(rEnd,1,'last')``, one continuous range
|
|
604
|
+
spanning every event. Returns ``(auto_reject, eIndex)`` with ``eIndex`` the
|
|
605
|
+
1-based index reaccepted, or ``None`` (MATLAB's ``[]``).
|
|
606
|
+
"""
|
|
607
|
+
rej = np.array(list(auto_reject), dtype="<U1")
|
|
608
|
+
ia = np.asarray(int_arr, dtype=np.float64).ravel()
|
|
609
|
+
ia3 = np.asarray(int_arr3, dtype=np.float64).ravel()
|
|
610
|
+
diam = np.asarray(particle_diameter_minR, dtype=np.float64).ravel()
|
|
611
|
+
r_begin = (ia > thresh) & (ia3 < thresh)
|
|
612
|
+
r_end = (ia < thresh) & (ia3 > thresh)
|
|
613
|
+
max_particle = reaccptD
|
|
614
|
+
e_index: int | None = None
|
|
615
|
+
b = np.flatnonzero(r_begin)
|
|
616
|
+
e = np.flatnonzero(r_end)
|
|
617
|
+
if b.size and e.size and e[-1] >= b[0]:
|
|
618
|
+
for i_event in range(b[0], e[-1] + 1):
|
|
619
|
+
if diam[i_event] > max_particle and ia[i_event] < reaccptMaxIA:
|
|
620
|
+
max_particle = diam[i_event]
|
|
621
|
+
e_index = i_event + 1
|
|
622
|
+
if e_index is not None:
|
|
623
|
+
rej[e_index - 1] = "R"
|
|
624
|
+
return rej, e_index
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
# ---------------------------------------------------------------------------
|
|
628
|
+
# 3. iNewHabit detection
|
|
629
|
+
# ---------------------------------------------------------------------------
|
|
630
|
+
|
|
631
|
+
HABIT_SCHEME_SENTINEL_VARIABLE = "width_length_percentile"
|
|
632
|
+
HABIT_ATTR_NEW = "Schima et al. (2024)"
|
|
633
|
+
HABIT_ATTR_OLD = "Holroyd (1987; doi:10.1175/1520-0426(1987)004<0498:STAUOC>2.0.CO;2)"
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
def detect_habit_scheme(variable_names: Sequence[str]) -> tuple[int, str]:
|
|
637
|
+
"""v3.5 ``sizeDist.m:117-123``: ``(iNewHabit, attr_habit)`` from the input
|
|
638
|
+
file's variable list. Exact, case-sensitive membership, as ``ismember`` on
|
|
639
|
+
a cellstr is."""
|
|
640
|
+
if HABIT_SCHEME_SENTINEL_VARIABLE in list(variable_names):
|
|
641
|
+
return 1, HABIT_ATTR_NEW
|
|
642
|
+
return 0, HABIT_ATTR_OLD
|