anofa commited on
Commit
ce3cc6a
·
verified ·
1 Parent(s): a42d686

Upload 50 files

Browse files
Files changed (50) hide show
  1. .gitattributes +38 -35
  2. Dockerfile +20 -0
  3. LICENSE +21 -0
  4. README.md +10 -10
  5. building_tv50_1.geojson +0 -0
  6. building_tv50_2.geojson +0 -0
  7. building_tv50_3.geojson +0 -0
  8. demo/.DS_Store +0 -0
  9. demo/__init__.py +3 -0
  10. demo/__pycache__/__init__.cpython-312.pyc +0 -0
  11. demo/assets/custom.css +18 -0
  12. demo/pages/__init__.py +817 -0
  13. demo/pages/__pycache__/__init__.cpython-312.pyc +0 -0
  14. demo/pages/__pycache__/engine.cpython-312.pyc +0 -0
  15. demo/pages/engine.py +332 -0
  16. demo/public/Museo700-Regular.woff2 +0 -0
  17. demo/public/Museo900-Regular.woff +0 -0
  18. demo/public/Museo900-Regular.woff2 +0 -0
  19. demo/public/OpenSans400.woff2 +0 -0
  20. demo/public/open-sans.regular.ttf +0 -0
  21. demo/public/tc-logo.png +0 -0
  22. demo/public/tc-logo_old1.png +0 -0
  23. demo/public/tc-logo_old2.png +0 -0
  24. demo/public/tc-logo_old3.png +0 -0
  25. demo/public/tomorrows-cities-logo-header.png +0 -0
  26. earthquake_fragility.xml +0 -0
  27. flood_vulnerability.csv +92 -0
  28. hazard_debris.geojson +0 -0
  29. hazard_debris.xlsx +0 -0
  30. hazard_earthquake.geojson +0 -0
  31. hazard_flood.geojson +3 -0
  32. household_tv50_1.xlsx +0 -0
  33. household_tv50_2.xlsx +0 -0
  34. household_tv50_3.xlsx +0 -0
  35. individual_tv50_1.xlsx +3 -0
  36. individual_tv50_2.xlsx +3 -0
  37. individual_tv50_3.xlsx +3 -0
  38. landuse_tv0.geojson +29 -0
  39. landuse_tv50_1.geojson +0 -0
  40. landuse_tv50_1.png +0 -0
  41. landuse_tv50_1_selected.png +0 -0
  42. landuse_tv50_2.geojson +0 -0
  43. landuse_tv50_2.png +0 -0
  44. landuse_tv50_2_selected.png +0 -0
  45. landuse_tv50_3.geojson +0 -0
  46. landuse_tv50_3.png +0 -0
  47. landuse_tv50_3_selected.png +0 -0
  48. mypy.ini +3 -0
  49. pyproject.toml +29 -0
  50. requirements.txt +8 -0
.gitattributes CHANGED
@@ -1,35 +1,38 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -texthazard_flood.geojson filter=lfs diff=lfs merge=lfs -text
36
+ individual_tv50_1.xlsx filter=lfs diff=lfs merge=lfs -text
37
+ individual_tv50_2.xlsx filter=lfs diff=lfs merge=lfs -text
38
+ individual_tv50_3.xlsx filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ RUN useradd -m -u 1000 user
4
+
5
+ #USER root
6
+ RUN apt update
7
+ RUN apt -y install gdal-bin libgdal-dev
8
+
9
+ USER user
10
+
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ COPY --chown=user . $HOME/app
15
+
16
+ WORKDIR $HOME/app
17
+
18
+ RUN (cd demo & pip install -e .)
19
+
20
+ CMD ["solara", "run", "--theme-variant", "dark", "demo.pages", "--host", "0.0.0.0", "--port", "7860"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
README.md CHANGED
@@ -1,10 +1,10 @@
1
- ---
2
- title: Tcdemo2
3
- emoji: 👀
4
- colorFrom: green
5
- colorTo: red
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: Demo
3
+ emoji: 📈
4
+ colorFrom: yellow
5
+ colorTo: pink
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
building_tv50_1.geojson ADDED
The diff for this file is too large to render. See raw diff
 
building_tv50_2.geojson ADDED
The diff for this file is too large to render. See raw diff
 
building_tv50_3.geojson ADDED
The diff for this file is too large to render. See raw diff
 
demo/.DS_Store ADDED
Binary file (6.15 kB). View file
 
demo/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ """Example Solara app as python packages"""
2
+ __title__ = "Solara example app"
3
+ __version__ = "0.0.1"
demo/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (259 Bytes). View file
 
demo/assets/custom.css ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ header {
2
+ background-image: url('/static/public/tomorrows-cities-logo-header.png'); /* Replace 'your-image.jpg' with the path to your image file */
3
+ background-position: center; /* Center the background image */
4
+ background-repeat: no-repeat; /* Prevent image from repeating */
5
+ height: 200px; /* Set a specific height for the header */
6
+ }
7
+
8
+ .v-application--wrap > div:nth-child(2) > div:nth-child(2){
9
+ display: none !important;
10
+ }
11
+
12
+ .theme--light.v-sheet {
13
+ background-color: #EBEBEB;
14
+ }
15
+
16
+ .v-navigation-drawer__content {
17
+ background-color: #EBEBEB;
18
+ }
demo/pages/__init__.py ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #%%
2
+ css = """
3
+
4
+ @font-face {
5
+ font-family: 'Open Sans';
6
+ font-style: normal;
7
+ font-weight: 400;
8
+ font-stretch: 100%;
9
+ font-display: swap;
10
+ src: url('/static/public/open-sans.regular.ttf') format('truetype');
11
+ }
12
+
13
+ @font-face {
14
+ font-family: 'Museo 900';
15
+ src: url('/static/public/Museo900-Regular.woff2') format('woff2'),
16
+ url('/static/public/Museo900-Regular.woff') format('woff');
17
+ font-weight: 900;
18
+ font-style: normal;
19
+ font-display: swap;
20
+ }
21
+
22
+
23
+ @font-face {
24
+ font-family: 'Museo 700';
25
+ src: url('/static/public/Museo700-Regular.woff2') format('woff2')
26
+ }
27
+
28
+
29
+ .v-application {
30
+ font-family: 'Open Sans'
31
+ }
32
+
33
+ .v-card__title {
34
+ padding: 2px;
35
+ font-family: 'Museo 900'
36
+ }
37
+
38
+ .v-application .ma-2 {
39
+ margin: 2px!important;
40
+ }
41
+
42
+ .leaflet-control-attribution {
43
+ display: none;
44
+ }
45
+ .v-btn__content {
46
+ font-size: 12px;
47
+ text-overflow: ellipsis;
48
+ }
49
+
50
+ .v-input__control {
51
+ height: 30px
52
+ }
53
+
54
+ .jupyter-widgets.leaflet-widgets {
55
+ height: 280px;
56
+ overflow: hidden;
57
+ }
58
+
59
+ .col {
60
+ overflow: hidden;
61
+ }
62
+
63
+ .v-card__title {
64
+ font-size: 20px;
65
+ text-color: "orange";
66
+ }
67
+
68
+ label.v-label.theme--dark {
69
+ font-size: 14px;
70
+ line-height: 100%;
71
+ }
72
+
73
+ .metricdesc {
74
+ font-size: 15px;
75
+ margin-top: -30px;
76
+ text-align: center;
77
+ }
78
+ .infobox {
79
+ font-size: 14px;
80
+ line-height: 110%;
81
+ }
82
+
83
+ .infoitem {
84
+ font-size: 12px;
85
+ line-height: 110%;
86
+ }
87
+
88
+ .maintitle {
89
+ font-family: 'Museo 900';
90
+ font-size: 24px;
91
+ text-align: center;
92
+ }
93
+
94
+ """
95
+
96
+ import solara
97
+ import pandas as pd
98
+ import geopandas as gpd
99
+ import ipyleaflet
100
+ from random import uniform
101
+ import random
102
+ import numpy as np
103
+ import json
104
+ import matplotlib.pyplot as plt
105
+ from .engine import run_engine
106
+
107
+ languages = ["EN","TR"]
108
+ lang = solara.reactive("EN")
109
+
110
+ lbl_land_use_btn = [{'EN': 'Civil Society',
111
+ 'TR': 'Sivil Toplum'},
112
+ {'EN': 'Women',
113
+ 'TR': 'Kadınlar'},
114
+ {'EN': 'Youth',
115
+ 'TR': 'Gençler'},]
116
+ lbl_maintitle = {'EN': 'Tomorrow\'s Cities Decision Making Simulation','TR': 'Yarının Şehirleri için Karar Verme Simülasyonu'}
117
+ lbl_earthquake= {'EN': 'Earthquake', 'TR': 'Deprem'}
118
+ lbl_flood = {'EN': 'Flood', 'TR': 'Sel'}
119
+ lbl_debris = {'EN': 'Landslide', 'TR': 'Heyelan'}
120
+ lbl_reset = {'EN': 'Reset Simulation', 'TR': 'Simülasyonu Sıfırla'}
121
+ lbl_language = {'EN': 'Language', 'TR': 'Dil'}
122
+ lbl_luf_res_high = {'EN': 'Residential (High Density)', 'TR': 'Yerlesim Alani (Yuksek Yogunluk)'}
123
+ lbl_tv0_map_title = {'EN': '1. Today\'s land use', 'TR': '1. Mevcut plan'}
124
+ lbl_density_map_title = {'EN': '2. Select the potential hazard', 'TR': '2. Olası tehlikeyi seçin'}
125
+ lbl_policy_card_title = {'EN': '4. Select three policies to make your city resillient', 'TR': '4. Şehrinizi dayanıklı hale getirmek için üç politika seçin'}
126
+ lbl_too_many_policy_selected_error = {'EN': 'You cannot select more than three policies',
127
+ 'TR': 'Üçten fazla politika seçemezsiniz.'}
128
+ lbl_infobox = {'EN': f'''
129
+ Our decisions directly influence our future. It is critical for a
130
+ resilient city life where the decisions at the city scale reduces the disaster risk in the future.
131
+ In this simulation, we calculate possible disaster impacts calculated with Tomorrow's Cities Decision
132
+ Support System (TCDSE). The simulation shows how earthquake, flood and landslide hazards that may occur
133
+ in an imaginary urban environment affect different urban scenarios. To use the simulation: <br>1) Check land use, <br>2) Select the
134
+ possible hazard, <br>3) Select the possible city scenarios for the future, <br>4) Choose policies, <br>5) Run and check the metrics.
135
+ ''',
136
+ "TR": f'''
137
+ Aldığımız kararlar, geleceğimizi doğrudan etkilemektedir. Kent ölçeğinde alınan kararların, gelecekte afet riskini azaltacak
138
+ nitelikte olması dayanıklı bir şehir hayatı için önemlidir.
139
+ Bu simülasyonda, Yarının Şehirleri Karar Destek Sistemi (TCDSE) ile hesaplanan olası afet etkilerini hesaplıyoruz. Simülasyon,
140
+ hayali bir kent ortamında meydana gelebilecek deprem, sel ve heyelan tehlikelerinin, farklı kent senaryolarını nasıl etkilediğini gösteriyor.
141
+ Simülasyonu kullanmak için: <br>1) Mevcut planı inceleyin, <br>2) Olası tehlikeyi seçin, <br>3) Geleceğe dair olası şehir senaryolarını seçin,
142
+ <br>4) Politikaları seçin, <br>5) Çalıştırın ve metrikleri inceleyin.'''}
143
+ lbl_infobox_title = {'EN': '', 'TR': ''}
144
+ lbl_landuse_plans_title = {'EN': '3. Future land uses', 'TR': '3. Geleceğin alternatif yerleşim planlarından birini seçin'}
145
+ lbl_run_btn = {'EN': 'RUN', 'TR': 'ÇALIŞTIR'}
146
+ lbl_results_card_title = {'EN': '5. Impact metrics', 'TR': '5. Etki metrikleri'}
147
+ lbl_info1 = {'EN': 'Number of individuals<br>63676', 'TR': 'Kişi Sayısı<br>63676'}
148
+ lbl_info2 = {'EN': 'Number of households<br>10380', 'TR': 'Hane Sayısı<br>10380'}
149
+ lbl_info3 = {'EN': 'Number of buildings<br>3917', 'TR': 'Bina Sayısı<br>3917'}
150
+ lbl_info4 = {'EN': 'Number of schools<br>12', 'TR': 'Okul Sayısı<br>12'}
151
+ lbl_info5 = {'EN': 'Number of hospitals<br>1', 'TR': 'Hastane Sayısı<br>1'}
152
+ #lbl_info6 = {'EN': 'Number of green field<br>', 'TR': 'Yeşİl Alan Sayısı<br>'}
153
+
154
+ hazard_types = ["earthquake", "flood", "debris"]
155
+ hazard_type_default = hazard_types[0]
156
+ hazard_type = solara.reactive("flood")
157
+
158
+ flood_df = gpd.read_file('hazard_flood.geojson')
159
+ debris_df = gpd.read_file('hazard_debris.geojson')
160
+ earthquake_df = gpd.read_file('hazard_earthquake.geojson')
161
+
162
+ earthquake_df_as_geo = gpd.read_file('hazard_earthquake.geojson')
163
+ print('bir',earthquake_df_as_geo.crs)
164
+ earthquake_df_as_geo = earthquake_df_as_geo.set_crs("EPSG:4326",allow_override=True)
165
+ print('iki',earthquake_df_as_geo.crs)
166
+ earthquake_df_as_geo = earthquake_df_as_geo.to_crs(32636)
167
+ print('uc',earthquake_df_as_geo.crs)
168
+
169
+
170
+ debris_df_as_geo = gpd.read_file('hazard_debris.geojson')
171
+ debris_df_as_geo = debris_df_as_geo.set_crs("EPSG:4326",allow_override=True)
172
+ debris_df_as_geo = debris_df_as_geo.to_crs("EPSG:32636")
173
+
174
+ flood_df_as_geo = gpd.read_file('hazard_flood.geojson')
175
+ flood_df_as_geo = flood_df_as_geo.set_crs("EPSG:4326",allow_override=True)
176
+ flood_df_as_geo = flood_df_as_geo.to_crs("EPSG:32636")
177
+
178
+ landuse_tv0_df = gpd.read_file('landuse_tv0.geojson')
179
+ landuse_tv50_1_df = gpd.read_file('landuse_tv50_1.geojson')
180
+ landuse_tv50_2_df = gpd.read_file('landuse_tv50_2.geojson')
181
+ landuse_tv50_3_df = gpd.read_file('landuse_tv50_3.geojson')
182
+ n_landuses = 3
183
+
184
+ luf_types = pd.unique(landuse_tv0_df['luf'])
185
+
186
+ luf_colors = dict()
187
+ for luf_label in luf_types:
188
+ if luf_label == 'RESIDENTIAL (HIGH DENSITY)':
189
+ luf_colors[luf_label] = {
190
+ 'color': 'black',
191
+ 'fillColor': '#A0522D', # sienna
192
+ }
193
+ elif luf_label == 'RESIDENTIAL (MODERATE DENSITY)':
194
+ luf_colors[luf_label] = {
195
+ 'color': 'black',
196
+ 'fillColor': '#cd853f', # peru
197
+ }
198
+ elif luf_label == 'RESIDENTIAL (LOW DENSITY)':
199
+ luf_colors[luf_label] = {
200
+ 'color': 'black',
201
+ 'fillColor': '#D2B48C', # tan
202
+ }
203
+ elif luf_label == 'COMMERCIAL':
204
+ luf_colors[luf_label] = {
205
+ 'color': 'black',
206
+ 'fillColor': 'red',
207
+ }
208
+ elif luf_label == 'INDUSTRIAL':
209
+ luf_colors[luf_label] = {
210
+ 'color': 'black',
211
+ 'fillColor': '#5A0000',
212
+ }
213
+ elif luf_label == 'AGRICULTURE':
214
+ luf_colors[luf_label] = {
215
+ 'color': 'black',
216
+ 'fillColor': 'yellow',
217
+ }
218
+ elif luf_label == 'RECREATION AREA':
219
+ luf_colors[luf_label] = {
220
+ 'color': 'black',
221
+ 'fillColor': '#32CD32', #lime
222
+ }
223
+ elif luf_label == 'DOWN TOWN':
224
+ luf_colors[luf_label] = {
225
+ 'color': 'black',
226
+ 'fillColor': '#E6E6FA', # lavender
227
+ }
228
+ elif luf_label == 'GREEN BELTS':
229
+ luf_colors[luf_label] = {
230
+ 'color': 'black',
231
+ 'fillColor': 'green',
232
+ }
233
+ elif luf_label == 'GREEN OPEN AREAS':
234
+ luf_colors[luf_label] = {
235
+ 'color': 'black',
236
+ 'fillColor': '#90EE90', # lightgreen
237
+ }
238
+ elif luf_label == 'PARKS':
239
+ luf_colors[luf_label] = {
240
+ 'color': 'black',
241
+ 'fillColor': '#90EE90', # lightgreen
242
+ }
243
+ elif luf_label == 'PUBLIC FACILITIES':
244
+ luf_colors[luf_label] = {
245
+ 'color': 'black',
246
+ 'fillColor': '#BDC000',
247
+ }
248
+ elif luf_label == 'HOSPITAL CITY':
249
+ luf_colors[luf_label] = {
250
+ 'color': 'black',
251
+ 'fillColor': 'orange',
252
+ }
253
+ elif luf_label == 'ANTIQUITIES AREA':
254
+ luf_colors[luf_label] = {
255
+ 'color': 'black',
256
+ 'fillColor': '#C7FCF2',
257
+ }
258
+ elif luf_label == 'VACANT ZONE':
259
+ luf_colors[luf_label] = {
260
+ 'color': 'black',
261
+ 'fillColor': '#90EE90', # lightgreen
262
+ }
263
+ elif luf_label == 'CEMETRY':
264
+ luf_colors[luf_label] = {
265
+ 'color': 'black',
266
+ 'fillColor': '#7400FF',
267
+ }
268
+ elif luf_label == 'SERVICES AREA':
269
+ luf_colors[luf_label] = {
270
+ 'color': 'black',
271
+ 'fillColor': '#CB2BC3',
272
+ }
273
+ elif luf_label == 'SOLAR CELLS':
274
+ luf_colors[luf_label] = {
275
+ 'color': 'black',
276
+ 'fillColor': '#FFF1C0',
277
+ }
278
+ elif luf_label == 'TECHNOLOGY AREA':
279
+ luf_colors[luf_label] = {
280
+ 'color': 'black',
281
+ 'fillColor': '#FF99D2',
282
+ }
283
+ elif luf_label == 'TOURISTIC AREA':
284
+ luf_colors[luf_label] = {
285
+ 'color': 'black',
286
+ 'fillColor': '#2B65CB',
287
+ }
288
+ elif luf_label == 'VOCATIONAL TRAINING CENTER':
289
+ luf_colors[luf_label] = {
290
+ 'color': 'black',
291
+ 'fillColor': '#ADC483',
292
+ }
293
+ elif luf_label == 'WASTE COLLECTION STATION':
294
+ luf_colors[luf_label] = {
295
+ 'color': 'black',
296
+ 'fillColor': '#2C0061',
297
+ }
298
+ elif luf_label == 'WATER PURIFICATION AND RECYCLING PLANT':
299
+ luf_colors[luf_label] = {
300
+ 'color': 'black',
301
+ 'fillColor': '#006AFF',
302
+ }
303
+ else:
304
+ luf_colors[luf_label] = {
305
+ 'color': 'black',
306
+ 'fillColor': random.choice(['red', 'yellow', 'green', 'orange', 'blue']),
307
+ }
308
+
309
+ plt.switch_backend("agg")
310
+ plt.rcParams['axes.facecolor'] = '#1e1e1e'
311
+ plt.rcParams['axes.edgecolor'] = '#1e1e1e'
312
+ #plt.switch_backend('macosx')
313
+ #%matplotlib inline
314
+ for j in range(1, n_landuses+1):
315
+ df = eval(f'landuse_tv50_{j}_df')
316
+ title = f'tv50_{j}'
317
+ for i, row in df.iterrows():
318
+ df.loc[i, 'color'] = luf_colors[row['luf']]['fillColor']
319
+ fig, ax = plt.subplots(nrows=1, ncols=1,figsize=(4*1.3, 5*1.3))
320
+ fig.set_tight_layout(True)
321
+ fig.patch.set_facecolor('white')
322
+ #fig.patch.set_alpha(0.7)
323
+ df.plot(color=df['color'],ax=ax)
324
+ #ax.set_title(f'{title}')
325
+ ax.set_xticks([])
326
+ ax.set_yticks([])
327
+ plt.savefig(f'landuse_{title}_selected.png')
328
+
329
+ fig, ax = plt.subplots(nrows=1, ncols=1,figsize=(4*1.3,5*1.3))
330
+ fig.set_tight_layout(True)
331
+ #fig.patch.set_facecolor('black')
332
+ fig.patch.set_alpha(0.0)
333
+ df.plot(color=df['color'],ax=ax)
334
+ #ax.set_title(f'{title}')
335
+ ax.set_xticks([])
336
+ ax.set_yticks([])
337
+ plt.savefig(f'landuse_{title}.png')
338
+
339
+ landuse_tv0_json = json.loads(landuse_tv0_df.to_json())
340
+ luf_filtered_data = solara.reactive(landuse_tv0_json)
341
+
342
+ luf_selected = solara.reactive(luf_types)
343
+ luf_type_selected = dict()
344
+ for luf_type in luf_types:
345
+ luf_type_selected[luf_type] = solara.reactive(True)
346
+
347
+ lbl_luf = dict()
348
+ for luf_label in luf_types:
349
+ if luf_label == 'RESIDENTIAL (HIGH DENSITY)':
350
+ lbl_luf[luf_label] = {'EN': 'Residential (High Density)', 'TR': 'Konut Alanı (Yuksek Yoğunluk)'}
351
+ elif luf_label == 'RESIDENTIAL (MODERATE DENSITY)':
352
+ lbl_luf[luf_label] = {'EN': 'Residential (Moderate Density)', 'TR': 'Konut Alanı (Orta Yoğunluk)'}
353
+ elif luf_label == 'RESIDENTIAL (LOW DENSITY)':
354
+ lbl_luf[luf_label] = {'EN': 'Residential (Low Density)', 'TR': 'Konut Alanı (Düşük Yoğunluk)'}
355
+ elif luf_label == 'COMMERCIAL':
356
+ lbl_luf[luf_label] = {'EN': 'Commercial', 'TR': 'Ticari'}
357
+ elif luf_label == 'DOWN TOWN':
358
+ lbl_luf[luf_label] = {'EN': 'City Center', 'TR': 'Şehir Merkezi'}
359
+ elif luf_label == 'INDUSTRIAL':
360
+ lbl_luf[luf_label] = {'EN': 'Industrial', 'TR': 'Sanayi'}
361
+ elif luf_label == 'AGRICULTURE':
362
+ lbl_luf[luf_label] = {'EN': 'Agriculture', 'TR': 'Tarım'}
363
+ elif luf_label == 'RECREATION AREA':
364
+ lbl_luf[luf_label] = {'EN': 'Recreation Area', 'TR': 'Park'}
365
+ elif luf_label == 'ANTIQUITIES AREA':
366
+ lbl_luf[luf_label] = {'EN': 'Antiquities Area', 'TR': 'Tarihi Eserler'}
367
+ elif luf_label == 'CEMETRY':
368
+ lbl_luf[luf_label] = {'EN': 'Cemetery', 'TR': 'Mezarlık'}
369
+ elif luf_label == 'GREEN BELTS':
370
+ lbl_luf[luf_label] = {'EN': 'Green Belt', 'TR': 'Yeşil Kemer'}
371
+ elif luf_label == 'GREEN OPEN AREAS':
372
+ lbl_luf[luf_label] = {'EN': 'Green Open Area', 'TR': 'Yeşil Açık Alan'}
373
+ elif luf_label == 'HOSPITAL CITY':
374
+ lbl_luf[luf_label] = {'EN': 'Hospital', 'TR': 'Hastane'}
375
+ elif luf_label == 'PARKS':
376
+ lbl_luf[luf_label] = {'EN': 'Park', 'TR': 'Park'}
377
+ elif luf_label == 'PUBLIC FACILITIES':
378
+ lbl_luf[luf_label] = {'EN': 'Public Facilities', 'TR': 'Kamu Tesisleri'}
379
+ elif luf_label == 'SERVICES AREA':
380
+ lbl_luf[luf_label] = {'EN': 'Services Area', 'TR': 'Hizmet Alanı'}
381
+ elif luf_label == 'SOLAR CELLS':
382
+ lbl_luf[luf_label] = {'EN': 'Solar Cells', 'TR': 'Güneş Panelleri'}
383
+ elif luf_label == 'TECHNOLOGY AREA':
384
+ lbl_luf[luf_label] = {'EN': 'Technology Area', 'TR': 'Teknoloji Alanı'}
385
+ elif luf_label == 'TOURISTIC AREA':
386
+ lbl_luf[luf_label] = {'EN': 'Touristic Area', 'TR': 'Turistik Alan'}
387
+ elif luf_label == 'VOCATIONAL TRAINING CENTER':
388
+ lbl_luf[luf_label] = {'EN': 'Vocational Training Centre', 'TR': 'Mesleki Eğitim Merkezi'}
389
+ elif luf_label == 'WASTE COLLECTION STATION':
390
+ lbl_luf[luf_label] = {'EN': 'Waste Collection Station', 'TR': 'Atık Toplama İstasyonu'}
391
+ elif luf_label == 'WATER PURIFICATION AND RECYCLING PLANT':
392
+ lbl_luf[luf_label] = {'EN': 'Water Purification and Recycling Plant', 'TR': 'Su Arıtma ve Geri Dönüşüm Tesisi'}
393
+ else:
394
+ lbl_luf[luf_label] = {'EN': luf_label, 'TR': '(TR)'+luf_label}
395
+
396
+ policies = [1,2,3,4,5,6]
397
+ lbl_policy = dict()
398
+ lbl_policy[1] = {'EN': 'Loans for reconstruction for minor to moderate damages',
399
+ 'TR': 'Küçük ila orta dereceli hasarlar için yeniden yapılanma kredileri'}
400
+ lbl_policy[2] = {'EN': 'Knowledge sharing about disaster risk reduction in schools',
401
+ 'TR': 'Devlet ve özel okullarda afet risklerinin azaltılması hakkında bilgi paylaşımı'}
402
+ lbl_policy[3] = {'EN': 'Catastrophe bond for education/health facilities',
403
+ 'TR': 'Eğitim ve sağlık tesislerini yapılandırmak için afet bonosu'}
404
+ lbl_policy[4] = {'EN': 'Repair loan assistance for flooding',
405
+ 'TR': 'Sel için onarım kredisi yardımı'}
406
+ lbl_policy[5] = {'EN': 'Technical assistance for debris removal in education facilities',
407
+ 'TR': 'Eğitim tesislerinde enkaz kaldırma için teknik yardım'}
408
+ lbl_policy[6] = {'EN': 'Compulsory content insurance for schools and hospitals',
409
+ 'TR': 'Okullar ve hastaneler için zorunlu eşya sigortası'}
410
+ #lbl_policy[7] = {'EN': 'Green resilient infrastructure (prevention) & financial support for business recovery', 'TR': 'Politika 7'}
411
+ #lbl_policy[8] = {'EN': 'Green resilient infrastructure (prevention), reinforcement of schools, hospitals & shelters, financial support for affected business & household', 'TR': 'Politika 8'}
412
+ policy_selected = dict()
413
+ for policy in policies:
414
+ policy_selected[policy] = solara.reactive(False)
415
+ last_selected_policies = solara.reactive(set())
416
+
417
+ earthquake_locs = np.array([earthquake_df.geometry.y.to_list(), earthquake_df.geometry.x.to_list(), earthquake_df.im.to_list()]).transpose().tolist()
418
+ flood_locs = np.array([flood_df.geometry.y.to_list(), flood_df.geometry.x.to_list(), flood_df.im.to_list()]).transpose().tolist()
419
+ debris_locs = np.array([debris_df.geometry.y.to_list(), debris_df.geometry.x.to_list(), debris_df.im.to_list()]).transpose().tolist()
420
+
421
+ hazard_intensities = {
422
+ "earthquake": earthquake_locs,
423
+ "flood": flood_locs,
424
+ "debris": debris_locs
425
+ }
426
+
427
+ hazard_df = {
428
+ "earthquake": earthquake_df,
429
+ "flood": flood_df,
430
+ "debris": debris_df
431
+ }
432
+
433
+ hazard_df_as_geo = {
434
+ "earthquake": earthquake_df_as_geo,
435
+ "flood": flood_df_as_geo,
436
+ "debris": debris_df_as_geo
437
+ }
438
+
439
+ zoom_default = 12
440
+ tv0_zoom = solara.reactive(zoom_default)
441
+
442
+ tv0_center_default = (flood_df.geometry.y.mean(), flood_df.geometry.x.mean())
443
+ tv0_center = solara.reactive(tv0_center_default)
444
+ print(tv0_center)
445
+ def random_color(feature):
446
+ return luf_colors[feature['properties']['luf']]
447
+
448
+ @solara.component
449
+ def TV0MAP():
450
+ selected_lufs = set()
451
+ for luf_type in luf_types:
452
+ if luf_type_selected[luf_type].value:
453
+ selected_lufs.add(luf_type)
454
+ x = {'type':landuse_tv0_json['type'] }
455
+ x['features'] = []
456
+ for f in landuse_tv0_json['features']:
457
+ if f['properties']['luf'] in selected_lufs:
458
+ x['features'].append(f)
459
+ ipyleaflet.Map.element(
460
+ zoom=tv0_zoom.value,
461
+ on_zoom=tv0_zoom.set,
462
+ max_zoom=zoom_default,
463
+ min_zoom=zoom_default,
464
+ center=tv0_center.value,
465
+ on_center=tv0_center.set,
466
+ scroll_wheel_zoom=False,
467
+ dragging=False,
468
+ double_click_zoom=False,
469
+ touch_zoom=False,
470
+ box_zoom=False,
471
+ keyboard=False,
472
+ zoom_control=False,
473
+ layers=[
474
+ ipyleaflet.basemap_to_tiles(ipyleaflet.basemaps.Esri.WorldImagery),
475
+ ipyleaflet.GeoJSON(
476
+ data=x,
477
+ style={
478
+ 'opacity': 1, 'dashArray': '9', 'fillOpacity': 0.5, 'weight': 1
479
+ },
480
+ hover_style={
481
+ 'color': 'white', 'dashArray': '0', 'fillOpacity': 0.5
482
+ },
483
+ style_callback=random_color)
484
+ ],
485
+ )
486
+
487
+ @solara.component
488
+ def DensityMap(hazard_type):
489
+ locs = hazard_intensities[hazard_type]
490
+ ipyleaflet.Map.element(
491
+ zoom=tv0_zoom.value,
492
+ max_zoom=zoom_default,
493
+ min_zoom=zoom_default,
494
+ on_zoom=tv0_zoom.set,
495
+ center=tv0_center.value,
496
+ on_center=tv0_center.set,
497
+ scroll_wheel_zoom=False,
498
+ dragging=False,
499
+ double_click_zoom=False,
500
+ touch_zoom=False,
501
+ box_zoom=False,
502
+ keyboard=False,
503
+ zoom_control=False,
504
+ layers=[
505
+ ipyleaflet.basemap_to_tiles(ipyleaflet.basemaps.Esri.WorldTopoMap),
506
+ ipyleaflet.Heatmap(
507
+ name=hazard_type,
508
+ locations=locs,
509
+ radius=10
510
+ ),
511
+ ],
512
+ )
513
+
514
+
515
+ run_is_allowed = solara.reactive(True)
516
+
517
+ @solara.component
518
+ def PolicyValidation():
519
+ npolicies_selected = 0
520
+ selected_policies = set()
521
+ for p in policies:
522
+ if policy_selected[p].value:
523
+ selected_policies.add(p)
524
+ npolicies_selected += 1
525
+ if npolicies_selected > 3:
526
+ print("roll-back")
527
+ solara.Warning(label=lbl_too_many_policy_selected_error[lang.value])
528
+ run_is_allowed.value = False
529
+ # Roll-back to last selection
530
+ #for p in policies:
531
+ # if p in last_selected_policies.value:
532
+ # policy_selected[p].value = True
533
+ # else:
534
+ # policy_selected[p].value = False
535
+ else:
536
+ last_selected_policies.value = selected_policies
537
+ run_is_allowed.value = True
538
+
539
+
540
+ landuseplan_selected = solara.reactive(1)
541
+
542
+ lbl_metric1 = {"EN": "Number of workers unemployed", "TR": "İşini kaybedenlerin sayısı"}
543
+ lbl_metric2 = {"EN": "Number of children with no access to education", "TR": "Okula gidemeyen çocuk sayısı"}
544
+ lbl_metric3 = {"EN": "Number of households with no access to hospital", "TR": "Hastane erişimi olmayan hane sayısı"}
545
+ lbl_metric4 = {"EN": "Number of individuals with no access to hospital", "TR": "Hastane erişimi olmayan kişi sayısı"}
546
+ lbl_metric5 = {"EN": "Number of homeless households", "TR": "İşlevsiz kalan hane sayısı"}
547
+ lbl_metric6 = {"EN": "Number of homeless individuals", "TR": "Evsiz kalan sayısı"}
548
+ lbl_metric7 = {"EN": "Population displacement", "TR": "Yer değiştirmek zorunda kalan kişi sayısı"}
549
+
550
+ metrics = {"metric1": {"desc": lbl_metric1, "value": solara.reactive(0), "max_value": solara.reactive(0)},
551
+ "metric2": {"desc": lbl_metric2, "value": solara.reactive(0), "max_value": solara.reactive(0)},
552
+ "metric3": {"desc": lbl_metric3, "value": solara.reactive(0), "max_value": solara.reactive(0)},
553
+ "metric4": {"desc": lbl_metric4, "value": solara.reactive(0), "max_value": solara.reactive(0)},
554
+ "metric5": {"desc": lbl_metric5, "value": solara.reactive(0), "max_value": solara.reactive(0)},
555
+ "metric6": {"desc": lbl_metric6, "value": solara.reactive(0), "max_value": solara.reactive(0)},
556
+ "metric7": {"desc": lbl_metric7, "value": solara.reactive(0), "max_value": solara.reactive(0)}}
557
+
558
+
559
+ @solara.component
560
+ def MetricWidget(name, description, value, max_value=10000):
561
+ value, set_value = solara.use_state_or_update(value)
562
+ max_value, set_max_value = solara.use_state_or_update(max_value)
563
+ options = {
564
+ "series": [ {
565
+ "type": 'gauge',
566
+ "min": 0,
567
+ "name": description,
568
+ "max": max(1,max_value), # workaround when max_value = 0
569
+ "startAngle": 180,
570
+ "endAngle": 0,
571
+ "progress": {"show": True, "width": 8, "itemStyle": {"color": 'red'}},
572
+ "pointer": { "show": False},
573
+ "axisLine": {"lineStyle": {"width": 8}},
574
+ "axisTick": {"show": False},
575
+ "splitLine": {"show": False},
576
+ "axisLabel": {"show": False},
577
+ "anchor": {"show": False},
578
+ "title": {"show": False},
579
+ "detail": {
580
+ "valueAnimation": True,
581
+ "offsetCenter": [0, '-15%'],
582
+ "fontSize": 14,
583
+ "color": 'white'},
584
+ #"title": {"fontSize": 12},
585
+ "data": [{"value": value, "name": name}]}]}
586
+ print(f'value/max_value {value}:{max_value}')
587
+
588
+
589
+ solara.FigureEcharts(option=options, attributes={ "style": "height: 100px; width: 100px" })
590
+
591
+
592
+ @solara.component
593
+ def MetricsPanel(metrics):
594
+ '''
595
+ with solara.Columns([33,33,33]):
596
+ with solara.Column(align="center", gap="2px"):
597
+ for key in ["metric1","metric2"]:
598
+ MetricWidget(key, metrics[key]["desc"], metrics[key]["value"].value,
599
+ max_value=metrics[key]["max_value"].value)
600
+ solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
601
+ with solara.Column(align="center", gap="2px"):
602
+ for key in ["metric3","metric4"]:
603
+ MetricWidget(key, metrics[key]["desc"], metrics[key]["value"].value,
604
+ max_value=metrics[key]["max_value"].value)
605
+ solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
606
+ with solara.Column(align="center", gap="2px"):
607
+ for key in ["metric6","metric7"]:
608
+ MetricWidget(key, metrics[key]["desc"], metrics[key]["value"].value,
609
+ max_value=metrics[key]["max_value"].value)
610
+ solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
611
+ '''
612
+ with solara.GridFixed(columns=3):
613
+ for key in ["metric2","metric4","metric6"]:
614
+ with solara.Row(justify="center"):
615
+ MetricWidget(key, metrics[key]["desc"], metrics[key]["value"].value,
616
+ max_value=metrics[key]["max_value"].value)
617
+ for key in ["metric2","metric4","metric6"]:
618
+ with solara.Row(justify="center"):
619
+ solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
620
+ # for key in ["metric1","metric2","metric3"]:
621
+ # with solara.Row(justify="center"):
622
+ # MetricWidget(key, metrics[key]["desc"], metrics[key]["value"].value,
623
+ # max_value=metrics[key]["max_value"].value)
624
+ # for key in ["metric1","metric2","metric3"]:
625
+ # with solara.Row(justify="center"):
626
+ # solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
627
+ # for key in ["metric4","metric6","metric7"]:
628
+ # with solara.Row(justify="center"):
629
+ # MetricWidget(key,metrics[key]["desc"], metrics[key]["value"].value,
630
+ # max_value=metrics[key]["max_value"].value)
631
+ # for key in ["metric4","metric6","metric7"]:
632
+ # with solara.Row(justify="center"):
633
+ # solara.HTML(unsafe_innerHTML=metrics[key]["desc"][lang.value], classes=["metricdesc"])
634
+
635
+
636
+ def run_simulation():
637
+ print("Running simulation")
638
+ print(f"Selected landuse plans: {landuseplan_selected.value}")
639
+ selected_policies = set()
640
+ for p in policies:
641
+ if policy_selected[p].value:
642
+ selected_policies.add(p)
643
+ print(f"Selected policies: {selected_policies}")
644
+
645
+ new_metrics = run_engine(hazard_type.value,
646
+ landuseplan_selected.value,
647
+ hazard_df_as_geo[hazard_type.value],
648
+ list(selected_policies))
649
+ for key in new_metrics.keys():
650
+ metrics[key]["value"].value = new_metrics[key]["value"]
651
+ metrics[key]["max_value"].value = new_metrics[key]["max_value"]
652
+
653
+ print(metrics)
654
+
655
+
656
+ @solara.component
657
+ def LandUsePlans():
658
+ for p in policies:
659
+ if policy_selected[p].value:
660
+ print(p, 'selected')
661
+
662
+ for p in policies:
663
+ if policy_selected[p].value:
664
+ print(p, 'selected')
665
+
666
+ #with solara.Column(gap="2px"):
667
+ # with solara.Columns([2,32,32,32,2]):
668
+ # solara.HTML(unsafe_innerHTML="")
669
+ # for i in range(1, n_landuses+1):
670
+ # if landuseplan_selected.value == i:
671
+ # solara.Image(f"landuse_tv50_{i}_selected.png", width="230px")
672
+ # else:
673
+ # solara.Image(f"landuse_tv50_{i}.png",width="230px")
674
+ # solara.HTML(unsafe_innerHTML="")
675
+ # with solara.Row():
676
+ # with solara.ToggleButtonsSingle(value=landuseplan_selected):
677
+ # for i in range(0, n_landuses):
678
+ # solara.Button(lbl_land_use_btn[i][lang.value], value=i+1, text=True, style="width: 320px; height: 26px")
679
+
680
+
681
+ def landuse_1():
682
+ landuseplan_selected.value = 1
683
+
684
+ def landuse_2():
685
+ landuseplan_selected.value = 2
686
+
687
+ def landuse_3():
688
+ landuseplan_selected.value = 3
689
+
690
+ funcs = {1: landuse_1, 2: landuse_2, 3: landuse_3}
691
+
692
+ butons = []
693
+ with solara.Columns([33,33,33]):
694
+ for i in range(0, n_landuses):
695
+ with solara.Column():
696
+ if landuseplan_selected.value == i + 1:
697
+ solara.Button(lbl_land_use_btn[i][lang.value], value=i+1,
698
+ text=True, on_click=funcs[i+1], style="background-color: #545454; width: auto; height: 26px")
699
+ with solara.Row(justify="center"):
700
+ solara.Image(f"landuse_tv50_{i+1}_selected.png", width="200px")
701
+
702
+ else:
703
+ solara.Button(lbl_land_use_btn[i][lang.value], value=i+1,
704
+ text=True, on_click=funcs[i+1], style="width: auto; height: 26px")
705
+ with solara.Row(justify="center"):
706
+ solara.Image(f"landuse_tv50_{i+1}.png", width="200px")
707
+
708
+
709
+ @solara.component
710
+ def Page():
711
+ def reset_view():
712
+ tv0_zoom.value = zoom_default
713
+ tv0_center.value = tv0_center_default
714
+ hazard_type.value = hazard_type_default
715
+ for luf_type in luf_types:
716
+ luf_type_selected[luf_type].value = True
717
+ landuseplan_selected.value = 1
718
+
719
+ solara.Style(css)
720
+ with solara.Column():
721
+ solara.HTML(unsafe_innerHTML="")
722
+ with solara.Column():
723
+ with solara.Columns([1,2,1],style="display: flex; justify-content: center; align-items: center;"):
724
+ with solara.Column():
725
+ solara.Markdown("""[![Tomorrow's Cities](/static/public/tc-logo.png)](https://tomorrowscities.org/)""")
726
+ with solara.Column():
727
+ solara.HTML(unsafe_innerHTML="")
728
+ #solara.Button(label=lbl_reset[lang.value], on_click=reset_view, style="height: 26px;")
729
+ solara.HTML(unsafe_innerHTML=lbl_maintitle[lang.value],classes=["maintitle"])
730
+ with solara.ToggleButtonsSingle(value=lang, style={"justify-content": "center"}):
731
+ solara.Button(label="EN", value="EN", text=True,classes=["langbutton"],style="width: auto; height: 26px;")
732
+ solara.Button(label="TR", value="TR", text=True,classes=["langbutton"],style="width: auto; height: 26px;")
733
+ with solara.Column():
734
+ solara.Markdown("")
735
+ with solara.Column():
736
+ with solara.Column(gap="2px"):
737
+ with solara.Card(title=lbl_tv0_map_title[lang.value]):
738
+ with solara.Column(classes=["mycol"]):
739
+ TV0MAP()
740
+ with solara.Columns([50,50]):
741
+ with solara.Column(gap="4px"):
742
+ for luf_type in luf_types:
743
+ with solara.Row():
744
+ #solara.Button(label="",
745
+ # color=luf_colors[luf_type]['fillColor'],
746
+ # classes=["lufbox"])
747
+ solara.HTML(unsafe_innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
748
+ style=f"margin: 1px; background-color: {luf_colors[luf_type]['fillColor']};")
749
+ solara.HTML(unsafe_innerHTML=lbl_luf[luf_type][lang.value],
750
+ style="font-size: 12px; line-height: 100%; display: flex; justify-content: center; align-items: center;")
751
+ #solara.Checkbox(label=lbl_luf[luf_type][lang.value],value=luf_type_selected[luf_type],
752
+ # style="margin-top: 0px; line-height: 80%;")
753
+ with solara.Column(gap="20px"):
754
+ solara.HTML(unsafe_innerHTML=lbl_info1[lang.value], classes=["infoitem"])
755
+ solara.HTML(unsafe_innerHTML=lbl_info2[lang.value], classes=["infoitem"])
756
+ solara.HTML(unsafe_innerHTML=lbl_info3[lang.value], classes=["infoitem"])
757
+ solara.HTML(unsafe_innerHTML=lbl_info4[lang.value], classes=["infoitem"])
758
+ solara.HTML(unsafe_innerHTML=lbl_info5[lang.value], classes=["infoitem"])
759
+ with solara.Card(title=lbl_infobox_title[lang.value], style={"text-align": "justify"}):
760
+ solara.HTML(unsafe_innerHTML=lbl_infobox[lang.value], classes=["infobox"])
761
+ with solara.Card(title=lbl_density_map_title[lang.value]):
762
+ with solara.Columns([1]):
763
+ with solara.Column():
764
+ if hazard_type.value == "flood":
765
+ bgcolor = "background-color: #545454;"
766
+ else:
767
+ bgcolor = ""
768
+ with solara.Row(justify="center"):
769
+ solara.Button(lbl_flood[lang.value], value="flood", text=True, on_click=lambda: hazard_type.set("flood"), style=f"{bgcolor} width: 100%; height: 26px")
770
+ DensityMap("flood")
771
+ with solara.Column():
772
+ if hazard_type.value == "earthquake":
773
+ bgcolor = "background-color: #545454;"
774
+ else:
775
+ bgcolor = ""
776
+ with solara.Row(justify="center"):
777
+ solara.Button(lbl_earthquake[lang.value], value="earthquake", text=True, on_click=lambda: hazard_type.set("earthquake"), style=f"{bgcolor} width: 100%; height: 26px")
778
+ DensityMap("earthquake")
779
+ # with solara.Column():
780
+ # if hazard_type.value == "debris":
781
+ # bgcolor = "background-color: #545454;"
782
+ # else:
783
+ # bgcolor = ""
784
+ # with solara.Row(justify="center"):
785
+ # solara.Button(lbl_debris[lang.value], value="debris", text=True, on_click=lambda: hazard_type.set("debris"), style=f"{bgcolor} width: 200px; height: 26px")
786
+ # DensityMap("debris")
787
+ #with solara.Columns([30,30,30]):
788
+ # DensityMap("earthquake")
789
+ # DensityMap("flood")
790
+ # DensityMap("debris")
791
+ with solara.Column(gap="2px"):
792
+ with solara.Card(title=lbl_landuse_plans_title[lang.value]):
793
+ LandUsePlans()
794
+ with solara.Card(lbl_policy_card_title[lang.value]):
795
+ with solara.GridFixed(columns=1,row_gap="2px", column_gap="2px"):
796
+ for p in policies:
797
+ solara.Checkbox(label=lbl_policy[p][lang.value],value=policy_selected[p], style="font-size: 15px; text-align: justify")
798
+ solara.Button(label=lbl_run_btn[lang.value],on_click=run_simulation, disabled=not run_is_allowed.value, style="width: 100%; height: 50px")
799
+ PolicyValidation()
800
+ with solara.Card(title=lbl_results_card_title[lang.value]):
801
+ MetricsPanel(metrics)
802
+ solara.HTML(unsafe_innerHTML="")
803
+ solara.Title("Tomorrow's Cities Demo")
804
+
805
+ @solara.component
806
+ def Layout(children):
807
+ # if you need the normal applayout
808
+ # layout = solara.AppLayout(children=children, style)
809
+ layout = solara.Div(children=children, style={"width": "100%", "min-height": "100vh"})
810
+
811
+ def log(*args):
812
+ print("stop doing that!")
813
+
814
+ #solara.v.use_event(layout, "contextmenu.prevent", log)
815
+ return layout
816
+
817
+ Page()
demo/pages/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (38.7 kB). View file
 
demo/pages/__pycache__/engine.cpython-312.pyc ADDED
Binary file (15.2 kB). View file
 
demo/pages/engine.py ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #%%
2
+ import warnings
3
+ import json
4
+ import sys
5
+ import argparse
6
+ import io
7
+ import os
8
+ import pandas as pd
9
+ import psycopg2
10
+ import geopandas as gpd
11
+ import numpy as np
12
+ from scipy.stats import norm
13
+ from scipy.interpolate import interp1d
14
+
15
+ # Damage States
16
+ DS_NO = 1
17
+ DS_SLIGHT = 2
18
+ DS_MODERATE = 3
19
+ DS_EXTENSIZE = 4
20
+ DS_COLLAPSED = 5
21
+
22
+ # Hazard Types
23
+ HAZARD_EARTHQUAKE = "earthquake"
24
+ HAZARD_FLOOD = "flood"
25
+ HAZARD_DEBRIS = "debris"
26
+
27
+ weights = {
28
+ "earthquake": {"metric1": 0.2,
29
+ "metric2": 0.2,
30
+ "metric3": 0.2,
31
+ "metric4": 0.2,
32
+ "metric5": 0.2,
33
+ "metric6": 0.2,
34
+ "metric7": 0.2,
35
+ },
36
+ "flood": {"metric1": 20,
37
+ "metric2": 20,
38
+ "metric3": 20,
39
+ "metric4": 20,
40
+ "metric5": 20,
41
+ "metric6": 20,
42
+ "metric7": 20,
43
+ },
44
+ "debris": {"metric1": 200,
45
+ "metric2": 200,
46
+ "metric3": 200,
47
+ "metric4": 200,
48
+ "metric5": 200,
49
+ "metric6": 200,
50
+ "metric7": 200,
51
+ }
52
+ }
53
+
54
+ def run_engine(hazard_type, scenario, gdf_intensity, policies=[]):
55
+
56
+ building_file = f"building_tv50_{scenario}.geojson"
57
+ household_file = f"household_tv50_{scenario}.xlsx"
58
+ individual_file = f"individual_tv50_{scenario}.xlsx"
59
+
60
+ threshold = 1
61
+ threshold_flood = 0.2
62
+ threshold_flood_distance = 40
63
+ epsg = 32636 # Nblus
64
+ df_buildings = gpd.read_file(building_file)
65
+ df_household = pd.read_excel(household_file)
66
+ df_individual = pd.read_excel(individual_file)
67
+ #gdf_intensity = intensity_df.copy()
68
+
69
+ # Read vulnerability from this table if hazard is earthquake
70
+ if hazard_type == HAZARD_EARTHQUAKE:
71
+ df_eq = pd.read_csv('earthquake_fragility.xml')
72
+
73
+ elif hazard_type == HAZARD_FLOOD or hazard_type == HAZARD_DEBRIS:
74
+ df_flood = pd.read_csv('flood_vulnerability.csv')
75
+
76
+ # TODO: Fix the confusion geometry/geograhy etc
77
+ gdf_buildings = gpd.GeoDataFrame(df_buildings,
78
+ geometry=gpd.points_from_xy(df_buildings.xcoord, df_buildings.ycoord))
79
+
80
+ #
81
+ # We asssume all input is EPSG:4326
82
+ gdf_buildings = gdf_buildings.set_crs("EPSG:4326",allow_override=True)
83
+ #gdf_intensity = gdf_intensity.set_crs("EPSG:4326",allow_override=True)
84
+
85
+ # Convert both to the same target coordinate system
86
+ print(epsg)
87
+ gdf_buildings = gdf_buildings.to_crs(f"EPSG:{epsg}")
88
+ #gdf_intensity = gdf_intensity.to_crs(f"EPSG:{epsg}")
89
+
90
+ #%%
91
+ gdf_building_intensity = gpd.sjoin_nearest(gdf_buildings,gdf_intensity,
92
+ how='left', rsuffix='intensity',distance_col='distance')
93
+ gdf_building_intensity = gdf_building_intensity.drop_duplicates(subset=['bldid'], keep='first')
94
+
95
+ # TODO: Check if the logic makes sense
96
+ if hazard_type == HAZARD_FLOOD or hazard_type == HAZARD_DEBRIS:
97
+ away_from_flood = gdf_building_intensity['distance'] > threshold_flood_distance
98
+ print('threshold_flood_distance',threshold_flood_distance)
99
+ print('number of distant buildings', len(gdf_building_intensity.loc[away_from_flood, 'im']))
100
+ gdf_building_intensity.loc[away_from_flood, 'im'] = 0
101
+
102
+ #%%
103
+ gdf_building_intensity[['material','code_level','storeys','occupancy']] = \
104
+ gdf_building_intensity['expstr'].str.split('+',expand=True)
105
+ gdf_building_intensity['height'] = gdf_building_intensity['storeys'].str.extract(r'([0-9]+)s').astype('int')
106
+ #%%
107
+ lr = (gdf_building_intensity['height'] <= 4)
108
+ mr = (gdf_building_intensity['height'] >= 5) & (gdf_building_intensity['height'] <= 8)
109
+ hr = (gdf_building_intensity['height'] >= 9)
110
+ gdf_building_intensity.loc[lr, 'height_level'] = 'LR'
111
+ gdf_building_intensity.loc[mr, 'height_level'] = 'MR'
112
+ gdf_building_intensity.loc[hr, 'height_level'] = 'HR'
113
+
114
+ #%%
115
+ gdf_building_intensity['vulnstreq'] = \
116
+ gdf_building_intensity[['material','code_level','height_level']] \
117
+ .agg('+'.join,axis=1)
118
+
119
+ #%%
120
+ if hazard_type == HAZARD_EARTHQUAKE:
121
+ bld_eq = gdf_building_intensity.merge(df_eq, on='vulnstreq', how='left')
122
+ nulls = bld_eq['muds1_g'].isna()
123
+ bld_eq.loc[nulls, ['muds1_g','muds2_g','muds3_g','muds4_g']] = [0.048,0.203,0.313,0.314]
124
+ bld_eq.loc[nulls, ['sigmads1','sigmads2','sigmads3','sigmads4']] = [0.301,0.276,0.252,0.253]
125
+ bld_eq['logim'] = np.log(bld_eq['im']/9.81)
126
+ for m in ['muds1_g','muds2_g','muds3_g','muds4_g']:
127
+ bld_eq[m] = np.log(bld_eq[m])
128
+
129
+ for i in [1,2,3,4]:
130
+ bld_eq[f'prob_ds{i}'] = norm.cdf(bld_eq['logim'],bld_eq[f'muds{i}_g'],bld_eq[f'sigmads{i}'])
131
+ bld_eq[['prob_ds0','prob_ds5']] = [1,0]
132
+ for i in [1,2,3,4,5]:
133
+ bld_eq[f'ds_{i}'] = np.abs(bld_eq[f'prob_ds{i-1}'] - bld_eq[f'prob_ds{i}'])
134
+ df_ds = bld_eq[['ds_1','ds_2','ds_3','ds_4','ds_5']]
135
+ bld_eq['eq_ds'] = df_ds.idxmax(axis='columns').str.extract(r'ds_([0-9]+)').astype('int')
136
+
137
+ # Create a simplified building-hazard relation
138
+ bld_hazard = bld_eq[['bldid','occupancy','eq_ds']]
139
+ bld_hazard = bld_hazard.rename(columns={'eq_ds':'ds'})
140
+
141
+ ds_str = {1: 'No Damage',2:'Low',3:'Medium',4:'High',5:'Collapsed'}
142
+
143
+ elif hazard_type == HAZARD_FLOOD or hazard_type == HAZARD_DEBRIS:
144
+ bld_flood = gdf_building_intensity.merge(df_flood, on='expstr', how='left')
145
+ x = np.array([0,0.5,1,1.5,2,3,4,5,6])
146
+ y = bld_flood[['hw0','hw0.5','hw1','hw1.5','hw2','hw3','hw4','hw5','hw6']].to_numpy()
147
+ xnew = bld_flood['im'].to_numpy()
148
+ flood_mapping = interp1d(x,y,axis=1,kind='linear',bounds_error=False, fill_value=(0,1))
149
+ # TODO: find another way for vectorized interpolate
150
+ bld_flood['fl_prob'] = np.diag(flood_mapping(xnew))
151
+ bld_flood['fl_ds'] = 0
152
+ bld_flood.loc[bld_flood['fl_prob'] > threshold_flood,'fl_ds'] = 1
153
+
154
+ # Create a simplified building-hazard relation
155
+ bld_hazard = bld_flood[['bldid','occupancy','fl_ds']]
156
+ bld_hazard = bld_hazard.rename(columns={'fl_ds':'ds'})
157
+
158
+ ds_str = {0: 'No Damage',1:'Flooded'}
159
+
160
+ bld_hazard['occupancy'] = pd.Categorical(bld_hazard['occupancy'])
161
+ for key, value in ds_str.items():
162
+ bld_hazard.loc[bld_hazard['ds'] == key,'damage_level'] = value
163
+ bld_hazard['damage_level'] = pd.Categorical(bld_hazard['damage_level'], list(ds_str.values()))
164
+
165
+ #%% Find the damage state of the building that the household is in
166
+ df_household_bld = df_household.merge(bld_hazard[['bldid','ds']], on='bldid', how='left',validate='many_to_one')
167
+ #%% find the damage state of the hospital that the household is associated with
168
+ df_hospitals = df_household.merge(bld_hazard[['bldid','damage_level', 'ds']],
169
+ how='left', left_on='commfacid', right_on='bldid', suffixes=['','_comm'],
170
+ validate='many_to_one')
171
+ #%%
172
+ df_workers = df_individual.merge(bld_hazard[['bldid','damage_level', 'ds']],
173
+ how='left', left_on='indivfacid_2', right_on='bldid',
174
+ suffixes=['_l','_r'],validate='many_to_one')
175
+
176
+ #%%
177
+ df_students = df_individual.merge(bld_hazard[['bldid','damage_level', 'ds']],
178
+ how='left', left_on='indivfacid_1', right_on='bldid',
179
+ suffixes=['_l','_r'],validate='many_to_one')
180
+ #%%
181
+ df_indiv_hosp = df_individual.merge(df_hospitals[['hhid','ds','bldid']],
182
+ how='left', on='hhid', validate='many_to_one')
183
+ #%%
184
+ # get the ds of household that individual lives in
185
+ df_indiv_household = df_individual[['hhid','individ']].merge(df_household_bld[['hhid','ds']])
186
+
187
+ df_displaced_indiv = df_indiv_hosp.rename(columns={'ds':'ds_hospital'})\
188
+ .merge(df_workers[['individ','ds']].rename(columns={'ds':'ds_workplace'}),on='individ', how='inner')\
189
+ .merge(df_students[['individ','ds']].rename(columns={'ds':'ds_school'}), on='individ', how='inner')\
190
+ .merge(df_indiv_household[['individ','ds']].rename(columns={'ds':'ds_household'}), on='individ',how='left')
191
+ #%%
192
+ if hazard_type == HAZARD_EARTHQUAKE:
193
+ # Effect of policies on thresholds
194
+ # First get the global threshold
195
+ thresholds = {f'metric{id}': threshold for id in range(8)}
196
+ else:
197
+ # Default thresholds for flood and debris
198
+ # For flood, there are only two states: 0 or 1.
199
+ # So threshold is set to 0.
200
+ thresholds = {f'metric{id}': 0 for id in range(8)}
201
+
202
+ # Policy 6 is valid for all three hazard types
203
+ # Policy-6: Compulsory content insurance for schools and hospitals
204
+ # increases threshold for loss of edu/health in all hazard-types from minor to moderate
205
+ # slight to moderate
206
+ if 6 in policies and thresholds['metric3'] == DS_NO:
207
+ thresholds['metric3'] = DS_SLIGHT
208
+ if 6 in policies and thresholds['metric2'] == DS_NO:
209
+ thresholds['metric2'] = DS_SLIGHT
210
+
211
+ if hazard_type == HAZARD_EARTHQUAKE:
212
+ # Policy-1: Loans for reconstruction for minor to moderate damages
213
+ # Changes: Damage state thresholds for “displacement”
214
+ # Increase thresholds from “slight to moderate” as fewer people will be displaced.
215
+ if 1 in policies and thresholds['metric7'] == DS_NO:
216
+ thresholds['metric7'] = DS_SLIGHT
217
+
218
+ # Policy-3: Cat-bond agreement for education and health facilities
219
+ # Changes: Damage state thresholds for “loss of access to hospitals” and “loss of access to schools”
220
+ # Increase thresholds from “slight to moderate” as fewer people will be displaced.
221
+ if 3 in policies and thresholds['metric3'] == DS_NO:
222
+ thresholds['metric3'] = DS_SLIGHT
223
+ if 3 in policies and thresholds['metric2'] == DS_NO:
224
+ thresholds['metric2'] = DS_SLIGHT
225
+
226
+ # Policy-2: Knowledge sharing about DRR in public and private schools
227
+ # Changes: Damage state thresholds for “loss of school access”
228
+ # Increase thresholds loss of school access to beyond current scale. So that the impact will be downgraded to “0”.
229
+ if 2 in policies:
230
+ thresholds['metric2'] = DS_COLLAPSED
231
+
232
+ if hazard_type == HAZARD_FLOOD:
233
+ # Polcy-4: Repair loan assistance for flooding
234
+ # we have only two states 0/1. So if this policy
235
+ # is effective, increase it to 1 meaning that
236
+ # population displacement is solved
237
+ if 4 in policies:
238
+ thresholds['metric6'] = 1
239
+
240
+ if hazard_type == HAZARD_FLOOD or hazard_type == HAZARD_DEBRIS:
241
+ # Policy-5: Technical assistance for debris removal in education facilities
242
+ # loss of education is solved via this policy. For both flood and debris
243
+ # loss of education metric is fixed.
244
+ if 5 in policies:
245
+ thresholds['metric2'] = 1
246
+
247
+ #%% metric 1 number of unemployed workers in each building
248
+ df_workers_per_building = df_workers[df_workers['ds'] > thresholds['metric1']].groupby('bldid',as_index=False).agg({'individ':'count'})
249
+ df_metric1 = bld_hazard.merge(df_workers_per_building,how='left',left_on='bldid',right_on = 'bldid')[['bldid','individ']]
250
+ df_metric1.rename(columns={'individ':'metric1'}, inplace=True)
251
+ df_metric1['metric1'] = df_metric1['metric1'].fillna(0).astype(int)
252
+
253
+ #%% metric 2 number of students in each building with no access to schools
254
+ df_students_per_building = df_students[df_students['ds'] > thresholds['metric2']].groupby('bldid',as_index=False).agg({'individ':'count'})
255
+ df_metric2 = bld_hazard.merge(df_students_per_building,how='left',left_on='bldid',right_on = 'bldid')[['bldid','individ']]
256
+ df_metric2.rename(columns={'individ':'metric2'}, inplace=True)
257
+ df_metric2['metric2'] = df_metric2['metric2'].fillna(0).astype(int)
258
+
259
+ #%% metric 3 number of households in each building with no access to hospitals
260
+ df_hospitals_per_household = df_hospitals[df_hospitals['ds'] > thresholds['metric3']].groupby('bldid',as_index=False).agg({'hhid':'count'})
261
+ df_metric3 = bld_hazard.merge(df_hospitals_per_household,how='left',left_on='bldid',right_on='bldid')[['bldid','hhid']]
262
+ df_metric3.rename(columns={'hhid':'metric3'}, inplace=True)
263
+ df_metric3['metric3'] = df_metric3['metric3'].fillna(0).astype(int)
264
+
265
+ #%% metric 4 number of individuals in each building with no access to hospitals
266
+ df_hospitals_per_individual = df_hospitals[df_hospitals['ds'] > thresholds['metric4']].groupby('bldid',as_index=False).agg({'nind':'sum'})
267
+ df_metric4 = bld_hazard.merge(df_hospitals_per_individual,how='left',left_on='bldid',right_on='bldid')[['bldid','nind']]
268
+ df_metric4.rename(columns={'nind':'metric4'}, inplace=True)
269
+ df_metric4['metric4'] = df_metric4['metric4'].fillna(0).astype(int)
270
+
271
+ #%% metric 5 number of damaged households in each building
272
+ df_homeless_households = df_household_bld[df_household_bld['ds'] > thresholds['metric5']].groupby('bldid',as_index=False).agg({'hhid':'count'})
273
+ df_metric5 = bld_hazard.merge(df_homeless_households,how='left',left_on='bldid',right_on='bldid')[['bldid','hhid']]
274
+ df_metric5.rename(columns={'hhid':'metric5'}, inplace=True)
275
+ df_metric5['metric5'] = df_metric5['metric5'].fillna(0).astype(int)
276
+
277
+ #%% metric 6 number of homeless individuals in each building
278
+ df_homeless_individuals = df_household_bld[df_household_bld['ds'] > thresholds['metric6']].groupby('bldid',as_index=False).agg({'nind':'sum'})
279
+ df_metric6 = bld_hazard.merge(df_homeless_individuals,how='left',left_on='bldid',right_on='bldid')[['bldid','nind']]
280
+ df_metric6.rename(columns={'nind':'metric6'}, inplace=True)
281
+ df_metric6['metric6'] = df_metric6['metric6'].fillna(0).astype(int)
282
+
283
+ #%% metric 7 the number of displaced individuals in each building
284
+ # more info: an individual is displaced if at least of the conditions below hold
285
+ df_disp_per_bld = df_displaced_indiv[(df_displaced_indiv['ds_household'] > thresholds['metric6']) |
286
+ (df_displaced_indiv['ds_school'] > thresholds['metric7']) |
287
+ (df_displaced_indiv['ds_workplace'] > thresholds['metric7']) |
288
+ (df_displaced_indiv['ds_hospital'] > thresholds['metric7'])].groupby('bldid',as_index=False).agg({'individ':'count'})
289
+ df_metric7 = bld_hazard.merge(df_disp_per_bld,how='left',left_on='bldid',right_on='bldid')[['bldid','individ']]
290
+ df_metric7.rename(columns={'individ':'metric7'}, inplace=True)
291
+ df_metric7['metric7'] = df_metric7['metric7'].fillna(0).astype(int)
292
+
293
+ df_metrics = {'metric1': df_metric1,
294
+ 'metric2': df_metric2,
295
+ 'metric3': df_metric3,
296
+ 'metric4': df_metric4,
297
+ 'metric5': df_metric5,
298
+ 'metric6': df_metric6,
299
+ 'metric7': df_metric7}
300
+
301
+ #%%
302
+ number_of_workers = len(df_workers.loc[df_workers['indivfacid_2'] > 0])
303
+ print('number of workers', number_of_workers)
304
+
305
+ number_of_students = len(df_workers.loc[df_students['indivfacid_1'] > 0])
306
+ print('number of students', number_of_students)
307
+
308
+ number_of_households = len(df_household)
309
+ print('number of households', number_of_households)
310
+
311
+ number_of_individuals = len(df_individual)
312
+ print('number of individuals', number_of_individuals)
313
+ metrics = {"metric1": {"desc": "Number of workers unemployed", "value": 0, "max_value": 20_000},
314
+ "metric2": {"desc": "Number of children with no access to education", "value": 0, "max_value": number_of_students},
315
+ "metric3": {"desc": "Number of households with no access to hospital", "value": 0, "max_value": 20_000},
316
+ "metric4": {"desc": "Number of individuals with no access to hospital", "value": 0, "max_value": number_of_individuals},
317
+ "metric5": {"desc": "Number of homeless households", "value": 0, "max_value": number_of_households},
318
+ "metric6": {"desc": "Number of homeless individuals", "value": 0, "max_value": number_of_individuals},
319
+ "metric7": {"desc": "Population displacement", "value": 0, "max_value": 75_000},}
320
+ metrics["metric1"]["value"] = int(df_metric1['metric1'].sum())
321
+ metrics["metric2"]["value"] = int(df_metric2['metric2'].sum())
322
+ metrics["metric3"]["value"] = int(df_metric3['metric3'].sum())
323
+ metrics["metric4"]["value"] = int(df_metric4['metric4'].sum())
324
+ metrics["metric5"]["value"] = int(df_metric5['metric5'].sum())
325
+ metrics["metric6"]["value"] = int(df_metric6['metric6'].sum())
326
+ metrics["metric7"]["value"] = int(df_metric7['metric7'].sum())
327
+
328
+ for key in metrics.keys():
329
+ metrics[key]["value"] = int(metrics[key]["value"] * weights[hazard_type][key])
330
+
331
+ # return to WSG
332
+ return metrics
demo/public/Museo700-Regular.woff2 ADDED
Binary file (19.2 kB). View file
 
demo/public/Museo900-Regular.woff ADDED
Binary file (28 kB). View file
 
demo/public/Museo900-Regular.woff2 ADDED
Binary file (19.5 kB). View file
 
demo/public/OpenSans400.woff2 ADDED
Binary file (15.8 kB). View file
 
demo/public/open-sans.regular.ttf ADDED
Binary file (217 kB). View file
 
demo/public/tc-logo.png ADDED
demo/public/tc-logo_old1.png ADDED
demo/public/tc-logo_old2.png ADDED
demo/public/tc-logo_old3.png ADDED
demo/public/tomorrows-cities-logo-header.png ADDED
earthquake_fragility.xml ADDED
The diff for this file is too large to render. See raw diff
 
flood_vulnerability.csv ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ expstr,hw0,hw0.5,hw1,hw1.5,hw2,hw3,hw4,hw5,hw6
2
+ CR+CIP/LDUAL+DUL+LC+1s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
3
+ CR+CIP/LDUAL+DUL+LC+1s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
4
+ CR+CIP/LDUAL+DUL+LC+2s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
5
+ CR+CIP/LDUAL+DUL+LC+2s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
6
+ CR+CIP/LDUAL+DUL+LC+3s+Ind,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
7
+ CR+CIP/LDUAL+DUL+LC+3s+Res,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
8
+ CR+CIP/LDUAL+DUL+LC+4s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
9
+ CR+CIP/LDUAL+DUL+LC+4s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
10
+ CR+CIP/LDUAL+DUL+LC+5s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
11
+ CR+CIP/LDUAL+DUL+LC+5s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
12
+ CR+CIP/LDUAL+DUL+LC+6s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
13
+ CR+CIP/LDUAL+DUL+LC+6s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
14
+ CR+CIP/LDUAL+DUL+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
15
+ CR+CIP/LDUAL+DUL+LC+7s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
16
+ CR+CIP/LDUAL+DUL+LC+8s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
17
+ CR+CIP/LDUAL+DUM+HC+2s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
18
+ CR+CIP/LDUAL+DUM+HC+3s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
19
+ CR+CIP/LDUAL+DUM+HC+4s+Edu,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
20
+ CR+CIP/LDUAL+DUM+LC+1s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
21
+ CR+CIP/LDUAL+DUM+LC+1s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
22
+ CR+CIP/LDUAL+DUM+LC+2s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
23
+ CR+CIP/LDUAL+DUM+LC+2s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
24
+ CR+CIP/LDUAL+DUM+LC+3s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
25
+ CR+CIP/LDUAL+DUM+LC+3s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
26
+ CR+CIP/LDUAL+DUM+LC+4s+Com,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
27
+ CR+CIP/LDUAL+DUM+LC+4s+Res,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
28
+ CR+CIP/LDUAL+DUM+LC+5s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
29
+ CR+CIP/LDUAL+DUM+LC+5s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
30
+ CR+CIP/LDUAL+DUM+LC+6s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
31
+ CR+CIP/LDUAL+DUM+LC+6s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
32
+ CR+CIP/LDUAL+DUM+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
33
+ CR+CIP/LDUAL+DUM+LC+7s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
34
+ CR+CIP/LDUAL+DUM+LC+8s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
35
+ CR+CIP/LDUAL+DUM+MC+2s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
36
+ CR+CIP/LDUAL+DUM+MC+2s+Hea,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
37
+ CR+CIP/LDUAL+DUM+MC+3s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
38
+ CR+CIP/LDUAL+DUM+MC+3s+Hea,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
39
+ CR+CIP/LDUAL+DUM+MC+4s+Edu,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
40
+ CR+CIP/LDUAL+DUM+MC+6s+Hea,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
41
+ CR+CIP/LFINF+DUL+LC+1s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
42
+ CR+CIP/LFINF+DUL+LC+1s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
43
+ CR+CIP/LFINF+DUL+LC+2s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
44
+ CR+CIP/LFINF+DUL+LC+2s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
45
+ CR+CIP/LFINF+DUL+LC+3s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
46
+ CR+CIP/LFINF+DUL+LC+3s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
47
+ CR+CIP/LFINF+DUL+LC+4s+Com,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
48
+ CR+CIP/LFINF+DUL+LC+4s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
49
+ CR+CIP/LFINF+DUL+LC+5s+Com,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
50
+ CR+CIP/LFINF+DUL+LC+5s+Res,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
51
+ CR+CIP/LFINF+DUL+LC+6s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
52
+ CR+CIP/LFINF+DUL+LC+6s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
53
+ CR+CIP/LFINF+DUL+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
54
+ CR+CIP/LFINF+DUL+LC+7s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
55
+ CR+CIP/LFINF+DUL+LC+8s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
56
+ CR+CIP/LFINF+DUM+HC+2s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
57
+ CR+CIP/LFINF+DUM+HC+4s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
58
+ CR+CIP/LFINF+DUM+LC+1s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
59
+ CR+CIP/LFINF+DUM+LC+1s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
60
+ CR+CIP/LFINF+DUM+LC+2s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
61
+ CR+CIP/LFINF+DUM+LC+2s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
62
+ CR+CIP/LFINF+DUM+LC+3s+Ind,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
63
+ CR+CIP/LFINF+DUM+LC+3s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
64
+ CR+CIP/LFINF+DUM+LC+4s+Com,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
65
+ CR+CIP/LFINF+DUM+LC+4s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
66
+ CR+CIP/LFINF+DUM+LC+5s+Com,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
67
+ CR+CIP/LFINF+DUM+LC+5s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
68
+ CR+CIP/LFINF+DUM+LC+6s+Com,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
69
+ CR+CIP/LFINF+DUM+LC+6s+Res,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
70
+ CR+CIP/LFINF+DUM+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
71
+ CR+CIP/LFINF+DUM+LC+7s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
72
+ CR+CIP/LFINF+DUM+LC+8s+Res,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
73
+ CR+CIP/LFINF+DUM+MC+2s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
74
+ CR+CIP/LFINF+DUM+MC+3s+Edu,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
75
+ CR+CIP/LFINF+DUM+MC+5s+Hea,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
76
+ S/LFM+DUL+LC+1s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
77
+ S/LFM+DUL+LC+2s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
78
+ S/LFM+DUL+LC+3s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
79
+ S/LFM+DUL+LC+4s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
80
+ S/LFM+DUL+LC+5s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
81
+ S/LFM+DUL+LC+6s+Com,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
82
+ S/LFM+DUL+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
83
+ S/LFM+DUM+LC+1s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
84
+ S/LFM+DUM+LC+2s+Ind,0,0.177733152,0.262687435,0.306963335,0.354476222,0.405383527,0.411142413,0.429122294,0.428379327
85
+ S/LFM+DUM+LC+3s+Ind,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
86
+ S/LFM+DUM+LC+4s+Com,0,0.09657431,0.152314837,0.210957251,0.25092166,0.325020173,0.371306737,0.39710519,0.411620673
87
+ S/LFM+DUM+LC+5s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
88
+ S/LFM+DUM+LC+6s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
89
+ S/LFM+DUM+LC+7s+Com,0,0.080980337,0.149899454,0.195422753,0.228108138,0.294514186,0.334146853,0.367496796,0.386751292
90
+ HazusPP,0,0.041010499,0.082020997,0.123031496,0.164041995,0.292125984,0.3,0.3,0.3
91
+ HazusSS,0,0.032808399,0.062808399,0.079212598,0.095616798,0.148425197,0.15,0.15,0.15
92
+ HazusTL,0,0,0.01,0.01,0.015616798,0.02,0.02,0.02,0.02
hazard_debris.geojson ADDED
The diff for this file is too large to render. See raw diff
 
hazard_debris.xlsx ADDED
Binary file (33.5 kB). View file
 
hazard_earthquake.geojson ADDED
The diff for this file is too large to render. See raw diff
 
hazard_flood.geojson ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e19f1c13ed81066a67d675ea0999ba05c00f57b06b09ca30b0774546afea07d
3
+ size 77623793
household_tv50_1.xlsx ADDED
Binary file (294 kB). View file
 
household_tv50_2.xlsx ADDED
Binary file (252 kB). View file
 
household_tv50_3.xlsx ADDED
Binary file (329 kB). View file
 
individual_tv50_1.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c88c29c9ae5ac0ded468f649d5ceaaee98f04cc9a0bec51911137bafd80c466e
3
+ size 2541880
individual_tv50_2.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17f245b073b643cc5931152cab657b032fc6922edc98e481ed055f68c911d213
3
+ size 2153829
individual_tv50_3.xlsx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbce7361613276c13acea929da5f16937d40cf80d272e2fec08696b854971a61
3
+ size 2358056
landuse_tv0.geojson ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type": "FeatureCollection",
3
+ "name": "landuse_tv0",
4
+ "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5
+ "features": [
6
+ { "type": "Feature", "properties": { "zoneid": 1, "luf": "AGRICULTURE", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.193941031476015, 32.219917914923769 ], [ 35.180771799335332, 32.211701255350931 ], [ 35.176105538451338, 32.216244012432583 ], [ 35.191405197617598, 32.225507192576401 ], [ 35.193941031476015, 32.219917914923769 ] ] ] ] } },
7
+ { "type": "Feature", "properties": { "zoneid": 2, "luf": "ANTIQUITIES AREA", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.226377643506169, 32.198522747718243 ], [ 35.211836325478771, 32.188786310901435 ], [ 35.203296064670724, 32.190072739861421 ], [ 35.218076198379094, 32.201369033818366 ], [ 35.226377643506169, 32.198522747718243 ] ] ] ] } },
8
+ { "type": "Feature", "properties": { "zoneid": 3, "luf": "CEMETRY", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.211836325478771, 32.188786310901435 ], [ 35.226377643506169, 32.198522747718243 ], [ 35.234679083384776, 32.195676458611956 ], [ 35.227697824675147, 32.189163362956435 ], [ 35.220376594204595, 32.187499883612873 ], [ 35.211836325478771, 32.188786310901435 ] ] ] ] } },
9
+ { "type": "Feature", "properties": { "zoneid": 4, "luf": "COMMERCIAL", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.200129693421275, 32.212136938820151 ], [ 35.184936122200725, 32.200825633008549 ], [ 35.182660054207986, 32.206769855667176 ], [ 35.196476862627151, 32.214328634437152 ], [ 35.200129693421275, 32.212136938820151 ] ] ] ] } },
10
+ { "type": "Feature", "properties": { "zoneid": 5, "luf": "DOWN TOWN", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.184936122200725, 32.200825633008549 ], [ 35.200129693421275, 32.212136938820151 ], [ 35.203782519118647, 32.209945239976946 ], [ 35.187212192879883, 32.194881414133874 ], [ 35.184936122200725, 32.200825633008549 ] ] ] ] } },
11
+ { "type": "Feature", "properties": { "zoneid": 6, "luf": "GREEN BELTS", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.196146193959578, 32.191149731760447 ], [ 35.210929360196189, 32.205657138158415 ], [ 35.218076198379094, 32.201369033818366 ], [ 35.203296064670724, 32.190072739861421 ], [ 35.196146193959578, 32.191149731760447 ] ] ] ] } },
12
+ { "type": "Feature", "properties": { "zoneid": 7, "luf": "GREEN OPEN AREAS", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.210929360196189, 32.205657138158415 ], [ 35.196146193959578, 32.191149731760447 ], [ 35.187212192879883, 32.194881414133874 ], [ 35.203782519118647, 32.209945239976946 ], [ 35.210929360196189, 32.205657138158415 ] ] ] ] } },
13
+ { "type": "Feature", "properties": { "zoneid": 8, "luf": "HOSPITAL CITY", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.234501843282374, 32.185449494574357 ], [ 35.240850417996285, 32.193560514797696 ], [ 35.251281966720853, 32.189983880935699 ], [ 35.244155221627068, 32.188715563222274 ], [ 35.241377000154785, 32.186666926867133 ], [ 35.239916737167846, 32.183827783525544 ], [ 35.234501843282374, 32.185449494574357 ] ] ] ] } },
14
+ { "type": "Feature", "properties": { "zoneid": 9, "luf": "INDUSTRIAL", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.240850417996285, 32.193560514797696 ], [ 35.234501843282374, 32.185449494574357 ], [ 35.227697824675147, 32.189163362956435 ], [ 35.234679083384776, 32.195676458611956 ], [ 35.240850417996285, 32.193560514797696 ] ] ] ] } },
15
+ { "type": "Feature", "properties": { "zoneid": 10, "luf": "PARKS", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.180771799335332, 32.211701255350931 ], [ 35.193941031476015, 32.219917914923769 ], [ 35.196476862627151, 32.214328634437152 ], [ 35.182660054207986, 32.206769855667176 ], [ 35.180771799335332, 32.211701255350931 ] ] ] ] } },
16
+ { "type": "Feature", "properties": { "zoneid": 11, "luf": "PUBLIC FACILITIES", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.186966095778246, 32.235291509309945 ], [ 35.171783787209108, 32.228126460661827 ], [ 35.170834333204482, 32.231852887231469 ], [ 35.170396368597665, 32.239197165017231 ], [ 35.177308733211532, 32.244180557586731 ], [ 35.182526989294786, 32.24507582253284 ], [ 35.186966095778246, 32.235291509309945 ] ] ] ] } },
17
+ { "type": "Feature", "properties": { "zoneid": 12, "luf": "RECREATION AREA", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.171783787209108, 32.228126460661827 ], [ 35.186966095778246, 32.235291509309945 ], [ 35.191405197617598, 32.225507192576401 ], [ 35.176105538451338, 32.216244012432583 ], [ 35.173854139152695, 32.22000075284592 ], [ 35.171783787209108, 32.228126460661827 ] ] ] ] } },
18
+ { "type": "Feature", "properties": { "zoneid": 13, "luf": "RESIDENTIAL (HIGH DENSITY)", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.201557464916959, 32.238729772707302 ], [ 35.186966091659031, 32.235291507984073 ], [ 35.182526989294786, 32.24507582253284 ], [ 35.18774524651451, 32.245971084000473 ], [ 35.19484414793925, 32.245616228106485 ], [ 35.203803754439889, 32.242054998239723 ], [ 35.201557464916959, 32.238729772707302 ] ] ] ] } },
19
+ { "type": "Feature", "properties": { "zoneid": 14, "luf": "RESIDENTIAL (LOW DENSITY)", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.205361348752433, 32.231187843105943 ], [ 35.191405194339154, 32.225507191533325 ], [ 35.186966091659031, 32.235291507984073 ], [ 35.201557464916959, 32.238729772707302 ], [ 35.202448501747028, 32.233857984908184 ], [ 35.205361348752433, 32.231187843105943 ] ] ] ] } },
20
+ { "type": "Feature", "properties": { "zoneid": 15, "luf": "RESIDENTIAL (MODERATE DENSITY)", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.210447348652622, 32.226525616974016 ], [ 35.193941026770801, 32.219917913303902 ], [ 35.191405194339154, 32.225507191533325 ], [ 35.205361348752433, 32.231187843105943 ], [ 35.210447348652622, 32.226525616974016 ] ] ] ] } },
21
+ { "type": "Feature", "properties": { "zoneid": 16, "luf": "SERVICES AREA", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.215771919941176, 32.221644694215627 ], [ 35.196476859200175, 32.214328632605032 ], [ 35.193941026770801, 32.219917913303902 ], [ 35.210447348652622, 32.226525616974016 ], [ 35.215771919941176, 32.221644694215627 ] ] ] ] } },
22
+ { "type": "Feature", "properties": { "zoneid": 17, "luf": "SOLAR CELLS", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.221096488995499, 32.216763770622663 ], [ 35.200129687990568, 32.212136936993375 ], [ 35.196476859200175, 32.214328632605032 ], [ 35.215771919941176, 32.221644694215627 ], [ 35.221096488995499, 32.216763770622663 ] ] ] ] } },
23
+ { "type": "Feature", "properties": { "zoneid": 18, "luf": "TECHNOLOGY AREA", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.233869721889789, 32.21278052529567 ], [ 35.203782514849195, 32.2099452401132 ], [ 35.200129687990568, 32.212136936993375 ], [ 35.221096488995499, 32.216763770622663 ], [ 35.229445498910707, 32.218138332418221 ], [ 35.234474055433338, 32.216543206703705 ], [ 35.233869721889789, 32.21278052529567 ] ] ] ] } },
24
+ { "type": "Feature", "properties": { "zoneid": 19, "luf": "TOURISTIC AREA", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.233265384925176, 32.209017843312097 ], [ 35.210929355259509, 32.205657136833452 ], [ 35.203782514849195, 32.2099452401132 ], [ 35.233869721889789, 32.21278052529567 ], [ 35.233265384925176, 32.209017843312097 ] ] ] ] } },
25
+ { "type": "Feature", "properties": { "zoneid": 20, "luf": "VOCATIONAL TRAINING CENTER", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.239182734977078, 32.205268273581453 ], [ 35.218076194388857, 32.201369032789501 ], [ 35.210929355259509, 32.205657136833452 ], [ 35.233265384925176, 32.209017843312097 ], [ 35.239182734977078, 32.205268273581453 ] ] ] ] } },
26
+ { "type": "Feature", "properties": { "zoneid": 21, "luf": "WASTE COLLECTION STATION", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.249953251853469, 32.206472023022741 ], [ 35.226377639357679, 32.198522745438481 ], [ 35.218076194388857, 32.201369032789501 ], [ 35.239182734977078, 32.205268273581453 ], [ 35.243002207685834, 32.207283147049679 ], [ 35.249953251853469, 32.206472023022741 ] ] ] ] } },
27
+ { "type": "Feature", "properties": { "zoneid": 22, "luf": "WATER PURIFICATION AND RECYCLING PLANT", "population": 0, "densitycap": 0.0, "avgincome": null, "setback": 0.0, "fptarea": 0.0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 35.24771859586059, 32.194272006364315 ], [ 35.251281966720853, 32.189983880935699 ], [ 35.240850413271914, 32.193560513777527 ], [ 35.234679078971794, 32.1956764577684 ], [ 35.226377639357679, 32.198522745438481 ], [ 35.249953251853469, 32.206472023022741 ], [ 35.252127511893036, 32.202606671966805 ], [ 35.249772060690759, 32.200070033587622 ], [ 35.246812650861557, 32.199224487922152 ], [ 35.24771859586059, 32.194272006364315 ] ] ] ] } }
28
+ ]
29
+ }
landuse_tv50_1.geojson ADDED
The diff for this file is too large to render. See raw diff
 
landuse_tv50_1.png ADDED
landuse_tv50_1_selected.png ADDED
landuse_tv50_2.geojson ADDED
The diff for this file is too large to render. See raw diff
 
landuse_tv50_2.png ADDED
landuse_tv50_2_selected.png ADDED
landuse_tv50_3.geojson ADDED
The diff for this file is too large to render. See raw diff
 
landuse_tv50_3.png ADDED
landuse_tv50_3_selected.png ADDED
mypy.ini ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [mypy]
2
+ check_untyped_defs = True
3
+ ignore_missing_imports = True
pyproject.toml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["hatchling >=0.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "demo"
7
+ license = {file = "LICENSE"}
8
+ classifiers = ["License :: OSI Approved :: MIT License"]
9
+ dynamic = ["version", "description"]
10
+ dependencies = [
11
+ "solara",
12
+ "geopandas",
13
+ "ipyleaflet",
14
+ "matplotlib",
15
+ "psycopg2-binary",
16
+ "scipy",
17
+ ]
18
+
19
+ [tool.hatch.version]
20
+ path = "demo/__init__.py"
21
+
22
+ [project.urls]
23
+ Home = "https://www.github.com/widgetti/solara"
24
+
25
+ [tool.black]
26
+ line-length = 160
27
+
28
+ [tool.isort]
29
+ profile = "black"
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ solara
2
+ geopandas
3
+ ipyleaflet
4
+ plotly
5
+ lorem_text
6
+ matplotlib
7
+ psycopg2-binary
8
+ scipy