From bc43cd97464992e799f96e3a9cf7e60a1a4d422f Mon Sep 17 00:00:00 2001 From: Chris Jewell Date: Thu, 4 Mar 2021 11:55:40 +0000 Subject: [PATCH] Added cumulative incidence to `summary_longformat.xlsx` CHANGES: 1. Added code in `summary_longformat.py` to calculate cumulative incidence; 2. Switched from `openpyxl` to `xlsxwriter` for lower memory usage when writing to summary_longformat.xlsx. --- covid/tasks/summary_longformat.py | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/covid/tasks/summary_longformat.py b/covid/tasks/summary_longformat.py index 94f8612..416e5de 100644 --- a/covid/tasks/summary_longformat.py +++ b/covid/tasks/summary_longformat.py @@ -116,6 +116,13 @@ def summary_longformat(input_files, output_file): medium_df["value_name"] = "absolute_incidence" df = pd.concat([df, medium_df], axis="index") + # Cumulative cases + medium_df = xarray2summarydf( + medium_term["events"][..., 2].cumsum(dim="time").reset_coords(drop=True) + ) + medium_df["value_name"] = "cumulative_absolute_incidence" + df = pd.concat([df, medium_df], axis="index") + # Medium term incidence per 100k medium_df = xarray2summarydf( ( diff --git a/pyproject.toml b/pyproject.toml index 998fbc9..67b91f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,6 @@ descartes = "^1.1.0" matplotlib = "^3.3.2" xlrd = "^1.2.0" tqdm = "^4.50.2" -openpyxl = "^3.0.5" h5py = "^2.10.0" gemlib = {git = "http://fhm-chicas-code.lancs.ac.uk/GEM/gemlib.git"} xarray = "^0.16.1" @@ -26,6 +25,7 @@ seaborn = "^0.11.0" ruffus = "^2.8.4" tensorflow = "^2.4.0" jedi = "^0.17.2" +XlsxWriter = "^1.3.7" [tool.poetry.dev-dependencies] ipython = "^7.18.1" -- GitLab