diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index e6cd21b7..ef0b479a 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -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: diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py index be8f8322..278a0a79 100644 --- a/cara/apps/calculator/report_generator.py +++ b/cara/apps/calculator/report_generator.py @@ -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)Ventilation data: