From 759fdaca6b861b57889c1f9a835f8f2cc1358067 Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Tue, 1 Jul 2025 14:24:57 +0200 Subject: [PATCH 1/2] check for bin edge coord when masking to avoid having masks on edges --- src/ess/powder/masking.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ess/powder/masking.py b/src/ess/powder/masking.py index 3de907de..d17e51f6 100644 --- a/src/ess/powder/masking.py +++ b/src/ess/powder/masking.py @@ -58,10 +58,15 @@ def apply_masks( "two_theta": two_theta_mask_func, }.items(): if mask is not None: - if dim in out.bins.coords: + if (out.bins is not None) and (dim in out.bins.coords): out.bins.masks[dim] = mask(out.bins.coords[dim]) else: - out.masks[dim] = mask(out.coords[dim]) + coord = ( + sc.midpoints(out.coords[dim]) + if out.coords.is_edges(dim) + else out.coords[dim] + ) + out.masks[dim] = mask(coord) return MaskedData[RunType](out) From 53cbc1cb42f6ff7afcc30d041bcaa58d65a5a14e Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Tue, 1 Jul 2025 16:51:18 +0200 Subject: [PATCH 2/2] fix error with multi-d coords --- src/ess/powder/masking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ess/powder/masking.py b/src/ess/powder/masking.py index d17e51f6..dcd185ed 100644 --- a/src/ess/powder/masking.py +++ b/src/ess/powder/masking.py @@ -63,7 +63,7 @@ def apply_masks( else: coord = ( sc.midpoints(out.coords[dim]) - if out.coords.is_edges(dim) + if out.coords.is_edges(dim, dim) else out.coords[dim] ) out.masks[dim] = mask(coord)