Updated report to use form values
This commit is contained in:
parent
0f415abad9
commit
881669ab09
3 changed files with 69 additions and 24 deletions
|
|
@ -2,28 +2,77 @@ 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'}
|
||||
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}
|
||||
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': form.simulation_name,
|
||||
'room_number': form.room_number,
|
||||
'room_volume': form.room_volume,
|
||||
'ventilation_type': form.ventilation_type,
|
||||
'air_supply': form.air_supply,
|
||||
'air_changes': form.air_changes,
|
||||
'windows_number': form.windows_number,
|
||||
'window_height': form.window_height,
|
||||
'window_width': form.window_width,
|
||||
'opening_distance': form.opening_distance,
|
||||
'windows_open': form.windows_open,
|
||||
'hepa_option': 'No',
|
||||
'total_people': form.total_people,
|
||||
'infected_people': form.infected_people,
|
||||
'activity_type': form.activity_type,
|
||||
'activity_start': form.activity_start,
|
||||
'activity_finish': form.activity_finish,
|
||||
'exposure_start': '00:00',
|
||||
'exposure_finish': '01:15',
|
||||
'event_type': form.event_type,
|
||||
'single_event_date': form.single_event_date,
|
||||
'recurrent_event_month': form.recurrent_event_month,
|
||||
'lunch_option': form.lunch_option,
|
||||
'lunch_start': form.lunch_start,
|
||||
'lunch_finish': form.lunch_finish,
|
||||
'coffee_breaks': form.coffee_breaks,
|
||||
'coffee_duration': form.coffee_duration,
|
||||
'coffee_times': [['00:00','00:00'], ['00:00','00:00'], ['00:00','00:00'], ['00:00','00:00']],
|
||||
'mask_wearing': form.mask_wearing,
|
||||
'infection_probability': round(model.infection_probability(), 2),
|
||||
'reproduction_rate': 2
|
||||
}
|
||||
|
||||
p = Path(__file__).parent / 'templates'
|
||||
env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(Path(p)))
|
||||
template = env.get_template('report.html.j2')
|
||||
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)
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
padding: 20px;
|
||||
}
|
||||
|
||||
h1{
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
|
@ -36,13 +36,10 @@ p.result_title {
|
|||
}
|
||||
|
||||
.image {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
font-size: 13pt;
|
||||
}
|
||||
|
||||
.discalimer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 10pt;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
|
@ -102,8 +102,7 @@
|
|||
|
||||
<br><br><br><br><br><br><br>
|
||||
<div style="border: 2px solid black; padding: 15px;">
|
||||
<p class="image"> <img src="/calculator/static/images/disclaimer.jpg" width="40" height="40">
|
||||
<br><br><b>Disclaimer:</b><br><br></p>
|
||||
<p class="image"> <img <img align="middle" src="/calculator/static/images/disclaimer.jpg" width="40" height="40"><b>Disclaimer:</b><br><br></p>
|
||||
<p class="discalimer">The risk assessment tool simulates the long range airborne spread SARS-CoV-2 virus in a finite volume, assuming a homogenous mixture, and estimates the risk of COVID-19 infection thereto. The results DO NOT include short-range airborne exposure (where the physical distance plays a factor) nor the other know modes of transmission of SARS-CoV-2. Hence, this model implies that proper physical distancing, good hand hygiene and other barrier measures are ensured.<br><br>
|
||||
It is based on current scientific data and can be used to measures the effectiveness of different mitigation measures.<br><br>
|
||||
Note that this model is based on a deterministic approach, i.e., at least one person is infected and shedding viruses into the volume. Nonetheless, it is also important to understand that the absolute risk of infection is uncertain as it will depend on the probability that someone infected attends the event. The model is mostly useful to compare the impact and effectiveness of mitigation measures such as ventilation, filtration, exposure time, activity and the size of the room on long-range airborne transmission of COVID-19 in indoor settings.<br><br>
|
||||
|
|
|
|||
Loading…
Reference in a new issue