@@ -184,9 +184,10 @@ def _get_full_filename(self, band):
184
184
185
185
def _check_if_zipped (self , path ):
186
186
""" Checks if the filename shows a tar/zip file """
187
+
187
188
filename = get_file (path ).split ('.' )
188
189
189
- if filename [- 1 ] in ['bz' , 'bz2' ]:
190
+ if filename [- 1 ] in ['bz' , 'bz2' , 'gz' ]:
190
191
return True
191
192
192
193
return False
@@ -260,22 +261,26 @@ def _write_to_file(self, new_bands, **kwargs):
260
261
# Color Correction
261
262
band = self ._color_correction (band , self .bands [i ], 0 , coverage )
262
263
263
- output .write_band (i + 1 , img_as_ubyte (band ))
264
+ output .write_band (i + 1 , img_as_ubyte (band ))
264
265
265
266
new_bands [i ] = None
266
267
self .output ("Writing to file" , normal = True , color = 'green' , indent = 1 )
267
268
268
269
return output_file
269
270
270
271
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
279
284
280
285
def _percent_cut (self , color , low , high ):
281
286
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):
492
497
band = numpy .multiply (band , pan )
493
498
band = self ._color_correction (band , self .bands [i ], 0 , coverage )
494
499
495
- output .write_band (i + 1 , img_as_ubyte (band ))
500
+ output .write_band (i + 1 , img_as_ubyte (band ))
496
501
497
502
new_bands [i ] = None
498
503
0 commit comments