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,183 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Reproduces SODA-2, Copyright (c) 2016 UCAR; see LICENSES/BSD-3-Clause.txt and NOTICE.md.
|
|
3
|
+
"""``poisson_spot_correct.pro`` -- Korolev (2007) hole-filling size correction.
|
|
4
|
+
|
|
5
|
+
Source: ``SODA2/abansemer-soda2-afcea15/poisson_spot_correct.pro`` (33 lines).
|
|
6
|
+
Called from exactly one place, the shared per-particle tail of
|
|
7
|
+
``soda2_processbuffer.pro:716``::
|
|
8
|
+
|
|
9
|
+
zeed = 0
|
|
10
|
+
area_orig[i] = total(roi)
|
|
11
|
+
roifilled = fillholes(roi)
|
|
12
|
+
area_filled[i] = total(roifilled)
|
|
13
|
+
sizecorrection[i] = poisson_spot_correct(area_orig[i], area_filled[i], zd=zeed)
|
|
14
|
+
|
|
15
|
+
``total()`` of a byte/int array is IDL FLOAT (``soda2_processbuffer.pro:713-716``),
|
|
16
|
+
so both call-site arguments are FLOAT scalars, and the whole computation here is
|
|
17
|
+
float32 end to end -- bare decimal literals in the ``.pro`` source are also FLOAT.
|
|
18
|
+
|
|
19
|
+
What ``poisson_spot_correct.pro`` does, by line:
|
|
20
|
+
|
|
21
|
+
- ``:1`` -- takes the original and filled image areas; returns ``zd``
|
|
22
|
+
through a keyword.
|
|
23
|
+
- ``:8-13``, ``:14-18``, ``:19-22`` -- three 164-entry FLOAT tables: the
|
|
24
|
+
spot-to-edge ratio (0.003 to 0.95), the edge-to-true-diameter ratio
|
|
25
|
+
(1.0 to 1.845) and ``Zd`` (0.0 to 8.15 in 0.05 steps).
|
|
26
|
+
- ``:24-25`` -- defaults: correction 1.0, ``Zd`` 0.0.
|
|
27
|
+
- ``:26`` -- only when both areas are non-negative:
|
|
28
|
+
- ``:27`` -- the ratio is the square root of the hole fraction, (filled
|
|
29
|
+
minus original) over filled, in FLOAT;
|
|
30
|
+
- ``:28`` -- the index is the last table entry not above that ratio,
|
|
31
|
+
clamped to the table's bounds;
|
|
32
|
+
- ``:29-30`` -- ``Zd`` and the correction are read at that index.
|
|
33
|
+
- ``:32`` -- returns the correction.
|
|
34
|
+
|
|
35
|
+
**The ``where`` / clamp trap.** ``where(Dspot_Dedge le ratio)`` on an empty
|
|
36
|
+
match returns ``-1``; IDL's ``max`` of a single-element ``[-1]`` array is
|
|
37
|
+
``-1``; ``> 0`` (IDL's binary MAX, not a comparison) lifts that to ``0``; the
|
|
38
|
+
trailing ``< 163`` (IDL's binary MIN) is a no-op at that end. So a ``ratio``
|
|
39
|
+
of ``NaN`` (from a ``0/0`` or a negative radicand) makes every ``le``
|
|
40
|
+
comparison false, ``where`` returns ``-1``, and the clamp lands on index 0 --
|
|
41
|
+
exactly the same ``(1.0, 0.0)`` the *untaken* branch (``img_orig < 0`` or
|
|
42
|
+
``img_fill < 0``) returns, by a completely different route. See
|
|
43
|
+
finding S4-t for the
|
|
44
|
+
arithmetic-error consequence
|
|
45
|
+
IDL/GDL reports along the way.
|
|
46
|
+
|
|
47
|
+
**Cross-chain table identity.** ``Dspot_Dedge`` equals UIOOPS's ``SPOT_EDGE``
|
|
48
|
+
(``arrayprobe.reject.SPOT_EDGE``) at every index except **146**, where SODA-2
|
|
49
|
+
has the correct ``0.757`` and UIOOPS carries the preserved ``calculate_reject_
|
|
50
|
+
unified.m:54`` typo ``0757`` (parsed as the integer ``757.0``). ``Dedge_D0``
|
|
51
|
+
equals ``arrayprobe.reject.EDGE_0`` and ``Zeed`` equals ``arrayprobe.reject.
|
|
52
|
+
Z_D``, all 164 entries each -- both chains transcribed the same Korolev (2007)
|
|
53
|
+
table; SODA-2's copy is the one without the typo. This module does **not**
|
|
54
|
+
import ``arrayprobe`` -- the tables below are transcribed independently from
|
|
55
|
+
``poisson_spot_correct.pro:8-22`` so the cross-chain test in
|
|
56
|
+
``test_soda2_poisson_spot_correct.py`` compares two independent transcriptions,
|
|
57
|
+
not one value imported twice.
|
|
58
|
+
|
|
59
|
+
Validated against GDL by ``tests/test_soda2_poisson_spot_correct.py``.
|
|
60
|
+
"""
|
|
61
|
+
from __future__ import annotations
|
|
62
|
+
|
|
63
|
+
from dataclasses import dataclass
|
|
64
|
+
|
|
65
|
+
import numpy as np
|
|
66
|
+
|
|
67
|
+
__all__ = ["DSPOT_DEDGE", "DEDGE_D0", "ZEED", "PoissonCorrection", "poisson_spot_correct"]
|
|
68
|
+
|
|
69
|
+
#: ``poisson_spot_correct.pro:8-13`` -- Korolev's hole-to-edge diameter ratio.
|
|
70
|
+
#: Monotone non-decreasing. 164 entries.
|
|
71
|
+
DSPOT_DEDGE = np.array([
|
|
72
|
+
0.003, 0.008, 0.017, 0.024, 0.033, 0.04, 0.047, 0.054, 0.062, 0.072,
|
|
73
|
+
0.076, 0.088, 0.093, 0.096, 0.101, 0.119, 0.123, 0.127, 0.13, 0.134,
|
|
74
|
+
0.139, 0.148, 0.175, 0.18, 0.184, 0.188, 0.192, 0.195, 0.199, 0.202,
|
|
75
|
+
0.206, 0.209, 0.213, 0.217, 0.221, 0.225, 0.23, 0.235, 0.243, 0.327,
|
|
76
|
+
0.334, 0.34, 0.345, 0.351, 0.355, 0.36, 0.365, 0.369, 0.373, 0.377,
|
|
77
|
+
0.381, 0.385, 0.389, 0.393, 0.397, 0.4, 0.404, 0.408, 0.411, 0.415,
|
|
78
|
+
0.419, 0.422, 0.426, 0.429, 0.433, 0.436, 0.439, 0.443, 0.446, 0.45,
|
|
79
|
+
0.453, 0.457, 0.46, 0.463, 0.467, 0.47, 0.473, 0.477, 0.48, 0.484,
|
|
80
|
+
0.487, 0.49, 0.494, 0.497, 0.501, 0.504, 0.507, 0.511, 0.514, 0.518,
|
|
81
|
+
0.521, 0.525, 0.528, 0.532, 0.535, 0.539, 0.543, 0.547, 0.55, 0.554,
|
|
82
|
+
0.558, 0.562, 0.566, 0.569, 0.572, 0.575, 0.578, 0.581, 0.584, 0.587,
|
|
83
|
+
0.59, 0.593, 0.596, 0.598, 0.601, 0.605, 0.61, 0.614, 0.618, 0.623,
|
|
84
|
+
0.627, 0.631, 0.635, 0.64, 0.644, 0.648, 0.653, 0.657, 0.662, 0.666,
|
|
85
|
+
0.671, 0.676, 0.68, 0.685, 0.69, 0.695, 0.7, 0.705, 0.711, 0.716,
|
|
86
|
+
0.721, 0.727, 0.733, 0.738, 0.744, 0.751, 0.757, 0.763, 0.77, 0.777,
|
|
87
|
+
0.784, 0.792, 0.8, 0.808, 0.817, 0.826, 0.836, 0.846, 0.858, 0.87,
|
|
88
|
+
0.884, 0.901, 0.921, 0.95,
|
|
89
|
+
], dtype=np.float32)
|
|
90
|
+
|
|
91
|
+
#: ``:14-18`` -- Korolev's size-correction factor. NOT monotone (rises to
|
|
92
|
+
#: 1.908, then falls) -- that is the shape of Korolev's curve, not a defect.
|
|
93
|
+
#: 164 entries.
|
|
94
|
+
DEDGE_D0 = np.array([
|
|
95
|
+
1.0, 1.054, 1.083, 1.101, 1.095, 1.11, 1.148, 1.162, 1.155, 1.123,
|
|
96
|
+
1.182, 1.121, 1.162, 1.21, 1.242, 1.134, 1.166, 1.202, 1.238, 1.27,
|
|
97
|
+
1.294, 1.278, 1.13, 1.148, 1.17, 1.194, 1.218, 1.242, 1.265, 1.288,
|
|
98
|
+
1.31, 1.331, 1.351, 1.369, 1.386, 1.4, 1.411, 1.416, 1.407, 1.074,
|
|
99
|
+
1.08, 1.087, 1.096, 1.106, 1.117, 1.127, 1.139, 1.15, 1.162, 1.173,
|
|
100
|
+
1.185, 1.197, 1.208, 1.22, 1.232, 1.243, 1.255, 1.266, 1.277, 1.289,
|
|
101
|
+
1.3, 1.311, 1.322, 1.333, 1.344, 1.355, 1.366, 1.376, 1.387, 1.397,
|
|
102
|
+
1.407, 1.418, 1.428, 1.438, 1.448, 1.458, 1.467, 1.477, 1.486, 1.496,
|
|
103
|
+
1.505, 1.515, 1.524, 1.533, 1.542, 1.551, 1.559, 1.568, 1.577, 1.585,
|
|
104
|
+
1.594, 1.602, 1.61, 1.618, 1.626, 1.634, 1.642, 1.65, 1.657, 1.665,
|
|
105
|
+
1.673, 1.68, 1.687, 1.694, 1.702, 1.709, 1.716, 1.722, 1.729, 1.736,
|
|
106
|
+
1.742, 1.749, 1.755, 1.761, 1.768, 1.774, 1.78, 1.786, 1.791, 1.797,
|
|
107
|
+
1.803, 1.808, 1.813, 1.819, 1.824, 1.829, 1.834, 1.839, 1.843, 1.848,
|
|
108
|
+
1.852, 1.857, 1.861, 1.865, 1.869, 1.872, 1.876, 1.88, 1.883, 1.886,
|
|
109
|
+
1.889, 1.892, 1.895, 1.897, 1.899, 1.901, 1.903, 1.905, 1.906, 1.907,
|
|
110
|
+
1.908, 1.908, 1.908, 1.908, 1.907, 1.905, 1.903, 1.9, 1.897, 1.892,
|
|
111
|
+
1.885, 1.877, 1.865, 1.845,
|
|
112
|
+
], dtype=np.float32)
|
|
113
|
+
|
|
114
|
+
#: ``:19-22`` -- Korolev's dimensionless object-plane distance, 0.05 steps.
|
|
115
|
+
#: Monotone. 164 entries.
|
|
116
|
+
ZEED = np.array([
|
|
117
|
+
0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45,
|
|
118
|
+
0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
|
|
119
|
+
1.0, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45,
|
|
120
|
+
1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95,
|
|
121
|
+
2.0, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45,
|
|
122
|
+
2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95,
|
|
123
|
+
3.0, 3.05, 3.1, 3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45,
|
|
124
|
+
3.5, 3.55, 3.6, 3.65, 3.7, 3.75, 3.8, 3.85, 3.9, 3.95,
|
|
125
|
+
4.0, 4.05, 4.1, 4.15, 4.2, 4.25, 4.3, 4.35, 4.4, 4.45,
|
|
126
|
+
4.5, 4.55, 4.6, 4.65, 4.7, 4.75, 4.8, 4.85, 4.9, 4.95,
|
|
127
|
+
5.0, 5.05, 5.1, 5.15, 5.2, 5.25, 5.3, 5.35, 5.4, 5.45,
|
|
128
|
+
5.5, 5.55, 5.6, 5.65, 5.7, 5.75, 5.8, 5.85, 5.9, 5.95,
|
|
129
|
+
6.0, 6.05, 6.1, 6.15, 6.2, 6.25, 6.3, 6.35, 6.4, 6.45,
|
|
130
|
+
6.5, 6.55, 6.6, 6.65, 6.7, 6.75, 6.8, 6.85, 6.9, 6.95,
|
|
131
|
+
7.0, 7.05, 7.1, 7.15, 7.2, 7.25, 7.3, 7.35, 7.4, 7.45,
|
|
132
|
+
7.5, 7.55, 7.6, 7.65, 7.7, 7.75, 7.8, 7.85, 7.9, 7.95,
|
|
133
|
+
8.0, 8.05, 8.1, 8.15,
|
|
134
|
+
], dtype=np.float32)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass(frozen=True)
|
|
138
|
+
class PoissonCorrection:
|
|
139
|
+
"""``{correction, zd}`` -- ``poisson_spot_correct``'s return value plus
|
|
140
|
+
its ``zd=`` keyword output, and ``ip``, the clamped table index (not part
|
|
141
|
+
of the IDL return, exposed here because the tests and the GDL bank need
|
|
142
|
+
to inspect it). ``ip == -1`` means the branch at ``:26`` was not taken."""
|
|
143
|
+
|
|
144
|
+
correction: np.float32
|
|
145
|
+
zd: np.float32
|
|
146
|
+
ip: int
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def poisson_spot_correct(
|
|
150
|
+
img_orig: float | np.floating, img_fill: float | np.floating,
|
|
151
|
+
) -> PoissonCorrection:
|
|
152
|
+
"""``poisson_spot_correct(img_orig, img_fill, zd=zd)`` -- Korolev (2007)
|
|
153
|
+
hole-filling size correction, ported line for line.
|
|
154
|
+
|
|
155
|
+
Source: ``poisson_spot_correct.pro`` (SODA-2).
|
|
156
|
+
|
|
157
|
+
Both arguments are cast to ``np.float32`` at entry (the call site's
|
|
158
|
+
``total()`` already returns FLOAT, so this is a type assertion, not a
|
|
159
|
+
conversion decision). Runs under ``np.errstate(all="ignore")`` because a
|
|
160
|
+
zero or shrinking fill area drives ``:27`` to ``0/0`` or the square root
|
|
161
|
+
of a negative -- IDL/GDL report this as a floating-point arithmetic error
|
|
162
|
+
(SODA-2 register entry S4-t) but the *value* that reaches the caller is well defined: the same
|
|
163
|
+
``(1.0, 0.0)`` the untaken branch returns, arrived at through the
|
|
164
|
+
``where`` result of ``-1`` being clamped to ``0`` at ``:28``.
|
|
165
|
+
"""
|
|
166
|
+
img_orig = np.float32(img_orig)
|
|
167
|
+
img_fill = np.float32(img_fill)
|
|
168
|
+
|
|
169
|
+
correction = np.float32(1.0) # :24
|
|
170
|
+
zd = np.float32(0.0) # :25
|
|
171
|
+
ip = -1
|
|
172
|
+
|
|
173
|
+
with np.errstate(all="ignore"):
|
|
174
|
+
if img_orig >= 0 and img_fill >= 0: # :26
|
|
175
|
+
diff = np.float32(img_fill) - img_orig # :27
|
|
176
|
+
ratio = np.sqrt(diff / img_fill) # :27
|
|
177
|
+
hits = np.flatnonzero(DSPOT_DEDGE <= ratio) # :28 where(...)
|
|
178
|
+
ip = int(hits[-1]) if hits.size else -1 # max(where(...))
|
|
179
|
+
ip = min(max(ip, 0), DSPOT_DEDGE.size - 1) # > 0 < 163
|
|
180
|
+
zd = ZEED[ip] # :29
|
|
181
|
+
correction = DEDGE_D0[ip] # :30
|
|
182
|
+
|
|
183
|
+
return PoissonCorrection(correction=correction, zd=zd, ip=ip)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Reproduces SODA-2, Copyright (c) 2016 UCAR; see LICENSES/BSD-3-Clause.txt and NOTICE.md.
|
|
3
|
+
"""``princomp.pro`` -- SODA-2's orthogonal ("principal components") line fit.
|
|
4
|
+
|
|
5
|
+
23 lines of IDL, no dependencies.
|
|
6
|
+
|
|
7
|
+
**Not a geometry-chain file**, despite being ported first: the design doc's call graph said
|
|
8
|
+
``aspect_ratio`` calls it, and measured against the source it does not. Its only
|
|
9
|
+
callers in the vendored tree are ``fitexp.pro:8`` and ``fitpl.pro:11``, so it is a
|
|
10
|
+
distribution-**fitting** utility. The port is correct and validated; only its
|
|
11
|
+
stage attribution was wrong.
|
|
12
|
+
|
|
13
|
+
**What it computes, and why it is not least squares.** ``yfit = c[0] + c[1]*x``
|
|
14
|
+
minimising the **perpendicular** distance from each point to the line, not the
|
|
15
|
+
vertical one. For a particle's major axis that is the correct choice and an
|
|
16
|
+
ordinary least-squares fit is not: OLS is asymmetric in x and y, so rotating the
|
|
17
|
+
particle would change the answer. The slope comes from the larger eigenvalue of
|
|
18
|
+
the scatter matrix (``princomp.pro:17-20``): the larger eigenvalue
|
|
19
|
+
``xlam`` of the 2x2 scatter matrix; the slope ``c[1]`` as ``xlam`` minus
|
|
20
|
+
``sxx`` over ``sxy``; the intercept ``c[0]`` through the means
|
|
21
|
+
(``:19``); and the correlation as ``sxy`` over the root of ``sxx*syy``.
|
|
22
|
+
|
|
23
|
+
**Two unguarded divisions, and they are reproduced rather than fixed.** ``sxy``
|
|
24
|
+
is zero for any point set with no linear correlation -- a horizontal or vertical
|
|
25
|
+
line, a symmetric cross, a symmetric parabola, a single point. IDL does not raise
|
|
26
|
+
there; it yields Inf or NaN by IEEE rules and carries on. Measured under GDL on
|
|
27
|
+
the vendored source (``gdl_oracle/run_soda2_princomp_bank.py``), and the four
|
|
28
|
+
outcomes are genuinely different, which is why they are worth pinning:
|
|
29
|
+
|
|
30
|
+
=================== ========== ========== ======= ====================================
|
|
31
|
+
case ``c[0]`` ``c[1]`` ``corr`` why
|
|
32
|
+
=================== ========== ========== ======= ====================================
|
|
33
|
+
horizontal line NaN NaN NaN ``sxy`` and ``syy`` both 0
|
|
34
|
+
vertical line ``-inf`` ``+inf`` NaN ``sxx`` 0, so ``xlam-sxx`` > 0 over 0
|
|
35
|
+
symmetric cross NaN NaN **0** ``xlam == sxx`` exactly, so 0/0
|
|
36
|
+
symmetric parabola NaN ``+inf`` **0** ``xlam-sxx`` > 0 over 0
|
|
37
|
+
=================== ========== ========== ======= ====================================
|
|
38
|
+
|
|
39
|
+
Note the last two: ``corr`` is a clean **0** in both -- ``sxy`` is 0 and
|
|
40
|
+
``sqrt(sxx*syy)`` is positive -- while ``c[1]`` is NaN in one and ``+inf`` in the
|
|
41
|
+
other, decided purely by whether ``xlam - sxx`` is zero. A port that collapsed
|
|
42
|
+
these to a single "degenerate" answer would be wrong about three of the four.
|
|
43
|
+
|
|
44
|
+
**The length mismatch is a halt, not a return.** ``print`` then ``stop``: IDL
|
|
45
|
+
drops to the interactive prompt, which in a batch run ends it. Reproduced as a
|
|
46
|
+
raised exception, the same pattern the v3.5 port uses for ``CGAL_minR``'s
|
|
47
|
+
abort -- an exception is the closest Python equivalent of "execution stops here",
|
|
48
|
+
and returning a value would invent a behaviour the original does not have.
|
|
49
|
+
|
|
50
|
+
Provenance: ``SODA2/abansemer-soda2-afcea15/princomp.pro`` (whole file).
|
|
51
|
+
Validated against GDL by ``tests/test_soda2_princomp.py``.
|
|
52
|
+
"""
|
|
53
|
+
from __future__ import annotations
|
|
54
|
+
|
|
55
|
+
import numpy as np
|
|
56
|
+
from numpy.typing import ArrayLike
|
|
57
|
+
|
|
58
|
+
__all__ = ["PrincompLengthMismatch", "princomp"]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class PrincompLengthMismatch(RuntimeError):
|
|
62
|
+
"""``princomp.pro``'s own length check reached: it prints
|
|
63
|
+
``** Error: x and y arrays not the same length`` and then ``stop``, which
|
|
64
|
+
halts IDL rather than returning. Raised here for the same reason the v3.5
|
|
65
|
+
port raises on ``CGAL_minR``'s abort: the original does not produce a value
|
|
66
|
+
on this path, so neither may the port."""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def princomp(x: ArrayLike, y: ArrayLike) -> tuple[np.ndarray, float]:
|
|
70
|
+
"""``c = princomp(x, y, corr)`` -- returns ``(c, corr)``.
|
|
71
|
+
|
|
72
|
+
Source: ``princomp.pro`` (SODA-2).
|
|
73
|
+
|
|
74
|
+
IDL's third argument is a pass-by-reference **output**; Python has no such
|
|
75
|
+
thing, so it is returned alongside ``c`` rather than mutated into a caller's
|
|
76
|
+
variable.
|
|
77
|
+
|
|
78
|
+
Arithmetic is float64 throughout, matching ``dblarr(2)`` and the
|
|
79
|
+
``total()`` calls on doubled inputs. Division by zero is left to IEEE --
|
|
80
|
+
see the module docstring for the four measured outcomes.
|
|
81
|
+
"""
|
|
82
|
+
xa = np.asarray(x, dtype=np.float64).ravel()
|
|
83
|
+
ya = np.asarray(y, dtype=np.float64).ravel()
|
|
84
|
+
if ya.size != xa.size:
|
|
85
|
+
raise PrincompLengthMismatch(
|
|
86
|
+
f"x and y arrays not the same length ({xa.size} vs {ya.size}); "
|
|
87
|
+
"princomp.pro prints and then stops, so there is no return value "
|
|
88
|
+
"to reproduce")
|
|
89
|
+
|
|
90
|
+
npts = xa.size
|
|
91
|
+
xmean = xa.sum() / float(npts)
|
|
92
|
+
ymean = ya.sum() / float(npts)
|
|
93
|
+
sxx = ((xa - xmean) ** 2).sum()
|
|
94
|
+
syy = ((ya - ymean) ** 2).sum()
|
|
95
|
+
sxy = ((xa - xmean) * (ya - ymean)).sum()
|
|
96
|
+
|
|
97
|
+
xlam = 0.5 * (sxx + syy) + 0.5 * np.sqrt((sxx - syy) ** 2 + 4.0 * sxy ** 2)
|
|
98
|
+
|
|
99
|
+
# `errstate(invalid, divide)`: IDL raises nothing here and neither may we.
|
|
100
|
+
# numpy would otherwise warn on 0/0 and x/0, and a warning filter set
|
|
101
|
+
# elsewhere in a caller's process could turn that into an exception.
|
|
102
|
+
with np.errstate(invalid="ignore", divide="ignore"):
|
|
103
|
+
c1 = (xlam - sxx) / sxy
|
|
104
|
+
c0 = ymean - c1 * xmean
|
|
105
|
+
corr = sxy / np.sqrt(sxx * syy)
|
|
106
|
+
|
|
107
|
+
return np.array([c0, c1], dtype=np.float64), float(corr)
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Reproduces SODA-2, Copyright (c) 2016 UCAR; see LICENSES/BSD-3-Clause.txt and NOTICE.md.
|
|
3
|
+
"""`soda2_probespecs.pro` -- the SODA-2 probe table, 72 probes.
|
|
4
|
+
|
|
5
|
+
Vendored source: `SODA2/abansemer-soda2-afcea15/soda2_probespecs.pro` (1,479
|
|
6
|
+
lines). Bank: `gdl_oracle/run_soda2_probespecs_bank.py`, golden
|
|
7
|
+
`tests/data/gdl_soda2_probespecs_golden.json` -- every field of every probe,
|
|
8
|
+
and its IDL type, as GDL evaluates the unmodified `.pro`.
|
|
9
|
+
|
|
10
|
+
**What the routine is.** One `base` structure (`:8-10`), copied 72 times with
|
|
11
|
+
its fields overwritten (`x=base`, `x.<tag>=...`, `all=[all,x]`), then
|
|
12
|
+
`:1463-1478`: look up by `name=`, by `id=`, or return the whole table.
|
|
13
|
+
Units (`:3`): `res`/`yres` um, `armwidth` cm, `tau` s, `wavelength` m.
|
|
14
|
+
|
|
15
|
+
**Types are the point, not the numbers.** Every assignment converts to the
|
|
16
|
+
field's declared type (`:8-10`), and the rest of the chain computes in that
|
|
17
|
+
type:
|
|
18
|
+
|
|
19
|
+
- STRING: `probename`, `shortname`, `format`, `probetype`, `probeid`;
|
|
20
|
+
- INT (`numpy.int16`): `subformat` (`0s`), `greythresh`, `firstsliceskip`;
|
|
21
|
+
- FLOAT (`numpy.float32`): `res`, `yres`, `armwidth`, `numdiodes`, `tau`,
|
|
22
|
+
`dofthreshold`, `dofconst`, `wavelength`. `x.res=25` is an INT literal stored
|
|
23
|
+
as FLOAT 25.0; `x.tau=41.0e-9` is a FLOAT literal, and the 2D-S's
|
|
24
|
+
`x.wavelength=0.785e-6` (`:955`) is float32 7.849999974e-07 -- the value
|
|
25
|
+
`soda2_samplearea.pro:14`'s Lawson sentinel compares against in FLOAT;
|
|
26
|
+
- LONG[3] (`numpy.int32`): `seatag`; INT[2] (`numpy.int16`): `dioderange`.
|
|
27
|
+
|
|
28
|
+
`numdiodes` is FLOAT here but INT in `soda2_update_op.pro:23`'s default
|
|
29
|
+
(`update_op.py` keeps it INT16): the two routes to an `op` disagree on its type.
|
|
30
|
+
|
|
31
|
+
**A short array into a longer field fills the leading elements (GDL-measured).**
|
|
32
|
+
`x.seatag=[33000]` (`:496`) gives `[33000, 0, 0]`; `x.seatag=[33000, 32000]`
|
|
33
|
+
(`:156`) gives `[33000, 32000, 0]` -- not a broadcast, not an error. The
|
|
34
|
+
trailing elements are `base`'s zeros, because every block starts from
|
|
35
|
+
`x=base`. IDL's own behaviour here is not measured (no IDL licence); the port
|
|
36
|
+
follows GDL, and `soda2_update_op.pro:30`'s default `[33000,0,0]` -- which
|
|
37
|
+
reads as "image tag first, the rest unused" -- is consistent with it.
|
|
38
|
+
|
|
39
|
+
**Return shape.** IDL structures are always arrays (`size(/n_dimensions)` is 1
|
|
40
|
+
for a single structure). This port returns a ``dict`` for a one-element result
|
|
41
|
+
and a ``list[dict]`` for more, because a field read through a one-element
|
|
42
|
+
structure array is a scalar **under GDL** (measured: `r.res` has
|
|
43
|
+
`n_dimensions` 0 for `r = soda2_probespecs(name=...)`), and every `op` in this
|
|
44
|
+
port carries scalars. **IDL keeps `Array[1]` there** (read, not measured --
|
|
45
|
+
the same GDL collapse the Y2 `process_2d` bank met), so IDL's own
|
|
46
|
+
`example_batch.pro:47-52` builds an `op` whose probe fields are one-element
|
|
47
|
+
arrays; UND's 0914 HVPS-3 `op` in its SAVE file carries exactly that shape.
|
|
48
|
+
The port's scalars are the GDL reading, named here rather than hidden.
|
|
49
|
+
|
|
50
|
+
**Lookup edges, all banked:** a miss returns `base` silently; the `name` test
|
|
51
|
+
(`:1464`) is case- and whitespace-exact; an *array* `name` compares
|
|
52
|
+
element-wise against the leading probes only (IDL's shortest-operand rule), so
|
|
53
|
+
`name=['HVPS-3']` compares against `all[0]` and misses, and a two-element
|
|
54
|
+
`name` halts at `:1465` (`IF` on a two-element condition); `id` is guarded by
|
|
55
|
+
`max(id) lt n_elements(all)` (`:1474`), which admits a negative scalar (GDL
|
|
56
|
+
wraps it: `id=-1` is the last probe) and a negative entry in an index array
|
|
57
|
+
(clipped to 0); `name` wins over `id`; `fn` is ignored except for
|
|
58
|
+
`'Simulation'`, where `:1467-1469` hands the probe to `soda2_update_op`
|
|
59
|
+
(`update_op.py`, whose `.txt` header parse is refused by name there).
|
|
60
|
+
"""
|
|
61
|
+
from __future__ import annotations
|
|
62
|
+
|
|
63
|
+
import copy
|
|
64
|
+
from typing import Any
|
|
65
|
+
|
|
66
|
+
import numpy as np
|
|
67
|
+
|
|
68
|
+
__all__ = ["IDL_TYPES", "PROBE_NAMES", "SOURCE_LINES", "TAGS", "soda2_probespecs"]
|
|
69
|
+
|
|
70
|
+
#: The 18 tags of `base` (`:8-10`), in declaration order, lower-case.
|
|
71
|
+
TAGS: tuple[str, ...] = (
|
|
72
|
+
"probename", "shortname", "format", "subformat", "probetype", "probeid",
|
|
73
|
+
"greythresh", "res", "yres", "armwidth", "numdiodes", "tau", "firstsliceskip",
|
|
74
|
+
"dofthreshold", "dofconst", "wavelength", "seatag", "dioderange",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
#: IDL type of each tag, as `base` declares it (`:8-10`) and GDL reports it.
|
|
78
|
+
IDL_TYPES: dict[str, str] = {
|
|
79
|
+
"probename": "STRING", "shortname": "STRING", "format": "STRING",
|
|
80
|
+
"subformat": "INT", "probetype": "STRING", "probeid": "STRING",
|
|
81
|
+
"greythresh": "INT", "res": "FLOAT", "yres": "FLOAT", "armwidth": "FLOAT",
|
|
82
|
+
"numdiodes": "FLOAT", "tau": "FLOAT", "firstsliceskip": "INT",
|
|
83
|
+
"dofthreshold": "FLOAT", "dofconst": "FLOAT", "wavelength": "FLOAT",
|
|
84
|
+
"seatag": "LONG", "dioderange": "INT",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_DTYPES: dict[str, type] = {"INT": np.int16, "LONG": np.int32, "FLOAT": np.float32}
|
|
88
|
+
_ARRAY_LEN: dict[str, int] = {"seatag": 3, "dioderange": 2} # lonarr(3), intarr(2)
|
|
89
|
+
|
|
90
|
+
#: The 72 blocks, in source order: the line of each block's `x=base`, then the
|
|
91
|
+
#: 17 values its `x.<tag>=` lines assign in `TAGS` order (`probename` ...
|
|
92
|
+
#: `seatag`), then `dioderange` (assigned by three blocks only; `None` keeps
|
|
93
|
+
#: `base`'s `[0, 0]`). Values are the source literals, unconverted -- `_coerce`
|
|
94
|
+
#: applies the field's type, as IDL's assignment does. Transcribed
|
|
95
|
+
#: mechanically from the `.pro` and asserted field by field against GDL's
|
|
96
|
+
#: evaluation of it (`tests/test_soda2_probespecs.py`).
|
|
97
|
+
_ROWS: tuple[tuple[Any, ...], ...] = (
|
|
98
|
+
(18, "NASA Langley CAPS", "CIP10", "DMT", 0, "CIP", "", 0,
|
|
99
|
+
25, 25, 10, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
100
|
+
(39, "CAPS-Grey", "CIPG", "DMT", 1, "CIPG", "", 2,
|
|
101
|
+
15, 15, 10, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
102
|
+
(59, "CAPS-Grey (University of Wyoming)", "CIPG", "DMT", 1, "CIPG", "", 2,
|
|
103
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
104
|
+
(79, "NOAA HRD CIP Grey (PADS)", "CIPG", "DMT", 1, "CIPG", "", 2,
|
|
105
|
+
25, 25, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
106
|
+
(99, "DLR CAPS-Grey (PADS)", "CIP_DLR", "DMT", 1, "CIPG", "", 2,
|
|
107
|
+
25, 25, 4.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
108
|
+
(119, "DLR PIP (PADS)", "PIP", "DMT", 1, "CIPG", "", 1,
|
|
109
|
+
100, 100, 26.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
110
|
+
(139, "WMI CIP (SEA M300)", "CIP", "SEA", 1, "CIPG", "", 1,
|
|
111
|
+
15, 15, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (33000, 32000,), None),
|
|
112
|
+
(159, "CIRPAS CIP (PACS)", "CIP", "DMT", 0, "CIP", "", 0,
|
|
113
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
114
|
+
(179, "CIRPAS PIP (PACS)", "PIP", "DMT", 0, "CIP", "", 0,
|
|
115
|
+
100, 100, 10, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
116
|
+
(199, "CIRPAS CIP (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
117
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
118
|
+
(219, "CIRPAS PIP (PADS)", "PIP", "DMT", 1, "CIP", "", 0,
|
|
119
|
+
100, 100, 10, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
120
|
+
(239, "NCAR-RAL CIP (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
121
|
+
25, 25, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
122
|
+
(259, "NCAR-RAL PIP (PADS)", "PIP", "DMT", 1, "CIP", "", 0,
|
|
123
|
+
100, 100, 26.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
124
|
+
(279, "NOAA HRD CIP (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
125
|
+
25, 25, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
126
|
+
(299, "NOAA HRD PIP (PADS)", "PIP", "DMT", 1, "CIP", "", 0,
|
|
127
|
+
100, 100, 40.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
128
|
+
(319, "University of Oslo CIP (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
129
|
+
25, 25, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
130
|
+
(338, "FAAM CIP100 (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
131
|
+
100, 100, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
132
|
+
(359, "FAAM CIP-Grey (PADS)", "CIPG", "DMT", 1, "CIPG", "", 2,
|
|
133
|
+
15, 15, 4.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
134
|
+
(379, "SEA CIP-Grey (SEA M300)", "CIPG", "SEA", 1, "CIPG", "", 2,
|
|
135
|
+
25, 25, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (3000, 2000,), None),
|
|
136
|
+
(399, "NASA Glenn CIP-Grey (SEA M300)", "CIPG", "SEA", 1, "CIPG", "", 2,
|
|
137
|
+
15, 15, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (23000, 22000,), None),
|
|
138
|
+
(419, "Shanxi CIP-Mono (PADS)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
139
|
+
25, 25, 10.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
140
|
+
(439, "Shanxi PIP-Mono (PADS)", "PIP", "DMT", 1, "CIP", "", 0,
|
|
141
|
+
100, 100, 26.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
142
|
+
(459, "Shanxi PIP-Grey (PADS)", "PIPG", "DMT", 1, "CIPG", "", 2,
|
|
143
|
+
100, 100, 26.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
144
|
+
(479, "Monash CIP (SEA M300)", "CIP", "SEA", 1, "CIP", "", 0,
|
|
145
|
+
25, 25, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (33000,), None),
|
|
146
|
+
(499, "NRC CIP (SEA M300)", "CIP", "SEA", 1, "CIP", "", 0,
|
|
147
|
+
15, 15, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (33000,), None),
|
|
148
|
+
(519, "NRC PIP (SEA M300)", "PIP", "SEA", 1, "CIP", "", 0,
|
|
149
|
+
100, 100, 22.7, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (31000,), None),
|
|
150
|
+
(539, "NRC 2DC (SEA M300)", "2DC", "SEA", 1, "2DC", "", 0,
|
|
151
|
+
50, 50, 7.7, 32, 0.58e-6, 1, 0.0, 3.0, 0.6328e-6, (7000, 7006, 7007,), None),
|
|
152
|
+
(559, "NRC 2DP (SEA M300)", "2DP", "SEA", 1, "2DC", "", 0,
|
|
153
|
+
200, 200, 26.0, 32, 0.58e-6, 1, 0.0, 3.0, 0.6328e-6, (8000, 8006, 8007,), None),
|
|
154
|
+
(579, "HIWC PIP (SEA M300)", "PIP", "SEA", 1, "CIP", "", 0,
|
|
155
|
+
100, 100, 22.2, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (35000, 34000, 0,), None),
|
|
156
|
+
(599, "HIWC PIP (PADS)", "PIP", "DMT", 1, "CIP", "", 0,
|
|
157
|
+
100, 100, 22.2, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (35000, 34000, 0,), None),
|
|
158
|
+
(619, "CCP from SPEC (SEA M300)", "CIP", "SEA", 1, "CIP", "", 0,
|
|
159
|
+
15, 15, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (36000,), None),
|
|
160
|
+
(639, "NIMS CCP (15um)", "CIP", "DMT", 1, "CIP", "", 0,
|
|
161
|
+
15, 15, 4.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
162
|
+
(659, "UNIVIE CIP Greyscale", "CIP", "DMT", 1, "CIPG", "", 2,
|
|
163
|
+
15, 15, 7.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
164
|
+
(679, "UNIVIE PIP Monoscale", "PIP", "DMT", 1, "CIP", "", 0,
|
|
165
|
+
100, 100, 22.5, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
166
|
+
(699, "NCAR Fast-2DC [C4] (25um)", "F2DC", "RAF", 3, "F2DC", "C4", 0,
|
|
167
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
168
|
+
(719, "NCAR Fast-2DC_v2 [C4] (25um)", "F2DC", "RAF", 3, "F2DC_v2", "C4", 0,
|
|
169
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
170
|
+
(739, "NCAR Fast-2DC [C4] (25um) Pre-2011", "F2DC", "RAF", 0, "F2DC", "C4", 0,
|
|
171
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
172
|
+
(759, "NCAR Fast-2DC (25um) 66% DoF threshold", "F2DC", "RAF", 3, "F2DC66", "C4", 0,
|
|
173
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 66.0, 3.0, 0.658e-6, (0,), None),
|
|
174
|
+
(779, "NCAR Fast-2DC [C5] (25um)", "F2DC", "RAF", 3, "F2DC", "C5", 0,
|
|
175
|
+
25, 25, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
176
|
+
(799, "NCAR Fast-2DC [C6] (10um)", "F2DC10", "RAF", 3, "F2DC", "C6", 0,
|
|
177
|
+
10, 10, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
178
|
+
(819, "NCAR Fast-2DC_v2 [C6] (10um)", "F2DC10", "RAF", 3, "F2DC_v2", "C6", 0,
|
|
179
|
+
10, 10, 6.1, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
180
|
+
(839, "NCAR 2DP", "2DP", "RAF", 3, "2DC", "P1", 0,
|
|
181
|
+
200, 200, 26.1, 32, 0.6e-6, 1, 0.0, 3.0, 0.6328e-6, (0,), None),
|
|
182
|
+
(859, "NCAR Fast-2DP [P4] (150um)", "F2DP", "RAF", 3, "F2DC", "P4", 0,
|
|
183
|
+
150, 150, 26.1, 64, 0.6e-6, 0, 0.0, 3.0, 0.6328e-6, (0,), None),
|
|
184
|
+
(879, "Wyoming Fast-2DC (NCAR-RAF format)", "F2DC", "RAF", 3, "F2DC", "C5", 0,
|
|
185
|
+
25, 25, 6.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (0,), None),
|
|
186
|
+
(899, "Wyoming 2DP (NCAR-RAF format)", "2DP", "RAF", 4, "2DC", "P1", 0,
|
|
187
|
+
200, 200, 26.0, 32, 0.6e-6, 1, 0.0, 3.0, 0.6328e-6, (0,), None),
|
|
188
|
+
(919, "HVPS-3", "HVPS3", "SPEC", 0, "HVPS3", "V", 0,
|
|
189
|
+
150, 150, 16.25, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
190
|
+
(939, "2D-S Horizontal Array", "2DS", "SPEC", 0, "2DS", "H", 0,
|
|
191
|
+
10, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
192
|
+
(959, "2D-S Vertical Array", "2DS", "SPEC", 0, "2DS", "V", 0,
|
|
193
|
+
10, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
194
|
+
(979, "2D-S Horizontal Array (11um)", "2DS", "SPEC", 0, "2DS", "H", 0,
|
|
195
|
+
11, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
196
|
+
(999, "2D-S Vertical Array (11um)", "2DS", "SPEC", 0, "2DS", "V", 0,
|
|
197
|
+
11, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
198
|
+
(1019, "Fast 2D-S Horizontal Array (11um)", "F2DS", "SPEC", 1, "2DS", "H", 0,
|
|
199
|
+
11, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
200
|
+
(1039, "Fast 2D-S Vertical Array (11um)", "F2DS", "SPEC", 1, "2DS", "V", 0,
|
|
201
|
+
11, 10, 6.3, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
202
|
+
(1059, "3VCPI/Hawkeye Horizontal Array", "3VCPI", "SPEC", 1, "3VCPI", "H", 0,
|
|
203
|
+
10, 10, 5.08, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
204
|
+
(1079, "3VCPI/Hawkeye Horizontal Array (50um)", "3VCPI", "SPEC", 1, "3VCPI", "H", 0,
|
|
205
|
+
50, 50, 5.08, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
206
|
+
(1099, "3VCPI/Hawkeye Vertical Array", "3VCPI", "SPEC", 1, "3VCPI", "V", 0,
|
|
207
|
+
10, 10, 5.08, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
208
|
+
(1119, "HVPS-4 Vertical Array (50um)", "HVPS4", "SPEC", 2, "HVPS4", "V50", 0,
|
|
209
|
+
50, 50, 12.0, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
210
|
+
(1139, "HVPS-4 Vertical Array (150um)", "HVPS4", "SPEC", 2, "HVPS4", "V150", 0,
|
|
211
|
+
150, 150, 12.0, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
212
|
+
(1159, "HVPS-4 Horizontal Array (50um)", "HVPS4", "SPEC", 2, "HVPS4", "H50", 0,
|
|
213
|
+
50, 50, 12.0, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
214
|
+
(1179, "HVPS-4 Horizontal Array (150um)", "HVPS4", "SPEC", 2, "HVPS4", "H150", 0,
|
|
215
|
+
150, 150, 12.0, 128, 41.0e-9, 0, 0.0, 8.12, 0.785e-6, (0,), None),
|
|
216
|
+
(1199, "UND 2DC", "2DC", "SEA", 0, "2DC", "", 0,
|
|
217
|
+
30, 30, 6.1, 32, 0.6e-6, 1, 0.0, 3.0, 0.6328e-6, (5000, 5001, 5002,), None),
|
|
218
|
+
(1219, "UND 2DC with Korolev Tips", "2DC7", "SEA", 0, "2DC", "", 0,
|
|
219
|
+
30, 30, 7.0, 32, 0.6e-6, 1, 0.0, 3.0, 0.6328e-6, (5000, 5001, 5002,), None),
|
|
220
|
+
(1239, "UND CIP (SEA M300)", "CIP", "SEA", 1, "CIP", "", 0,
|
|
221
|
+
25, 25, 6.0, 64, 0.051e-6, 0, 0.0, 3.0, 0.658e-6, (33000, 32000, 0,), None),
|
|
222
|
+
(1259, "MSC 2DC", "2DC", "SEA", 0, "2DC", "", 0,
|
|
223
|
+
25, 25, 6.1, 32, 0.58e-6, 1, 0.0, 3.0, 0.6328e-6, (33000,), None),
|
|
224
|
+
(1279, "SEA 1D2D-X (15um)", "1D2D-X", "SEA", 0, "1D2D", "", 0,
|
|
225
|
+
15, 15, 5.83, 64, 0.020e-6, 0, 0.0, 8.0, 0.660e-6, (10000, 10001,), None),
|
|
226
|
+
(1299, "SEA 1D2D-Y (50um)", "1D2D-Y", "SEA", 0, "1D2D", "", 0,
|
|
227
|
+
50, 50, 26.0, 64, 0.020e-6, 0, 0.0, 8.0, 0.660e-6, (11000, 11001,), None),
|
|
228
|
+
(1319, "SDSMT Hail Spectrometer (SEA)", "HAIL", "SEA", 0, "HAIL", "", 0,
|
|
229
|
+
900, 900, 99.0, 64, 0.020e-6, 0, 0.0, 3.0, 0.660e-6, (320,), None),
|
|
230
|
+
(1339, "SDSMT HVPS-1 (SEA)", "HVPS1", "SEA", 0, "HVPS1", "", 0,
|
|
231
|
+
200, 400, 20.0, 256, 0.020e-6, 0, 0.0, 3.0, 0.660e-6, (6000, 6001, 6002,), (40, 230,)),
|
|
232
|
+
(1360, "SDSMT HVPS-1 (1995 Format)", "HVPS1", "HVPS1995", 0, "HVPS1", "", 0,
|
|
233
|
+
200, 400, 20.0, 256, 0.020e-6, 0, 0.0, 3.0, 0.660e-6, (6000, 6001, 6002,), (35, 220,)),
|
|
234
|
+
(1381, "SDSMT 2DC (SEA)", "2DC", "SEA", 0, "2DC", "", 0,
|
|
235
|
+
25, 25, 6.1, 32, 0.051e-6, 1, 0.0, 3.0, 0.632e-6, (300, 301, 302,), None),
|
|
236
|
+
(1401, "SDSMT 2DP (SEA)", "2DP", "SEA", 0, "2DC", "", 0,
|
|
237
|
+
200, 200, 26.0, 32, 0.051e-6, 1, 0.0, 3.0, 0.632e-6, (310, 311, 312,), None),
|
|
238
|
+
(1421, "NCAR HVPS-1", "HVPS1", "RAF", 3, "HVPS1", "H1", 0,
|
|
239
|
+
200, 400, 20.0, 256, 0.020e-6, 0, 0.0, 3.0, 0.660e-6, (0,), (35, 220,)),
|
|
240
|
+
(1442, "Simulation", "SIM", "TXT", 0, "TXT", "", 0,
|
|
241
|
+
0, 0, 0, 0, 0, 0, 0.0, 0.0, 0, (0,), None),
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _coerce(tag: str, value: Any) -> Any:
|
|
246
|
+
"""`value` converted to `tag`'s declared type, as IDL's field assignment does."""
|
|
247
|
+
kind = IDL_TYPES[tag]
|
|
248
|
+
if kind == "STRING":
|
|
249
|
+
return str(value)
|
|
250
|
+
dtype = _DTYPES[kind]
|
|
251
|
+
if tag in _ARRAY_LEN:
|
|
252
|
+
out: np.ndarray = np.zeros(_ARRAY_LEN[tag], dtype=dtype)
|
|
253
|
+
if value is not None:
|
|
254
|
+
vals = np.atleast_1d(np.asarray(value))
|
|
255
|
+
# GDL-measured: fewer elements than the field fill the leading ones.
|
|
256
|
+
out[: len(vals)] = vals
|
|
257
|
+
return out
|
|
258
|
+
return dtype(value)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _base() -> dict[str, Any]:
|
|
262
|
+
"""`:8-10`: the `base` structure -- what every miss returns."""
|
|
263
|
+
b: dict[str, Any] = {}
|
|
264
|
+
for tag in TAGS:
|
|
265
|
+
kind = IDL_TYPES[tag]
|
|
266
|
+
b[tag] = "" if kind == "STRING" else _coerce(tag, None if tag in _ARRAY_LEN else 0)
|
|
267
|
+
b["dofconst"] = np.float32(3.0) # `dofconst:3.0`
|
|
268
|
+
return b
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _build(row: tuple[Any, ...]) -> dict[str, Any]:
|
|
272
|
+
x = _base() # `x=base`
|
|
273
|
+
for tag, value in zip(TAGS, row[1:], strict=True):
|
|
274
|
+
x[tag] = _coerce(tag, value)
|
|
275
|
+
return x
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
#: `all`, built once. Never handed out directly: lookups return deep copies,
|
|
279
|
+
#: because IDL returns a copy and a caller that edits its `op` must not edit
|
|
280
|
+
#: the table for the next caller.
|
|
281
|
+
_ALL: tuple[dict[str, Any], ...] = tuple(_build(r) for r in _ROWS)
|
|
282
|
+
|
|
283
|
+
#: Every probe name, in table order (`all.probename`).
|
|
284
|
+
PROBE_NAMES: tuple[str, ...] = tuple(p["probename"] for p in _ALL)
|
|
285
|
+
|
|
286
|
+
#: Each probe's `x=base` line in the vendored `.pro`, for citation.
|
|
287
|
+
SOURCE_LINES: dict[str, int] = {r[1]: r[0] for r in _ROWS}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def _result(items: list[dict[str, Any]]) -> dict[str, Any] | list[dict[str, Any]]:
|
|
291
|
+
items = [copy.deepcopy(p) for p in items]
|
|
292
|
+
return items[0] if len(items) == 1 else items
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def soda2_probespecs(
|
|
296
|
+
name: str | list[str] | tuple[str, ...] | None = None,
|
|
297
|
+
id: int | list[int] | tuple[int, ...] | None = None, # noqa: A002 - the IDL keyword
|
|
298
|
+
fn: str | None = None,
|
|
299
|
+
) -> dict[str, Any] | list[dict[str, Any]]:
|
|
300
|
+
"""`soda2_probespecs(name=, id=, fn=)`, `:1463-1478`.
|
|
301
|
+
|
|
302
|
+
Source: ``soda2_probespecs.pro`` (SODA-2); bare line references here are into that file.
|
|
303
|
+
|
|
304
|
+
Returns one probe as a ``dict`` (the table row, or `base` on a miss), or a
|
|
305
|
+
``list[dict]`` when IDL would return several. See the module docstring for
|
|
306
|
+
every edge; each is a bank case.
|
|
307
|
+
"""
|
|
308
|
+
n_all = len(_ALL)
|
|
309
|
+
# :1463 `IF n_elements(name) ne 0`
|
|
310
|
+
if name is not None and not (isinstance(name, (list, tuple)) and len(name) == 0):
|
|
311
|
+
if isinstance(name, str):
|
|
312
|
+
# :1464 scalar `name eq all.probename` -> every probe compared.
|
|
313
|
+
w = [i for i, pn in enumerate(PROBE_NAMES) if pn == name]
|
|
314
|
+
sim = name == "Simulation"
|
|
315
|
+
else:
|
|
316
|
+
names = list(name)
|
|
317
|
+
# Shortest-operand rule: element k against all[k], k < min length.
|
|
318
|
+
m = min(len(names), n_all)
|
|
319
|
+
w = [k for k in range(m) if names[k] == PROBE_NAMES[k]]
|
|
320
|
+
if len(names) > 1:
|
|
321
|
+
# :1465 `IF` on a multi-element condition halts IDL/GDL.
|
|
322
|
+
raise ValueError(
|
|
323
|
+
"soda2_probespecs.pro:1465: Expression must be a scalar or 1 "
|
|
324
|
+
"element array in this context (a name array of "
|
|
325
|
+
f"{len(names)} elements)")
|
|
326
|
+
sim = names[0] == "Simulation"
|
|
327
|
+
if sim and fn is not None:
|
|
328
|
+
raise NotImplementedError(
|
|
329
|
+
"soda2_probespecs.pro:1465-1469 with a one-element ARRAY name "
|
|
330
|
+
"'Simulation' and fn=: `where` misses (it compares against "
|
|
331
|
+
"all[0] only), so :1467 subscripts all[-1]; not banked, "
|
|
332
|
+
"not ported")
|
|
333
|
+
if sim and fn is not None:
|
|
334
|
+
# :1467 create_struct(all[w], 'fn', fn, 'endbins', [0,0]); :1468.
|
|
335
|
+
from arrayprobe_soda2.update_op import update_op
|
|
336
|
+
|
|
337
|
+
probe = copy.deepcopy(_ALL[w[0]])
|
|
338
|
+
probe["fn"] = fn
|
|
339
|
+
probe["endbins"] = np.array([0, 0], dtype=np.int16)
|
|
340
|
+
return update_op(probe)
|
|
341
|
+
# :1471
|
|
342
|
+
return _result([_ALL[i] for i in w]) if w else _base()
|
|
343
|
+
# :1473 `IF n_elements(id) ne 0`
|
|
344
|
+
if id is not None and not (isinstance(id, (list, tuple)) and len(id) == 0):
|
|
345
|
+
if isinstance(id, (list, tuple, np.ndarray)):
|
|
346
|
+
ids = [int(i) for i in np.asarray(id).ravel()]
|
|
347
|
+
if max(ids) >= n_all: # :1474 guard
|
|
348
|
+
return _base()
|
|
349
|
+
# Index-array subscript: negative entries clip to 0 (GDL-measured).
|
|
350
|
+
return _result([_ALL[max(i, 0)] for i in ids])
|
|
351
|
+
i = int(id)
|
|
352
|
+
if i >= n_all:
|
|
353
|
+
return _base()
|
|
354
|
+
if i < -n_all:
|
|
355
|
+
raise IndexError(
|
|
356
|
+
f"soda2_probespecs.pro:1474: id={i} is below -{n_all}; the guard "
|
|
357
|
+
"admits it and the subscript is out of range (not banked)")
|
|
358
|
+
# Negative scalar subscript: GDL wraps (id=-1 is the last probe).
|
|
359
|
+
return _result([_ALL[i]])
|
|
360
|
+
# :1478 everything.
|
|
361
|
+
return [copy.deepcopy(p) for p in _ALL]
|