diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py index 3edfaa37..2ce64f03 100644 --- a/cara/apps/calculator/report_generator.py +++ b/cara/apps/calculator/report_generator.py @@ -2,84 +2,28 @@ from datetime import datetime from pathlib import Path import jinja2 -import numpy as np from cara import models from .model_generator import FormData -def calculate_report_data(model: models.Model): - resolution = 600 - times = list(np.linspace(0, 10, resolution)) - concentrations = [model.concentration(time) for time in times] - highest_const = max(concentrations) - prob = model.infection_probability() - er = model.infected.emission_rate(0.1) - exposed_occupants = model.exposed_occupants - r0 = prob * exposed_occupants / 100 - return { - "times": times, - "concentrations": concentrations, - "highest_const": highest_const, - "prob_inf": prob, - "emission_rate": er, - "exposed_occupants": exposed_occupants, - "R0": r0, - } - - def build_report(model: models.Model, form: FormData): now = datetime.now() - time = now.strftime("%d/%m/%Y %H:%M:%S") - request = {"the": "form", "request": "data"} + time = now.strftime('%d/%m/%Y %H:%M:%S') + request = {'the': 'form', 'request': 'data'} + context = {'model': model, 'request': request, 'creation_date': time, 'model_version': 'Beta v1.0.0', + 'simulation_name': 'SAMPLE', 'room_number': '40/1-02A', 'room_volume': 30, 'ventilation_type': 'natural_ventilation', + 'air_supply': 1, 'air_changes': 2, 'windows_number': 5, 'window_height': 2, 'window_width': 1, + 'opening_distance': 0.05, 'windows_open': '20 minutes every 2 hours', 'hepa_option': 'No', 'total_people': 8, + 'infected_people': 7, 'activity_type': 'Office work ā typical scenario with all persons seated, talking', + 'activity_start': '00:00', 'activity_finish': '01:15', 'exposure_start': '00:00', 'exposure_finish': '01:15', + 'event_type' : 'single_event', 'single_event_date': '5th November', 'recurrent_event_month': 'November', + 'lunch_option': 'No', 'lunch_start': '00:00', 'lunch_finish': '01:15', 'coffee_breaks': 4,'coffee_duration': 15, + 'coffee_times': [['00:00','00:00'], ['00:00','00:00'], ['00:00','00:00'], ['00:00','00:00']], 'mask_wearing': 'No', + 'infection_probability': round(model.infection_probability(), 2), 'reproduction_rate': 2} - context = { - "model": model, - "form": form, - "creation_date": time, - "model_version": "Beta v1.0.0", - "simulation_name": "SAMPLE", - "room_number": "40/1-02A", - "room_volume": 30, - "mechanical_ventilation": "Yes", - "air_supply": 1, - "air_changes": 2, - "windows_number": 5, - "window_height": 2, - "window_width": 1, - "opening_distance": 0.05, - "windows_open": "20 minutes every 2 hours", - "hepa_filtration": "No", - "total_people": 8, - "infected_people": 7, - "activity_type": "Office work ā typical scenario with all persons seated, talking", - "activity_start": "00:00", - "activity_finish": "01:15", - "exposure_start": "00:00", - "exposure_finish": "01:15", - "single_event_date": "5th November", - "lunch_option": "Yes", - "lunch_start": "00:00", - "lunch_finish": "01:15", - "coffee_option": "Yes", - "coffee_number": 4, - "coffee_duration": 15, - "coffee_start1": "00:00", - "coffee_finish1": "00:00", - "coffee_start2": "00:00", - "coffee_finish2": "00:00", - "coffee_start3": "00:00", - "coffee_finish3": "00:00", - "coffee_start4": "00:00", - "coffee_finish4": "00:00", - "mask_wearing": "Yes", - "infection_probability": round(model.infection_probability(), 2), - "reproduction_rate": 2, - } - - context.update(calculate_report_data(model)) - - p = Path(__file__).parent / "templates" - env = jinja2.Environment(loader=jinja2.FileSystemLoader(Path(p))) - template = env.get_template("report.html.j2") - return template.render(**context) + p = Path(__file__).parent / 'templates' + env = jinja2.Environment( + loader=jinja2.FileSystemLoader(Path(p))) + template = env.get_template('report.html.j2') + return template.render(**context) \ No newline at end of file diff --git a/cara/apps/calculator/static/css/report.css b/cara/apps/calculator/static/css/report.css index eb4363a5..1ecf4eaf 100644 --- a/cara/apps/calculator/static/css/report.css +++ b/cara/apps/calculator/static/css/report.css @@ -6,13 +6,6 @@ padding: 20px; } -.image { - display: flex; - align-items: center; - justify-content: center; - font-size: 13pt; -} - h1{ text-align: center; } @@ -41,3 +34,15 @@ p.result_title { font-weight: bold; font-size: 15pt; } + +.image { + display: flex; + justify-content: center; + font-size: 13pt; +} + +.discalimer { + display: flex; + justify-content: center; + font-size: 10pt; +} \ No newline at end of file diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2 index c714ec60..3fdc8dc1 100644 --- a/cara/apps/calculator/templates/report.html.j2 +++ b/cara/apps/calculator/templates/report.html.j2 @@ -9,9 +9,6 @@
-
- VERY IMPORTANT DISCLAIMER
Created {{ creation_date }} using model version {{ model_version }}
Ventilation data:
Mechanical ventilation: {{ mechanical_ventilation }}
Mechanical ventilation: + {% if ventilation_type == "mechanical_ventilation"%} + Yes
Air supply flow rate: {{ air_supply }}
Air changes per hour: {{ air_changes }}
Natural ventilation: No
HEPA Filtration: {{ hepa_filtration }}
HEPA Filtration: {{ hepa_option }}
Event data:
@@ -54,29 +55,41 @@Number of attendees and infected people: {{ total_people }} in attendance, of whom {{ infected_people }} are infected.
Activity type: {{ activity_type }}
Start time: {{ activity_start }} End time: {{ activity_finish }}
Start time: {{ activity_start }}    End time: {{ activity_finish }}
Exposure time (presence of infected person):
Start time: {{ exposure_start }} End time: {{ exposure_finish }}
Start time: {{ exposure_start }}    End time: {{ exposure_finish }}
Single event on {{ single_event_date }}
Recurrent event for the month of {{ recurrent_event_month }}
Break data:
Lunchbreak: {{ lunch_option }} Start: {{ lunch_start }} End: {{ lunch_end }}
Coffee breaks: {{ coffee_option }} Number: {{ coffee_number }} Duration: {{ coffee_duration }}
Lunch break: {{ lunch_option }}
Coffee break 1: Start: {{ coffee_start1 }} End: {{ coffee_finish1 }}
Coffee break 2: Start: {{ coffee_start2 }} End: {{ coffee_finish2 }}
Coffee break 3: Start: {{ coffee_start3 }} End: {{ coffee_finish3 }}
Coffee break 4: Start: {{ coffee_start4 }} End: {{ coffee_finish4 }}
Coffee breaks: {{ coffee_breaks }} + {% if coffee_breaks > 0 %} + each of {{ coffee_duration }} minutes duration +
Coffee break {{ loop.index }}: Start: {{ coffee[0] }}    End: {{ coffee[1] }}
Mask wearing:
Masks worn at workstations? {{ mask_wearing }}
Results:
-In this scenario, the estimated probability of one exposed occupant getting infected (Pi) is {{ infection_probability }} % and the estimated basic reproduction rate (R0) rate is {{ reproduction_rate }}. If you have selected a recurrent event, this is the probability per day, and is cumulative over the number of days.
-
Exposure graph: - +
In this scenario, the estimated probability of one exposed occupant getting infected P(i) is {{ infection_probability }} % and the estimated basic reproduction rate (R0) rate is {{ reproduction_rate }}. This probability estimate is per simulated time period, i.e. if you have simulated a working day, which will be repeated n times per week, the cumulative probability of infection per person is n x P(i).
+
Exposure graph: