moczarr.fabricate
Exact NESTED cell_ids fabricated from packed morton words.
The morton-only storage decision (englacial/zagg#262: "NESTED is fabricated,
never stored") drops the stored NESTED cell_ids array from hive leaves;
morton becomes the only stored cell coordinate. This module is the
load-bearing replacement — the ratified gate for zagg's writer flip: NESTED
ids are derived exactly from the packed words via mortie's vectorized
mort2healpix, so Python consumers keep NESTED for free.
Order-24 seam (resolved per the final mortie spec §1/§4 — kind is carried
by the word encoding): NESTED ids above order 24 exceed the float64-exact
integer range (2**53), so JS/browser consumers cannot hold them
losslessly as Numbers. POINT-kind words (§1 suffix 48..=63 — an
order-29 location with no area claim) clip to order 24 for the NESTED view:
membership at a coarser level is ordinary truncation (§4), so nothing
labelled changes. Genuine AREA cells are NEVER clipped — coarsening an area
cell changes the labelled thing (that is aggregation, zagg D24) — so
fabrication of area cells above order 24 keeps the exact ids and warns
(see :data:FLOAT64_EXACT_MAX_ORDER).
fabricate_cell_ids(morton_words, *, level=None, _stacklevel=3)
Exact NESTED uint64 cell ids of packed morton words.
Pure function (mortie/numpy only): mort2healpix on the packed words.
The AREA words must share one order — the invariant enforced here, and
the whole of it (issue #8): NESTED has no mixed-order form, so a
mixed-order area coordinate (a pyramid/overview store, zagg#262) cannot
fabricate a NESTED view at all; fabricate per level, or keep a
multi-order encoding (UNIQ-style) instead. Hive stores are fine: their
cell coordinates are single-order at the manifest's cell_order.
POINT-kind words (spec §1 suffix 48..=63) are exempt from that
invariant and may ride alongside AREA words at ANY order (the pre-flip
uniformity guard happened to admit only order-29 areas; the area-order
check that replaced it does not care — same widening aoi_mask got).
Points clip to order :data:FLOAT64_EXACT_MAX_ORDER for the NESTED
view: a point has no area claim, so coarser membership is ordinary
truncation (§4), keeping every fabricated id float64-exact. Area cells
NEVER clip. A mixed-KIND result is therefore deliberately two-nside —
the points sit at the order-24 clip while the areas keep their own
order — which is the §4 posture, not an oversight; a consumer that
needs one nside fabricates the kinds separately. Because mortie's kernel
takes one order per call, points (clipped to 24) and areas fabricate
separately and reassemble by position anyway.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
morton_words
|
array - like
|
Packed |
required |
level
|
int
|
Expected HEALPix order of the words' ENCODING. When given it is
cross-checked against the order mortie derives from the area words
(and against 29 for point words — their encoded order, not the
clipped NESTED order) and a mismatch raises |
None
|
_stacklevel
|
int
|
Frame depth for the above-order-24 |
3
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NESTED cell ids, |
Source code in src/moczarr/fabricate.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |