From 9fd7b8cd4aeb36c47fa061eb3ec97e7a4ce08c7c Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:45:06 -0500 Subject: [PATCH 1/2] fix_apply_inverse_weights_map --- sotodlib/coords/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sotodlib/coords/helpers.py b/sotodlib/coords/helpers.py index 63f8bb8b6..4b8dbeef4 100644 --- a/sotodlib/coords/helpers.py +++ b/sotodlib/coords/helpers.py @@ -600,8 +600,8 @@ def _apply_inverse_weights_map(inverse_weights, target, out=None): """ if out is None: - out = np.empty(inverse_weights.shape[1:], - dtype=target.dtype) + out = enmap.ndmap(np.empty(inverse_weights.shape[1:], + dtype=target.dtype), target.wcs) # Recall matmul(a, b) operates on the last two axes of (a, b). So # move axes, and create a second one in target; re-order at end. iw = np.moveaxis(inverse_weights, (0,1), (-2,-1)) From 871d918a7a28c940fd7292edb79043d252c27d8e Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:04:19 -0500 Subject: [PATCH 2/2] add type check --- sotodlib/coords/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sotodlib/coords/helpers.py b/sotodlib/coords/helpers.py index 4b8dbeef4..0a7d8bb34 100644 --- a/sotodlib/coords/helpers.py +++ b/sotodlib/coords/helpers.py @@ -600,8 +600,10 @@ def _apply_inverse_weights_map(inverse_weights, target, out=None): """ if out is None: - out = enmap.ndmap(np.empty(inverse_weights.shape[1:], - dtype=target.dtype), target.wcs) + out = np.empty(inverse_weights.shape[1:], + dtype=target.dtype) + if isinstance(target, enmap.ndmap): + out = enmap.ndmap(out, target.wcs) # Recall matmul(a, b) operates on the last two axes of (a, b). So # move axes, and create a second one in target; re-order at end. iw = np.moveaxis(inverse_weights, (0,1), (-2,-1))