From 5bac26aef812c827b9e03cb081af5cbb26e727e0 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Thu, 20 Jun 2013 16:37:40 +0000 Subject: [PATCH] adding a check to stop some of the calculated statistics from crashing when a variable is all fill data git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@228 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/stats.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyglance/glance/stats.py b/pyglance/glance/stats.py index 807556f..6ce9ca4 100644 --- a/pyglance/glance/stats.py +++ b/pyglance/glance/stats.py @@ -567,14 +567,15 @@ class GeneralStatistics (StatisticalData) : # grab the valid data for some calculations tempGoodData = dataObject.data[dataObject.masks.valid_mask] + noData = (tempGoodData.size <= 0) # fill in our statistics self.missing_value = dataObject.select_fill_value() - self.max = np.max(tempGoodData) - self.min = np.min(tempGoodData) - self.mean = np.mean(tempGoodData) - self.median = np.median(tempGoodData) - self.std_val = np.std(tempGoodData) + self.max = np.max(tempGoodData) if not noData else np.nan + self.min = np.min(tempGoodData) if not noData else np.nan + self.mean = np.mean(tempGoodData) if not noData else np.nan + self.median = np.median(tempGoodData) if not noData else np.nan + self.std_val = np.std(tempGoodData) if not noData else np.nan # also calculate the invalid points self.spatially_invalid_pts_ignored = np.sum(dataObject.masks.ignore_mask) -- GitLab