Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
521213c
1
Parent(s):
fbce734
Update imports_utils.py
Browse files- imports_utils.py +50 -0
imports_utils.py
CHANGED
@@ -255,6 +255,56 @@ def landusesToSubdomains(DistanceMatrix, LanduseDf, LanduseToSubdomainDict, Uniq
|
|
255 |
return df_LivabilitySubdomainsArea
|
256 |
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
|
260 |
|
|
|
255 |
return df_LivabilitySubdomainsArea
|
256 |
|
257 |
|
258 |
+
def FindWorkplacesNumber (DistanceMatrix,SubdomainAttributeDict,destinationWeights,UniqueSubdomainsList ):
|
259 |
+
|
260 |
+
df_LivabilitySubdomainsWorkplaces = pd.DataFrame(0, index=DistanceMatrix.index, columns=['jobs'])
|
261 |
+
|
262 |
+
for subdomain in UniqueSubdomainsList:
|
263 |
+
for key, value_list in SubdomainAttributeDict.items():
|
264 |
+
sqm_per_empl = float(SubdomainAttributeDict[subdomain]['sqmPerEmpl'])
|
265 |
+
if key in destinationWeights.columns and key == subdomain:
|
266 |
+
if sqm_per_empl > 0:
|
267 |
+
df_LivabilitySubdomainsWorkplaces['jobs'] += (round(destinationWeights[key] / sqm_per_empl,2)).fillna(0)
|
268 |
+
else:
|
269 |
+
df_LivabilitySubdomainsWorkplaces['jobs'] += 0
|
270 |
+
|
271 |
+
return df_LivabilitySubdomainsWorkplaces
|
272 |
+
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
def computeAccessibility (DistanceMatrix, destinationWeights=None,alpha = 0.0038, threshold = 600):
|
277 |
+
|
278 |
+
decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
|
279 |
+
|
280 |
+
# for weighted accessibility (e. g. areas)
|
281 |
+
if destinationWeights is not None: #not destinationWeights.empty:
|
282 |
+
subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
|
283 |
+
for col in destinationWeights.columns:
|
284 |
+
subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
|
285 |
+
else:
|
286 |
+
print("Destination weights parameter is None")
|
287 |
+
|
288 |
+
return subdomainsAccessibility
|
289 |
+
|
290 |
+
|
291 |
+
|
292 |
+
def computeAccessibility_pointOfInterest (DistanceMatrix, columnName, alpha = 0.0038, threshold = 600):
|
293 |
+
|
294 |
+
decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
|
295 |
+
|
296 |
+
pointOfInterestAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=[columnName])
|
297 |
+
for col in pointOfInterestAccessibility.columns:
|
298 |
+
pointOfInterestAccessibility[col] = (decay_factors * 1).sum(axis=1)
|
299 |
+
|
300 |
+
return pointOfInterestAccessibility
|
301 |
+
|
302 |
+
|
303 |
+
|
304 |
+
def remap(value, B_min, B_max, C_min, C_max):
|
305 |
+
return C_min + (((value - B_min) / (B_max - B_min))* (C_max - C_min))
|
306 |
+
|
307 |
+
|
308 |
|
309 |
|
310 |
|