diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 36bd0131..ea69b39c 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -259,6 +259,7 @@ class FormData: evaporation_factor=0.3, ), short_range = mc.ShortRangeModel( + activities=sr_activities, presence=sr_presence, expirations=short_range_expirations, dilutions=dilution_factor(activities=sr_activities, distance=np.random.uniform(0.5, 1.5, 250000)), diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py index 0d4702b3..a92fc7e2 100644 --- a/cara/apps/calculator/report_generator.py +++ b/cara/apps/calculator/report_generator.py @@ -106,10 +106,16 @@ def calculate_report_data(model: models.ExposureModel): np.array(model.concentration(float(time))).mean() for time in times ] - concentrations = [ - np.array(model.concentration_model.concentration(float(time))).mean() - for time in times - ] + + concentrations = [] + for time in times: + for index, (start, stop) in enumerate(short_range_intervals): + # For visualization issues, add short range breathing activity to the initial long range concentrations + if start <= time <= stop and model.short_range.activities[index] == 'Breathing': + concentrations.append(np.array(model.concentration(float(time))).mean()) + break + concentrations.append(np.array(model.concentration_model.concentration(float(time))).mean()) + highest_const = max(short_range_concentrations) prob = np.array(model.infection_probability()).mean() er = np.array(model.concentration_model.infected.emission_rate_when_present()).mean() diff --git a/cara/apps/calculator/static/js/report.js b/cara/apps/calculator/static/js/report.js index 23f41795..1e72372d 100644 --- a/cara/apps/calculator/static/js/report.js +++ b/cara/apps/calculator/static/js/report.js @@ -639,14 +639,14 @@ function draw_plot(svg_id, times, concentrations, short_range_concentrations, cu .select('.line') .transition() .duration(1000) - .attr("d", lineFunc(data_for_graphs)); + .attr("d", lineFunc(long_range_data)); // Area. exposed_presence_intervals.forEach((b, index) => { exposedArea[index].x(d => xTimeRange(d.time)) .y0(graph_height - 50) .y1(d => yRange(d.concentration)); - drawArea[index].transition().duration(1000).attr('d', exposedArea[index](data_for_graphs.filter(d => { + drawArea[index].transition().duration(1000).attr('d', exposedArea[index](long_range_data.filter(d => { return d.time >= b[0] && d.time <= b[1] }))); }); @@ -657,7 +657,7 @@ function draw_plot(svg_id, times, concentrations, short_range_concentrations, cu .y0(graph_height - 50) .y1(d => yRange(d.concentration)); - drawShortRangeArea[index].transition().duration(1000).attr('d', shortRangeArea[index](data_for_graphs.filter(d => { + drawShortRangeArea[index].transition().duration(1000).attr('d', shortRangeArea[index](long_range_data.filter(d => { return d.time >= b[0] && d.time <= b[1] }))); }); @@ -805,16 +805,22 @@ function draw_plot(svg_id, times, concentrations, short_range_concentrations, cu if (button_full_exposure) { button_full_exposure.addEventListener("click", () => { update_concentration_plot(short_range_concentrations, data_for_graphs.short_range_concentrations, data_for_graphs.short_range_concentrations); + button_full_exposure.disabled = true; + button_long_exposure.disabled = false; }); } if (button_long_exposure) { button_long_exposure.addEventListener("click", () => { update_concentration_plot(concentrations, data_for_graphs.short_range_concentrations, data_for_graphs.concentrations); + button_full_exposure.disabled = false; + button_long_exposure.disabled = true; }); } // If user double click, reinitialize the chart vis.on("dblclick",function(){ + button_full_exposure.disabled = true; + button_long_exposure.disabled = false; yRange.domain([0., Math.max(...short_range_concentrations)]) yAxisEl.transition().call(d3.axisLeft(yRange)) lineFunc.defined(d => !isNaN(d.concentration)) diff --git a/cara/apps/expert.py b/cara/apps/expert.py index 208b3568..b0a7d0f5 100644 --- a/cara/apps/expert.py +++ b/cara/apps/expert.py @@ -504,6 +504,7 @@ baseline_model = models.ExposureModel( evaporation_factor=0.3, ), short_range=models.ShortRangeModel( + activities=(), presence=(), expirations=(), dilutions=(), diff --git a/cara/apps/templates/base/calculator.report.html.j2 b/cara/apps/templates/base/calculator.report.html.j2 index 2ae4fbd6..43e1f46d 100644 --- a/cara/apps/templates/base/calculator.report.html.j2 +++ b/cara/apps/templates/base/calculator.report.html.j2 @@ -90,8 +90,7 @@

* The results are based on the parameters and assumptions published in the CERN Open Report CERN-OPEN-2021-004.

{% if form.short_range_option == "short_range_yes" %} - - + {% endif %}