From a2a99824b774917040eb22533c097ed7b9f46762 Mon Sep 17 00:00:00 2001 From: Josh Sixsmith Date: Thu, 1 Sep 2016 08:51:01 +1000 Subject: [PATCH] Bug fix for int data, and cumulative dist function. --- gaip/tests/test_fc_products.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gaip/tests/test_fc_products.py b/gaip/tests/test_fc_products.py index 5a54b2c..c95b713 100755 --- a/gaip/tests/test_fc_products.py +++ b/gaip/tests/test_fc_products.py @@ -35,7 +35,7 @@ def test_photosynthetic_veg_band(self): out_dir = self.output_directory with rasterio.open(self.reference_fname, 'r') as ref_ds: - ref_img = ref_ds.read(2, masked=False) + ref_img = ref_ds.read(2, masked=False).astype('float') with rasterio.open(self.test_fname, 'r') as test_ds: test_img = test_ds.read(2, masked=False) @@ -48,13 +48,14 @@ def test_photosynthetic_veg_band(self): max_diff = diff.max() min_diff = diff.min() - h = histogram(diff, minv=min_diff, maxv=max_diff) + h = histogram(diff, minv=min_diff, maxv=max_diff, omin='omin') array_sz = ref_img.size hist = h['histogram'] + omin = h['omin'] cumu_h = numpy.cumsum(hist, dtype='float') cdf = (cumu_h / array_sz) * 100 - pct_no_diff = cdf[0] + pct_no_diff = cdf[0 - omin] # Initialise a dict ready for output to JSON result = OrderedDict() @@ -109,7 +110,7 @@ def test_non_photosynthetic_veg_band(self): out_dir = self.output_directory with rasterio.open(self.reference_fname, 'r') as ref_ds: - ref_img = ref_ds.read(3, masked=False) + ref_img = ref_ds.read(3, masked=False).astype('float') with rasterio.open(self.test_fname, 'r') as test_ds: test_img = test_ds.read(3, masked=False) @@ -122,13 +123,14 @@ def test_non_photosynthetic_veg_band(self): max_diff = diff.max() min_diff = diff.min() - h = histogram(diff, minv=min_diff, maxv=max_diff) + h = histogram(diff, minv=min_diff, maxv=max_diff, omin='omin') array_sz = ref_img.size hist = h['histogram'] + omin = h['omin'] cumu_h = numpy.cumsum(hist, dtype='float') cdf = (cumu_h / array_sz) * 100 - pct_no_diff = cdf[0] + pct_no_diff = cdf[0 - omin] # Initialise a dict ready for output to JSON result = OrderedDict() @@ -184,7 +186,7 @@ def test_bare_soil_band(self): out_dir = self.output_directory with rasterio.open(self.reference_fname, 'r') as ref_ds: - ref_img = ref_ds.read(1, masked=False) + ref_img = ref_ds.read(1, masked=False).astype('float') with rasterio.open(self.test_fname, 'r') as test_ds: test_img = test_ds.read(1, masked=False) @@ -197,13 +199,14 @@ def test_bare_soil_band(self): max_diff = diff.max() min_diff = diff.min() - h = histogram(diff, minv=min_diff, maxv=max_diff) + h = histogram(diff, minv=min_diff, maxv=max_diff, omin='omin') array_sz = ref_img.size hist = h['histogram'] + omin = h['omin'] cumu_h = numpy.cumsum(hist, dtype='float') cdf = (cumu_h / array_sz) * 100 - pct_no_diff = cdf[0] + pct_no_diff = cdf[0 - omin] # Initialise a dict ready for output to JSON result = OrderedDict() @@ -257,7 +260,7 @@ def test_unmixing_error_band(self): out_dir = self.output_directory with rasterio.open(self.reference_fname, 'r') as ref_ds: - ref_img = ref_ds.read(4, masked=False) + ref_img = ref_ds.read(4, masked=False).astype('float') with rasterio.open(self.test_fname, 'r') as test_ds: test_img = test_ds.read(4, masked=False) @@ -270,13 +273,14 @@ def test_unmixing_error_band(self): max_diff = diff.max() min_diff = diff.min() - h = histogram(diff, minv=min_diff, maxv=max_diff) + h = histogram(diff, minv=min_diff, maxv=max_diff, omin='omin') array_sz = ref_img.size hist = h['histogram'] + omin = h['omin'] cumu_h = numpy.cumsum(hist, dtype='float') cdf = (cumu_h / array_sz) * 100 - pct_no_diff = cdf[0] + pct_no_diff = cdf[0 - omin] # Initialise a dict ready for output to JSON result = OrderedDict()