re-factor expected new cases method
This commit is contained in:
parent
abd6bb0767
commit
507e586757
2 changed files with 14 additions and 10 deletions
|
|
@ -56,11 +56,18 @@
|
|||
<div class="tab-pane show active" id="results" role="tabpanel" aria-labelledby="results-tab" style="padding: 1%">
|
||||
|
||||
{% if form.short_range_option == "short_range_yes" %}
|
||||
{# Probability of infection values #}
|
||||
{% set scenario = alternative_scenarios.stats.values() | first %}
|
||||
{% set long_range_prob_inf = scenario.probability_of_infection %}
|
||||
{% set long_range_prob_probabilistic_exposure = scenario.prob_probabilistic_exposure if form.exposure_option == 'p_probabilistic_exposure' %}
|
||||
{# Expected new case values #}
|
||||
{% set long_range_expected_cases = scenario.expected_new_cases %}
|
||||
{% set total_expected_new_cases = scenario.expected_new_cases + expected_new_cases %}
|
||||
{% else %}
|
||||
{# Probability of infection values #}
|
||||
{% set long_range_prob_inf = prob_inf %}
|
||||
{# Expected new case values #}
|
||||
{% set total_expected_new_cases = expected_new_cases %}
|
||||
{% endif %}
|
||||
|
||||
{% block report_results %}
|
||||
|
|
@ -97,6 +104,7 @@
|
|||
</div>
|
||||
{% endblock long_range_warning_animation %}
|
||||
</div>
|
||||
<h6><b>Expected new cases:</b> {{ long_range_expected_cases | float_format }}</h6>
|
||||
</div>
|
||||
<br>
|
||||
{% if form.short_range_option == "short_range_yes" %}
|
||||
|
|
@ -118,13 +126,14 @@
|
|||
</div>
|
||||
{% endblock warning_animation %}
|
||||
</div>
|
||||
<h6><b>Expected new cases:</b> {{ expected_new_cases | float_format }}</h6>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="d-flex">
|
||||
{% block report_summary %}
|
||||
<div class="flex-row align-self-center">
|
||||
<div class="align-self-center alert alert-dark mb-0" role="alert">
|
||||
Taking into account the uncertainties tied to the model variables, in this scenario and assuming all occupants are exposed equally (i.e. without short-range interactions), the <b>probability of one exposed occupant getting infected is {{ long_range_prob_inf | non_zero_percentage }}</b> and the <b>expected number of new cases is {{ expected_new_cases | float_format }}</b>*.
|
||||
Taking into account the uncertainties tied to the model variables, in this scenario and assuming all occupants are exposed equally (i.e. without short-range interactions), the <b>probability of one exposed occupant getting infected is {{ long_range_prob_inf | non_zero_percentage }}</b> and the <b>expected number of new cases is {{ total_expected_new_cases | float_format }}</b>*.
|
||||
</div>
|
||||
{% if form.short_range_option == "short_range_yes" %}
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -1819,16 +1819,11 @@ class ExposureModel:
|
|||
"""
|
||||
The expect_new_cases should always take the long-range infection_probability and multiply by the occupants exposed to long-range.
|
||||
"""
|
||||
prob_inf: _VectorisedFloat = self.infection_probability()
|
||||
if self.short_range != ():
|
||||
# If short-range interaction are defined, the total expected number of new cases
|
||||
# has to take into account both the long- and short-range probability of infection.
|
||||
long_range_model = nested_replace(self, {'short_range': (),})
|
||||
long_range_prob = long_range_model.infection_probability()
|
||||
short_range_total_people = self.short_range[0].total_people
|
||||
return (prob_inf * short_range_total_people + long_range_prob * self.exposed.number) / 100
|
||||
# If short-range interaction are defined, the total exposed people
|
||||
# is only those of the short-range interactions.
|
||||
exposed = self.short_range[0].total_people if self.short_range != () else self.exposed.number
|
||||
|
||||
return prob_inf * self.exposed.number / 100
|
||||
return self.infection_probability() * exposed / 100
|
||||
|
||||
def reproduction_number(self) -> _VectorisedFloat:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue