Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Feature generation #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,11 @@ def __init__(self, optList, infra_bool):

def run(self):

# This part will is for Calculation of the top release cells and erasing the lower ones
#if __name__ != '__main__': # needed that it runs on windows, but it doesnt!!! if __name__ == main: would it be.
if self.infra_bool:
print("{} Processes started.".format(mp.cpu_count() - 1))
pool = mp.Pool(mp.cpu_count() - 1)
pool.map(fc.calculation, self.optList)
pool.close()
pool.join()
else:
print("{} Processes started.".format(mp.cpu_count() - 1))
pool = mp.Pool(mp.cpu_count() - 1)
pool.map(fc.calculation_effect, self.optList)
pool.close()
pool.join()
print("{} Processes started.".format(mp.cpu_count() - 1))
pool = mp.Pool(mp.cpu_count() - 1)
pool.map(fc.calculation, self.optList)
pool.close()
pool.join()

print("Processes finished")
self.finished.emit()
15 changes: 1 addition & 14 deletions flow_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def calc_distribution(self):
self.calc_persistence()
self.persistence *= self.no_flow
self.calc_tanbeta()
#print(self.persistence)

if not self.is_start:
self.calc_fp_travelangle()
Expand All @@ -194,19 +193,7 @@ def calc_distribution(self):
threshold = self.flux_threshold
if np.sum(self.r_t) > 0:
self.dist = (self.persistence * self.r_t) / np.sum(self.persistence * self.r_t) * self.flux
# This lines handle if a distribution to a neighbour cell is lower then the threshold, so we don´t lose
# flux.
# The flux of this cells will then spread equally to all neighbour cells
count = ((0 < self.dist) & (self.dist < threshold)).sum()
mass_to_distribute = np.sum(self.dist[self.dist < threshold])
'''Checking if flux is distributed to a field that isn't taking in account, when then distribute it equally to
the other fields'''
if mass_to_distribute > 0 and count > 0:
self.dist[self.dist > threshold] += mass_to_distribute / count
self.dist[self.dist < threshold] = 0
if np.sum(self.dist) < self.flux and count > 0:
self.dist[self.dist > threshold] += (self.flux - np.sum(self.dist))/count

row_local, col_local = np.where(self.dist > threshold)

return self.rowindex - 1 + row_local, self.colindex - 1 + col_local, self.dist[row_local, col_local], self.z_delta_neighbour[row_local, col_local]
return list(self.rowindex - 1 + row_local), list(self.colindex - 1 + col_local), list(self.dist[row_local, col_local]), list(self.z_delta_neighbour[row_local, col_local])
Loading