nastasiasnk commited on
Commit
9d78ab1
1 Parent(s): 63a6362

Update imports_utils.py

Browse files
Files changed (1) hide show
  1. imports_utils.py +58 -0
imports_utils.py CHANGED
@@ -319,6 +319,64 @@ def getDataFromNotion(
319
 
320
 
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  def splitDictByStrFragmentInColumnName(original_dict, substrings):
323
  result_dicts = {substring: {} for substring in substrings}
324
  for key, nested_dict in original_dict.items():
 
319
 
320
 
321
 
322
+ def getDataFromGrasshopper(
323
+ inputNameMatrix,
324
+ inputNameLanduse,
325
+ inputNameAttributeMapper,
326
+ inputNameLanduseMapper,
327
+ inputNameAlpha = "alpha",
328
+ inputNameThreshold = "threshold"
329
+ ):
330
+
331
+ if inputNameMatrix is not None:
332
+ matrix = inputs['input'][inputNameMatrix]
333
+ dfMatrix_gh = pd.DataFrame(matrix).T
334
+ dfMatrix_gh = dfMatrix_gh.apply(pd.to_numeric, errors='coerce')
335
+ dfMatrix_gh = dfMatrix_gh.replace([np.inf, -np.inf], 10000).fillna(0)
336
+ dfMatrix_gh = dfMatrix_gh.round(0).astype(int)
337
+ else:
338
+ matrix = None
339
+
340
+ if inputNameLanduse is not None:
341
+ landuses = inputs['input'][inputNameLanduse]
342
+ dfLanduses_gh = pd.DataFrame(landuses).T
343
+ dfLanduses_gh = dfLanduses_gh.apply(pd.to_numeric, errors='coerce')
344
+ dfLanduses_gh = dfLanduses_gh.replace([np.inf, -np.inf], 0).fillna(0) # cleaning function?
345
+ dfLanduses_gh = dfLanduses_gh.round(0).astype(int)
346
+ else:
347
+ landuses = None
348
+
349
+
350
+ if inputNameAttributeMapper is not None:
351
+ attributeMapperDict_gh = inputs['input'][inputNameAttributeMapper]
352
+ else:
353
+ attributeMapperDict_gh = None
354
+
355
+ if inputNameLanduseMapper is not None:
356
+ landuseMapperDict_gh = inputs['input'][inputNameLanduseMapper]
357
+ else:
358
+ landuseMapperDict_gh = None
359
+
360
+
361
+ if inputNameAlpha is not None:
362
+ alpha = inputs['input'][inputNameAlpha]
363
+ if alpha is None:
364
+ alpha = alphaDefault
365
+ else:
366
+ alpha = alphaDefault
367
+
368
+ if inputNameThreshold is not None:
369
+ threshold = inputs['input'][inputNameThreshold]
370
+ if threshold is None:
371
+ threshold = thresholdDefault
372
+ else:
373
+ threshold = thresholdDefault
374
+
375
+
376
+ return dfMatrix_gh, dfLanduses_gh, attributeMapperDict_gh, landuseMapperDict_gh, alpha, threshold
377
+
378
+
379
+
380
  def splitDictByStrFragmentInColumnName(original_dict, substrings):
381
  result_dicts = {substring: {} for substring in substrings}
382
  for key, nested_dict in original_dict.items():