From c2508daa6bf3cb95c41f9d599571ffbfaf56a397 Mon Sep 17 00:00:00 2001
From: Paolo Veglio <paolo.veglio@ssec.wisc.edu>
Date: Fri, 28 Mar 2025 17:47:40 +0000
Subject: [PATCH] fixes to scenes and imports

---
 mvcm/scene.py             | 6 +++---
 mvcm/utility_functions.py | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mvcm/scene.py b/mvcm/scene.py
index ff5808e..7206c9a 100644
--- a/mvcm/scene.py
+++ b/mvcm/scene.py
@@ -133,7 +133,7 @@ class IdentifyPixels:
             coast_scene,
         )
 
-        coast_scene = xr.where(uniformity < 0, 1, coast_scene)
+        coast_scene = xr.where(uniformity <= 0, 1, coast_scene)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return coast_scene.astype(np.ubyte)
@@ -178,7 +178,7 @@ class IdentifyPixels:
             water_scene,
         )
 
-        water_scene = xr.where(uniformity < 0, 0, water_scene).astype(np.ubyte)
+        water_scene = xr.where(uniformity <= 0, 0, water_scene).astype(np.ubyte)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return water_scene
@@ -358,7 +358,7 @@ class IdentifyPixels:
             land_scene,
         )
 
-        land_scene = xr.where(uniformity < 0, 1, land_scene).astype(np.ubyte)
+        land_scene = xr.where(uniformity <= 0, 1, land_scene).astype(np.ubyte)
 
         logger.info(f"scene: Memory usage: {proc.memory_info().rss / 1e6} MB")
         return land_scene
diff --git a/mvcm/utility_functions.py b/mvcm/utility_functions.py
index 186dd43..2b25e4c 100644
--- a/mvcm/utility_functions.py
+++ b/mvcm/utility_functions.py
@@ -6,6 +6,8 @@ import numpy as np
 import xarray as xr
 from numpy.lib.stride_tricks import sliding_window_view
 
+from mvcm.constants import ConstantsNamespace
+
 logger = logging.getLogger(__name__)
 
 
@@ -26,6 +28,7 @@ def cloud_mask_spi(data: xr.Dataset):
         m07.coarsen(number_of_lines=2, number_of_pixels=2).std()
         / m07.coarsen(number_of_lines=2, number_of_pixels=2).mean()
     )
+    spi = xr.where(np.isnan(spi), ConstantsNamespace.BAD_DATA, spi)
     return spi
 
 
-- 
GitLab