Spaces:
Runtime error
Runtime error
Commit
·
f54fc00
1
Parent(s):
b4b0e96
ui: move preserve_edge_directions to engine page
Browse filespreserve_edge_directions parameter is moved from settings page
to engine page.
tomorrowcities/assets/custom.css
CHANGED
|
@@ -31,9 +31,18 @@ header {
|
|
| 31 |
}
|
| 32 |
|
| 33 |
.v-input--selection-controls .v-input__slot {
|
| 34 |
-
margin-top:
|
| 35 |
position: relative;
|
| 36 |
-
padding:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto, .col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-auto {
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
.v-input--selection-controls .v-input__slot {
|
| 34 |
+
margin-top: 0px;
|
| 35 |
position: relative;
|
| 36 |
+
padding: 0px;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.v-input--selection-controls {
|
| 40 |
+
margin-top: 4px;
|
| 41 |
+
padding-top: 2px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.v-input--checkbox {
|
| 45 |
+
height: 100%;
|
| 46 |
}
|
| 47 |
|
| 48 |
.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto, .col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-auto {
|
tomorrowcities/pages/engine.py
CHANGED
|
@@ -23,7 +23,7 @@ import pickle
|
|
| 23 |
import datetime
|
| 24 |
from . import storage, user, session_storage, store_in_session_storage, read_from_session_storage, config
|
| 25 |
from .settings import landslide_max_trials
|
| 26 |
-
from .settings import threshold_flood_ds2, threshold_flood_ds3, threshold_flood_ds4, threshold_flood_distance, threshold_road_water_height, threshold_culvert_water_height
|
| 27 |
population_displacement_consensus
|
| 28 |
from ..backend.engine import compute, compute_power_infra, compute_road_infra, generate_exposure, \
|
| 29 |
create_tally, generate_metrics
|
|
@@ -49,6 +49,7 @@ def create_new_app_state():
|
|
| 49 |
'datetime_analysis': datetime.datetime.utcnow(),
|
| 50 |
'landslide_trigger_level': solara.reactive('moderate'),
|
| 51 |
'landslide_trigger_level_list': ['minor','moderate','severe'],
|
|
|
|
| 52 |
'earthquake_intensity_unit': solara.reactive('m/s2'),
|
| 53 |
'earthquake_simulation_methods': ["legacy","monte carlo"],
|
| 54 |
'earthquake_simulation_method_selected': solara.reactive('legacy'),
|
|
@@ -1371,6 +1372,7 @@ def ExecutePanel():
|
|
| 1371 |
intensity = layers.value['layers']['intensity']['data'].value
|
| 1372 |
fragility = layers.value['layers']['road fragility']['data'].value
|
| 1373 |
earthquake_intensity_unit = layers.value['earthquake_intensity_unit'].value
|
|
|
|
| 1374 |
if layers.value['hazard'].value == 'landslide':
|
| 1375 |
fragility = layers.value['layers']['landslide fragility']['data'].value
|
| 1376 |
trigger_level= layers.value['landslide_trigger_level'].value
|
|
@@ -1392,7 +1394,7 @@ def ExecutePanel():
|
|
| 1392 |
household_hospital_access, individual_facility_access = \
|
| 1393 |
compute_road_infra(buildings, household, individual, nodes, edges, intensity,
|
| 1394 |
fragility, hazard, threshold_road_water_height.value, threshold_culvert_water_height.value,
|
| 1395 |
-
threshold_flood_distance.value, preserve_edge_directions
|
| 1396 |
earthquake_intensity_unit=earthquake_intensity_unit,
|
| 1397 |
policies=policies,
|
| 1398 |
cdf_median_increase_in_percent=cdf_median_increase_in_percent,
|
|
@@ -1422,6 +1424,7 @@ def ExecutePanel():
|
|
| 1422 |
fragility = layers.value['layers']['power fragility']['data'].value
|
| 1423 |
hazard = layers.value['hazard'].value
|
| 1424 |
earthquake_intensity_unit = layers.value['earthquake_intensity_unit'].value
|
|
|
|
| 1425 |
threshold_flood = [threshold_flood_ds2.value, threshold_flood_ds3.value, threshold_flood_ds4.value]
|
| 1426 |
|
| 1427 |
if layers.value['hazard'].value == 'landslide':
|
|
@@ -1440,7 +1443,7 @@ def ExecutePanel():
|
|
| 1440 |
intensity,
|
| 1441 |
fragility,
|
| 1442 |
hazard, threshold_flood, threshold_flood_distance.value,
|
| 1443 |
-
preserve_edge_directions
|
| 1444 |
earthquake_intensity_unit=earthquake_intensity_unit,
|
| 1445 |
)
|
| 1446 |
|
|
@@ -1606,6 +1609,12 @@ def ExecutePanel():
|
|
| 1606 |
solara.Markdown("#### Infrastructure")
|
| 1607 |
with solara.Row(justify="left"):
|
| 1608 |
solara.ToggleButtonsMultiple(value=layers.value['infra'].value, on_value=layers.value['infra'].set, values=["building","power","road"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1609 |
solara.Markdown("#### Hazard")
|
| 1610 |
with solara.Row(justify="left"):
|
| 1611 |
solara.ToggleButtonsSingle(value=layers.value['hazard'].value, on_value=layers.value['hazard'].set, values=layers.value['hazard_list'])
|
|
|
|
| 23 |
import datetime
|
| 24 |
from . import storage, user, session_storage, store_in_session_storage, read_from_session_storage, config
|
| 25 |
from .settings import landslide_max_trials
|
| 26 |
+
from .settings import threshold_flood_ds2, threshold_flood_ds3, threshold_flood_ds4, threshold_flood_distance, threshold_road_water_height, threshold_culvert_water_height,\
|
| 27 |
population_displacement_consensus
|
| 28 |
from ..backend.engine import compute, compute_power_infra, compute_road_infra, generate_exposure, \
|
| 29 |
create_tally, generate_metrics
|
|
|
|
| 49 |
'datetime_analysis': datetime.datetime.utcnow(),
|
| 50 |
'landslide_trigger_level': solara.reactive('moderate'),
|
| 51 |
'landslide_trigger_level_list': ['minor','moderate','severe'],
|
| 52 |
+
'preserve_edge_directions': solara.reactive(False),
|
| 53 |
'earthquake_intensity_unit': solara.reactive('m/s2'),
|
| 54 |
'earthquake_simulation_methods': ["legacy","monte carlo"],
|
| 55 |
'earthquake_simulation_method_selected': solara.reactive('legacy'),
|
|
|
|
| 1372 |
intensity = layers.value['layers']['intensity']['data'].value
|
| 1373 |
fragility = layers.value['layers']['road fragility']['data'].value
|
| 1374 |
earthquake_intensity_unit = layers.value['earthquake_intensity_unit'].value
|
| 1375 |
+
preserve_edge_directions = layers.value['preserve_edge_directions'].value
|
| 1376 |
if layers.value['hazard'].value == 'landslide':
|
| 1377 |
fragility = layers.value['layers']['landslide fragility']['data'].value
|
| 1378 |
trigger_level= layers.value['landslide_trigger_level'].value
|
|
|
|
| 1394 |
household_hospital_access, individual_facility_access = \
|
| 1395 |
compute_road_infra(buildings, household, individual, nodes, edges, intensity,
|
| 1396 |
fragility, hazard, threshold_road_water_height.value, threshold_culvert_water_height.value,
|
| 1397 |
+
threshold_flood_distance.value, preserve_edge_directions,
|
| 1398 |
earthquake_intensity_unit=earthquake_intensity_unit,
|
| 1399 |
policies=policies,
|
| 1400 |
cdf_median_increase_in_percent=cdf_median_increase_in_percent,
|
|
|
|
| 1424 |
fragility = layers.value['layers']['power fragility']['data'].value
|
| 1425 |
hazard = layers.value['hazard'].value
|
| 1426 |
earthquake_intensity_unit = layers.value['earthquake_intensity_unit'].value
|
| 1427 |
+
preserve_edge_directions = layers.value['preserve_edge_directions'].value
|
| 1428 |
threshold_flood = [threshold_flood_ds2.value, threshold_flood_ds3.value, threshold_flood_ds4.value]
|
| 1429 |
|
| 1430 |
if layers.value['hazard'].value == 'landslide':
|
|
|
|
| 1443 |
intensity,
|
| 1444 |
fragility,
|
| 1445 |
hazard, threshold_flood, threshold_flood_distance.value,
|
| 1446 |
+
preserve_edge_directions,
|
| 1447 |
earthquake_intensity_unit=earthquake_intensity_unit,
|
| 1448 |
)
|
| 1449 |
|
|
|
|
| 1609 |
solara.Markdown("#### Infrastructure")
|
| 1610 |
with solara.Row(justify="left"):
|
| 1611 |
solara.ToggleButtonsMultiple(value=layers.value['infra'].value, on_value=layers.value['infra'].set, values=["building","power","road"])
|
| 1612 |
+
# preserve_edge_directions is only used for graph-based inputs (power and road)
|
| 1613 |
+
if set(layers.value['infra'].value) & set(['power','road']):
|
| 1614 |
+
with solara.Row(justify="left", style="min-height: 0px"):
|
| 1615 |
+
with solara.Tooltip('Obey the edge directions in road/power networks (default: False)'):
|
| 1616 |
+
solara.Checkbox(label='Preserve directions', value=layers.value['preserve_edge_directions'])
|
| 1617 |
+
solara.Button(icon_name="mdi-help-box", attributes={"href": "https://github.com/TomorrowsCities/tomorrowscities/wiki/4%E2%80%90Engine#parameters", "target": "_blank"}, text=True, outlined=False)
|
| 1618 |
solara.Markdown("#### Hazard")
|
| 1619 |
with solara.Row(justify="left"):
|
| 1620 |
solara.ToggleButtonsSingle(value=layers.value['hazard'].value, on_value=layers.value['hazard'].set, values=layers.value['hazard_list'])
|
tomorrowcities/pages/settings.py
CHANGED
|
@@ -13,7 +13,6 @@ threshold_flood_ds4 = solara.reactive(0.50)
|
|
| 13 |
threshold_flood_distance = solara.reactive(10)
|
| 14 |
threshold_road_water_height = solara.reactive(0.3)
|
| 15 |
threshold_culvert_water_height = solara.reactive(1.5)
|
| 16 |
-
preserve_edge_directions = solara.reactive(False)
|
| 17 |
population_displacement_consensus = solara.reactive(2)
|
| 18 |
|
| 19 |
@solara.component
|
|
@@ -23,9 +22,6 @@ def Page(name: Optional[str] = None, page: int = 0, page_size=100):
|
|
| 23 |
subtitle='Minimum number of direct damage, inaccessibility or power lost should be observed to claim a population displacement.'):
|
| 24 |
solara.Select(label='population displacement consensus', values=[1,2,3,4], value=population_displacement_consensus)
|
| 25 |
|
| 26 |
-
with solara.Card(title='Connectivity Parameters',subtitle='Parameters effecting connectivity analysis in road/power networks'):
|
| 27 |
-
solara.Checkbox(label='Preserve directions in graph edges', value=preserve_edge_directions)
|
| 28 |
-
|
| 29 |
with solara.Card(title='Landslide Parameters',subtitle='Choose the parameters for the landslide simulation'):
|
| 30 |
solara.SliderInt(label='Number of Monte-Carlo Trials', value=landslide_max_trials, min=1,max=100)
|
| 31 |
|
|
|
|
| 13 |
threshold_flood_distance = solara.reactive(10)
|
| 14 |
threshold_road_water_height = solara.reactive(0.3)
|
| 15 |
threshold_culvert_water_height = solara.reactive(1.5)
|
|
|
|
| 16 |
population_displacement_consensus = solara.reactive(2)
|
| 17 |
|
| 18 |
@solara.component
|
|
|
|
| 22 |
subtitle='Minimum number of direct damage, inaccessibility or power lost should be observed to claim a population displacement.'):
|
| 23 |
solara.Select(label='population displacement consensus', values=[1,2,3,4], value=population_displacement_consensus)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
with solara.Card(title='Landslide Parameters',subtitle='Choose the parameters for the landslide simulation'):
|
| 26 |
solara.SliderInt(label='Number of Monte-Carlo Trials', value=landslide_max_trials, min=1,max=100)
|
| 27 |
|