Merge branch 'Calculator-report-page' into 'master'
Added foundations of calculator report page See merge request cara/cara!18
This commit is contained in:
commit
2f61d2a264
4 changed files with 167 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
from tornado.web import Application, RequestHandler, StaticFileHandler
|
||||
|
||||
import cara.models
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def build_model(request: dict) -> cara.models.Model:
|
||||
return None
|
||||
|
|
@ -34,6 +36,34 @@ class ConcentrationModel(RequestHandler):
|
|||
self.write(response_json)
|
||||
|
||||
|
||||
class StaticModel(RequestHandler):
|
||||
def get(self):
|
||||
|
||||
import cara.apps.expert
|
||||
model = cara.apps.expert.baseline_model
|
||||
|
||||
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, '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}
|
||||
|
||||
p = Path(__file__).parent / 'templates'
|
||||
env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(Path(p)))
|
||||
template = env.get_template('report.html.j2')
|
||||
self.write(template.render(**context))
|
||||
|
||||
|
||||
def make_app(debug=False, prefix='/calculator'):
|
||||
static_dir = Path(__file__).absolute().parent / 'static'
|
||||
urls = [
|
||||
|
|
@ -43,6 +73,9 @@ def make_app(debug=False, prefix='/calculator'):
|
|||
(
|
||||
prefix + r'/api/calculator', ConcentrationModel
|
||||
),
|
||||
(
|
||||
prefix + r'/baseline-model/result', StaticModel
|
||||
),
|
||||
(
|
||||
prefix + r'/static/(.*)',
|
||||
StaticFileHandler,
|
||||
|
|
|
|||
43
cara/apps/calculator/static/css/report.css
Normal file
43
cara/apps/calculator/static/css/report.css
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#body {
|
||||
top: 10px;
|
||||
left: 20px;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.image {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13pt;
|
||||
}
|
||||
|
||||
h1{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
font-size: 13pt;
|
||||
padding-bottom: 15pt;
|
||||
}
|
||||
|
||||
p.data_title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p.data_text {
|
||||
padding-left: 30px;
|
||||
padding-left:1em;
|
||||
}
|
||||
|
||||
p.data_subtext {
|
||||
padding-left: 60px;
|
||||
margin-left:-3em;
|
||||
}
|
||||
|
||||
p.result_title {
|
||||
font-weight: bold;
|
||||
font-size: 15pt;
|
||||
}
|
||||
BIN
cara/apps/calculator/static/images/disclaimer.jpg
Normal file
BIN
cara/apps/calculator/static/images/disclaimer.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
91
cara/apps/calculator/templates/report.html.j2
Normal file
91
cara/apps/calculator/templates/report.html.j2
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/calculator/static/css/report.css">
|
||||
</head>
|
||||
|
||||
<body id="body">
|
||||
|
||||
<p class=image> <img src="/calculator/static/images/disclaimer.jpg" width="40" height="40">
|
||||
VERY IMPORTANT DISCLAIMER</p>
|
||||
|
||||
<h1>Output from CARA - COVID Airborne Risk Assessment tool</h1>
|
||||
|
||||
<p class=subtitle> Created {{ creation_date }} using model version {{ model_version }}</p><br>
|
||||
|
||||
<p>Simulation Name: {{ simulation_name }}</p>
|
||||
<p>Room Number: {{ room_number }}</p>
|
||||
|
||||
<p class="data_title">Input data:</p>
|
||||
<ul>
|
||||
<li><p class="data_text">Room Volume: {{ room_volume }} m³</p></li>
|
||||
</ul>
|
||||
|
||||
<p class="data_title">Ventilation data:</p>
|
||||
<ul>
|
||||
<li><p class="data_text">Mechanical ventilation: {{ mechanical_ventilation }}</p></li>
|
||||
<!--If mechanical ventialtion is yes {-->
|
||||
<ul>
|
||||
<li><p class="data_subtext">Air supply flow rate: {{ air_supply }}</p></li>
|
||||
<li><p class="data_subtext">Air changes per hour: {{ air_changes }}</p></li>
|
||||
</ul>
|
||||
<!--}-->
|
||||
<li><p class="data_text">Natural ventilation: No</li>
|
||||
<!--If natural ventialtion is yes {
|
||||
<ul>
|
||||
<li><p class="data_subtext">Number of windows: {{ windows_number }}</p></li>
|
||||
<li><p class="data_subtext">Height of window: {{ window_height }}</p></li>
|
||||
<li><p class="data_subtext">Width of window: {{ window_width }}</p></li>
|
||||
<li><p class="data_subtext">Opening distance: {{ opening_distance }}</p></li>
|
||||
<li><p class="data_subtext">Windows open: {{ windows_open }}</p></li>
|
||||
</ul>
|
||||
}-->
|
||||
<li><p class="data_text">HEPA Filtration: {{ hepa_filtration }}</li>
|
||||
<!--If HEPA filtration is yes {
|
||||
X type of filter with y flow rate (default model assumption) ?
|
||||
}-->
|
||||
</ul>
|
||||
|
||||
<p class="data_title">Event data:</p>
|
||||
<ul>
|
||||
<li><p class="data_text">Number of attendees and infected people: {{ total_people }} in attendance, of whom {{ infected_people }} are infected.</p></li>
|
||||
<li><p class="data_text">Activity type: {{ activity_type }}</p></li>
|
||||
<ul>
|
||||
<li><p class="data_subtext">Start time: {{ activity_start }} End time: {{ activity_finish }}</p></li>
|
||||
</ul>
|
||||
<li><p class="data_text">Exposure time (presence of infected person):</p></li>
|
||||
<ul>
|
||||
<li><p class="data_subtext">Start time: {{ exposure_start }} End time: {{ exposure_finish }}</p></li>
|
||||
</ul>
|
||||
<li><p class="data_text">Single event on {{ single_event_date }}</p></li>
|
||||
</ul>
|
||||
|
||||
<p class="data_title">Break data:</p>
|
||||
<ul>
|
||||
<li><p class="data_text">Lunchbreak: {{ lunch_option }} Start: {{ lunch_start }} End: {{ lunch_end }}</p></li>
|
||||
<li><p class="data_text">Coffee breaks: {{ coffee_option }} Number: {{ coffee_number }} Duration: {{ coffee_duration }}</p></li>
|
||||
<ul>
|
||||
<li><p class="data_subtext">Coffee break 1: Start: {{ coffee_start1 }} End: {{ coffee_finish1 }}</p></li>
|
||||
<li><p class="data_subtext">Coffee break 2: Start: {{ coffee_start2 }} End: {{ coffee_finish2 }}</p></li>
|
||||
<li><p class="data_subtext">Coffee break 3: Start: {{ coffee_start3 }} End: {{ coffee_finish3 }}</p></li>
|
||||
<li><p class="data_subtext">Coffee break 4: Start: {{ coffee_start4 }} End: {{ coffee_finish4 }}</p></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<!--or Recurrent for months of X, Y and Z…-->
|
||||
|
||||
<p class="data_title">Mask wearing:</p>
|
||||
<ul>
|
||||
<li><p class="data_text">Masks worn at workstations? {{ mask_wearing }}</p></li>
|
||||
<li><p class="data_text">Mask type: Type 1 (default, for now)</p></li>
|
||||
</ul>
|
||||
|
||||
<p class="result_title">Results:</p>
|
||||
<p class="data_text"> 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.<p>
|
||||
<p class="data_title">Exposure graph:
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue