Commit 87f9d621 authored by Chris Jewell's avatar Chris Jewell
Browse files

summary_longformat now creates weekly cases registered to [Sunday, Sunday) intervals

parent 535b1397
......@@ -42,13 +42,17 @@ def prevalence(events, popsize):
def weekly_pred_cases_per_100k(prediction, popsize):
"""Returns weekly number of cases per 100k of population"""
prediction = prediction[..., 2] # Case removals
prediction = prediction[..., 2] # Case removals
prediction = prediction.reset_coords(drop=True)
# TODO: Find better way to sum up into weeks other than
# a list comprehension.
weeks = range(0, prediction.coords["time"].shape[0], 7)[:-1]
dates = pd.DatetimeIndex(prediction.coords["time"].data)
first_sunday_index = np.where(dates.weekday == 6)[0][0]
weeks = range(first_sunday_index, prediction.coords["time"].shape[0], 7)[
:-1
]
week_incidence = [
prediction[..., week : (week + 7)].sum(dim="time") for week in weeks
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment