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
c7765fac
Commit
c7765fac
authored
Feb 08, 2021
by
Chris Jewell
Browse files
Added mean summary longformat
parent
3139214d
Changes
2
Hide whitespace changes
Inline
Side-by-side
covid/tasks/summarize.py
View file @
c7765fac
...
...
@@ -10,6 +10,7 @@ from covid.model_spec import STOICHIOMETRY
SUMMARY_DAYS
=
np
.
array
([
1
,
7
,
14
,
28
,
35
,
42
,
49
,
56
],
np
.
int32
)
def
rt
(
input_file
,
output_file
):
"""Reads an array of next generation matrices and
outputs mean (ci) local Rt values.
...
...
@@ -24,11 +25,11 @@ def rt(input_file, output_file):
rt
=
np
.
sum
(
ngm
,
axis
=-
2
)
rt_summary
=
mean_and_ci
(
rt
,
name
=
"Rt"
)
exceed
=
np
.
mean
(
rt
>
1.0
,
axis
=
0
)
rt_summary
=
pd
.
DataFrame
(
rt_summary
,
index
=
pd
.
Index
(
ngm
.
coords
[
"dest"
],
name
=
"location"
)
)
rt_summary
[
'
Rt_exceed
'
]
=
exceed
rt_summary
[
"
Rt_exceed
"
]
=
exceed
rt_summary
.
to_csv
(
output_file
)
...
...
@@ -54,7 +55,8 @@ def infec_incidence(input_file, output_file):
idx
=
prediction
.
coords
[
"location"
]
abs_incidence
=
pd
.
DataFrame
(
pred_events
(
prediction
[...,
offset
:
5
,
2
],
name
=
"cases"
),
index
=
idx
pred_events
(
prediction
[...,
offset
:
(
offset
+
1
),
2
],
name
=
"cases"
),
index
=
idx
,
)
for
t
in
timepoints
[
1
:]:
tmp
=
pd
.
DataFrame
(
...
...
@@ -66,6 +68,10 @@ def infec_incidence(input_file, output_file):
abs_incidence
.
to_csv
(
output_file
)
def
weekly_pred_cases_per_100k
(
input_files
,
output_file
):
pass
def
prevalence
(
input_files
,
output_file
):
"""Reconstruct predicted prevalence from
original data and projection.
...
...
covid/tasks/summary_longformat.py
View file @
c7765fac
...
...
@@ -102,5 +102,6 @@ def summary_longformat(input_files, output_file):
geography
=
df
[
"location"
],
value_date
=
df
[
"time"
],
value_type
=
df
[
"value_name"
],
value
=
df
[
"value"
],
quantiles
=
{
q
:
df
[
q
]
for
q
in
quantiles
},
).
to_excel
(
output_file
,
index
=
False
)
Write
Preview
Supports
Markdown
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