This repository was archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_flood_hazard.py
69 lines (60 loc) · 2.05 KB
/
Test_flood_hazard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import time
from Hazard_Estimates.Model import *
from matplotlib import pyplot
import gc
import rasterio
hucNumber = "_Houston"
output = []
huc = "H:\HDM_Data\Spatial_Index/huc{}/".format(hucNumber)
files = [
'demFill',
# 'impervious',
'TWI',
'hand',
'Distance2Coast',
'distance2Stream',
'AccumulatedFlow',
'AverageKSAT',
]
dynamic_raster = [
{'filename':'AverageRoughness',
'time':[ 2016]},
{'filename': 'impervious',
'time': [2016]}
]
files = [f.lower() for f in files]
raster_location = "H:\HDM_Data\Spatial_Index"
new_model = model_framework('Load Model', "huc", 'inundated', XColumns=files, file_location=raster_location)
new_model.Dynamic_rasters=dynamic_raster
new_model.load_model(r"D:\OneDrive_Tamu\OneDrive - Texas A&M University\NED\GLO\GLO_M3FR\Python\flood_hazard.rf")
new_model.model.n_jobs = -1
y = 2017
folder = r"D:\OneDrive_Tamu\OneDrive - Texas A&M University\NED\GLO\GLO_M3FR\Python\RFOutPut\rasterio"
for hucNumber in [
# 12100407,
# 12040104,
# 12040204,
# 12040101,
# 12040102,
# 12040202,
# 12040203,
# 12030203,
# 12040103,
# 12040201,
#
# 12090401,
# 12070104,
"huc12040104",]:
raster_sets = new_model.locate_and_load(hucNumber)
gc.collect()
raster_sets.Convert_Dimensions()
starti = time.time()
src = raster_sets.generate_probability_raster(new_model,
location=f"{folder}/FloodProbability{hucNumber}_2016",
ignore_column='demfill',
nodata=32767
, file=f"H:/HDM_Data/Spatial_Index/huc{hucNumber}/demFill.tfw")
print(f"Time per image: {time.time() - starti}")
pyplot.imshow(src.asciiFile, vmin=0, vmax=.2, cmap='Blues')
print(np.max(src.asciiFile))
pyplot.show()