From 6a9d0c0ec281981194c0124ac93c0b0d403f9ab1 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Tue, 3 Oct 2023 15:14:51 +0200 Subject: [PATCH 1/7] expert apps updates following new matplotlib release --- caimira/apps/expert.py | 4 ++-- caimira/apps/expert_co2.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/caimira/apps/expert.py b/caimira/apps/expert.py index c15234c0..5162d8f0 100644 --- a/caimira/apps/expert.py +++ b/caimira/apps/expert.py @@ -126,7 +126,7 @@ class ExposureModelResult(View): self.figure.canvas, ]) - def initialize_axes(self) -> matplotlib.figure.Axes: + def initialize_axes(self) -> typing.Tuple[matplotlib.axes.Axes, matplotlib.axes.Axes]: ax = self.figure.add_subplot(1, 1, 1) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) @@ -230,7 +230,7 @@ class ExposureComparisonResult(View): # unless the widget is wrapped in a container (it is seen on all tabs otherwise!). return widgets.HBox([self.figure.canvas]) - def initialize_axes(self) -> matplotlib.figure.Axes: + def initialize_axes(self) -> typing.Tuple[matplotlib.axes.Axes, matplotlib.axes.Axes]: ax = self.figure.add_subplot(1, 1, 1) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) diff --git a/caimira/apps/expert_co2.py b/caimira/apps/expert_co2.py index 345f7cf7..5c3437bf 100644 --- a/caimira/apps/expert_co2.py +++ b/caimira/apps/expert_co2.py @@ -69,7 +69,7 @@ class ExposureModelResult(View): self.figure.canvas, ]) - def initialize_axes(self) -> matplotlib.figure.Axes: + def initialize_axes(self) -> matplotlib.axes.Axes: ax = self.figure.add_subplot(1, 1, 1) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) @@ -140,7 +140,7 @@ class ExposureComparisonResult(View): # unless the widget is wrapped in a container (it is seen on all tabs otherwise!). return widgets.HBox([self.figure.canvas]) - def initialize_axes(self) -> matplotlib.figure.Axes: + def initialize_axes(self) -> matplotlib.axes.Axes: ax = self.figure.add_subplot(1, 1, 1) ax.spines[['right', 'top']].set_visible(False) From c8f2b32feffb5b3a8c9cf15952069060da7bbb73 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Tue, 25 Jul 2023 14:56:13 +0200 Subject: [PATCH 2/7] modified CO2 concentration when ventilation is close to 0. (RR) --- caimira/models.py | 20 ++++++++----------- .../tests/models/test_concentration_model.py | 10 +++++++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/caimira/models.py b/caimira/models.py index e8de7667..db62293f 100644 --- a/caimira/models.py +++ b/caimira/models.py @@ -1132,23 +1132,21 @@ class _ConcentrationModelBase: return self.min_background_concentration()/self.normalization_factor() next_state_change_time = self._next_state_change(time) - RR = self.removal_rate(next_state_change_time) - # If RR is 0, conc_limit does not play a role but its computation - # would raise an error -> we set it to zero. - try: - conc_limit = self._normed_concentration_limit(next_state_change_time) - except ZeroDivisionError: - conc_limit = 0. t_last_state_change = self.last_state_change(time) conc_at_last_state_change = self._normed_concentration_cached(t_last_state_change) - delta_time = time - t_last_state_change + fac = np.exp(-RR * delta_time) - return conc_limit * (1 - fac) + conc_at_last_state_change * fac + if isinstance(RR, float) and RR == 0: + curr_conc_state = delta_time * self.population.people_present(time) / self.room.volume + else: + curr_conc_state = self._normed_concentration_limit(next_state_change_time) * (1 - fac) + return curr_conc_state + conc_at_last_state_change * fac + def concentration(self, time: float) -> _VectorisedFloat: """ Total concentration as a function of time. The normalization @@ -1260,9 +1258,7 @@ class CO2ConcentrationModel(_ConcentrationModelBase): return self.CO2_emitters def removal_rate(self, time: float) -> _VectorisedFloat: - # Setting minimum air exchange rate to 1e-6 to avoid divisions by - # zero when computing the CO2 concentration. - return np.maximum(1e-6,self.ventilation.air_exchange(self.room, time)) + return self.ventilation.air_exchange(self.room, time) def min_background_concentration(self) -> _VectorisedFloat: """ diff --git a/caimira/tests/models/test_concentration_model.py b/caimira/tests/models/test_concentration_model.py index f8f42106..27703a2f 100644 --- a/caimira/tests/models/test_concentration_model.py +++ b/caimira/tests/models/test_concentration_model.py @@ -252,8 +252,11 @@ def test_normed_integrated_concentration_vectorisation( "known_min_background_concentration", "expected_concentration"], [ - [0., 240., 240.], - [0., np.array([240., 240.]), np.array([240., 240.])] + [0., 240., 240. + 0.5/75], + [0.0001, 240.0, 240. + 0.5/75], + [1e-6, 240.0, 240 + 0.5/75], + [0., np.array([240., 240.]), np.array([240. + 0.5/75, 240. + 0.5/75])], + [np.array([0.0001, 1e-6]), np.array([240., 240.]), np.array([240. + 0.5/75, 240. + 0.5/75])], ] ) def test_zero_ventilation_rate( @@ -272,4 +275,5 @@ def test_zero_ventilation_rate( known_min_background_concentration = known_min_background_concentration) normed_concentration = known_conc_model.concentration(1) - npt.assert_almost_equal(normed_concentration, expected_concentration) + assert normed_concentration == pytest.approx(expected_concentration, abs=1e-6) + \ No newline at end of file From 9712ffc8ae464b59f9674e0973952d9d6a8893b2 Mon Sep 17 00:00:00 2001 From: Nicolas Mounet Date: Tue, 3 Oct 2023 12:05:31 +0200 Subject: [PATCH 3/7] Adapting zero removal rate case to case when RR is an array --- caimira/models.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/caimira/models.py b/caimira/models.py index db62293f..7a14f33f 100644 --- a/caimira/models.py +++ b/caimira/models.py @@ -1055,8 +1055,15 @@ class _ConcentrationModelBase: """ V = self.room.volume RR = self.removal_rate(time) - - return (self.population.people_present(time) / (RR * V) + + + if isinstance(RR, np.ndarray): + invRR = np.empty(RR.shape, dtype=np.float64) + invRR[RR == 0.] = np.nan + invRR[RR != 0.] = 1. / RR[RR != 0.] + else: + invRR = np.nan if RR == 0. else 1. / RR + + return (self.population.people_present(time) * invRR / V + self.min_background_concentration()/self.normalization_factor()) @method_cache @@ -1139,11 +1146,16 @@ class _ConcentrationModelBase: delta_time = time - t_last_state_change fac = np.exp(-RR * delta_time) - - if isinstance(RR, float) and RR == 0: - curr_conc_state = delta_time * self.population.people_present(time) / self.room.volume + if isinstance(RR, np.ndarray): + curr_conc_state = np.empty(RR.shape, dtype=np.float64) + curr_conc_state[RR == 0.] = delta_time * self.population.people_present(time) / ( + self.room.volume[RR == 0.] if isinstance(self.room.volume,np.ndarray) else self.room.volume) + curr_conc_state[RR != 0.] = self._normed_concentration_limit(next_state_change_time)[RR != 0.] * (1 - fac[RR != 0.]) else: - curr_conc_state = self._normed_concentration_limit(next_state_change_time) * (1 - fac) + if RR == 0.: + curr_conc_state = delta_time * self.population.people_present(time) / self.room.volume + else: + curr_conc_state = self._normed_concentration_limit(next_state_change_time) * (1 - fac) return curr_conc_state + conc_at_last_state_change * fac From e0a321dd86f2a2eab21e5bbd3679d10e297d2997 Mon Sep 17 00:00:00 2001 From: Nicolas Mounet Date: Tue, 3 Oct 2023 12:35:38 +0200 Subject: [PATCH 4/7] fixing mypy issue --- caimira/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caimira/models.py b/caimira/models.py index 7a14f33f..24ef62e2 100644 --- a/caimira/models.py +++ b/caimira/models.py @@ -1061,7 +1061,7 @@ class _ConcentrationModelBase: invRR[RR == 0.] = np.nan invRR[RR != 0.] = 1. / RR[RR != 0.] else: - invRR = np.nan if RR == 0. else 1. / RR + invRR = np.nan if RR == 0. else 1. / RR # type: ignore return (self.population.people_present(time) * invRR / V + self.min_background_concentration()/self.normalization_factor()) From 19f4e2c188252f4c633c7efb550ef537bde03f09 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Tue, 3 Oct 2023 12:02:00 +0200 Subject: [PATCH 5/7] update Acknowledgements --- caimira/apps/templates/common_text.md.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/caimira/apps/templates/common_text.md.j2 b/caimira/apps/templates/common_text.md.j2 index 79648ed6..d5ed0ba0 100644 --- a/caimira/apps/templates/common_text.md.j2 +++ b/caimira/apps/templates/common_text.md.j2 @@ -21,7 +21,8 @@ ## Acknowledgements -We wish to thank CERN’s HSE Unit, Beams Department, Experimental Physics Department, Information Technology Department, Industry, Procurement and Knowledge Transfer Department and International Relations Sector for their support to the study. Thanks to Doris Forkel-Wirth, Benoit Delille, Walid Fadel, Olga Beltramello, Letizia Di Giulio, Evelyne Dho, Wayne Salter, Benoit Salvant and colleagues from the COVID working group for providing expert advice and extensively testing the model. Finally, we wish to thank Fabienne Landua and the design service for preparing the illustrations and Alessandro Raimondo and Manuela Cirilli from the Knowledge Transfer Group for their continuous support. Our compliments towards the work and research performed by world leading scientists in this domain: Dr. Julian Tang, Prof. Manuel Gameiro, Dr. Linsey Marr, Prof. Lidia Morawska, Prof. Yuguo Li, and others – their scientific contribution was indispensable for this project. +We wish to thank CERN at the different Departments working on the project: Occupational Health & Safety and Environmental Protection Unit, Information Technology Department, Beams Department, Experimental Physics Department, Industry, Procurement and Knowledge Transfer Department and International Relations Sector for their support to the study. +We also wish to thank our collaborators at the World Health Organization (WHO) for thier endless support to this project, in particular to the members of the ARIA Expert Group. ## Disclaimer

From 1a7624fde21c9ff046f064f05c4261273a3755fb Mon Sep 17 00:00:00 2001 From: "CERN\\Andrejh" Date: Wed, 4 Oct 2023 17:49:34 +0200 Subject: [PATCH 6/7] about text update --- caimira/apps/templates/about.html.j2 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/caimira/apps/templates/about.html.j2 b/caimira/apps/templates/about.html.j2 index 479acc4b..00767484 100644 --- a/caimira/apps/templates/about.html.j2 +++ b/caimira/apps/templates/about.html.j2 @@ -43,7 +43,16 @@ Although the user is able to calculate the infection probability of a stand-alon

  • Adapt the maximum occupancy considering the effect of HEPA filters
  • Etc…
  • - + +
    +

    Collaboration with the World Health Organization (WHO)


    +The tool has attracted the attention of many international organisations, including the World Health Organization (WHO) and the United Nations Office at Geneva (UNOG). +In June 2021, CERN shared its own approach towards risk assessments for occupational hazards presenting, which was at the time called CARA, to WHO's COVID Expert Panel. +As a result, WHO has invited CERN to become a member of a multidisciplinary expert group of international experts called ARIA, which will work to define a standardised algorithm to quantify airborne transmission risk in indoor settings. +This will ensure that the model inculdes not only the science related to aerosol science but also the virological effects such as host-pathogen interaction. +The collaboration takes place within CERNs wide-ranging engagement with other international organisations, promoting shared solutions to societal challenges. +

    +

    Main Developers:


    {{ text_blocks['Main Developers'] }}
    From febc66af09c57161b62a22c490dc210c759a781a Mon Sep 17 00:00:00 2001 From: "CERN\\Andrejh" Date: Wed, 4 Oct 2023 17:54:42 +0200 Subject: [PATCH 7/7] additiobal updates --- caimira/apps/templates/about.html.j2 | 13 +++++++------ caimira/apps/templates/common_text.md.j2 | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/caimira/apps/templates/about.html.j2 b/caimira/apps/templates/about.html.j2 index 00767484..c0cf59f1 100644 --- a/caimira/apps/templates/about.html.j2 +++ b/caimira/apps/templates/about.html.j2 @@ -46,17 +46,18 @@ Although the user is able to calculate the infection probability of a stand-alon

    Collaboration with the World Health Organization (WHO)


    -The tool has attracted the attention of many international organisations, including the World Health Organization (WHO) and the United Nations Office at Geneva (UNOG). -In June 2021, CERN shared its own approach towards risk assessments for occupational hazards presenting, which was at the time called CARA, to WHO's COVID Expert Panel. -As a result, WHO has invited CERN to become a member of a multidisciplinary expert group of international experts called ARIA, which will work to define a standardised algorithm to quantify airborne transmission risk in indoor settings. -This will ensure that the model inculdes not only the science related to aerosol science but also the virological effects such as host-pathogen interaction. +

    The tool has attracted the attention of many international organisations, including the World Health Organization (WHO) and the United Nations Office at Geneva (UNOG). +In June 2021, CERN shared its own approach towards risk assessments for occupational hazards presenting, which was at the time called CARA, to WHO's COVID Expert Panel.

    +

    As a result, WHO has invited CERN to become a member of a multidisciplinary expert group of international experts called ARIA, which will work to define a standardised algorithm to quantify airborne transmission risk in indoor settings. +This will ensure that the model inculdes not only the science related to aerosol science but also the virological effects such as host-pathogen interaction.

    + The collaboration takes place within CERNs wide-ranging engagement with other international organisations, promoting shared solutions to societal challenges.

    -

    Main Developers:


    +

    Main code developers:


    {{ text_blocks['Main Developers'] }}
    -

    Code Contributors:


    +

    Other contributions from:


    {{ text_blocks['Code Contributors'] }}

    References:


    diff --git a/caimira/apps/templates/common_text.md.j2 b/caimira/apps/templates/common_text.md.j2 index d5ed0ba0..111ca5e8 100644 --- a/caimira/apps/templates/common_text.md.j2 +++ b/caimira/apps/templates/common_text.md.j2 @@ -13,7 +13,7 @@

    Anna Efimova1,2, Anel Massalimova1,3, Cole Austin Coughlin1,4, Germain Personne5

    -1Summer Students, CERN
    +1Summer Student Programme, CERN
    2M.V. Lomonosov Moscow State University
    3National Research Nuclear University "MEPhI"
    4University of Manitoba