nastasiasnk commited on
Commit
980735d
1 Parent(s): 1729426

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -56
app.py CHANGED
@@ -221,68 +221,16 @@ def test(input_json):
221
  from imports_utils import computeAccessibility
222
  from imports_utils import computeAccessibility_pointOfInterest
223
  from imports_utils import remap
224
-
225
 
226
  LivabilitySubdomainsWeights = landusesToSubdomains(df_dm,df_landuses_filtered,landuseMapperDict,subdomainsUnique)
227
 
228
 
229
-
230
- """
231
- def FindWorkplacesNumber (DistanceMatrix,SubdomainAttributeDict,destinationWeights,UniqueSubdomainsList ):
232
-
233
- df_LivabilitySubdomainsWorkplaces = pd.DataFrame(0, index=DistanceMatrix.index, columns=['jobs'])
234
-
235
- for subdomain in UniqueSubdomainsList:
236
- for key, value_list in SubdomainAttributeDict.items():
237
- sqm_per_empl = float(SubdomainAttributeDict[subdomain]['sqmPerEmpl'])
238
- if key in destinationWeights.columns and key == subdomain:
239
- if sqm_per_empl > 0:
240
- df_LivabilitySubdomainsWorkplaces['jobs'] += (round(destinationWeights[key] / sqm_per_empl,2)).fillna(0)
241
- else:
242
- df_LivabilitySubdomainsWorkplaces['jobs'] += 0
243
-
244
- return df_LivabilitySubdomainsWorkplaces
245
-
246
- """
247
  WorkplacesNumber = FindWorkplacesNumber(df_dm,attributeMapperDict,LivabilitySubdomainsWeights,subdomainsUnique)
248
 
249
  # prepare an input weights dataframe for the parameter LivabilitySubdomainsInputs
250
  LivabilitySubdomainsInputs =pd.concat([LivabilitySubdomainsWeights, WorkplacesNumber], axis=1)
251
-
252
-
253
- """
254
- def computeAccessibility (DistanceMatrix, destinationWeights=None,alpha = 0.0038, threshold = 600):
255
-
256
- decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
257
-
258
- # for weighted accessibility (e. g. areas)
259
- if destinationWeights is not None: #not destinationWeights.empty:
260
- subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
261
- for col in destinationWeights.columns:
262
- subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
263
- else:
264
- print("Destination weights parameter is None")
265
-
266
- return subdomainsAccessibility
267
-
268
-
269
-
270
-
271
- def computeAccessibility_pointOfInterest (DistanceMatrix, columnName, alpha = 0.0038, threshold = 600):
272
-
273
- decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
274
-
275
- pointOfInterestAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=[columnName])
276
- for col in pointOfInterestAccessibility.columns:
277
- pointOfInterestAccessibility[col] = (decay_factors * 1).sum(axis=1)
278
-
279
- return pointOfInterestAccessibility
280
-
281
-
282
- def remap(value, B_min, B_max, C_min, C_max):
283
- return C_min + (((value - B_min) / (B_max - B_min))* (C_max - C_min))
284
-
285
- """
286
 
287
  subdomainsAccessibility = computeAccessibility(df_dm,LivabilitySubdomainsInputs,alpha,threshold)
288
  artAccessibility = computeAccessibility_pointOfInterest(df_art_matrix,'ART',alpha,threshold)
@@ -294,7 +242,7 @@ def test(input_json):
294
  print("Error: Column 'jobs' does not exist in the subdomainsAccessibility.")
295
 
296
 
297
-
298
  def accessibilityToLivability (DistanceMatrix,accessibilityInputs, SubdomainAttributeDict,UniqueDomainsList):
299
 
300
  livability = pd.DataFrame(index=DistanceMatrix.index, columns=accessibilityInputs.columns)
@@ -331,7 +279,7 @@ def test(input_json):
331
  return livability
332
 
333
 
334
-
335
 
336
  livability = accessibilityToLivability(df_dm,AccessibilityInputs,attributeMapperDict,domainsUnique)
337
 
 
221
  from imports_utils import computeAccessibility
222
  from imports_utils import computeAccessibility_pointOfInterest
223
  from imports_utils import remap
224
+ from imports_utils import accessibilityToLivability
225
 
226
  LivabilitySubdomainsWeights = landusesToSubdomains(df_dm,df_landuses_filtered,landuseMapperDict,subdomainsUnique)
227
 
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  WorkplacesNumber = FindWorkplacesNumber(df_dm,attributeMapperDict,LivabilitySubdomainsWeights,subdomainsUnique)
230
 
231
  # prepare an input weights dataframe for the parameter LivabilitySubdomainsInputs
232
  LivabilitySubdomainsInputs =pd.concat([LivabilitySubdomainsWeights, WorkplacesNumber], axis=1)
233
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  subdomainsAccessibility = computeAccessibility(df_dm,LivabilitySubdomainsInputs,alpha,threshold)
236
  artAccessibility = computeAccessibility_pointOfInterest(df_art_matrix,'ART',alpha,threshold)
 
242
  print("Error: Column 'jobs' does not exist in the subdomainsAccessibility.")
243
 
244
 
245
+ """
246
  def accessibilityToLivability (DistanceMatrix,accessibilityInputs, SubdomainAttributeDict,UniqueDomainsList):
247
 
248
  livability = pd.DataFrame(index=DistanceMatrix.index, columns=accessibilityInputs.columns)
 
279
  return livability
280
 
281
 
282
+ """
283
 
284
  livability = accessibilityToLivability(df_dm,AccessibilityInputs,attributeMapperDict,domainsUnique)
285