Skip to content

Commit

Permalink
Bug fix for int data, and cumulative dist function.
Browse files Browse the repository at this point in the history
  • Loading branch information
sixy6e committed Aug 31, 2016
1 parent 84b5757 commit a2a9982
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions gaip/tests/test_fc_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit a2a9982

Please sign in to comment.