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
arrayprobe/selector.py
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""The project-level engine selector -- ``arrayprobe.engine()``.
|
|
3
|
+
|
|
4
|
+
**Why this exists, and what it supersedes.** Until 2026-09-21 the only selector
|
|
5
|
+
was ``uiops.engine()``, which dispatches between the two *UIOOPS* engines and
|
|
6
|
+
**raises** if asked for SODA-2 (that module's own docstring, "SODA-2 is not a
|
|
7
|
+
version here", author's decision 2026-09-12). Every schematic of the package
|
|
8
|
+
nonetheless drew one selector box with three engines under it, and the author
|
|
9
|
+
named the contradiction directly:
|
|
10
|
+
|
|
11
|
+
*"It's not uiops.engine, it's arrayprobe.engine because the uiops.engine is
|
|
12
|
+
then having arrayprobe soda too, which does not make sense."*
|
|
13
|
+
|
|
14
|
+
Two ways to make the picture and the code agree: draw SODA-2 as unreachable
|
|
15
|
+
from the selector, or make the selector actually reach it and stop naming it
|
|
16
|
+
after one upstream. **The author chose the second**, which supersedes the
|
|
17
|
+
2026-09-12 decision above. So this module is the selector the diagrams have
|
|
18
|
+
been drawing all along:
|
|
19
|
+
|
|
20
|
+
import arrayprobe
|
|
21
|
+
|
|
22
|
+
eng = arrayprobe.engine() # v3.5 -- the default
|
|
23
|
+
eng = arrayprobe.engine("3.1.4") # the archived-product anchor, where installed
|
|
24
|
+
eng = arrayprobe.engine("soda2") # the SODA-2 lineage
|
|
25
|
+
|
|
26
|
+
``uiops.engine()`` is unchanged, still works, and is not deprecated. It answers
|
|
27
|
+
a narrower question -- *which UIOOPS release* -- and keeps its refusal of SODA-2,
|
|
28
|
+
because for that question SODA-2 genuinely is not an answer. This module answers
|
|
29
|
+
the broader one: *which of this project's engines*.
|
|
30
|
+
|
|
31
|
+
**It dispatches; it computes nothing.** No number changes because a call came
|
|
32
|
+
through here. There is no state, no arithmetic, and **no engine is imported at
|
|
33
|
+
module level** -- ``tests/test_project_selector.py`` asserts all three by
|
|
34
|
+
parsing this file and by importing it in a clean subprocess, the same way
|
|
35
|
+
``test_uiops_selector.py`` guards ``uiops``.
|
|
36
|
+
|
|
37
|
+
``arrayprobe`` is both the namespace this selector belongs in and the package
|
|
38
|
+
that held the v3.1.4 translation, so ``arrayprobe.engine("3.1.4")`` names
|
|
39
|
+
``arrayprobe`` itself. An earlier translation of UIOOPS v3.1.4 reproduced
|
|
40
|
+
archived products and is not part of this package; where it is absent, asking
|
|
41
|
+
for it raises ``V314EngineAbsent``.
|
|
42
|
+
"""
|
|
43
|
+
from __future__ import annotations
|
|
44
|
+
|
|
45
|
+
from dataclasses import dataclass
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"DEFAULT_ENGINE",
|
|
49
|
+
"ENGINES",
|
|
50
|
+
"Engine",
|
|
51
|
+
"UnknownEngine",
|
|
52
|
+
"engine",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
#: Every engine this project ships, in the order a reader should meet them:
|
|
56
|
+
#: the default first, then the other live upstream, then the anchor.
|
|
57
|
+
def engines() -> tuple[str, ...]:
|
|
58
|
+
"""The engines installed: v3.5 and SODA-2 always, v3.1.4 only where its engine is."""
|
|
59
|
+
from arrayprobe._v314_lazy import engine_present
|
|
60
|
+
return ("3.5", "soda2", "3.1.4") if engine_present() else ("3.5", "soda2")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
ENGINES: tuple[str, ...] = engines()
|
|
64
|
+
|
|
65
|
+
#: What :func:`engine` returns when the caller names nothing.
|
|
66
|
+
DEFAULT_ENGINE: str = "3.5"
|
|
67
|
+
|
|
68
|
+
#: Spellings accepted for each engine. Deliberately small: a selector that
|
|
69
|
+
#: guesses is a selector that silently runs the wrong lineage.
|
|
70
|
+
_ALIASES: dict[str, str] = {
|
|
71
|
+
"3.5": "3.5", "v3.5": "3.5", "uiops": "3.5", "uiops-v3.5": "3.5",
|
|
72
|
+
"soda2": "soda2", "soda-2": "soda2", "soda_2": "soda2", "soda": "soda2",
|
|
73
|
+
"3.1.4": "3.1.4", "v3.1.4": "3.1.4", "oracles": "3.1.4",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_PACKAGE: dict[str, str] = {
|
|
77
|
+
"3.5": "arrayprobe_uiops",
|
|
78
|
+
"soda2": "arrayprobe_soda2",
|
|
79
|
+
"3.1.4": "arrayprobe",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#: Package names that are no longer importable, mapped to the package that
|
|
83
|
+
#: replaced each. A user-named module (a configuration file's
|
|
84
|
+
#: ``[fidelity].profile_module``, ``--probe-case-module``) written with a
|
|
85
|
+
#: retired package name is read under its replacement by ``canonical_module``.
|
|
86
|
+
RETIRED_PACKAGES: dict[str, str] = {"arrayprobe_v35": "arrayprobe_uiops"}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def canonical_module(dotted: str) -> str:
|
|
90
|
+
"""Return ``dotted`` with a retired leading package name replaced.
|
|
91
|
+
|
|
92
|
+
Only an exact match of the first dotted segment against
|
|
93
|
+
``RETIRED_PACKAGES`` is rewritten, old name to new; every other name is
|
|
94
|
+
returned unchanged. Nothing is matched by prefix or similarity. A value
|
|
95
|
+
that is not a string (a test double standing in for a module name) is
|
|
96
|
+
returned as it is.
|
|
97
|
+
"""
|
|
98
|
+
if not isinstance(dotted, str):
|
|
99
|
+
return dotted
|
|
100
|
+
head, sep, rest = dotted.partition(".")
|
|
101
|
+
new = RETIRED_PACKAGES.get(head)
|
|
102
|
+
if new is None:
|
|
103
|
+
return dotted
|
|
104
|
+
return f"{new}{sep}{rest}"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
_UPSTREAM: dict[str, str] = {
|
|
108
|
+
"3.5": "UIOOPS v3.5 (MATLAB, McFarquhar group)",
|
|
109
|
+
"soda2": "SODA-2 (IDL, NCAR)",
|
|
110
|
+
"3.1.4": "UIOOPS v3.1.4 (MATLAB, McFarquhar group)",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_VALIDATION: dict[str, str] = {
|
|
114
|
+
"3.5": "layer 2 -- whole-program Octave goldens of v3.5's own sources. No "
|
|
115
|
+
"archived product was ever written by v3.5, so layer 1 cannot exist "
|
|
116
|
+
"for it and that gap never closes.",
|
|
117
|
+
"soda2": "layer 2 -- GDL running SODA-2's unmodified .pro sources. UND's "
|
|
118
|
+
"archived output is an independent cross-check, never a "
|
|
119
|
+
"bit-fidelity target.",
|
|
120
|
+
"3.1.4": "layer 1 -- a field campaign's archived product, reproduced cell "
|
|
121
|
+
"by cell. The only engine with an archived product behind it, and "
|
|
122
|
+
"the reason to reach for it.",
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class UnknownEngine(ValueError):
|
|
127
|
+
"""Raised for a name that is not one of this project's engines."""
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass(frozen=True)
|
|
131
|
+
class Engine:
|
|
132
|
+
"""A chosen engine, and what a reader needs to know about it."""
|
|
133
|
+
|
|
134
|
+
name: str
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def package(self) -> str:
|
|
138
|
+
"""The importable package implementing it."""
|
|
139
|
+
return _PACKAGE[self.name]
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def upstream(self) -> str:
|
|
143
|
+
"""The package this engine reproduces, and who wrote it."""
|
|
144
|
+
return _UPSTREAM[self.name]
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def validation(self) -> str:
|
|
148
|
+
"""What results from this engine rest on, in one line."""
|
|
149
|
+
return _VALIDATION[self.name]
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def is_default(self) -> bool:
|
|
153
|
+
"""Whether :func:`engine` returns this one when the caller names nothing.
|
|
154
|
+
|
|
155
|
+
Default is not the same as authoritative, and the two are deliberately
|
|
156
|
+
different engines here: v3.5 is the default because it is the
|
|
157
|
+
developers' current source, while the v3.1.4 anchor is the only engine
|
|
158
|
+
that can reproduce an archived product. A figure that needs layer-1
|
|
159
|
+
evidence reaches for the anchor whatever this says.
|
|
160
|
+
"""
|
|
161
|
+
return self.name == DEFAULT_ENGINE
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def is_uiops(self) -> bool:
|
|
165
|
+
"""Whether ``uiops.engine()`` can also answer for this one."""
|
|
166
|
+
return self.name in ("3.5", "3.1.4")
|
|
167
|
+
|
|
168
|
+
def load(self):
|
|
169
|
+
"""Import and return the engine's package.
|
|
170
|
+
|
|
171
|
+
The import happens **here**, on demand, and never at module level --
|
|
172
|
+
which is what lets this selector be imported without pulling three
|
|
173
|
+
engines into the process. Where the v3.1.4 engine is not installed (the public
|
|
174
|
+
distribution), ``arrayprobe`` alone would import and answer for it, so this raises
|
|
175
|
+
:class:`~arrayprobe._v314_lazy.V314EngineAbsent` instead.
|
|
176
|
+
"""
|
|
177
|
+
import importlib
|
|
178
|
+
|
|
179
|
+
if self.name == "3.1.4":
|
|
180
|
+
from arrayprobe._v314_lazy import ABSENT_MESSAGE, V314EngineAbsent, engine_present
|
|
181
|
+
if not engine_present():
|
|
182
|
+
raise V314EngineAbsent(ABSENT_MESSAGE)
|
|
183
|
+
return importlib.import_module(self.package)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def engine(name: str | None = None) -> Engine:
|
|
187
|
+
"""The engine called ``name``, or the default if none is named.
|
|
188
|
+
|
|
189
|
+
Accepts the engine's version (``"3.5"``), its lineage
|
|
190
|
+
(``"soda2"``), or a small set of obvious spellings. Anything else raises
|
|
191
|
+
:class:`UnknownEngine` naming what is available -- a selector that falls
|
|
192
|
+
through to a default would silently run the wrong lineage.
|
|
193
|
+
"""
|
|
194
|
+
if name is None:
|
|
195
|
+
return Engine(DEFAULT_ENGINE)
|
|
196
|
+
key = str(name).strip().lower()
|
|
197
|
+
if key not in _ALIASES:
|
|
198
|
+
raise UnknownEngine(
|
|
199
|
+
f"unknown engine {name!r}. This project offers {list(engines())} "
|
|
200
|
+
f"(default {DEFAULT_ENGINE!r}); accepted spellings are "
|
|
201
|
+
f"{sorted(k for k, v in _ALIASES.items() if v in engines())}.")
|
|
202
|
+
chosen = _ALIASES[key]
|
|
203
|
+
if chosen == "3.1.4" and chosen not in engines():
|
|
204
|
+
from arrayprobe._v314_lazy import ABSENT_MESSAGE, V314EngineAbsent
|
|
205
|
+
raise V314EngineAbsent(ABSENT_MESSAGE)
|
|
206
|
+
return Engine(chosen)
|
arrayprobe/sizing.py
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""The size-definition registry -- an extensibility seam.
|
|
3
|
+
|
|
4
|
+
UIOOPS has no such registry. ``sizeDist.m:882-892`` hard-codes six particle-size
|
|
5
|
+
definitions behind a numeric ``d_choice``, and ``imgProc_sm.m:833`` calls
|
|
6
|
+
``dropsize`` unconditionally on every particle whatever its phase. This module
|
|
7
|
+
is the seam the plan requires in its place, and it exists for one binding
|
|
8
|
+
reason, from the phase-neutrality directive of 2026-08-19:
|
|
9
|
+
|
|
10
|
+
``dropsize`` stays behind the sizing registry, never hard-wired as the
|
|
11
|
+
sizing path. Same for any liquid-tuned threshold.
|
|
12
|
+
|
|
13
|
+
``dropsize.m`` is liquid-specific *by construction*: its two lookup tables map a
|
|
14
|
+
measured chord to the diameter of the **equivalent-volume sphere of a raindrop**
|
|
15
|
+
of that chord, using the Heymsfield-Parrish drop-shape relations. Applied to an
|
|
16
|
+
ice crystal the numbers are not merely imprecise, they answer a question nobody
|
|
17
|
+
asked -- "what raindrop would have cast this shadow". Nothing in the MATLAB
|
|
18
|
+
prevents that; the guard below does.
|
|
19
|
+
|
|
20
|
+
How the guard works
|
|
21
|
+
-------------------
|
|
22
|
+
|
|
23
|
+
Every registered definition declares the phase it is valid for. A definition
|
|
24
|
+
whose ``phase`` is not ``"any"`` cannot be selected through
|
|
25
|
+
:func:`universal_size_definition`, which is the accessor a generic pipeline
|
|
26
|
+
stage is expected to use -- so reaching :func:`dropsize` requires naming it, and
|
|
27
|
+
naming it is a decision that shows up in a diff and in the provenance stamp.
|
|
28
|
+
|
|
29
|
+
Scope note. This is deliberately the *seam* and not the full ``d_choice``
|
|
30
|
+
machinery: the six numeric definitions live in ``sizeDist.m`` and get registered
|
|
31
|
+
in S4, when that file is ported. Building them here would mean transcribing
|
|
32
|
+
``sizeDist.m`` from inside the drop-sizing module.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
from collections.abc import Callable
|
|
38
|
+
from dataclasses import dataclass, field
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"SizeDefinition",
|
|
42
|
+
"PhaseValidity",
|
|
43
|
+
"register_size_definition",
|
|
44
|
+
"get_size_definition",
|
|
45
|
+
"available_size_definitions",
|
|
46
|
+
"universal_size_definition",
|
|
47
|
+
"PhaseMismatchError",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
#: The phases a size definition may claim. ``"any"`` means the definition makes
|
|
51
|
+
#: no assumption about the particle's phase and may serve as a universal path.
|
|
52
|
+
PhaseValidity = str
|
|
53
|
+
|
|
54
|
+
_VALID_PHASES = frozenset({"any", "liquid", "ice"})
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class PhaseMismatchError(ValueError):
|
|
58
|
+
"""Raised when a phase-restricted definition is asked to serve universally.
|
|
59
|
+
|
|
60
|
+
Not a MATLAB behaviour -- MATLAB has no such check. This is the executable
|
|
61
|
+
form of the phase-neutrality directive, and it can only *refuse* a call; it
|
|
62
|
+
never changes a number.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True)
|
|
67
|
+
class SizeDefinition:
|
|
68
|
+
"""One named way of reducing a particle image to a diameter.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
key:
|
|
73
|
+
The registry name. Stamped into output provenance, so it is part of the
|
|
74
|
+
file contract once the framing stage writes it: treat renames as breaking changes.
|
|
75
|
+
func:
|
|
76
|
+
The callable. Signatures deliberately differ between definitions -- a
|
|
77
|
+
chord-table definition and a min-enclosing-circle definition do not take
|
|
78
|
+
the same arguments -- so the registry carries no signature contract.
|
|
79
|
+
phase:
|
|
80
|
+
``"any"``, ``"liquid"`` or ``"ice"``. Anything but ``"any"`` is barred
|
|
81
|
+
from :func:`universal_size_definition`.
|
|
82
|
+
description:
|
|
83
|
+
One line, shown by :func:`available_size_definitions`.
|
|
84
|
+
provenance:
|
|
85
|
+
``file:line`` in the MATLAB source, or the literature reference.
|
|
86
|
+
outputs:
|
|
87
|
+
The names this definition produces, in order.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
key: str
|
|
91
|
+
func: Callable
|
|
92
|
+
phase: PhaseValidity
|
|
93
|
+
description: str
|
|
94
|
+
provenance: str
|
|
95
|
+
outputs: tuple[str, ...] = field(default=())
|
|
96
|
+
|
|
97
|
+
def __post_init__(self) -> None:
|
|
98
|
+
if self.phase not in _VALID_PHASES:
|
|
99
|
+
raise ValueError(
|
|
100
|
+
f"phase must be one of {sorted(_VALID_PHASES)}, got {self.phase!r}"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
_REGISTRY: dict[str, SizeDefinition] = {}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def register_size_definition(definition: SizeDefinition) -> SizeDefinition:
|
|
108
|
+
"""Add a definition to the registry. Re-registering a key is an error."""
|
|
109
|
+
if definition.key in _REGISTRY:
|
|
110
|
+
raise ValueError(f"size definition {definition.key!r} is already registered")
|
|
111
|
+
_REGISTRY[definition.key] = definition
|
|
112
|
+
return definition
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_size_definition(key: str) -> SizeDefinition:
|
|
116
|
+
"""Look a definition up by name, phase restrictions and all.
|
|
117
|
+
|
|
118
|
+
This is the accessor that *does* reach liquid-only definitions -- naming one
|
|
119
|
+
is an explicit act, which is the whole point.
|
|
120
|
+
"""
|
|
121
|
+
try:
|
|
122
|
+
return _REGISTRY[key]
|
|
123
|
+
except KeyError:
|
|
124
|
+
raise KeyError(
|
|
125
|
+
f"unknown size definition {key!r}; "
|
|
126
|
+
f"registered: {sorted(_REGISTRY)}"
|
|
127
|
+
) from None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def available_size_definitions() -> dict[str, SizeDefinition]:
|
|
131
|
+
"""Every registered definition, keyed by name."""
|
|
132
|
+
return dict(_REGISTRY)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def universal_size_definition(key: str) -> SizeDefinition:
|
|
136
|
+
"""Look up a definition for use on particles of unknown phase.
|
|
137
|
+
|
|
138
|
+
Raises :class:`PhaseMismatchError` for anything that declared a phase. A
|
|
139
|
+
generic pipeline stage -- one that does not know what it is looking at --
|
|
140
|
+
calls this, so a liquid-tuned definition cannot become the default path by
|
|
141
|
+
accident.
|
|
142
|
+
"""
|
|
143
|
+
definition = get_size_definition(key)
|
|
144
|
+
if definition.phase != "any":
|
|
145
|
+
raise PhaseMismatchError(
|
|
146
|
+
f"size definition {key!r} is valid only for phase "
|
|
147
|
+
f"{definition.phase!r} and cannot be used as a universal sizing "
|
|
148
|
+
f"path (the package's phase-neutrality directive, 2026-08-19). "
|
|
149
|
+
f"Call get_size_definition({key!r}) to use it deliberately."
|
|
150
|
+
)
|
|
151
|
+
return definition
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
import sys as _sys
|
|
3
|
+
import typing as _typing
|
|
4
|
+
|
|
5
|
+
from arrayprobe_uiops import time_convert as _impl
|
|
6
|
+
|
|
7
|
+
# Static view for type checkers only: the alias below replaces this module at run time,
|
|
8
|
+
# so mypy would otherwise see an empty module. No run-time effect.
|
|
9
|
+
if _typing.TYPE_CHECKING:
|
|
10
|
+
from arrayprobe_uiops.time_convert import * # noqa: F403
|
|
11
|
+
|
|
12
|
+
_sys.modules[__name__] = _impl
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""The interarrival closure check -- McFarquhar et al. (2017) ch. 11 p. 11.20.
|
|
3
|
+
|
|
4
|
+
The community review states the check directly: *"checks should ensure that the sum of
|
|
5
|
+
particle interarrival times matches the record time."* This module is diagnostic-only --
|
|
6
|
+
it reads output, computes a comparison, and reports it; it changes no computed number, so
|
|
7
|
+
per this project's own doctrine (speed work aside, anything that "changes no computed
|
|
8
|
+
number" belongs beside :mod:`arrayprobe.compare` and :mod:`arrayprobe.triage_server`, not
|
|
9
|
+
in ``enhancements_uiops/``) it lives here, in the core port.
|
|
10
|
+
|
|
11
|
+
**What "the sum of particle interarrival times" actually is, for probetype 2 (2D-S /
|
|
12
|
+
HVPS).** ``imgProc_sm.m``'s ``inter_arrival`` variable is ``diff(Time_in_seconds)`` between
|
|
13
|
+
consecutive particles in the *whole file* (:func:`arrayprobe.imgproc._particle_time_probetype2`,
|
|
14
|
+
``:955-957``); ``Time_in_seconds`` is itself built from the probe's own 32-bit particle-frame
|
|
15
|
+
clock count, scaled to seconds by diode pitch and airspeed. Summing every particle's
|
|
16
|
+
``inter_arrival`` over a whole proc file therefore **telescopes exactly** to
|
|
17
|
+
``Time_in_seconds[-1] - Time_in_seconds[0]`` by construction -- that identity holds no matter
|
|
18
|
+
what the port or the original MATLAB does, so it is not the check McFarquhar means, and this
|
|
19
|
+
module does not offer it as one.
|
|
20
|
+
|
|
21
|
+
**The check that is actually informative** compares that particle-clock-derived span against
|
|
22
|
+
an *independent* measurement of the same interval: the raw file's own per-record housekeeping
|
|
23
|
+
timestamp (``hour``/``minute``/``second``/``millisec``, decoded by :mod:`arrayprobe.readers.spec`
|
|
24
|
+
onto every S2 record, the probe's sibling manuals confirm this
|
|
25
|
+
is the manufacturer's own wall-clock field, not derived from the particle clock at all). If the
|
|
26
|
+
probe's particle-timing clock and its separate housekeeping clock agree, the two spans should
|
|
27
|
+
match; if they diverge, that is evidence about clock integration, TAS scaling, or record
|
|
28
|
+
continuity that neither span alone would show.
|
|
29
|
+
|
|
30
|
+
**No published tolerance exists for how close is close enough** -- McFarquhar et al. (2017)
|
|
31
|
+
states the check, not a number, and this module does not invent one. :func:`check_closure`
|
|
32
|
+
reports the two spans, their difference and their ratio; interpreting whether a given
|
|
33
|
+
divergence is instrument noise, a TAS-scaling assumption, or something to escalate is left to
|
|
34
|
+
the caller, the way :mod:`arrayprobe.compare` reports tolerance-classed differences without
|
|
35
|
+
issuing a single pass/fail verdict.
|
|
36
|
+
|
|
37
|
+
**Scope: probetype 2 only.** ``inter_arrival``'s own attribute already says the
|
|
38
|
+
``diff(time_in_seconds)`` convention is for "all but 2DC/2DP" (probetype 2's dedicated
|
|
39
|
+
convention), and 2DC/2DP populate ``inter_arrival`` a different way
|
|
40
|
+
(:func:`arrayprobe.imgproc`, the ``probetype in (0, 1, 3)`` branches). Extending this check to
|
|
41
|
+
those probes needs its own reading of their convention; not done here.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
from __future__ import annotations
|
|
45
|
+
|
|
46
|
+
import dataclasses
|
|
47
|
+
|
|
48
|
+
import numpy as np
|
|
49
|
+
|
|
50
|
+
from . import ncio
|
|
51
|
+
|
|
52
|
+
__all__ = ["ClosureResult", "check_closure"]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _wallclock_seconds(hour: float, minute: float, second: float, millisec: float) -> float:
|
|
56
|
+
"""Seconds since local midnight, from the four housekeeping fields."""
|
|
57
|
+
return hour * 3600.0 + minute * 60.0 + second + millisec / 1000.0
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclasses.dataclass(frozen=True)
|
|
61
|
+
class ClosureResult:
|
|
62
|
+
"""The two independent measurements of one file's time span, and their disagreement.
|
|
63
|
+
|
|
64
|
+
Neither field is a verdict. ``ratio`` near 1.0 is closer agreement; how far from 1.0
|
|
65
|
+
is acceptable is not defined by the source this check implements, and is not defined
|
|
66
|
+
here either.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
#: ``Time_in_seconds[-1] - Time_in_seconds[0]`` from the proc file: the span implied
|
|
70
|
+
#: by the probe's own particle-frame clock, integrated across every particle.
|
|
71
|
+
particle_clock_span_s: float
|
|
72
|
+
#: The wall-clock span between the decoded file's first and last record, from the
|
|
73
|
+
#: housekeeping ``hour``/``minute``/``second``/``millisec`` fields -- independent of
|
|
74
|
+
#: the particle clock entirely.
|
|
75
|
+
record_clock_span_s: float
|
|
76
|
+
#: ``particle_clock_span_s - record_clock_span_s``.
|
|
77
|
+
difference_s: float
|
|
78
|
+
#: ``particle_clock_span_s / record_clock_span_s``; ``nan`` if the record span is zero.
|
|
79
|
+
ratio: float
|
|
80
|
+
n_particles: int
|
|
81
|
+
n_records: int
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def check_closure(decoded_path: str, proc_path: str, *, day_rollover_h: float = 24.0
|
|
85
|
+
) -> ClosureResult:
|
|
86
|
+
"""Compare a proc file's particle-clock time span against its decoded file's own
|
|
87
|
+
record-clock time span (McFarquhar et al. 2017, p. 11.20).
|
|
88
|
+
|
|
89
|
+
``decoded_path`` is the decode stage's output (``.H.nc``/``.V.nc`` from engine 3.5)
|
|
90
|
+
the particles in
|
|
91
|
+
``proc_path`` were framed from -- the caller is responsible for pairing them
|
|
92
|
+
correctly; this function does not check that ``proc_path``'s ``parent_rec_num``
|
|
93
|
+
range is consistent with ``decoded_path``'s record count, though a caller who wants
|
|
94
|
+
that assurance can read both and compare.
|
|
95
|
+
|
|
96
|
+
``day_rollover_h`` corrects a single midnight crossing between the decoded file's
|
|
97
|
+
first and last record (added once if the raw difference is negative). Two valid
|
|
98
|
+
``hour``/``minute``/``second``/``millisec`` readings are always less than 24h
|
|
99
|
+
apart, so the default always suffices; the check that the correction actually
|
|
100
|
+
fixed the sign exists so a caller who overrides ``day_rollover_h`` to something
|
|
101
|
+
too small gets a clear error rather than a silently wrong, still-negative span.
|
|
102
|
+
"""
|
|
103
|
+
hour = ncio.ncread(decoded_path, "hour").ravel().astype(np.float64)
|
|
104
|
+
minute = ncio.ncread(decoded_path, "minute").ravel().astype(np.float64)
|
|
105
|
+
second = ncio.ncread(decoded_path, "second").ravel().astype(np.float64)
|
|
106
|
+
millisec = ncio.ncread(decoded_path, "millisec").ravel().astype(np.float64)
|
|
107
|
+
n_records = hour.size
|
|
108
|
+
if n_records < 2:
|
|
109
|
+
raise ValueError(
|
|
110
|
+
f"{decoded_path} has {n_records} record(s); need at least 2 for a time span")
|
|
111
|
+
|
|
112
|
+
t0 = _wallclock_seconds(hour[0], minute[0], second[0], millisec[0])
|
|
113
|
+
t1 = _wallclock_seconds(hour[-1], minute[-1], second[-1], millisec[-1])
|
|
114
|
+
record_span = t1 - t0
|
|
115
|
+
if record_span < 0:
|
|
116
|
+
record_span += day_rollover_h * 3600.0
|
|
117
|
+
if record_span < 0:
|
|
118
|
+
raise ValueError(
|
|
119
|
+
f"{decoded_path}: last record precedes first even after one "
|
|
120
|
+
f"{day_rollover_h}h rollover correction -- day_rollover_h is too "
|
|
121
|
+
"small for a real midnight crossing, or the two records are not "
|
|
122
|
+
"in file order")
|
|
123
|
+
|
|
124
|
+
time_in_seconds = ncio.ncread(proc_path, "Time_in_seconds").ravel().astype(np.float64)
|
|
125
|
+
n_particles = time_in_seconds.size
|
|
126
|
+
if n_particles < 2:
|
|
127
|
+
raise ValueError(
|
|
128
|
+
f"{proc_path} has {n_particles} particle(s); need at least 2 for a time span")
|
|
129
|
+
|
|
130
|
+
particle_span = float(time_in_seconds[-1] - time_in_seconds[0])
|
|
131
|
+
difference = particle_span - record_span
|
|
132
|
+
ratio = particle_span / record_span if record_span else float("nan")
|
|
133
|
+
|
|
134
|
+
return ClosureResult(
|
|
135
|
+
particle_clock_span_s=particle_span,
|
|
136
|
+
record_clock_span_s=record_span,
|
|
137
|
+
difference_s=difference,
|
|
138
|
+
ratio=ratio,
|
|
139
|
+
n_particles=int(n_particles),
|
|
140
|
+
n_records=int(n_records),
|
|
141
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""Tooling that ships *inside* the installed package.
|
|
3
|
+
|
|
4
|
+
**Why this subpackage exists** (the ten-minute quickstart).
|
|
5
|
+
``scripts/`` holds the project's scripts, and
|
|
6
|
+
``[tool.setuptools.packages.find] where = ["src"]`` means none of them are
|
|
7
|
+
installed: ``pip install arrayprobe`` gives you the ``arrayprobe`` console
|
|
8
|
+
script and nothing else. So every command the documentation offers a stranger
|
|
9
|
+
-- including the quickstart's own first step -- worked only from a git clone,
|
|
10
|
+
which is the opposite of what a quickstart is for.
|
|
11
|
+
|
|
12
|
+
Modules land here when they are reachable from the installed package, i.e.
|
|
13
|
+
they import from ``arrayprobe`` and nothing outside it. ``make_demo_flight``
|
|
14
|
+
qualifies (``arrayprobe.readers.spec`` and numpy). Two scripts measurably do
|
|
15
|
+
not, and are named rather than silently left behind:
|
|
16
|
+
|
|
17
|
+
* ``scripts/run_flight.py`` -- 1,842 lines, referenced 435 times across 27 test
|
|
18
|
+
modules, and its ``--jobs``/``--chunks`` workers re-exec
|
|
19
|
+
``sys.executable str(Path(__file__).resolve())``, so moving it changes the
|
|
20
|
+
path two subprocess re-exec paths depend on. A real move, not a hard one to
|
|
21
|
+
get wrong quietly; sized here so whoever takes it starts from the measurement.
|
|
22
|
+
* ``scripts/reprocess.py`` -- small and self-contained *except* that it loads
|
|
23
|
+
``run_flight`` (a private copy per call) for its stamp labels and the S3/S4
|
|
24
|
+
stage functions. It follows ``run_flight``; it cannot lead. ``arrayprobe
|
|
25
|
+
reprocess`` reaches it by path, the way ``arrayprobe run`` reaches
|
|
26
|
+
``run_flight``.
|
|
27
|
+
"""
|