|
15 | 15 | from codes.CURVE import curve_preDEM |
16 | 16 | from codes.CURVE import curve_postDEM |
17 | 17 | from codes.MASK import mask |
18 | | -from codes.WSA import wsa |
19 | | - |
20 | | - |
| 18 | +from codes.WSA import wsa |
| 19 | +import pandas as pd |
| 20 | +import numpy as np |
| 21 | +df = pd.read_csv('processing_res_list.csv', parse_dates=True) |
21 | 22 |
|
22 | 23 | if __name__ == "__main__": |
23 | 24 |
|
| 25 | + |
24 | 26 | #====================================>> USER INPUT PARAMETERS |
| 27 | + i=0 |
| 28 | + #for i in range(0, np.size(df,0)): |
25 | 29 | parent_directory = "G:/My Drive/NUSproject/ReservoirExtraction/Reservoirs/" |
26 | 30 | os.chdir(parent_directory) |
27 | | - res_name = "Chulabhorn" |
28 | | - res_built_year = 1972 |
| 31 | + res_name = df.Name[i] |
| 32 | + res_built_year = df.Year[i] |
29 | 33 | dem_acquisition_year = 2000 #SRTM DEM (30m) acquired in Feb 2000 |
30 | 34 |
|
31 | 35 | # Other Reservaoir information |
32 | 36 | res_directory = parent_directory + res_name |
33 | 37 | # A point within the reservoir [longitude, latitude] |
34 | | - point = [101.636, 16.539] |
| 38 | + point = [float(value) for value in df.Point[i].split(',')] |
35 | 39 | # Upper-Left and Lower-right coordinates. Example coordinates [longitude, latitude] |
36 | | - boundary = [101.590, 16.617, 101.660, 16.524] |
37 | | - max_wl = 768 |
| 40 | + boundary = [float(value) for value in df.Boundary[i].split(',')] |
| 41 | + max_wl = df.Max_wl[i] |
38 | 42 | os.makedirs(res_name, exist_ok=True) |
39 | 43 | os.chdir(parent_directory + res_name) |
40 | 44 | # Create a new folder within the working directory to download the data |
41 | 45 | os.makedirs("Outputs", exist_ok=True) |
42 | 46 | # Path to DEM (SouthEastAsia_DEM30m.tif), PCS: WGS1984 |
43 | 47 | # We have a bigger DEM file that is being used to clip the reservoir-DEM |
44 | 48 | dem_file_path = "G:/My Drive/NUSproject/ReservoirExtraction/SEAsia_DEM/SouthEastAsia_DEM30m.tif" |
| 49 | + print('Name of the reservoir: ' + res_name) |
45 | 50 |
|
46 | 51 | #------------------->> FUNCTION CALLING -1 |
47 | 52 | # [1]. Data pre-processing (reprojection and clipping) |
|
61 | 66 |
|
62 | 67 |
|
63 | 68 | # CASE1- Reservoir built before DEM acquisition ============================================== |
64 | | - if res_built_year < dem_acquisition_year: |
| 69 | + if res_built_year <= dem_acquisition_year: |
65 | 70 | print('Name of the reservoir: ' + res_name) |
66 | 71 | print('Reservoir has built before the acquisition of DEM') |
67 | 72 |
|
68 | | - #------------------->> FUNCTION CALLING -4 |
69 | | - # [4]. DEM-Landsat-based updated Area-Elevation-Storage curve |
70 | | - os.chdir(parent_directory + res_name + '/Outputs') |
71 | | - res_minElev = curve_preDEM(res_name, point_loc, res_directory) |
72 | | - |
73 | 73 | #------------------->> FUNCTION CALLING -5 |
74 | | - # [5]. Calculating the water surface area |
| 74 | + # [4.1]. Calculating the water surface area |
75 | 75 | os.chdir(res_directory) |
76 | 76 | wsa(res_name, res_directory) |
77 | 77 |
|
| 78 | + #------------------->> FUNCTION CALLING -4 |
| 79 | + # [5.1]. DEM-Landsat-based updated Area-Elevation-Storage curve |
| 80 | + os.chdir(parent_directory + res_name + '/Outputs') |
| 81 | + res_minElev = curve_preDEM(res_name, point_loc, res_directory) |
| 82 | + |
| 83 | + |
78 | 84 | #------------------->> FUNCTION CALLING -6 |
79 | | - # [6]. Calculating the reservoir restorage (1 tiles) |
| 85 | + # [6.1]. Calculating the reservoir restorage (1 tiles) |
80 | 86 | os.chdir(res_directory) |
81 | 87 | one_tile(res_name, max_wl, res_minElev, res_directory) |
82 | | - |
| 88 | + |
83 | 89 | # CASE2- Reservoir built after DEM acquisition ============================================== |
84 | 90 | if res_built_year > dem_acquisition_year: |
85 | 91 | print('Name of the reservoir: ' + res_name) |
86 | 92 | print('Reservoir has built after the acquisition of DEM') |
87 | 93 |
|
88 | 94 | #------------------->> FUNCTION CALLING -4 |
89 | | - # [4]. DEM-Landsat-based updated Area-Elevation-Storage curve |
90 | | - os.chdir(parent_directory + res_name + '/Outputs') |
91 | | - res_minElev = curve_postDEM(res_name, res_directory) |
92 | | - |
93 | | - #------------------->> FUNCTION CALLING -5 |
94 | | - # [5]. Calculating the water surface area |
| 95 | + # [4.2]. Calculating the water surface area |
95 | 96 | os.chdir(res_directory) |
96 | 97 | wsa(res_name, res_directory) |
97 | 98 |
|
| 99 | + #------------------->> FUNCTION CALLING -5 |
| 100 | + # [4.2]. DEM-Landsat-based updated Area-Elevation-Storage curve |
| 101 | + os.chdir(parent_directory + res_name + '/Outputs') |
| 102 | + res_minElev = curve_postDEM(res_name, max_wl, res_directory) |
| 103 | + |
98 | 104 | #------------------->> FUNCTION CALLING -6 |
99 | | - # [6]. Calculating the reservoir restorage (1 tiles) |
| 105 | + # [6.2]. Calculating the reservoir restorage (1 tiles) |
100 | 106 | os.chdir(res_directory) |
101 | 107 | one_tile(res_name, max_wl, res_minElev, res_directory) |
102 | 108 |
|
103 | 109 |
|
104 | | -# ================================================ Finally moving all .png/jpg files in a seperate folder for better organisation |
105 | | -import shutil |
106 | | -# Create a folder to store the pictures if it doesn't exist |
107 | | -pictures_folder = "intermediate_pictures" |
108 | | -os.makedirs(pictures_folder, exist_ok=True) |
109 | | -# List all files in the current directory |
110 | | -files = os.listdir() |
111 | | -# Move all PNG files to the 'pictures' directory |
112 | | -for file in files: |
113 | | - if file.lower().endswith(".png"): |
114 | | - file_path = os.path.join(os.getcwd(), file) |
115 | | - shutil.move(file_path, os.path.join(pictures_folder, file)) |
| 110 | + # [7]. ============================ Finally moving all .png/jpg files in a seperate folder for better organisation |
| 111 | + import shutil |
| 112 | + # Create a folder to store the pictures if it doesn't exist |
| 113 | + pictures_folder = "intermediate_pictures" |
| 114 | + os.makedirs(pictures_folder, exist_ok=True) |
| 115 | + # List all files in the current directory |
| 116 | + files = os.listdir() |
| 117 | + # Move all PNG files to the 'pictures' directory |
| 118 | + for file in files: |
| 119 | + if file.lower().endswith(".png"): |
| 120 | + file_path = os.path.join(os.getcwd(), file) |
| 121 | + shutil.move(file_path, os.path.join(pictures_folder, file)) |
116 | 122 |
|
117 | 123 |
|
118 | 124 |
|
|
0 commit comments