Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Chris Jewell
covid19uk
Commits
87f9d621
Commit
87f9d621
authored
Feb 24, 2021
by
Chris Jewell
Browse files
summary_longformat now creates weekly cases registered to [Sunday, Sunday) intervals
parent
535b1397
Changes
1
Hide whitespace changes
Inline
Side-by-side
covid/tasks/summary_longformat.py
View file @
87f9d621
...
...
@@ -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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment