[docs]classRecovered:def__init__(self,model)->None:self.model=modelasserthasattr(model,"agents"),"Recovered: model needs to have a 'agents' attribute."model.agents.add_vector_property("R",length=model.params.nticks+1,dtype=np.int32,default=0)asserthasattr(model,"params"),"Recovered: model needs to have a 'params' attribute."assert"R_j_initial"inmodel.params,("Recovered: model params needs to have a 'R_j_initial' (initial recovered population) parameter.")model.agents.R[0]=model.params.R_j_initialreturn
[docs]defcheck(self):asserthasattr(self.model.agents,"S"),"Recovered: model agents needs to have a 'S' (susceptible) attribute."assert"d_jt"inself.model.params,"Recovered: model params needs to have a 'd_jt' (mortality rate) parameter."assert"epsilon"inself.model.params,"Recovered: model params needs to have a 'epsilon' (waning immunity rate) parameter."ifnothasattr(self.model.patches,"non_disease_deaths"):self.model.patches.add_vector_property("non_disease_deaths",length=self.model.params.nticks+1,dtype=np.int32,default=0)return
[docs]defplot(self,fig:Figure=None):# pragma: no cover_fig=plt.figure(figsize=(12,9),dpi=128,num="Recovered")iffigisNoneelsefigforipatchinnp.argsort(self.model.params.S_j_initial)[-10:]:plt.plot(self.model.agents.R[:,ipatch],label=f"{self.model.params.location_name[ipatch]}")plt.xlabel("Tick")plt.ylabel("Recovered")plt.legend()yield"Recovered"return