Commit dd85f093 authored by Chris Jewell's avatar Chris Jewell
Browse files

Analysis performed 2020-11-09

parent bc0adbee
#!/bin/bash
#$ -S /bin/bash
#$ -P chicas
#$ -q gpu
#$ -l ngpus=1
# -l ncpus=2
......@@ -10,26 +11,29 @@
#$ -cwd
. /etc/profile
. $HOME/.bashrc
. $HOME/.bash_profile
module add cuda/10.1
conda activate covid19uk
module add cuda/11.0
export XLA_FLAGS="--xla_gpu_cuda_data_dir=$CUDA_HOME"
echo Args: "$@"
echo -n "Preparing config..."
CONFIG=`python prepare_config.py "$@"`
CONFIG=`poetry run python prepare_config.py "$@"`
echo "Done"
echo Using config: $CONFIG
echo Working directory: `pwd`
echo -n "Run inference..."
python inference.py -c "$CONFIG"
poetry run python inference.py -c "$CONFIG"
echo "Done"
echo -n "Create summary..."
python summary.py -c "$CONFIG"
poetry run python summary.py -c "$CONFIG"
echo "Done"
echo -n "Localisation summary..."
poetry run python within_between.py -c "$CONFIG"
echo "Done"
......@@ -2,9 +2,9 @@
# Enqueues COVID-19 pipelines
CASES_FILE="data/Anonymised Combined Line List 20201019.csv"
DATE_LOW="2020-07-24"
DATE_HIGH="2020-10-16"
CASES_FILE="data/Anonymised Combined Line List 20201109.csv"
DATE_LOW="2020-08-14"
DATE_HIGH="2020-11-06"
TEMPLATE_CONFIG=template_config.yaml
......@@ -12,7 +12,7 @@ TEMPLATE_CONFIG=template_config.yaml
# Job submisison
switch-gpu
for PILLAR in both
for PILLAR in both 1
do
for CASE_DATE_TYPE in specimen report
do
......
......@@ -3,10 +3,12 @@
data:
mobility_matrix: data/mergedflows.csv
population_size: data/c2019modagepop.csv
commute_volume: data/201016_OFF_SEN_COVID19_road_traffic_national_table.xlsx
reported_cases: data/Anonymised Combined Line List 20201002.csv
commute_volume: data/201106_OFF_SEN_COVID19_road_traffic_national_table.xlsx
reported_cases: data/Anonymised Combined Line List 20201109.csv
case_date_type: specimen
pillar: both
tier_restriction_csv: data/NPI_dataset_full_extract_03_12_2020 (3).csv
geopackage: data/UK2019mod_pop.gpkg
parameter:
beta1: 0.291 # R0 2.4
......@@ -36,10 +38,10 @@ mcmc:
dmax: 21
nmax: 50
m: 1
occult_nmax: 5
occult_nmax: 15
num_event_time_updates: 35
num_bursts: 200
num_burst_samples: 1000
num_burst_samples: 50
thin: 20
prior:
gamma:
......
......@@ -9,35 +9,34 @@ import geopandas as gp
import tensorflow as tf
from covid.cli_arg_parse import cli_args
from covid.impl.util import compute_state
from gemlib.util import compute_state
import model_spec
GIS_TEMPLATE = "data/UK2019_mod_pop.gpkg"
def make_within_rate_fns(covariates, theta, xi):
C = tf.convert_to_tensor(covariates["C"], dtype=model_spec.DTYPE)
C = tf.linalg.set_diag(
C + tf.transpose(C), tf.zeros(C.shape[0], dtype=model_spec.DTYPE)
)
W = tf.constant(np.squeeze(covariates["W"], dtype=model_spec.DTYPE))
N = tf.constant(np.squeeze(covariates["N"], dtype=model_spec.DTYPE))
W = tf.convert_to_tensor(
tf.squeeze(covariates["W"]), dtype=model_spec.DTYPE
)
N = tf.convert_to_tensor(
tf.squeeze(covariates["N"]), dtype=model_spec.DTYPE
)
beta1 = theta[0]
beta2 = theta[1]
gamma = theta[2]
beta2 = theta[0]
def within_fn(t, state):
beta = np.exp(xi)
rate = beta * state[..., 2] / N
beta = tf.math.exp(xi)
rate = state[..., 2]
return rate
def between_fn(t, state):
w_idx = tf.clip_by_value(tf.cast(t, tf.int64), 0, W.shape[0] - 1)
commute_volume = tf.gather(W, w_idx)
beta = np.exp(xi)
beta = tf.math.exp(xi)
rate = (
beta
* beta2
......@@ -49,16 +48,17 @@ def make_within_rate_fns(covariates, theta, xi):
return within_fn, between_fn
@tf.function
# @tf.function
def calc_pressure_components(covariates, theta, xi, state):
def atomic_fn(theta_, xi_):
def atomic_fn(args):
theta_, xi_, state_ = args
within_fn, between_fn = make_within_rate_fns(covariates, theta_, xi_)
within = within_fn(covariates["W"].shape[0], state)
between = between_fn(covariates["W"].shape[0], state)
within = within_fn(covariates["W"].shape[0], state_)
between = between_fn(covariates["W"].shape[0], state_)
total = within + between
return within / total, between / total
return tf.vectorize_map(atomic_fn, elems=(theta, xi))
return tf.vectorized_map(atomic_fn, elems=(theta, xi, state))
args = cli_args()
......@@ -107,6 +107,8 @@ gpkg = gp.read_file(
gpkg = gpkg[gpkg["lad19cd"].str.startswith("E")]
gpkg = gpkg.sort_values("lad19cd")
print("Within shape:", within.shape)
gpkg["within_mean"] = np.mean(within, axis=0)
gpkg["between_mean"] = np.mean(between, axis=0)
gpkg["p_within_gt_between"] = np.mean(within > between)
......
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