Skip to content

Commit d1343d3

Browse files
authored
Merge pull request #169 from The-Strategy-Unit/track-centre-in-output-file
now the model region and centre are updated in the output file automa… Closes #166
2 parents 69838d0 + 5df768e commit d1343d3

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed
-12 Bytes
Binary file not shown.

renal_capacity_model/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def __init__(
3939
config_dict (dict, optional): Dict containing values to be used to run the model. Defaults to national_config_dict.
4040
path_to_time_to_event_curves (str, optional): Path to folder containing time to event curves as CSV files. Defaults to "reference/survival_time_to_event_curves".
4141
"""
42+
self.region = config_dict["region"]
43+
self.centre = config_dict["centre"]
4244
self.trace = config_dict.get("trace", False)
4345
self.initialise_prevalent_patients = config_dict.get(
4446
"initialise_prevalent_patients", True

renal_capacity_model/config_values.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
logger = get_logger(__name__)
1111

1212
national_config_dict = {
13+
"region": "England",
14+
"centre": "All",
1315
"multipliers": {
1416
"ttd": {
1517
"inc": 1,

renal_capacity_model/load_scenario.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ def load_scenario_from_excel(
231231
},
232232
}
233233
# The config values below this point are not different between validation and experimentation
234+
config_from_excel["region"] = input_scenario.iat[0, 4]
235+
config_from_excel["centre"] = input_scenario.iat[0, 6]
234236
config_from_excel["sim_duration"] = input_scenario.iat[0, 1]
235237
config_from_excel["age_dist"] = {
236238
1: input_scenario.iat[6, 1],

renal_capacity_model/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def main(
6262
filepaths.append(copy_excel_files(excel_file, run_start_time))
6363
write_results_to_excel(
6464
filepaths[1],
65+
config.region,
66+
config.centre,
6567
combined_results,
6668
trial.costs_dfs,
6769
sim_years=int(config.sim_duration / 365),

renal_capacity_model/process_outputs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from renal_capacity_model.helpers import get_logger
55
import os
66
import shutil
7+
from openpyxl import load_workbook
78

89
logger = get_logger(__name__)
910

@@ -193,6 +194,8 @@ def copy_excel_files(path_to_file: str, run_start_time: str) -> str:
193194

194195
def write_results_to_excel(
195196
path_to_results_excel_file: str,
197+
model_region: str,
198+
model_centre: str,
196199
combined_df: pd.DataFrame,
197200
costs_dfs: dict[str, pd.DataFrame],
198201
sim_years: int,
@@ -206,6 +209,14 @@ def write_results_to_excel(
206209
model simulation, for each model run
207210
sim_years (int): Number of years of sim duration, to truncate model result dataframes
208211
"""
212+
213+
"""Write region and centre name into the simulation summary results sheet"""
214+
workbook = load_workbook(path_to_results_excel_file)
215+
sheet_name = "Experiment Summary"
216+
sheet = workbook[sheet_name]
217+
sheet["G14"] = model_region
218+
sheet["G15"] = model_centre
219+
workbook.save(path_to_results_excel_file)
209220
with pd.ExcelWriter(
210221
path_to_results_excel_file,
211222
engine="openpyxl",
@@ -220,6 +231,7 @@ def write_results_to_excel(
220231
df.iloc[:, : sim_years + 1].to_excel(
221232
writer, sheet_name=f"{activity}_yearly"
222233
)
234+
223235
logger.info(
224236
f"✅ 💾 Excel format model results written to: \n{path_to_results_excel_file}"
225237
)

0 commit comments

Comments
 (0)