diff --git a/nnmm/mods/mortality.py b/nnmm/mods/mortality.py index a86a6b2..7c673c2 100644 --- a/nnmm/mods/mortality.py +++ b/nnmm/mods/mortality.py @@ -37,7 +37,8 @@ def init( model ): # Find index of first value after eula_age split_index = np.searchsorted(model.population.age, eula_age) # Get list of indices we would EULA-ify - dod_filtered = model.population.dod[0:split_index] + # If pop is age order, lowest to highest, we keep the "left chunk" and eula-ify the middle chunk + dod_filtered = model.population.dod[split_index:model.population.count] # Convert these all to "simulation year of death" death_years = dod_filtered // 365 # Now invoke function in Population class to calculate the expected deaths by simulation year @@ -88,7 +89,11 @@ def do_non_disease_deaths(model, tick): year = tick // 365 if model.population.expected_new_deaths_per_year is not None: for nodeid in range(len(model.population.expected_new_deaths_per_year)): - model.nodes.population[nodeid,tick+1] -= (model.population.expected_new_deaths_per_year[nodeid][year]/365) + # converting yearly number to daily basically sucks + deaths = (model.population.expected_new_deaths_per_year[nodeid][year]/365) + model.nodes.population[nodeid,tick+1] -= deaths + # Reporting only + model.nodes.deaths[nodeid,year] += deaths pq = model.nddq while len(pq) > 0 and pq.peekv() <= tick: diff --git a/src/idmlaser/numpynumba/population.py b/src/idmlaser/numpynumba/population.py index 308e5a7..8c1bf36 100644 --- a/src/idmlaser/numpynumba/population.py +++ b/src/idmlaser/numpynumba/population.py @@ -327,7 +327,7 @@ def expected_deaths_over_sim(self, death_years, split_index, sim_years=10): death_years[death_years > sim_years] = sim_years # Cap deaths at years-1 # Initialize the expected_new_deaths array - nodeids_filtered = self.nodeid[0:split_index] + nodeids_filtered = self.nodeid[split_index:self.count] unique_nodeids = np.unique(nodeids_filtered) # slow way of calculating node count nodeid_indices = {nodeid: i for i, nodeid in enumerate(unique_nodeids)} self.expected_new_deaths_per_year = np.zeros((len(unique_nodeids), sim_years+1), dtype=int)