Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
98e3569
1
Parent(s):
7c424e1
Update app.py
Browse files
app.py
CHANGED
@@ -122,7 +122,14 @@ def test(input_json):
|
|
122 |
# Accessing each dictionary
|
123 |
art_dict = result_dicts["DRT"]
|
124 |
gmt_dict = result_dicts["GMT"]
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
# create a mask based on the matrix size and ids, crop activity nodes to the mask
|
128 |
mask_connected = df_matrix.index.tolist()
|
@@ -221,18 +228,30 @@ def test(input_json):
|
|
221 |
subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
|
222 |
for col in destinationWeights.columns:
|
223 |
subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
|
224 |
-
# for unweighted accessibility (e. g. points of interest)
|
225 |
else:
|
226 |
-
|
227 |
-
for col in subdomainsAccessibility.columns:
|
228 |
-
subdomainsAccessibility[col] = (decay_factors * 1).sum(axis=1)
|
229 |
|
230 |
return subdomainsAccessibility
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
subdomainsAccessibility = computeAccessibility(df_matrix,LivabilitySubdomainsInputs,alpha,threshold)
|
233 |
-
|
234 |
|
235 |
-
|
236 |
|
237 |
|
238 |
|
@@ -283,12 +302,12 @@ def test(input_json):
|
|
283 |
|
284 |
|
285 |
|
286 |
-
livability = accessibilityToLivability(df_matrix,
|
287 |
|
288 |
|
289 |
livability_dictionary = livability.to_dict('index')
|
290 |
LivabilitySubdomainsInputs_dictionary = LivabilitySubdomainsInputs.to_dict('index')
|
291 |
-
subdomainsAccessibility_dictionary =
|
292 |
|
293 |
|
294 |
# Prepare the output
|
|
|
122 |
# Accessing each dictionary
|
123 |
art_dict = result_dicts["DRT"]
|
124 |
gmt_dict = result_dicts["GMT"]
|
125 |
+
|
126 |
+
|
127 |
+
df_art_matrix = pd.DataFrame(art_dict).T
|
128 |
+
df_art_matrix = df_art_matrix.round(0).astype(int)
|
129 |
+
|
130 |
+
df_gmt_matrix = pd.DataFrame(gmt_dict).T
|
131 |
+
df_gmt_matrix = df_art_matrix.round(0).astype(int)
|
132 |
+
|
133 |
|
134 |
# create a mask based on the matrix size and ids, crop activity nodes to the mask
|
135 |
mask_connected = df_matrix.index.tolist()
|
|
|
228 |
subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
|
229 |
for col in destinationWeights.columns:
|
230 |
subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
|
|
|
231 |
else:
|
232 |
+
print("Destination weights parameter is None")
|
|
|
|
|
233 |
|
234 |
return subdomainsAccessibility
|
235 |
|
236 |
+
|
237 |
+
|
238 |
+
|
239 |
+
def computeAccessibility_pointOfInterest (DistanceMatrix, columnName, alpha = 0.0038, threshold = 600):
|
240 |
+
|
241 |
+
decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
|
242 |
+
|
243 |
+
pointOfInterestAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=[columnName])
|
244 |
+
for col in pointOfInterestAccessibility.columns:
|
245 |
+
pointOfInterestAccessibility[col] = (decay_factors * 1).sum(axis=1)
|
246 |
+
|
247 |
+
return pointOfInterestAccessibility
|
248 |
+
|
249 |
+
|
250 |
+
|
251 |
subdomainsAccessibility = computeAccessibility(df_matrix,LivabilitySubdomainsInputs,alpha,threshold)
|
252 |
+
transportAccessibility = computeAccessibility_pointOfInterest(df_art_matrix,'ART',alpha,threshold)
|
253 |
|
254 |
+
AccessibilityInputs = pd.concat([subdomainsAccessibility, transportAccessibility], axis=1)
|
255 |
|
256 |
|
257 |
|
|
|
302 |
|
303 |
|
304 |
|
305 |
+
livability = accessibilityToLivability(df_matrix,AccessibilityInputs,attributeMapperDict,domainsUnique)
|
306 |
|
307 |
|
308 |
livability_dictionary = livability.to_dict('index')
|
309 |
LivabilitySubdomainsInputs_dictionary = LivabilitySubdomainsInputs.to_dict('index')
|
310 |
+
subdomainsAccessibility_dictionary = AccessibilityInputs.to_dict('index')
|
311 |
|
312 |
|
313 |
# Prepare the output
|