From 674e2d65c13b07339b693afe35bac7611ba2f878 Mon Sep 17 00:00:00 2001 From: Saransh Singh Date: Wed, 18 Dec 2024 16:21:58 -0800 Subject: [PATCH] fix scaling when dealing with masked arrays --- hexrdgui/scaling.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hexrdgui/scaling.py b/hexrdgui/scaling.py index 53b57c3b8..71e7522be 100644 --- a/hexrdgui/scaling.py +++ b/hexrdgui/scaling.py @@ -12,14 +12,23 @@ def none(x): def sqrt(x): + if isinstance(x, np.ma.masked_array): + return np.sqrt(x.filled(np.nan) - + np.nanmin(x.filled(np.nan))) return np.sqrt(x - np.nanmin(x)) def log(x): + if isinstance(x, np.ma.masked_array): + return np.log(x.filled(np.nan) - + np.nanmin(x.filled(np.nan)) + 1) return np.log(x - np.nanmin(x) + 1) def log_log_sqrt(x): + if isinstance(x, np.ma.masked_array): + return np.log(np.log(np.sqrt(x.filled(np.nan) - + np.nanmin(x.filled(np.nan))) + 1) + 1) return np.log(np.log(np.sqrt(x - np.nanmin(x)) + 1) + 1)