Exemple #1
0
    def run_models(self, refs, which):
        growths = self.get_growths(refs, which)
        R0s = []
        ms = []
        ms_bad = []
        ms_good = []
        for st_, (g, _) in growths.iterrows():
            params = covid19.params(region=st_)
            R0 = min(formulas.R0_from_K("SEAIR", params, K=np.log(g)), 2.5)
            R0s.append(R0)
            m = models.SEAIR(disease=covid19, region=st_, R0=R0)
            m.set_data(info.get_seair_curves_for_region(st_))
            base = m.copy()

            m.run(120)
            ms.append(m.clinical.overflow_model())

            m = base.copy(R0=2.74)
            m.run(120)
            ms_bad.append(m.clinical.overflow_model())

            m = base.copy(R0=1.0)
            m.run(120)
            ms_good.append(m.clinical.overflow_model())
        return map(tuple, [ms_good, ms, ms_bad])
Exemple #2
0
def run_model(region, duration, R0, notification_rate):
    m = models.SEAIR(region=region, disease=covid19, R0=R0)

    data = info.get_seair_curves_for_region(
        region, notification_rate=notification_rate)
    m.set_data(data)
    m.initial_cases = info.get_cases_for_region(region)["cases"].iloc[0]
    m.run(duration)
    return m.clinical.overflow_model()
Exemple #3
0
def process_region(region, targets, duration):
    data = info.get_seair_curves_for_region(region, use_deaths=True)
    m = models.SEAIR(region=region, disease=covid19)
    m.set_data(data)
    m.initial_cases = info.get_cases_for_region(region)["cases"].iloc[0]

    out = {}
    for level in targets:
        new = m.copy(name=_("Isolation {}").format(pc(level / 100)))
        new.R0 *= 1 - level / 100
        new.run(duration)
        out[level] = new.clinical.overflow_model()

    return MappingProxyType(out)
    def __run_simulations(self, region, duration) -> Tuple[Model, ModelGroup]:
        targets = self.user_inputs["targets"]
        disease = get_disease("covid-19")
        base = models.SEAIR(region=region, disease=disease, name=region.id)
        base.set_cases(self.__get_cases_information(region, disease), save_observed=True)

        column_names = []
        R0s = []
        for target in targets:
            column_names.append(_("Isolation {}").format(pc(target / 100)))
            R0s.append(base.R0 * (1 - target / 100))

        info_group = base.split(name=column_names, R0=R0s)
        info_group.run(duration)
        return base, info_group.clinical.overflow_model()
Exemple #5
0
def simulations(
    region, targets: Sequence[int], duration, disease
) -> Tuple[Model, ModelGroup]:
    disease = get_disease(disease)
    base = models.SEAIR(region=region, disease=disease, name=region.id)
    base.set_cases(cases(region, disease), save_observed=True)

    names = []
    R0s = []
    for target in targets:
        names.append(_("Isolation {}").format(pc(target / 100)))
        R0s.append(base.R0 * (1 - target / 100))

    group = base.split(name=names, R0=R0s)
    group.run(duration)
    return base, group.clinical.overflow_model()
    def __process_region(self, region):
        targets = self.user_inputs["targets"]

        data = info.get_seair_curves_for_region(region, use_deaths=True)
        model = models.SEAIR(region=region, disease=covid19)
        model.set_data(data)
        model.initial_cases = info.get_cases_for_region(region)["cases"].iloc[0]

        out = {}
        for level in targets:
            new_model = model.copy(name=_("Isolation {}").format(pc(level / 100)))
            new_model.R0 *= 1 - level / 100
            new_model.run(DURATION)
            out[level] = new_model.clinical.overflow_model()

        return MappingProxyType(out)
Exemple #7
0
def _infectious_curve(col, gamma, **kwargs):
    cases = fit.infectious_curve(col, gamma, **kwargs)
    cases *= col[-1] / cases.sum()
    return cases


def seir_curves(cases, params, **kwargs):
    for param in ["gamma", "sigma", "prob_symptoms", "rho", "R0"]:
        kwargs.setdefault(param, getattr(params, param))
    return fit.seair_curves(cases, **kwargs)


notification = st.slider("Sub-notificação", 0.01, 0.30, value=0.13)
R0 = st.slider("R0", 0.1, 3.0, value=2.0)

m = models.SEAIR(region=region, disease=covid19, R0=R0)
data = seir_curves(cases["cases"] / notification,
                   params,
                   population=region.population)
m.set_data(data)
m.run(60)

cm = m.clinical.overflow_model()
ax = cases.plot()
ax = (cases["cases"] / notification).plot(ax=ax)
cm.plot(["cases:dates", "deaths:dates"], ax=ax, logy=True)
st.pyplot()

df = pd.concat([cases.diff(), fit_infectious(cases)], axis=1)
df = np.maximum(df, 1).dropna()