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/regimes.py
ADDED
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
"""Named, evidence-based size-distribution (``sizeDist``) thresholds -- cloud-regime defaults.
|
|
3
|
+
|
|
4
|
+
**Why this exists.** ``run_flight.py`` hard-codes ``tree="production"`` for
|
|
5
|
+
every run, so a project name ``sizedist_config`` does not recognise
|
|
6
|
+
(``constants.PROJECTS_PRODUCTION`` is ``("PECAN", "GPM")`` only) falls through to the
|
|
7
|
+
``otherwise`` branch -- which is the archived production configuration's tuned row
|
|
8
|
+
(``area_ratio_z=0.5``, ``default_int_arr_thresh=6e-6``), because that campaign is itself an
|
|
9
|
+
``otherwise`` case (constants.py:663-680). The ACE-ENA chain has been running those values since it
|
|
10
|
+
started, not by choice. **Measured**: ``constants.sizedist_config("ARM_ENA", "2DS", "production")
|
|
11
|
+
== constants.sizedist_config("ORACLES", "2DS", "production")``.
|
|
12
|
+
|
|
13
|
+
The author's requirement (verbatim): *"the runs should be configurable - if the user doesnt
|
|
14
|
+
provide thresholds, the defaults should be regime based - like liquid warm clouds/ice clouds etc.,
|
|
15
|
+
not oracles thresholds blindly"*, later widened: *"it needs to be user-flexible - so raw values in
|
|
16
|
+
toml maybe and also regime selector"* -- the rule that (a config file may only *select*, never
|
|
17
|
+
*describe*, a threshold) is explicitly lifted for the two fields named here, and only these two.
|
|
18
|
+
Every other fidelity-sensitive field (``rej_hollow``, ``max_edge_img_ar``, ``max_comp_img_ar``,
|
|
19
|
+
``spec_buffer_guard``, ``hvps_reader``, ``zero_image_particle_recovery`` -- the
|
|
20
|
+
:class:`~arrayprobe_uiops.reject_core.RejectConfig` / :class:`~arrayprobe.profiles.FidelityProfile`
|
|
21
|
+
fields)
|
|
22
|
+
stays selection-only, guarded by ``arrayprobe.config._FORBIDDEN``.
|
|
23
|
+
|
|
24
|
+
**This module changes no computed number by itself.** A run that names no regime and gives no
|
|
25
|
+
override resolves exactly the values ``run_flight.py`` has always hard-coded
|
|
26
|
+
(``tree="production"``, ``reject=None`` -> :data:`arrayprobe_uiops.sizedist_core.ORACLES_REJECT`,
|
|
27
|
+
``default_int_arr_thresh`` from ``constants.sizedist_config(..., "production")``) --
|
|
28
|
+
:func:`resolve_thresholds` with no arguments reproduces that path bit-for-bit
|
|
29
|
+
(``tests/test_regimes.py::TestFidelity``). Regime selection is a choice being made explicit, not a
|
|
30
|
+
new computation.
|
|
31
|
+
|
|
32
|
+
**Where a field cannot be justified from evidence this repository holds, it is left at stock and
|
|
33
|
+
says so.** No ice-specific or mixed-phase-specific S4 threshold exists anywhere in this codebase
|
|
34
|
+
(measured: ``constants.py``'s two switch tables hold only PECAN/GPM/ORACLES-shaped rows, never a
|
|
35
|
+
phase-labelled one) -- inventing one would be fabricating a value, which this package never does.
|
|
36
|
+
:data:`ICE` and :data:`MIXED` therefore carry stock's own values, named as such, with a
|
|
37
|
+
concrete note on what evidence would settle a real one.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
from __future__ import annotations
|
|
41
|
+
|
|
42
|
+
from dataclasses import dataclass, replace
|
|
43
|
+
from types import MappingProxyType
|
|
44
|
+
from typing import TYPE_CHECKING, Any
|
|
45
|
+
|
|
46
|
+
if TYPE_CHECKING:
|
|
47
|
+
from arrayprobe_uiops.reject_core import RejectConfig
|
|
48
|
+
|
|
49
|
+
__all__ = [
|
|
50
|
+
"Regime", "ResolvedField", "ResolvedThresholds",
|
|
51
|
+
"LIQUID_WARM", "ICE", "MIXED", "REGIMES", "register_regime",
|
|
52
|
+
"ThresholdValidationError", "resolve_thresholds",
|
|
53
|
+
"Inherit", "INHERIT", "REJECT_FIELDS", "UncitedRegimeField",
|
|
54
|
+
"resolve_reject", "regime_reject_values", "regime_reject_sources",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass(frozen=True)
|
|
59
|
+
class Inherit:
|
|
60
|
+
"""The explicit "this regime does not set this reject field" marker, with its reason.
|
|
61
|
+
|
|
62
|
+
A regime slot holding an :class:`Inherit` takes the run's profile value for that field
|
|
63
|
+
(:func:`resolve_reject`). The reason is required: an inherited slot is a decision like any
|
|
64
|
+
other and says
|
|
65
|
+
why it was made.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
reason: str
|
|
69
|
+
|
|
70
|
+
def __post_init__(self) -> None:
|
|
71
|
+
if not isinstance(self.reason, str) or not self.reason.strip():
|
|
72
|
+
raise UncitedRegimeField(
|
|
73
|
+
"an Inherit marker must state its reason (a non-empty string)")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class UncitedRegimeField(ValueError):
|
|
77
|
+
"""A :class:`Regime` reject slot set to a value with no citation, or of the wrong type.
|
|
78
|
+
|
|
79
|
+
The shape of ``arrayprobe_uiops.probe_cases.UncitedProbeCaseField``: refused at construction,
|
|
80
|
+
so a regime that types a threshold without naming the vendored ``file:line`` or measurement
|
|
81
|
+
record it came from never exists (the never-invent-a-threshold rule).
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
INHERIT = Inherit(reason="inherits the profile's reject set; no regime-specific datum")
|
|
86
|
+
"""The sentinel the three shipped regimes carry on all six reject slots, so every ``--regime``
|
|
87
|
+
run resolves to the same eight thresholds it did before the slots existed."""
|
|
88
|
+
|
|
89
|
+
#: The six :class:`~arrayprobe_uiops.reject_core.RejectConfig` fields a regime may carry, with the
|
|
90
|
+
#: type
|
|
91
|
+
#: each must hold when set (``calculate_reject_unified.m:71-77``; ``reject.py``'s
|
|
92
|
+
#: ``RejectConfig``). ``tests/test_regimes_reject_slots.py`` asserts this tuple equals
|
|
93
|
+
#: ``RejectConfig``'s own field list, so the two cannot drift apart.
|
|
94
|
+
REJECT_FIELDS: tuple[str, ...] = (
|
|
95
|
+
"rej_zero_area", "rej_split", "rej_hollow",
|
|
96
|
+
"shadowed_area", "max_edge_img_ar", "max_comp_img_ar",
|
|
97
|
+
)
|
|
98
|
+
_REJECT_BOOL_FIELDS = frozenset({"rej_zero_area", "rej_split", "rej_hollow"})
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class ThresholdValidationError(ValueError):
|
|
102
|
+
"""A user-supplied raw threshold value that fails a physically-grounded bound.
|
|
103
|
+
|
|
104
|
+
Bounds are asserted only where the repository holds a reason to assert one (area ratio is
|
|
105
|
+
bounded to (0, 1] by its own definition -- image area divided by an enclosing shape's area);
|
|
106
|
+
where no such reason exists (``default_int_arr_thresh``'s upper end -- no evidence here bounds
|
|
107
|
+
a plausible inter-arrival threshold), nothing is asserted, and that is stated rather than an
|
|
108
|
+
invented limit being enforced silently.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@dataclass(frozen=True)
|
|
113
|
+
class Regime:
|
|
114
|
+
"""One named, evidence-based bundle of size-distribution-stage threshold defaults.
|
|
115
|
+
|
|
116
|
+
Both fields are cited individually -- ``area_ratio_z`` and ``default_int_arr_thresh`` are
|
|
117
|
+
independent MATLAB literals (the campaign-configured ``sizeDist.m:849`` and ``:269``) with
|
|
118
|
+
no shared history, so a regime that could justify one and not the other is expected, not an
|
|
119
|
+
oversight.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
name: str
|
|
123
|
+
area_ratio_z: float
|
|
124
|
+
area_ratio_z_justification: str
|
|
125
|
+
default_int_arr_thresh: float
|
|
126
|
+
default_int_arr_thresh_justification: str
|
|
127
|
+
provenance: str
|
|
128
|
+
"""The regime's own rationale -- what evidence ties these particular numbers to this cloud
|
|
129
|
+
type, or the explicit statement that none does and values are stock's own."""
|
|
130
|
+
|
|
131
|
+
# The six S3 reject thresholds (author, 2026-09-30: "let a regime carry all eight
|
|
132
|
+
# thresholds"). Each is a cited value or an :class:`Inherit` carrying its reason; a value
|
|
133
|
+
# needs a non-empty ``<field>_justification`` naming a vendored file:line or a measurement
|
|
134
|
+
# record, or construction raises :class:`UncitedRegimeField`. Defaulting to INHERIT keeps
|
|
135
|
+
# every regime written before the slots existed constructible and unchanged in effect.
|
|
136
|
+
rej_zero_area: bool | Inherit = INHERIT
|
|
137
|
+
rej_zero_area_justification: str = ""
|
|
138
|
+
rej_split: bool | Inherit = INHERIT
|
|
139
|
+
rej_split_justification: str = ""
|
|
140
|
+
rej_hollow: bool | Inherit = INHERIT
|
|
141
|
+
rej_hollow_justification: str = ""
|
|
142
|
+
shadowed_area: float | Inherit = INHERIT
|
|
143
|
+
shadowed_area_justification: str = ""
|
|
144
|
+
max_edge_img_ar: float | Inherit = INHERIT
|
|
145
|
+
max_edge_img_ar_justification: str = ""
|
|
146
|
+
max_comp_img_ar: float | Inherit = INHERIT
|
|
147
|
+
max_comp_img_ar_justification: str = ""
|
|
148
|
+
|
|
149
|
+
def __post_init__(self) -> None:
|
|
150
|
+
for f in REJECT_FIELDS:
|
|
151
|
+
value = getattr(self, f)
|
|
152
|
+
if isinstance(value, Inherit):
|
|
153
|
+
continue
|
|
154
|
+
if f in _REJECT_BOOL_FIELDS:
|
|
155
|
+
ok = isinstance(value, bool)
|
|
156
|
+
want = "a bool"
|
|
157
|
+
else:
|
|
158
|
+
ok = isinstance(value, (int, float)) and not isinstance(value, bool)
|
|
159
|
+
want = "a number (not a bool)"
|
|
160
|
+
if not ok:
|
|
161
|
+
raise UncitedRegimeField(
|
|
162
|
+
f"regime {self.name!r}: {f}={value!r} must be {want} or an Inherit marker "
|
|
163
|
+
"(RejectConfig's field type, reject.py)")
|
|
164
|
+
justification = getattr(self, f + "_justification")
|
|
165
|
+
if not isinstance(justification, str) or not justification.strip():
|
|
166
|
+
raise UncitedRegimeField(
|
|
167
|
+
f"regime {self.name!r} sets {f}={value!r} but cites nothing: a regime's "
|
|
168
|
+
f"reject value needs {f}_justification naming the vendored file:line or "
|
|
169
|
+
"measurement record it came from, or the slot must be an Inherit marker "
|
|
170
|
+
"with its reason")
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
LIQUID_WARM = Regime(
|
|
174
|
+
name="liquid-warm",
|
|
175
|
+
area_ratio_z=0.5,
|
|
176
|
+
area_ratio_z_justification=(
|
|
177
|
+
"sizeDist.m:849 (campaign-configured copy), "
|
|
178
|
+
"\"Changed from .2 to .5 for ORACLES - Siddhant Gupta - "
|
|
179
|
+
"11/1/17\" -- read. ORACLES 2016 sampled marine stratocumulus off Namibia, warm liquid "
|
|
180
|
+
"cloud (derived from the campaign's own description); a tighter "
|
|
181
|
+
"area-ratio cut is consistent with rejecting non-circular artefacts among spherical "
|
|
182
|
+
"liquid drops, which is what an area-ratio gate measures on a round particle."
|
|
183
|
+
),
|
|
184
|
+
default_int_arr_thresh=6e-6,
|
|
185
|
+
default_int_arr_thresh_justification=(
|
|
186
|
+
"sizeDist.m:269 (campaign-configured copy; constants.py:589), "
|
|
187
|
+
"\"Changed from 1e-6 to 6e-6 for "
|
|
188
|
+
"ORACLES\" -- read. Same campaign, same warm marine-stratocumulus tuning; no independent "
|
|
189
|
+
"shattering-rate measurement for this value is held by this repository beyond the "
|
|
190
|
+
"dated MATLAB comment itself."
|
|
191
|
+
),
|
|
192
|
+
provenance=(
|
|
193
|
+
"ORACLES_PRODUCTION's own dated 'for ORACLES' edits to the MATLAB source, named as a "
|
|
194
|
+
"regime rather than arriving as the unnamed 'otherwise' fallback a campaign that never "
|
|
195
|
+
"chose them would silently inherit (a measured defect)."
|
|
196
|
+
),
|
|
197
|
+
rej_zero_area=INHERIT,
|
|
198
|
+
rej_split=INHERIT,
|
|
199
|
+
rej_hollow=INHERIT,
|
|
200
|
+
shadowed_area=INHERIT,
|
|
201
|
+
max_edge_img_ar=INHERIT,
|
|
202
|
+
max_comp_img_ar=INHERIT,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
ICE = Regime(
|
|
206
|
+
name="ice",
|
|
207
|
+
area_ratio_z=0.2,
|
|
208
|
+
area_ratio_z_justification=(
|
|
209
|
+
"NOT JUSTIFIED FOR ICE -- left at stock's own value "
|
|
210
|
+
"(arrayprobe_uiops.sizedist_core.STOCK_REJECT, "
|
|
211
|
+
"measured 2026-08-19 against UIOPS-v3.1.4 and the OptArrProbDataProcessing variant tree, "
|
|
212
|
+
"both .2). No ice-specific area-ratio value exists anywhere in this codebase's two "
|
|
213
|
+
"sizeDist.m switch tables (constants.py) -- inventing one would be the fabrication "
|
|
214
|
+
"the project's rule against inventing values forbids. An area-ratio gate tuned on "
|
|
215
|
+
"spherical liquid drops "
|
|
216
|
+
"(LIQUID_WARM's .5) measures a different thing on ice habit, so it is not carried "
|
|
217
|
+
"over either. WHAT WOULD SETTLE A REAL VALUE: labelled ice-phase particle images from a "
|
|
218
|
+
"campaign with independent phase information (ARM context such as cloud "
|
|
219
|
+
"phase, temperature and companion probes)."
|
|
220
|
+
),
|
|
221
|
+
default_int_arr_thresh=4e-6,
|
|
222
|
+
default_int_arr_thresh_justification=(
|
|
223
|
+
"NOT JUSTIFIED FOR ICE -- left at stock's own per-probe default for the 2D-S "
|
|
224
|
+
"(constants.SIZEDIST_CONFIG, project='otherwise', probe='2DS', 4e-6 s). No "
|
|
225
|
+
"ice-specific inter-arrival threshold is held by this repository; ORACLES's 6e-6 is the "
|
|
226
|
+
"same warm-liquid tuning as its area_ratio_z. WHAT WOULD SETTLE A REAL VALUE: measured "
|
|
227
|
+
"shattering inter-arrival-time statistics on a known-ice flight segment."
|
|
228
|
+
),
|
|
229
|
+
provenance=(
|
|
230
|
+
"No evidence this repository holds justifies an ice-specific S4 threshold pair, so this "
|
|
231
|
+
"regime states stock's own values by name rather than letting a fallback silently supply "
|
|
232
|
+
"a warm-liquid campaign's numbers. See the per-field notes for what would settle each one."
|
|
233
|
+
),
|
|
234
|
+
rej_zero_area=INHERIT,
|
|
235
|
+
rej_split=INHERIT,
|
|
236
|
+
rej_hollow=INHERIT,
|
|
237
|
+
shadowed_area=INHERIT,
|
|
238
|
+
max_edge_img_ar=INHERIT,
|
|
239
|
+
max_comp_img_ar=INHERIT,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
MIXED = Regime(
|
|
243
|
+
name="mixed",
|
|
244
|
+
area_ratio_z=0.2,
|
|
245
|
+
area_ratio_z_justification=(
|
|
246
|
+
"NOT JUSTIFIED FOR MIXED PHASE -- same as ICE: no mixed-phase-specific evidence is held "
|
|
247
|
+
"by this repository; left at stock's .2 (arrayprobe_uiops.sizedist_core.STOCK_REJECT)."
|
|
248
|
+
),
|
|
249
|
+
default_int_arr_thresh=4e-6,
|
|
250
|
+
default_int_arr_thresh_justification=(
|
|
251
|
+
"NOT JUSTIFIED FOR MIXED PHASE -- same as ICE: no mixed-phase-specific evidence is held "
|
|
252
|
+
"by this repository; left at stock's per-probe default for the 2D-S, 4e-6 s."
|
|
253
|
+
),
|
|
254
|
+
provenance=(
|
|
255
|
+
"No evidence this repository holds distinguishes a mixed-phase S4 threshold pair from "
|
|
256
|
+
"ICE's; both sit at stock's values until measured campaign context (ARM "
|
|
257
|
+
"cloud-phase, temperature and companion-probe data) settles one for either."
|
|
258
|
+
),
|
|
259
|
+
rej_zero_area=INHERIT,
|
|
260
|
+
rej_split=INHERIT,
|
|
261
|
+
rej_hollow=INHERIT,
|
|
262
|
+
shadowed_area=INHERIT,
|
|
263
|
+
max_edge_img_ar=INHERIT,
|
|
264
|
+
max_comp_img_ar=INHERIT,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
_REGIMES: dict[str, Regime] = {r.name: r for r in (LIQUID_WARM, ICE, MIXED)}
|
|
268
|
+
REGIMES: MappingProxyType[str, Regime] = MappingProxyType(_REGIMES)
|
|
269
|
+
"""Every regime this module ships. A fork adds its own with :func:`register_regime` -- from
|
|
270
|
+
Python, with per-field justification required, never by describing one in a config file (the same
|
|
271
|
+
constraint :func:`arrayprobe.profiles.register_profile` holds a fork's profile to)."""
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def register_regime(new: Regime) -> Regime:
|
|
275
|
+
"""Register a fork's own :class:`Regime`, the same way
|
|
276
|
+
:func:`arrayprobe.profiles.register_profile` registers a fork's
|
|
277
|
+
:class:`~arrayprobe.profiles.FidelityProfile`.
|
|
278
|
+
|
|
279
|
+
Registering constructs the object in Python, where every field's justification is named; a
|
|
280
|
+
config file may only *select* the name afterwards, never describe the numbers.
|
|
281
|
+
"""
|
|
282
|
+
if not isinstance(new, Regime):
|
|
283
|
+
raise TypeError(f"register_regime takes a Regime, got {type(new).__name__}")
|
|
284
|
+
if new.name in _REGIMES:
|
|
285
|
+
raise ValueError(
|
|
286
|
+
f"{new.name!r} is already a registered regime ({sorted(_REGIMES)}); a fork's regime "
|
|
287
|
+
"may not shadow a shipped name")
|
|
288
|
+
_REGIMES[new.name] = new
|
|
289
|
+
return new
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
#: Physical bound on area_ratio_z: an area ratio (image area / enclosing-shape area) is bounded to
|
|
293
|
+
#: (0, 1] by its own definition, regardless of cloud regime -- the one bound this repository can
|
|
294
|
+
#: assert without inventing a threshold value.
|
|
295
|
+
_AREA_RATIO_BOUNDS = (0.0, 1.0)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
#: The pre-2026-10-16 spelling of the ``"default"`` source tag. Writers emit only
|
|
299
|
+
#: ``"default"``; readers of already-written stamps accept this too.
|
|
300
|
+
LEGACY_DEFAULT_SOURCE = "stock"
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def is_default_source(source: str) -> bool:
|
|
304
|
+
"""True for the built-in-fallback tag in either spelling (``default``, or the old ``stock``)."""
|
|
305
|
+
return source in ("default", LEGACY_DEFAULT_SOURCE)
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@dataclass(frozen=True)
|
|
309
|
+
class ResolvedField:
|
|
310
|
+
"""One resolved threshold value, tagged with WHERE it came from and why.
|
|
311
|
+
|
|
312
|
+
``source`` is one of ``"regime:<name>"``, ``"user:<path>"`` or ``"default"`` (the built-in
|
|
313
|
+
fallback nobody chose -- see :func:`resolve_thresholds`'s no-argument case) -- three
|
|
314
|
+
different epistemic objects that must never be blurred: a value someone typed into a TOML is
|
|
315
|
+
not the same claim as a named regime's cited default.
|
|
316
|
+
|
|
317
|
+
``"default"`` is the built-in fallback nobody chose, and its meaning depends on the tree: for
|
|
318
|
+
the production tree it is ``ORACLES_REJECT`` (area_ratio_z 0.5, the 2017 production edit,
|
|
319
|
+
``sizedist_core.py``); for the stock tree it is ``STOCK_REJECT`` (0.2, unmodified UIOOPS). It
|
|
320
|
+
does NOT mean "unmodified UIOOPS uses this value". Stamps written before 2026-10-16 spell it
|
|
321
|
+
``"stock"``; every reader accepts both (:data:`LEGACY_DEFAULT_SOURCE`).
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
value: float
|
|
325
|
+
source: str
|
|
326
|
+
justification: str
|
|
327
|
+
|
|
328
|
+
def render(self) -> str:
|
|
329
|
+
"""``"<value> (<source>)"`` -- the one line both the startup print and the ``.call``
|
|
330
|
+
stamp use, so the two can never say something different about the same run."""
|
|
331
|
+
return f"{self.value:g} ({self.source})"
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@dataclass(frozen=True)
|
|
335
|
+
class ResolvedThresholds:
|
|
336
|
+
"""The two size-distribution threshold fields in force for one run, each with its provenance.
|
|
337
|
+
|
|
338
|
+
Returned by :func:`resolve_thresholds` and consumed by ``scripts/run_flight.py`` in three
|
|
339
|
+
places that must never disagree: the startup print, the confirmation panel and the
|
|
340
|
+
``.call`` stamp. The two fields are kept separate rather than collapsed into one "source"
|
|
341
|
+
because a run may mix origins -- a regime for one and a raw override for the other -- and
|
|
342
|
+
reporting both as whichever was set last is exactly the blurring this module exists to prevent.
|
|
343
|
+
"""
|
|
344
|
+
|
|
345
|
+
area_ratio_z: ResolvedField
|
|
346
|
+
default_int_arr_thresh: ResolvedField
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def resolve_reject(regime: Regime | None, profile_reject: RejectConfig) -> RejectConfig:
|
|
350
|
+
"""The :class:`~arrayprobe_uiops.reject_core.RejectConfig` a run uses: the regime's cited
|
|
351
|
+
values over the profile's.
|
|
352
|
+
|
|
353
|
+
Each of the six slots the regime marks :class:`Inherit` takes ``profile_reject``'s value; each
|
|
354
|
+
it sets replaces it. ``regime=None`` returns ``profile_reject`` itself, unchanged. With the
|
|
355
|
+
three shipped regimes (all six INHERIT) the result equals ``profile_reject`` field for field,
|
|
356
|
+
so a ``--regime`` run keeps its profile's reject set (``tests/test_regimes_reject_slots.py``).
|
|
357
|
+
Precedence above the regime (a ``user:`` override) is the driver's, not this function's.
|
|
358
|
+
|
|
359
|
+
"""
|
|
360
|
+
if regime is None:
|
|
361
|
+
return profile_reject
|
|
362
|
+
if not isinstance(regime, Regime):
|
|
363
|
+
raise TypeError(f"resolve_reject takes a Regime or None, got {type(regime).__name__}")
|
|
364
|
+
# Any: dataclasses.replace's per-field types are checked against one dict value type.
|
|
365
|
+
supplied: dict[str, Any] = dict(regime_reject_values(regime))
|
|
366
|
+
return replace(profile_reject, **supplied) if supplied else profile_reject
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def regime_reject_values(regime: Regime) -> dict[str, bool | float]:
|
|
370
|
+
"""The reject slots the regime sets, ``{field: value}``; the Inherit slots are left out."""
|
|
371
|
+
out: dict[str, bool | float] = {}
|
|
372
|
+
for f in REJECT_FIELDS:
|
|
373
|
+
value = getattr(regime, f)
|
|
374
|
+
if not isinstance(value, Inherit):
|
|
375
|
+
out[f] = value
|
|
376
|
+
return out
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def regime_reject_sources(regime: Regime | None) -> dict[str, str]:
|
|
380
|
+
"""``{field: "regime:<name>"}`` for each reject slot the regime sets; empty when it sets none.
|
|
381
|
+
|
|
382
|
+
Lists only the fields the regime supplied, so a stamp built from it stays absent when unused
|
|
383
|
+
(design record section 3's ``reject_sources=`` key).
|
|
384
|
+
"""
|
|
385
|
+
if regime is None:
|
|
386
|
+
return {}
|
|
387
|
+
return {f: f"regime:{regime.name}" for f in regime_reject_values(regime)}
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def _legacy_reject(tree: str):
|
|
391
|
+
# The thresholds live in the shared v3.5 core (arrayprobe.sizedist re-exports the same
|
|
392
|
+
# objects), so this works whether or not the v3.1.4 engine is installed.
|
|
393
|
+
from arrayprobe_uiops.sizedist_core import ORACLES_REJECT, STOCK_REJECT
|
|
394
|
+
return ORACLES_REJECT if tree == "production" else STOCK_REJECT
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def _legacy_default_int_arr_thresh(projectname: str, probename: str, tree: str) -> float:
|
|
398
|
+
# Deferred import, same reason: constants.py has no reason to import this module.
|
|
399
|
+
from .constants import sizedist_config
|
|
400
|
+
return sizedist_config(projectname, probename, tree).default_int_arr_thresh
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def resolve_thresholds(
|
|
404
|
+
regime_name: str | None = None,
|
|
405
|
+
area_ratio_z_override: float | None = None,
|
|
406
|
+
default_int_arr_thresh_override: float | None = None,
|
|
407
|
+
override_source: str = "user",
|
|
408
|
+
*,
|
|
409
|
+
area_ratio_z_source: str | None = None,
|
|
410
|
+
default_int_arr_thresh_source: str | None = None,
|
|
411
|
+
projectname: str = "ORACLES",
|
|
412
|
+
probename: str = "2DS",
|
|
413
|
+
tree: str = "production",
|
|
414
|
+
) -> ResolvedThresholds:
|
|
415
|
+
"""Resolve the two size-distribution threshold fields, tagging where each value came from.
|
|
416
|
+
|
|
417
|
+
**No arguments** (the default): reproduces exactly what ``run_flight.py`` has always
|
|
418
|
+
hard-coded for every project, named rather than silently applied --
|
|
419
|
+
``arrayprobe_uiops.sizedist_core.ORACLES_REJECT.area_ratio_z`` (0.5) and the production
|
|
420
|
+
``otherwise/2DS``
|
|
421
|
+
row's ``default_int_arr_thresh`` (6e-6, ``constants.py:674-680``). This is the production-tuned
|
|
422
|
+
pair an unrecognised project was found silently inheriting -- kept as the literal
|
|
423
|
+
no-argument default so nothing about an already-validated run changes, but tagged
|
|
424
|
+
``"default"`` (meaning: the historical hard-coded fallback, not a regime anyone chose) rather
|
|
425
|
+
than arriving with no name at all.
|
|
426
|
+
|
|
427
|
+
``regime_name``: one of :data:`REGIMES`. Supplies both fields unless overridden below.
|
|
428
|
+
|
|
429
|
+
``*_override``: a raw value from a config file or the command line -- the rule that a
|
|
430
|
+
config file may only select, never set a threshold, is lifted for exactly these two fields
|
|
431
|
+
Validated before being accepted:
|
|
432
|
+
``area_ratio_z`` must fall in (0, 1] (an area ratio's own definition bounds it there); no bound
|
|
433
|
+
is asserted on ``default_int_arr_thresh`` beyond being a positive, finite number of seconds,
|
|
434
|
+
because no evidence this repository holds justifies an upper limit -- said here rather than an
|
|
435
|
+
invented one being silently enforced.
|
|
436
|
+
|
|
437
|
+
``override_source`` names where an override came from (typically a config file path or
|
|
438
|
+
``"cli"``), embedded in the returned field's ``source`` as ``"user:<override_source>"``.
|
|
439
|
+
``area_ratio_z_source``/``default_int_arr_thresh_source`` (keyword-only) override it per
|
|
440
|
+
field -- needed because a run may mix sources (one field from ``--area-ratio-z``, the other
|
|
441
|
+
from ``[thresholds]``), which the coordinating driver must tag distinctly rather than
|
|
442
|
+
reporting both as coming from wherever the last one was set.
|
|
443
|
+
|
|
444
|
+
``projectname``/``probename``/``tree`` (keyword-only) matter only for the no-regime,
|
|
445
|
+
no-override "default" fallback: ``default_int_arr_thresh`` is looked up from
|
|
446
|
+
``constants.sizedist_config(projectname, probename, tree)`` exactly as ``sizedist.run`` itself
|
|
447
|
+
would, so the fallback stays probe-correct rather than a single literal borrowed from the 2D-S
|
|
448
|
+
case (HVPS and CIP take a different value in the same ``otherwise`` row --
|
|
449
|
+
constants.py:663-688). Default to ``"ORACLES"``/``"2DS"``/``"production"``, which
|
|
450
|
+
reproduces exactly the call every validated flight has used to date.
|
|
451
|
+
"""
|
|
452
|
+
if regime_name is not None and regime_name not in REGIMES:
|
|
453
|
+
raise ValueError(f"unknown regime {regime_name!r}; known: {sorted(REGIMES)}")
|
|
454
|
+
regime = REGIMES[regime_name] if regime_name is not None else None
|
|
455
|
+
|
|
456
|
+
if area_ratio_z_override is not None:
|
|
457
|
+
lo, hi = _AREA_RATIO_BOUNDS
|
|
458
|
+
if not (lo < area_ratio_z_override <= hi):
|
|
459
|
+
raise ThresholdValidationError(
|
|
460
|
+
f"area_ratio_z={area_ratio_z_override!r} is outside ({lo}, {hi}]: an area ratio "
|
|
461
|
+
"(image area / enclosing-shape area) is bounded there by its own definition, "
|
|
462
|
+
"regardless of cloud regime")
|
|
463
|
+
_src = area_ratio_z_source if area_ratio_z_source is not None else override_source
|
|
464
|
+
area_field = ResolvedField(
|
|
465
|
+
value=float(area_ratio_z_override), source=f"user:{_src}",
|
|
466
|
+
justification=f"raw value from {_src}, not tied to a named regime")
|
|
467
|
+
elif regime is not None:
|
|
468
|
+
area_field = ResolvedField(
|
|
469
|
+
value=regime.area_ratio_z, source=f"regime:{regime.name}",
|
|
470
|
+
justification=regime.area_ratio_z_justification)
|
|
471
|
+
else:
|
|
472
|
+
legacy = _legacy_reject(tree)
|
|
473
|
+
area_field = ResolvedField(
|
|
474
|
+
value=legacy.area_ratio_z, source="default",
|
|
475
|
+
justification=("no regime or override given -- the historical hard-coded fallback "
|
|
476
|
+
"every run before 2026-09-17 used unnamed: " + legacy.provenance))
|
|
477
|
+
|
|
478
|
+
if default_int_arr_thresh_override is not None:
|
|
479
|
+
if not (default_int_arr_thresh_override > 0.0
|
|
480
|
+
and default_int_arr_thresh_override < float("inf")):
|
|
481
|
+
raise ThresholdValidationError(
|
|
482
|
+
f"default_int_arr_thresh={default_int_arr_thresh_override!r} must be a positive, "
|
|
483
|
+
"finite number of seconds; no upper bound is asserted (no evidence held here "
|
|
484
|
+
"justifies one)")
|
|
485
|
+
_isrc = (default_int_arr_thresh_source if default_int_arr_thresh_source is not None
|
|
486
|
+
else override_source)
|
|
487
|
+
iat_field = ResolvedField(
|
|
488
|
+
value=float(default_int_arr_thresh_override), source=f"user:{_isrc}",
|
|
489
|
+
justification=f"raw value from {_isrc}, not tied to a named regime")
|
|
490
|
+
elif regime is not None:
|
|
491
|
+
iat_field = ResolvedField(
|
|
492
|
+
value=regime.default_int_arr_thresh, source=f"regime:{regime.name}",
|
|
493
|
+
justification=regime.default_int_arr_thresh_justification)
|
|
494
|
+
else:
|
|
495
|
+
legacy_iat = _legacy_default_int_arr_thresh(projectname, probename, tree)
|
|
496
|
+
iat_field = ResolvedField(
|
|
497
|
+
value=legacy_iat, source="default",
|
|
498
|
+
justification=(
|
|
499
|
+
f"no regime or override given -- the historical hard-coded fallback: "
|
|
500
|
+
f"constants.sizedist_config({projectname!r}, {probename!r}, {tree!r})"
|
|
501
|
+
f".default_int_arr_thresh, applied before 2026-09-17 to every project this "
|
|
502
|
+
f"driver ran (for ORACLES/2DS/production this is "
|
|
503
|
+
f"sizeDist.m:269 (campaign-configured copy), "
|
|
504
|
+
f"'Changed from 1e-6 to 6e-6 for ORACLES', constants.py:674-680), named rather "
|
|
505
|
+
f"than silent from here on"))
|
|
506
|
+
|
|
507
|
+
return ResolvedThresholds(area_ratio_z=area_field, default_int_arr_thresh=iat_field)
|