Example #1
0
    def __call__(self, tspan, y0, dt=.05):
        influxes = super().__call__(tspan, y0, dt=dt)
        t = influxes.t

        for key, (src, prob, dist) in self.readouts.items():
            influxes.y[key] = dist.convolve_pdf(t, influxes.y[src], prob)

        sol = SimulationResult(t, {})

        for key, val in influxes.y.items():
            if key not in ["susceptible", "population"]:
                sol.y[key] = np.cumsum(val, axis=0)
            else:
                sol.y[key] = val

        infectious_dist = GammaDistribution(mean=5, std=2)
        sol.y['infectious'] = infectious_dist.convolve_survival(
            t, influxes.y['infected']
        )
        sol.y["critical"] = sol.y["icu"] - sol.y["dead"] - sol.y["recovered"]
        sol.y['ventilators'] = .73 * sol.y['critical']

        i = np.searchsorted(sol.t, sol.t[0] + 5)
        sol.y["hospitalized"] = np.zeros_like(sol.y['critical'])
        sol.y["hospitalized"][:-i] = 2.7241 * sol.y['critical'][i:]
        sol.y["hospitalized"][-i:] = np.nan

        return sol
Example #2
0
    def __call__(self, tspan, y0, dt=.05):
        influxes = super().__call__(tspan, y0, dt=dt)
        t = influxes.t

        for key, (src, prob, dist) in self.readouts.items():
            influxes.y[key] = dist.convolve_pdf(t, influxes.y[src], prob)

        sol = SimulationResult(t, {})

        for key, val in influxes.y.items():
            if key not in ["susceptible", "population"]:
                sol.y[key] = np.cumsum(val, axis=0)
            else:
                sol.y[key] = val

        infectious_dist = GammaDistribution(mean=5, std=2)
        sol.y['infectious'] = infectious_dist.convolve_survival(
            t, influxes.y['infected']
        )

        return sol
Example #3
0
    def __call__(self, tspan, y0, dt=.05):
        influxes = super().__call__(tspan, y0, dt=dt)
        t = influxes.t

        for key, (src, prob, dist) in self.readouts.items():
            influxes.y[key] = dist.convolve_pdf(t, influxes.y[src], prob)

        sol = SimulationResult(t, {})

        for key, val in influxes.y.items():
            if key not in ["susceptible", "population"]:
                sol.y[key] = np.cumsum(val, axis=0)
            else:
                sol.y[key] = val

        infectious_dist = GammaDistribution(mean=5, std=2)
        sol.y['infectious'] = infectious_dist.convolve_survival(
            t, influxes.y['infected']
        )

        sol.y['critical'] = sol.y['icu'] - sol.y['general_ward'] - sol.y['dead']
        sol.y['ventilators'] = .73 * sol.y['critical']
        sol.y['hospitalized'] = (
            sol.y['admitted_to_hospital']
            - sol.y['hospital_recovered'] - sol.y['icu']
        )
        sol.y['hospitalized'] += (sol.y['general_ward']
                                  - sol.y['general_ward_recovered'])

        sol.y['total_discharged'] = (
            sol.y['hospital_recovered'] + sol.y['general_ward_recovered']
        )
        sol.y['recovered'] = (
            sol.y['infected'] - sol.y['infectious'] - sol.y['all_dead']
        )

        return sol