From 11d89e1dbd3575a485ee248845852b23418a408f Mon Sep 17 00:00:00 2001 From: Scisco Date: Thu, 18 Feb 2016 14:14:23 -0500 Subject: [PATCH 1/4] fix usgs dependency closes #154 --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 571d994..3e7105d 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def readme(): license='CCO', platforms='Posix; MacOS X; Windows', install_requires=[ - 'usgs==0.1.9', + 'usgs2==0.2.0', 'requests==2.7.0', 'python-dateutil>=2.4.2', 'numpy>=1.9.3', @@ -49,9 +49,6 @@ def readme(): 'polyline==1.1', 'geocoder>=1.5.1' ], - dependency_links=[ - "git+https://github.com/developmentseed/usgs@develop#egg=usgs-0.1.9" - ], test_suite='nose.collector', tests_require=test_requirements ) From 38729db6a2f11b9ed37038c3f6f089d70ff03dce Mon Sep 17 00:00:00 2001 From: Scisco Date: Thu, 18 Feb 2016 14:19:47 -0500 Subject: [PATCH 2/4] accept tar.gz files --- landsat/image.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/landsat/image.py b/landsat/image.py index 61fa869..8247b6e 100644 --- a/landsat/image.py +++ b/landsat/image.py @@ -184,9 +184,10 @@ def _get_full_filename(self, band): def _check_if_zipped(self, path): """ Checks if the filename shows a tar/zip file """ + filename = get_file(path).split('.') - if filename[-1] in ['bz', 'bz2']: + if filename[-1] in ['bz', 'bz2', 'gz']: return True return False @@ -260,7 +261,7 @@ def _write_to_file(self, new_bands, **kwargs): # Color Correction band = self._color_correction(band, self.bands[i], 0, coverage) - output.write_band(i+1, img_as_ubyte(band)) + output.write_band(i + 1, img_as_ubyte(band)) new_bands[i] = None self.output("Writing to file", normal=True, color='green', indent=1) @@ -492,7 +493,7 @@ def _write_to_file(self, new_bands, pan, **kwargs): band = numpy.multiply(band, pan) band = self._color_correction(band, self.bands[i], 0, coverage) - output.write_band(i+1, img_as_ubyte(band)) + output.write_band(i + 1, img_as_ubyte(band)) new_bands[i] = None From 4b59512742bd3b0ae08e85cc5cac1bb14d49acd9 Mon Sep 17 00:00:00 2001 From: Scisco Date: Thu, 18 Feb 2016 14:19:56 -0500 Subject: [PATCH 3/4] bump up version to 0.12.1 --- landsat/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/landsat/__init__.py b/landsat/__init__.py index 2c7bffb..f8d9095 100644 --- a/landsat/__init__.py +++ b/landsat/__init__.py @@ -1 +1 @@ -__version__ = '0.12.0' +__version__ = '0.12.1' From 3d550aef8f03163459dec723f29d499dab5fbf9b Mon Sep 17 00:00:00 2001 From: Scisco Date: Thu, 18 Feb 2016 14:49:25 -0500 Subject: [PATCH 4/4] skip color correction for ndvi --- landsat/image.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/landsat/image.py b/landsat/image.py index 8247b6e..af123be 100644 --- a/landsat/image.py +++ b/landsat/image.py @@ -269,14 +269,18 @@ def _write_to_file(self, new_bands, **kwargs): return output_file def _color_correction(self, band, band_id, low, coverage): - self.output("Color correcting band %s" % band_id, normal=True, color='green', indent=1) - p_low, cloud_cut_low = self._percent_cut(band, low, 100 - (coverage * 3 / 4)) - temp = numpy.zeros(numpy.shape(band), dtype=numpy.uint16) - cloud_divide = 65000 - coverage * 100 - mask = numpy.logical_and(band < cloud_cut_low, band > 0) - temp[mask] = rescale_intensity(band[mask], in_range=(p_low, cloud_cut_low), out_range=(256, cloud_divide)) - temp[band >= cloud_cut_low] = rescale_intensity(band[band >= cloud_cut_low], out_range=(cloud_divide, 65535)) - return temp + if self.bands == [4, 5]: + return band + else: + self.output("Color correcting band %s" % band_id, normal=True, color='green', indent=1) + p_low, cloud_cut_low = self._percent_cut(band, low, 100 - (coverage * 3 / 4)) + temp = numpy.zeros(numpy.shape(band), dtype=numpy.uint16) + cloud_divide = 65000 - coverage * 100 + mask = numpy.logical_and(band < cloud_cut_low, band > 0) + temp[mask] = rescale_intensity(band[mask], in_range=(p_low, cloud_cut_low), out_range=(256, cloud_divide)) + temp[band >= cloud_cut_low] = rescale_intensity(band[band >= cloud_cut_low], + out_range=(cloud_divide, 65535)) + return temp def _percent_cut(self, color, low, high): return numpy.percentile(color[numpy.logical_and(color > 0, color < 65535)], (low, high))