Update processing.py
Browse files- processing.py +13 -0
processing.py
CHANGED
|
@@ -62,6 +62,16 @@ def coords_to_pixels(ref, utm, m=10):
|
|
| 62 |
return x, y
|
| 63 |
|
| 64 |
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
def extract_sub_image(bandes_path,tile_path,area,resolution=10, d= 3, cld_path = None):
|
| 66 |
|
| 67 |
xml_file=open(tile_path,"r")
|
|
@@ -83,7 +93,10 @@ def extract_sub_image(bandes_path,tile_path,area,resolution=10, d= 3, cld_path =
|
|
| 83 |
images = []
|
| 84 |
# sub_image_extraction
|
| 85 |
for band_path in tqdm(bandes_path, total=len(bandes_path)):
|
|
|
|
| 86 |
image = load_file(band_path).astype(np.float32)
|
|
|
|
|
|
|
| 87 |
if resolution==60:
|
| 88 |
sub_image = image[y,x]
|
| 89 |
images.append(sub_image)
|
|
|
|
| 62 |
return x, y
|
| 63 |
|
| 64 |
##
|
| 65 |
+
|
| 66 |
+
def timer(message,start_time=None):
|
| 67 |
+
if not start_time:
|
| 68 |
+
start_time = datetime.now()
|
| 69 |
+
return start_time
|
| 70 |
+
elif start_time:
|
| 71 |
+
thour, temp_sec = divmod((datetime.now() - start_time).total_seconds(), 3600)
|
| 72 |
+
tmin, tsec = divmod(temp_sec, 60)
|
| 73 |
+
print('\n'+message+' Time taken: %i hours %i minutes and %s seconds.' % (thour, tmin, round(tsec, 2)))
|
| 74 |
+
##
|
| 75 |
def extract_sub_image(bandes_path,tile_path,area,resolution=10, d= 3, cld_path = None):
|
| 76 |
|
| 77 |
xml_file=open(tile_path,"r")
|
|
|
|
| 93 |
images = []
|
| 94 |
# sub_image_extraction
|
| 95 |
for band_path in tqdm(bandes_path, total=len(bandes_path)):
|
| 96 |
+
start_time_loading = timer('load image',start_time=None)
|
| 97 |
image = load_file(band_path).astype(np.float32)
|
| 98 |
+
start_time_loading = timer('load image',start_time_loading)
|
| 99 |
+
|
| 100 |
if resolution==60:
|
| 101 |
sub_image = image[y,x]
|
| 102 |
images.append(sub_image)
|