From 84853373e3f09bcb3899aa524159df4d5c9ca600 Mon Sep 17 00:00:00 2001
From: lrdossan <luis.aleixo@cern.ch>
Date: Mon, 1 Jul 2024 11:26:25 +0100
Subject: [PATCH 1/2] added transition points to dilution factor methods

---
 Short-Range_paper/scripts_paper.py | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/Short-Range_paper/scripts_paper.py b/Short-Range_paper/scripts_paper.py
index d76838f..e66f328 100644
--- a/Short-Range_paper/scripts_paper.py
+++ b/Short-Range_paper/scripts_paper.py
@@ -62,8 +62,8 @@ def define_colormap(factors):
 
 
 def define_colormap_linear(cns):
-    min_val, max_val = 0., 1
-    n = 100
+    min_val, max_val = 0.25, 0.85
+    n = 10
     orig_cmap = mpl.cm.Reds
     colors = orig_cmap(np.linspace(min_val, max_val, n))
 
@@ -337,13 +337,11 @@ def short_range_concentration(long_range_concentration: float, activity: str, ex
 
 def dilution_factor(activity: str, max_distance: float, full: bool = False) -> None:
     distances: models._VectorisedFloat = np.linspace(0, max_distance, 100)
-    activity_dist: models._VectorisedFloat = activity_distributions(data_registry)[activity].build_model(
-        SAMPLE_SIZE)
+    activity_dist: models._VectorisedFloat = activity_distributions(data_registry)[activity].build_model(SAMPLE_SIZE)
     if full == True:
-
         velocities: models._VectorisedFloat = np.linspace(0.5, 5.8, 200)
         cmap = define_colormap_linear(velocities)
-        for u0 in tqdm(velocities):
+        for index, u0 in enumerate(tqdm(velocities)):
             dilutions: list = []
             for d in distances:
                 short_range: SimpleShortRangeModel = short_range_model(
@@ -359,6 +357,15 @@ def dilution_factor(activity: str, max_distance: float, full: bool = False) -> N
                 dilutions.append(current_dilution)
             plt.plot(distances, dilutions,
                      color=cmap.to_rgba(u0_new), linewidth=1)
+            
+            # Transition point xstar (first one, lowest velocity)
+            if index == 0:
+                closest_index_xstar = np.argmin(np.abs(np.array(distances) - xstar))
+                plt.scatter(distances[closest_index_xstar], dilutions[closest_index_xstar], label='Transition point (lowest velocity)', zorder=10,)
+        
+        # Transition point xstar (last one, highest velocity)
+        closest_index_xstar = np.argmin(np.abs(np.array(distances) - xstar))
+        plt.scatter(distances[closest_index_xstar], dilutions[closest_index_xstar], label='Transition point (highest velocity)', zorder=10)
 
         # Use these lines to add the colorbar
         cmap = plt.colorbar(cmap, ticks=[1, 2, 3, 4, 5], ax=plt.gca())
@@ -391,14 +398,21 @@ def dilution_factor(activity: str, max_distance: float, full: bool = False) -> N
                 presence=((8, 12),),  # Not relevant
                 distance=d
             )
-            dilutions.append(short_range.dilution_factor()[0])
+            dilution_factor_output = short_range.dilution_factor()
+            dilutions.append(dilution_factor_output[0])
+
+        xstar = dilution_factor_output[1]
+        # Transition point xstar
+        closest_index_xstar = np.argmin(np.abs(np.array(distances) - xstar))
+        plt.scatter(distances[closest_index_xstar], dilutions[closest_index_xstar], color='black', label='Transition point', zorder=10)
 
         plt.yscale('log')
         plt.xticks(fontsize=12)
         plt.yticks(fontsize=12)
         plt.xlabel('Distance (m)', fontsize=13)
         plt.ylabel('Dilution factor', fontsize=13)
-        plt.plot(distances, dilutions)
+        plt.plot(distances, dilutions, label='Dilution factor')
+        plt.legend()
         plt.show()
 
     return None
-- 
GitLab


From 15cf9eda197d318446f12ccc588d3a50a3a2b286 Mon Sep 17 00:00:00 2001
From: lrdossan <luis.aleixo@cern.ch>
Date: Mon, 1 Jul 2024 15:04:01 +0100
Subject: [PATCH 2/2] merge branches

---
 Short-Range_paper/results_paper.py |  7 ++++++-
 Short-Range_paper/scripts_paper.py | 23 ++++++++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/Short-Range_paper/results_paper.py b/Short-Range_paper/results_paper.py
index 685a69f..1f7ae3d 100644
--- a/Short-Range_paper/results_paper.py
+++ b/Short-Range_paper/results_paper.py
@@ -10,11 +10,16 @@ from model_scenarios_paper import *
 
 ############# Data ############
 
-## Short range emission rate for a given physical activity (jet origin concentration * breathing rate)
+# Short range emission rate for a given physical activity (jet origin concentration * breathing rate)
 # short_range_emission_rate_values(physical_activity='Standing', expiratory_activity='Breathing') 
 # short_range_emission_rate_values(physical_activity='Standing', expiratory_activity='Speaking')
 # short_range_emission_rate_values(physical_activity='Standing', expiratory_activity='Shouting')
 
+# Emission rate comparisson between different physical activitites
+# short_range_emission_rate_physical_activity_comparison(first_physical_activity='Heavy exercise', 
+#                                               second_physical_activity='Standing', 
+#                                               expiratory_activity='Speaking')
+
 # C0_sr, C_sr @ 1m
 # short_range_values(activity='Standing', expiration='Shouting', distance=1., room_humidity = 0.5)
 # short_range_values(activity='Standing', expiration='Speaking', distance=1., room_humidity = 0.5)
diff --git a/Short-Range_paper/scripts_paper.py b/Short-Range_paper/scripts_paper.py
index e66f328..017c30f 100644
--- a/Short-Range_paper/scripts_paper.py
+++ b/Short-Range_paper/scripts_paper.py
@@ -884,8 +884,7 @@ def statistics_for_random_variable(physical_activity: bool = False,
 def short_range_emission_rate_values(physical_activity: str, 
                                      expiratory_activity: str,
                                      virus_dist: typing.Optional[models.Virus] = None,
-                                     print_results: bool = True,
-                                     ):
+                                     print_results: bool = True):
     
     if virus_dist:
         SAMPLE_SIZE = len(virus_dist.viral_load_in_sputum)
@@ -1009,4 +1008,22 @@ def present_vl_er_histograms(physical_activity: str, expiratory_activities: typi
     plt.tight_layout()
     plt.show()
 
-    return None
\ No newline at end of file
+    return None
+
+def short_range_emission_rate_physical_activity_comparison(first_physical_activity: str, 
+                                                  second_physical_activity: str, 
+                                                  expiratory_activity=str):
+
+    first_emission_rate, _ = short_range_emission_rate_values(first_physical_activity, expiratory_activity)
+    second_emission_rate, _ = short_range_emission_rate_values(second_physical_activity, expiratory_activity)
+
+    print(
+        'Expiratory Activity:', expiratory_activity,
+        '\nFirst Physical Activity: ', first_physical_activity,
+        '\nSecond Physical Activity: ', second_physical_activity, 
+        '\nvR_sr_1 (first activity): ', np.mean(first_emission_rate),
+        '\nvR_sr_2 (second activity): ', np.mean(second_emission_rate),
+        f'\nvR_sr_1 / vR_sr_2 ({expiratory_activity}): {np.mean(first_emission_rate)/np.mean(second_emission_rate):.0f} -fold'
+        '\n>>>>>>>'
+        '\n'
+    )
-- 
GitLab