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' diff --git a/landsat/image.py b/landsat/image.py index 61fa869..af123be 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) @@ -268,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)) @@ -492,7 +497,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 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 )