Skip to content

Commit 8fb3019

Browse files
committed
intital commit
1 parent 45b0877 commit 8fb3019

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

InfeRes_package/MASK.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
6767

6868

6969
# [1] ============================= CLIP LANDSAT IMAGES BY THE UTM BOUNDING BOX
70+
print('============ [1] CLIP LANDSAT IMAGES BY THE UTM BOUNDING BOX ===============')
7071
print("Clipping Landsat images by the bounding box ...")
7172
clip_count = 0
7273
os.chdir(res_directory + "/LandsatData")
@@ -102,6 +103,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
102103

103104

104105
# [2] =============================== DELETE >80% cloudy (over the reservoir) images
106+
print('============ [2] DELETE >80% cloudy (over the reservoir) images ===============')
105107
print("Estimating cloud fraction...")
106108
class_count = 0
107109
cloud_threshold = 80
@@ -182,6 +184,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
182184

183185

184186
# [3] =================================== NDWI CALCULATION (adding cloud mask)
187+
print('============ [3] NDWI CALCULATION (adding cloud mask) ===============')
185188
print("Adding cloud mask to NDWI images...")
186189
count = 0
187190
os.chdir(res_directory + "/LandsatData_Clip")
@@ -241,6 +244,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
241244

242245
# [4] ============================== CREATE DEM-BASED MAX WATER EXTENT MASK
243246
# DEM is preprocessed to have the same cell size and alignment with Landsat images
247+
print('============ [4] CREATE DEM-BASED MAX WATER EXTENT MASK ===============')
244248
print("Creating DEM-based max water extent mask ...")
245249
os.chdir(res_directory + "/Outputs")
246250
res_dem_file = res_name + "DEM.tif"
@@ -268,6 +272,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
268272

269273

270274
# [5] ============================ CREATE LANDSAT-BASED MAX WATER EXTENT MASK
275+
print('============ [5] CREATE LANDSAT-BASED MAX WATER EXTENT MASK ===============')
271276
print("Creating Landsat-based max water extent mask ...")
272277
os.chdir(res_directory + "/Outputs")
273278
res_dem_file = res_name + "DEM.tif"
@@ -292,7 +297,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
292297
cloud_percentage = round(np.nansum(ndwi)/np.nansum(res_iso)*100,2)
293298
print(str(cloud_percentage) + '% cloud')
294299
if cloud_percentage < 20:
295-
print('Image qualified for creating Landsat-based MASK')
300+
print('-------------------------------------------------')
296301
ndwi = gdal_array.LoadFile(filename).astype(np.float32)
297302
water = ndwi
298303
water[np.where(ndwi >= 0)] = 1
@@ -340,6 +345,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
340345

341346

342347
# [6] ====================== CREATE EXPANDED MASK (by 3 pixels surrounding each of water pixels)
348+
print('============ [6] CREATE EXPANDED MASK ===============')
343349
print("Creating expanded mask ...")
344350
os.chdir(res_directory + "/Outputs")
345351
mask_1 = gdal_array.LoadFile("Landsat_Mask.tif").astype(np.float32)
@@ -366,6 +372,7 @@ def mask(res_name, yearOFcommission, max_wl, point, boundary, dem_file_path, res
366372

367373

368374
# [7] ================================= CREATE 50-ZONE MAP (FREQUENCE MAP)
375+
print('============ [7] CREATE 50-ZONE MAP (FREQUENCE MAP) ===============')
369376
print("Creating 50-zone map (frequence map) ...")
370377
os.chdir(res_directory + "/Outputs")
371378
count = gdal_array.LoadFile("Count.tif").astype(np.float32)

InfeRes_package/data_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def clip_image_to_geometry(image):
5252

5353
slno = l8images_clip.toList(l8images_clip.size())
5454
count = 1
55-
for i in range(num_images): # range(num_images)
55+
for i in range(2): # range(num_images)
5656
print(count)
5757
selected_image = ee.Image(slno.get(i))
5858

@@ -142,7 +142,7 @@ def clip_image_to_geometry(image):
142142
collection_id = "LANDSAT/LC08/C02/T1_TOA"
143143
start_data = '2001-01-01'
144144
end_date = '2022-12-31'
145-
#get_landsat_images(Satellite, row, path, point_coordinates, boundary_coordinates, collection_id, start_data, end_date)
145+
get_landsat_images(Satellite, row, path, point_coordinates, boundary_coordinates, collection_id, start_data, end_date)
146146
print("Congratulations...all Landsat-8 files have successfully downloaded!")
147147

148148
#====================================>> USER INPUT PARAMETERS (Landsat-7 Image Specifications)

InfeRes_package/data_processing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
os.chdir(parent_directory)
2525
res_name = "Xiaowan" # Name of the reservoir
2626
# A point within the reservoir [longitude, latitude]
27-
point = [99.95, 24.745]
27+
point = [100.420, 24.66]
2828
# Upper-Left and Lower-right coordinates. Example coordinates [longitude, latitude]
29-
boundary = [99.20, 25.60, 100.25, 24.65]
30-
max_wl = 1236
31-
dead_wl = 1162
32-
yearOFcommission = 2010
29+
boundary = [100.115, 24.79, 100.51, 24.61]
30+
max_wl = 1020
31+
dead_wl = 980
32+
yearOFcommission = 2000
3333
Number_of_tiles = 1
3434
os.makedirs(res_name, exist_ok=True)
3535
os.chdir(parent_directory + res_name)

0 commit comments

Comments
 (0)