Merge branch 'feature/exposure_overlap' into 'master'

Illustrate  exposure in concentration plot

Closes #123 and #119

See merge request cara/cara!114
This commit is contained in:
Philip James Elson 2020-12-02 17:56:08 +00:00
commit d4e2c34941
3 changed files with 18 additions and 8 deletions

View file

@ -252,7 +252,7 @@ class FormData:
break_times.append((begin, end))
return tuple(break_times)
def coffee_break_times(self) -> typing.Tuple[typing.Tuple[int, int]]:
def coffee_break_times(self) -> typing.Tuple[typing.Tuple[int, int]]:
if not self.coffee_breaks:
return ()
if self.lunch_option:

View file

@ -61,7 +61,7 @@ def calculate_report_data(model: models.ExposureModel):
"emission_rate": er,
"exposed_occupants": exposed_occupants,
"expected_new_cases": expected_new_cases,
"scenario_plot_src": embed_figure(plot(times, concentrations)),
"scenario_plot_src": embed_figure(plot(times, concentrations, model)),
"repeated_events": repeated_events,
}
@ -78,10 +78,10 @@ def embed_figure(figure) -> str:
return f'data:image/png;base64,{pic_hash}'
def plot(times, concentrations):
def plot(times, concentrations, model: models.ExposureModel):
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(times, concentrations)
ax.plot(times, concentrations, lw=2, color='#1f77b4', label='Concentration')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
@ -89,9 +89,19 @@ def plot(times, concentrations):
ax.set_ylabel('Concentration ($q/m^3$)')
ax.set_title('Concentration of infectious quanta')
# top = max([0.75, max(concentrations)])
# print(max(concentrations))
# ax.set_ylim(bottom=1e-4, top=top)
# Plot presence of exposed person
for i, (presence_start, presence_finish) in enumerate(model.exposed.presence.boundaries()):
plt.fill_between(
times, concentrations, 0,
where=(np.array(times)>presence_start) & (np.array(times)<presence_finish),
color="#1f77b4", alpha=0.1,
label="Presence of exposed person(s)" if i == 0 else ""
)
# Place a legend outside of the axes itself.
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left')
ax.set_ylim(0)
return fig

View file

@ -210,7 +210,7 @@
<b>Ventilation data:</b> <br>
<ul>
<li>Mechanical ventilation = check the rates with a specialist.</li>
<li>Natural ventilation = the window opening distance is between the fixed frame and movable part when open.</li>
<li>Natural ventilation = the window opening distance is between the fixed frame and movable part when open (commonly used values are window height = 1.6m and window opening = 0.15m).</li>
<li>HEPA filtration = the air flow of the device. The following values are based on the different fan velocities of a specific commercial device proposed by the HSE Unit:</li>
<ul>
<li>Level 6 (max) = 430 m<sup>3</sup>/h (noisy)</li>