@@ -184,9 +184,10 @@ def _get_full_filename(self, band):
184184
185185 def _check_if_zipped (self , path ):
186186 """ Checks if the filename shows a tar/zip file """
187+
187188 filename = get_file (path ).split ('.' )
188189
189- if filename [- 1 ] in ['bz' , 'bz2' ]:
190+ if filename [- 1 ] in ['bz' , 'bz2' , 'gz' ]:
190191 return True
191192
192193 return False
@@ -260,22 +261,26 @@ def _write_to_file(self, new_bands, **kwargs):
260261 # Color Correction
261262 band = self ._color_correction (band , self .bands [i ], 0 , coverage )
262263
263- output .write_band (i + 1 , img_as_ubyte (band ))
264+ output .write_band (i + 1 , img_as_ubyte (band ))
264265
265266 new_bands [i ] = None
266267 self .output ("Writing to file" , normal = True , color = 'green' , indent = 1 )
267268
268269 return output_file
269270
270271 def _color_correction (self , band , band_id , low , coverage ):
271- self .output ("Color correcting band %s" % band_id , normal = True , color = 'green' , indent = 1 )
272- p_low , cloud_cut_low = self ._percent_cut (band , low , 100 - (coverage * 3 / 4 ))
273- temp = numpy .zeros (numpy .shape (band ), dtype = numpy .uint16 )
274- cloud_divide = 65000 - coverage * 100
275- mask = numpy .logical_and (band < cloud_cut_low , band > 0 )
276- temp [mask ] = rescale_intensity (band [mask ], in_range = (p_low , cloud_cut_low ), out_range = (256 , cloud_divide ))
277- temp [band >= cloud_cut_low ] = rescale_intensity (band [band >= cloud_cut_low ], out_range = (cloud_divide , 65535 ))
278- return temp
272+ if self .bands == [4 , 5 ]:
273+ return band
274+ else :
275+ self .output ("Color correcting band %s" % band_id , normal = True , color = 'green' , indent = 1 )
276+ p_low , cloud_cut_low = self ._percent_cut (band , low , 100 - (coverage * 3 / 4 ))
277+ temp = numpy .zeros (numpy .shape (band ), dtype = numpy .uint16 )
278+ cloud_divide = 65000 - coverage * 100
279+ mask = numpy .logical_and (band < cloud_cut_low , band > 0 )
280+ temp [mask ] = rescale_intensity (band [mask ], in_range = (p_low , cloud_cut_low ), out_range = (256 , cloud_divide ))
281+ temp [band >= cloud_cut_low ] = rescale_intensity (band [band >= cloud_cut_low ],
282+ out_range = (cloud_divide , 65535 ))
283+ return temp
279284
280285 def _percent_cut (self , color , low , high ):
281286 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):
492497 band = numpy .multiply (band , pan )
493498 band = self ._color_correction (band , self .bands [i ], 0 , coverage )
494499
495- output .write_band (i + 1 , img_as_ubyte (band ))
500+ output .write_band (i + 1 , img_as_ubyte (band ))
496501
497502 new_bands [i ] = None
498503
0 commit comments