Skip to content
GitLab
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
4991f523
Commit
4991f523
authored
Sep 23, 2020
by
Chris Jewell
Browse files
Added selection for report vs specimen data in linelisting ingester.
parent
9face1b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
covid/pydata.py
View file @
4991f523
...
...
@@ -90,7 +90,7 @@ def _read_csv(filename, date_format="%m/%d/%Y"):
return
data
def
phe_case_data
(
linelisting_file
,
date_range
=
None
,
pillar
=
None
):
def
phe_case_data
(
linelisting_file
,
date_range
=
None
,
date_type
=
'specimen'
,
pillar
=
None
):
read_file
=
dict
(
csv
=
_read_csv
,
xlsx
=
pd
.
read_excel
)
match_extension
=
re
.
match
(
r
"(.*)\.(.*)$"
,
linelisting_file
)
...
...
@@ -106,7 +106,11 @@ def phe_case_data(linelisting_file, date_range=None, pillar=None):
if
pillar
is
not
None
:
ll
=
ll
.
loc
[
ll
[
"pillar"
]
==
pillar
]
date
=
ll
[
"specimen_date"
]
date_type_map
=
{
'specimen'
:
'specimen_type'
,
'report'
:
'lab_report_date'
}
date
=
ll
[
date_type_map
[
date_type
]]
ltla_region
=
ll
[
"LTLA_code"
]
# Merged regions
...
...
mcmc.py
View file @
4991f523
...
...
@@ -65,7 +65,7 @@ covar_data = load_data(config["data"], settings, DTYPE)
# We load in cases and impute missing infections first, since this sets the
# time epoch which we are analysing.
cases
=
phe_case_data
(
config
[
"data"
][
"reported_cases"
],
settings
[
"inference_period"
])
cases
=
phe_case_data
(
config
[
"data"
][
"reported_cases"
],
date_range
=
settings
[
"inference_period"
]
,
date_type
=
'report'
)
ei_events
,
lag_ei
=
impute_previous_cases
(
cases
,
0.44
)
se_events
,
lag_se
=
impute_previous_cases
(
ei_events
,
2.0
)
ir_events
=
np
.
pad
(
cases
,
((
0
,
0
),
(
lag_ei
+
lag_se
-
2
,
0
)))
...
...
@@ -145,7 +145,7 @@ def logp(theta, xi, events):
concentration
=
tf
.
constant
(
1.0
,
dtype
=
DTYPE
),
rate
=
tf
.
constant
(
1.0
,
dtype
=
DTYPE
)
)
sigma
=
tf
.
constant
(
0.1
,
dtype
=
DTYPE
)
sigma
=
tf
.
constant
(
0.
0
1
,
dtype
=
DTYPE
)
phi
=
tf
.
constant
(
12.0
,
dtype
=
DTYPE
)
kernel
=
tfp
.
math
.
psd_kernels
.
MaternThreeHalves
(
sigma
,
phi
)
idx_pts
=
tf
.
cast
(
tf
.
range
(
events
.
shape
[
1
]
//
xi_freq
)
*
xi_freq
,
dtype
=
DTYPE
)
...
...
@@ -376,7 +376,7 @@ theta_scale = tf.constant(
theta_scale
=
theta_scale
*
0.2
/
theta_scale
.
shape
[
0
]
xi_scale
=
tf
.
eye
(
current_state
[
1
].
shape
[
0
],
dtype
=
DTYPE
)
xi_scale
=
xi_scale
*
0.001
/
xi_scale
.
shape
[
0
]
xi_scale
=
xi_scale
*
0.00
0
1
/
xi_scale
.
shape
[
0
]
# We loop over successive calls to sample because we have to dump results
# to disc, or else end OOM (even on a 32GB system).
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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