hkayabilisim
commited on
Commit
•
2d38182
1
Parent(s):
47de6e6
Minor changes
Browse files
app.py
CHANGED
@@ -54,7 +54,6 @@ typeI_typologies= ['Adb','Erth','Inf','M','Re','Wwd']
|
|
54 |
# Digitized on JRC flood depths
|
55 |
typeI_damage_function = [0,0.49,0.91,1.00,1.00,1.00,1.00,1.00,1]
|
56 |
|
57 |
-
|
58 |
def get_damage_function(occupancy, typology, code_level, nstoreys, nairobi_patch):
|
59 |
jrc_damage = damage_functions[occupancy]
|
60 |
|
@@ -104,7 +103,6 @@ def plot_damage_function(occupancy, typology, code_level, nstoreys, nairobi_patc
|
|
104 |
def generate_excel(nairobi_patch):
|
105 |
hwcolumns = [f'hw{hw}' for hw in flood_depths]
|
106 |
df = pd.DataFrame(columns=['expstr']+hwcolumns)
|
107 |
-
|
108 |
for occupancy in occupancies:
|
109 |
for typology in typologies:
|
110 |
for code_level in code_levels:
|
@@ -116,7 +114,6 @@ def generate_excel(nairobi_patch):
|
|
116 |
adjusted_curve_as_text = [f'{c:5.3f}' for c in adjusted_curve]
|
117 |
row = [tax] + adjusted_curve_as_text
|
118 |
df.loc[len(df)] = row
|
119 |
-
|
120 |
# Save df to Excel
|
121 |
filename = 'flood_vulnerability'+str(uuid.uuid4())+'.xlsx'
|
122 |
df.to_excel(filename,index=False)
|
@@ -150,6 +147,7 @@ with gd.Blocks() as demo:
|
|
150 |
btn = gd.Button(value="Generate Flood Vulnerability File")
|
151 |
file = gd.File(label="Generated File")
|
152 |
|
|
|
153 |
demo.load(plot_damage_function,
|
154 |
inputs=[occupancy,typology, code_level, nstoreys, nairobi_patch],
|
155 |
outputs=[plot])
|
@@ -158,4 +156,6 @@ with gd.Blocks() as demo:
|
|
158 |
inputs=[occupancy,typology, code_level, nstoreys, nairobi_patch],
|
159 |
outputs=[plot])
|
160 |
btn.click(generate_excel, inputs=[nairobi_patch],outputs=[file] )
|
|
|
|
|
161 |
demo.launch()
|
|
|
54 |
# Digitized on JRC flood depths
|
55 |
typeI_damage_function = [0,0.49,0.91,1.00,1.00,1.00,1.00,1.00,1]
|
56 |
|
|
|
57 |
def get_damage_function(occupancy, typology, code_level, nstoreys, nairobi_patch):
|
58 |
jrc_damage = damage_functions[occupancy]
|
59 |
|
|
|
103 |
def generate_excel(nairobi_patch):
|
104 |
hwcolumns = [f'hw{hw}' for hw in flood_depths]
|
105 |
df = pd.DataFrame(columns=['expstr']+hwcolumns)
|
|
|
106 |
for occupancy in occupancies:
|
107 |
for typology in typologies:
|
108 |
for code_level in code_levels:
|
|
|
114 |
adjusted_curve_as_text = [f'{c:5.3f}' for c in adjusted_curve]
|
115 |
row = [tax] + adjusted_curve_as_text
|
116 |
df.loc[len(df)] = row
|
|
|
117 |
# Save df to Excel
|
118 |
filename = 'flood_vulnerability'+str(uuid.uuid4())+'.xlsx'
|
119 |
df.to_excel(filename,index=False)
|
|
|
147 |
btn = gd.Button(value="Generate Flood Vulnerability File")
|
148 |
file = gd.File(label="Generated File")
|
149 |
|
150 |
+
# Layout is done, add triggers now
|
151 |
demo.load(plot_damage_function,
|
152 |
inputs=[occupancy,typology, code_level, nstoreys, nairobi_patch],
|
153 |
outputs=[plot])
|
|
|
156 |
inputs=[occupancy,typology, code_level, nstoreys, nairobi_patch],
|
157 |
outputs=[plot])
|
158 |
btn.click(generate_excel, inputs=[nairobi_patch],outputs=[file] )
|
159 |
+
|
160 |
+
# Launch the GUI
|
161 |
demo.launch()
|