cn build-model: compute the per-probe LRR spread in column chunks (peak memory hit the 5 GB cap on 120 GSA arrays)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01814GKVzZVL3FuF3DeiZXhv
This commit is contained in:
1 parent
210dbaf964
commit
ce0eef6217
1 file changed
+9
-5
@@ -94,10 +94,14 @@ def reference_lrr_spread(lrr: npt.NDArray[np.float32], ref_lrr: npt.NDArray[np.f
|
||||
fewer than 5 finite values."""
|
||||
import warnings
|
||||
|
||||
x = np.where(np.isfinite(lrr), lrr, np.nan).astype(np.float32)
|
||||
out = np.full(lrr.shape[1], np.nan, dtype=np.float32)
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", RuntimeWarning)
|
||||
x = x - np.nanmedian(x, axis=1, keepdims=True) - ref_lrr[None, :]
|
||||
mad = np.nanmedian(np.abs(x - np.nanmedian(x, axis=0)), axis=0)
|
||||
n = np.isfinite(x).sum(axis=0)
|
||||
return np.where(n >= 5, 1.4826 * mad, np.nan).astype(np.float32)
|
||||
smed = np.nanmedian(np.where(np.isfinite(lrr), lrr, np.nan), axis=1, keepdims=True).astype(np.float32)
|
||||
for j in range(0, lrr.shape[1], 20_000): # column chunks keep the temporaries small
|
||||
x = np.where(np.isfinite(lrr[:, j : j + 20_000]), lrr[:, j : j + 20_000], np.nan) - smed
|
||||
x -= ref_lrr[None, j : j + 20_000]
|
||||
mad = np.nanmedian(np.abs(x - np.nanmedian(x, axis=0)), axis=0)
|
||||
n = np.isfinite(x).sum(axis=0)
|
||||
out[j : j + 20_000] = np.where(n >= 5, 1.4826 * mad, np.nan)
|
||||
return out
|
||||
Reference in new issue
Block a user