diff --git a/app/covid-calculator.ipynb b/app/covid-calculator.ipynb index ca3b1030..f353483b 100644 --- a/app/covid-calculator.ipynb +++ b/app/covid-calculator.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 57, "metadata": { "pycharm": { "name": "#%%\n" @@ -21,15 +21,15 @@ "source": [ "intro_box = w.VBox(children=(w.HTML(value='CARA Covid Calculator'),\n", " w.Text(placeholder=\"E.g. Workshop without masks\", description=\"Simulation name:\",\n", - " style={'description_width': '35%'}),\n", + " style={'description_width': 'auto'}, layout=w.Layout(width='auto')),\n", " w.Text(placeholder=\"E.g. 17/R-033\", description=\"Room number:\",\n", - " style={'description_width': '35%'})),\n", + " style={'description_width': 'auto'}, layout=w.Layout(width='auto'))),\n", " layout=w.Layout(padding='0px 0px 50px 0px'))" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 58, "metadata": { "pycharm": { "name": "#%%\n" @@ -37,9 +37,9 @@ }, "outputs": [], "source": [ - "volume_text = w.Text(placeholder=\"Room volume (m³)\", description=\"Room volume\")\n", - "area_text = w.Text(placeholder=\"Room floor area (m²)\", description=\"Floor area\")\n", - "height_text = w.Text(placeholder=\"Room ceiling height (m²)\", description=\"Ceiling height\")\n", + "volume_text = w.Text(placeholder=\"Room volume (m³)\", description=\"Room volume\", layout=w.Layout(width='auto'))\n", + "area_text = w.Text(placeholder=\"Room floor area (m²)\", description=\"Floor area\", layout=w.Layout(width='auto'))\n", + "height_text = w.Text(placeholder=\"Room ceiling height (m²)\", description=\"Ceiling height\", layout=w.Layout(width='auto'))\n", "\n", "room_dimensions_box = w.VBox(children=(volume_text, w.Label(value=\"------- OR -------\"),area_text, height_text),\n", " layout=w.Layout(padding='0px 0px 50px 0px'))\n", @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 59, "metadata": { "pycharm": { "name": "#%%\n" @@ -72,29 +72,32 @@ "mechanical_button = w.ToggleButton(value=False, description='Mechanical', layout={'width': 'auto'})\n", "natural_button = w.ToggleButton(value=False, description='Natural', layout={'width': 'auto'})\n", "\n", - "acph_text = w.Text(description=\"Air changes per hour\", style={'description_width': 'auto'})\n", - "asfr_text = w.Text(description=\"Air supply flow rate\", style={'description_width': 'auto'})\n", + "acph_text = w.Text(description=\"Air changes per hour\", style={'description_width': 'auto'}, layout=w.Layout(width='auto'))\n", + "asfr_text = w.Text(description=\"Air supply flow rate\", style={'description_width': 'auto'}, layout=w.Layout(width='auto'))\n", "\n", "w.jsdlink((acph_text, 'value'), (asfr_text, 'disabled'))\n", "w.jsdlink((asfr_text, 'value'), (acph_text, 'disabled'))\n", "\n", "mech_vent_box = w.VBox(\n", " children=(acph_text, w.Label(value=\"------- OR -------\"), asfr_text),\n", - " layout=w.Layout(display='none')\n", + " layout=w.Layout(display='none', width='auto')\n", ")\n", "\n", "nat_vent_box = w.VBox(\n", " children=(\n", - " w.Text(description='Number of windows:', style={'description_width': 'auto'}),\n", - " w.Text(description='Height of window:', placeholder='meters', style={'description_width': 'auto'}),\n", - " w.Text(description='Width of window:', placeholder='meters', style={'description_width': 'auto'}),\n", - " w.Text(description='Opening distance:', placeholder='centimeters', style={'description_width': 'auto'}),\n", + " w.Text(description='Number of windows:', style={'description_width': 'auto'}, layout=w.Layout(width='auto')),\n", + " w.Text(description='Height of window:', placeholder='meters', style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto')),\n", + " w.Text(description='Width of window:', placeholder='meters', style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto')),\n", + " w.Text(description='Opening distance:', placeholder='centimeters', style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto')),\n", " w.HBox(children=(\n", - " w.Label('Windows open'),\n", - " w.RadioButtons(options=('Always', '15 min / 2h'))\n", + " w.Label('Windows open', layout=w.Layout(width='auto')),\n", + " w.RadioButtons(options=('Always', '15 min / 2h'), layout=w.Layout(width='auto'))\n", " ))\n", " ),\n", - " layout=w.Layout(display='none'),\n", + " layout=w.Layout(display='none', width='auto'),\n", ")\n", "\n", "\n", @@ -119,37 +122,30 @@ " ventilation_box.children[1].layout.display = 'none'\n", "\n", "natural_button.observe(handle_natural_toggle)\n", - "mechanical_button.observe(handle_mechanical_toggle)" + "mechanical_button.observe(handle_mechanical_toggle)\n", + "left_column = w.VBox(children=(intro_box, room_dimensions_box, ventilation_box),\n", + " layout=w.Layout(width='25%', padding=\"0px 20px 0px 0px\"))" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 60, "metadata": { "pycharm": { "name": "#%%\n" - } + }, + "scrolled": false }, - "outputs": [ - { - "data": { - "text/plain": "VBox(children=(ToggleButton(value=False, description='Lunch break'), HBox(children=(VBox(children=(Label(value…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "5998e5c52baa48b4af05c6c65acef726" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "event_data_label = w.Label(\"Event data:\")\n", "attendees_label = w.Label(\"Attendees:\")\n", - "total_people_text = w.Text(description=\"Total number of people:\", style={'description_width': 'auto'})\n", - "infected_people_text = w.Text(description=\"Number of infected people:\", style={'description_width': 'auto'})\n", - "activity_dropdown = w.Dropdown(description=\"Activity type:\", options=[\"Training\", \"Workshop\", \"Office\"], value=None)\n", + "total_people_text = w.Text(description=\"Total number of people:\", style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto'))\n", + "infected_people_text = w.Text(description=\"Number of infected people:\", style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto'))\n", + "activity_dropdown = w.Dropdown(description=\"Activity type:\", options=[\"Training\", \"Workshop\", \"Office\"], value=None,\n", + " layout=w.Layout(width='auto'))\n", "start_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)], value=\"HH\")\n", "start_minute = w.Dropdown(options=[\"MM\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(60)], value=\"MM\")\n", "finish_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)], value=\"HH\")\n", @@ -159,16 +155,15 @@ " layout=w.Layout(padding=\"0px 20px 0px 0px\"))\n", "finish_box = w.VBox(children=(w.Label(\"Finish:\"),\n", " w.HBox(children=(finish_hour, finish_minute))))\n", - "event_time_box = w.HBox(children=(start_box, finish_box))\n", + "event_time_box = w.HBox(children=(start_box, finish_box), layout=w.Layout(width='auto'))\n", "\n", - "event_intro_box = w.VBox(children=(\n", - " event_data_label,\n", - " attendees_label,\n", - " total_people_text,\n", - " infected_people_text,\n", - " activity_dropdown,\n", - " event_time_box\n", - "))\n", + "event_intro_box = w.VBox(children=(event_data_label,\n", + " attendees_label,\n", + " total_people_text,\n", + " infected_people_text,\n", + " activity_dropdown,\n", + " event_time_box),\n", + " layout=w.Layout(padding=\"50px 0px 20px 0px\"))\n", "\n", "months = (\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n", " \"July\", \"August\", \"September\", \"October\", \"November\", \"December\")\n", @@ -200,7 +195,8 @@ "recurrent_button.observe(handle_recurrent_click)\n", "\n", "date_box = w.VBox(children=(w.HBox(children=(single_button, recurrent_button)),\n", - " w.HBox(children=(date_selector, months_bar))))\n", + " w.HBox(children=(date_selector, months_bar))),\n", + " layout=w.Layout(padding=\"0px 0px 30px 0px\"))\n", "\n", "lunch_start_hour = w.Dropdown(options=[\"HH\"] + [(\"0\" + str(i)) if len(str(i)) == 1 else str(i) for i in range(24)],\n", " value=\"HH\", disabled=True)\n", @@ -215,7 +211,7 @@ " layout=w.Layout(padding=\"0px 20px 0px 0px\"))\n", "lunch_finish_box = w.VBox(children=(w.Label(\"Finish:\"),\n", " w.HBox(children=(lunch_finish_minute, lunch_finish_minute))))\n", - "lunch_time_box = w.HBox(children=(lunch_start_box, lunch_finish_box))\n", + "lunch_time_box = w.HBox(children=(lunch_start_box, lunch_finish_box), layout=w.Layout(width='auto'))\n", "\n", "lunch_button = w.ToggleButton(value=False, description=\"Lunch break\")\n", "\n", @@ -225,8 +221,91 @@ "\n", "lunch_button.observe(handle_lunch)\n", "\n", - "break_box = w.VBox(children=(lunch_button, lunch_time_box))\n", - "\n" + "lunch_break_box = w.VBox(children=(lunch_button, lunch_time_box), layout=w.Layout(padding='0px 0px 20px 0px'))\n", + "\n", + "coffee_button = w.ToggleButton(value=False, description=\"Coffee breaks\")\n", + "coffee_breaks_text = w.Text(description=\"Number of breaks:\", disabled=True, style={'description_width': 'auto'},\n", + " layout=w.Layout(width='auto'))\n", + "coffee_duration = w.Dropdown(description=\"Duration:\", options=[\"MM\"] + [str(i) for i in range(1, 31)], value=\"MM\",\n", + " disabled=True, style={'description_width': 'auto'}, layout=w.Layout(width='auto'))\n", + "regular_breaks_label = w.Label(\"Regular breaks are spread evenly throughout the day\")\n", + "coffee_break_box = w.VBox(children=(coffee_button, coffee_breaks_text, coffee_duration, regular_breaks_label))\n", + "def handle_coffee_button(_):\n", + " coffee_duration.disabled = not coffee_button.value\n", + " coffee_breaks_text.disabled = not coffee_button.value\n", + "\n", + "coffee_button.observe(handle_coffee_button)\n", + "break_box = w.VBox(children=(lunch_break_box, coffee_break_box))\n", + "\n", + "middle_column = w.VBox(children=(event_intro_box, date_box, break_box),\n", + " layout=w.Layout(width='40%', padding='0px 20px 0px 0px'))" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'w' is not defined", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)", + "\u001B[0;32m\u001B[0m in \u001B[0;36m\u001B[0;34m\u001B[0m\n\u001B[0;32m----> 1\u001B[0;31m \u001B[0mmask_label\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mw\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mLabel\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m\"Mask wearing:\"\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m 2\u001B[0m \u001B[0mmask_buttons\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mw\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mToggleButtons\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0moptions\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;34m\"Continuous\"\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;34m\"Removed when seated >2m\"\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 3\u001B[0m \u001B[0mmask_box\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mw\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mVBox\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mchildren\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmask_label\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mmask_buttons\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mlayout\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mw\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mLayout\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpadding\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m'50px 0px 30px 0px'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 4\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m 5\u001B[0m info_box = w.HTML(value=''\n", + "\u001B[0;31mNameError\u001B[0m: name 'w' is not defined" + ] + } + ], + "source": [ + "mask_label = w.Label(\"Mask wearing:\")\n", + "mask_buttons = w.ToggleButtons(options=[\"Continuous\", \"Removed when seated >2m\"])\n", + "mask_box = w.VBox(children=(mask_label, mask_buttons), layout=w.Layout(padding='50px 0px 30px 0px'))\n", + "\n", + "info_box = w.HTML(value=''\n", + " '

This tool estimates the risk of COVID-19 spread. It is based on current scientific data and '\n", + " 'can be used to provide an illustration for different real world scenarios.


'\n", + " '

How to use this tool:

'\n", + " '

Room data

'\n", + " '

Enter the data about the area you wish to study. You can find these in GIS, or by measuring '\n", + " 'them yourself.

For mechanical ventilation, you should check with a specialist for the '\n", + " 'air flow or air change rate.


'\n", + " '

Event data

'\n", + " '

Enter the total number of people and how many you assume are infected.


'\n", + " '

Activity types:

'\n", + " '

Office = typical scenario all persons seated, talking quietly.

'\n", + " '

Workshop = assembly workshop environment, all persons doing light exercise, talking.

'\n", + " '

Training = one person standing, talking, all others seated, breathing normally.

'\n", + " '

Seminar = As training, but all participants take turns in standing and talking.

'\n", + " '

You should specify if the event is a one off (give date) or recurrent use of the same space '\n", + " 'for the same activity, in which case tick the months when the activity takes place.

'\n", + " '

Specify if a lunch break should be included, and when it starts/stops.

'\n", + " '

If you will take coffee breaks, they are spread out evenly throughout the day, '\n", + " 'in addition to lunch.

Mask wearing: Specify if they are worn all the time, '\n", + " 'or only when less than 2 meters apart.

',\n", + " layout=w.Layout(padding='0px 0px 30px 0px'))\n", + "\n", + "report_button = w.Button(description=\"Generate report\")\n", + "\n", + "right_column = w.VBox(children=(mask_box, info_box, report_button), layout=w.Layout(width='35%'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [], + "source": [ + "w.HBox(children=(left_column, middle_column, right_column))\n" ] } ],