Skip to content

Commit

Permalink
Merge pull request #155 from developmentseed/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Scisco committed Feb 18, 2016
2 parents 0b0050f + 3d550ae commit ede7714
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion landsat/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.12.0'
__version__ = '0.12.1'
27 changes: 16 additions & 11 deletions landsat/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -260,22 +261,26 @@ 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)

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))
Expand Down Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
)

0 comments on commit ede7714

Please sign in to comment.