Move assignments down to fitting cases, or uniform subsequent code
@@ -52,9 +52,6 @@ class SimSirModel:
susceptible = p.population - infected
- intrinsic_growth_rate = get_growth_rate(p.doubling_time)
- self.intrinsic_growth_rate = intrinsic_growth_rate
-
gamma = 1.0 / p.infectious_days
self.gamma = gamma
@@ -66,6 +63,8 @@ class SimSirModel:
# Back-projecting to when the first hospitalized case would have
logger.info('Using doubling_time: %s', p.doubling_time)
+ intrinsic_growth_rate = get_growth_rate(p.doubling_time)
+
self.beta = get_beta(intrinsic_growth_rate, gamma, self.susceptible, 0.0)
self.i_day = 0 # seed to the full length
@@ -112,7 +111,6 @@ class SimSirModel:
self.beta_t = get_beta(intrinsic_growth_rate, self.gamma, self.susceptible, p.relative_contact_rate)
self.run_projection(p)
- self.intrinsic_growth_rate = intrinsic_growth_rate
self.population = p.population
else:
logger.info(
@@ -129,6 +127,8 @@ class SimSirModel:
self.susceptible = self.raw_df['susceptible'].values[self.i_day]
self.recovered = self.raw_df['recovered'].values[self.i_day]
+ self.intrinsic_growth_rate = intrinsic_growth_rate
+
# r_t is r_0 after distancing
self.r_t = self.beta_t / gamma * susceptible
self.r_naught = self.beta / gamma * susceptible
