PySDM-examples 2.49__py3-none-any.whl → 2.52__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,38 @@ import numpy as np
3
3
  from PySDM.physics import si, in_unit
4
4
  from PySDM.physics.constants import PER_CENT
5
5
 
6
+ CLOUD_BASE = 300 * si.m
7
+
8
+
9
+ def find_drop_ids_by_dry_size(plot_drops_with_dry_radii_um, simulation_r_dry):
10
+ drop_ids = []
11
+ for drop_size_um in plot_drops_with_dry_radii_um:
12
+ drop_id = (np.abs(simulation_r_dry - drop_size_um * si.um)).argmin()
13
+ drop_ids.append(drop_id)
14
+ return drop_ids
15
+
16
+
17
+ def compute_table_values(height_above_cb_m, height_cb_m, products, ascent_mask):
18
+ """constructing data for Table 4"""
19
+ data = {"ascent": [], "descent": []}
20
+ for level_idx, height_m in enumerate(products["z"]):
21
+ rounded_height_above_cb_m = np.round(height_m - height_cb_m)
22
+ if rounded_height_above_cb_m in height_above_cb_m:
23
+ r_mean = products["r_mean_act"][level_idx]
24
+ r_standard_deviation = products["r_std_act"][level_idx]
25
+ r_relative_dispersion = r_standard_deviation / r_mean
26
+
27
+ data["ascent" if ascent_mask[level_idx] else "descent"].append(
28
+ (
29
+ f"{rounded_height_above_cb_m:.0f}",
30
+ f"{in_unit(r_mean, si.um):.2f}",
31
+ f"{in_unit(r_standard_deviation, si.um):.2f}",
32
+ f"{r_relative_dispersion:.3f}",
33
+ )
34
+ )
35
+ data["ascent"].append(data["descent"][0])
36
+ return data
37
+
6
38
 
7
39
  def figure(
8
40
  *,
@@ -12,9 +44,9 @@ def figure(
12
44
  plot_drops_with_dry_radii_um,
13
45
  xlim_r_um: tuple,
14
46
  xlim_S_percent: tuple,
47
+ return_masks: bool = False,
15
48
  ):
16
- cloud_base = 300 * si.m
17
- y_axis = np.asarray(output["products"]["z"]) - settings.z0 - cloud_base
49
+ y_axis = np.asarray(output["products"]["z"]) - settings.z0 - CLOUD_BASE
18
50
 
19
51
  masks = {}
20
52
  if settings.t_end_of_ascent is None:
@@ -37,13 +69,13 @@ def figure(
37
69
  color=colors[label],
38
70
  )
39
71
  axs["S"].set_xlim(*xlim_S_percent)
40
- axs["S"].set_xlabel("S (%)")
41
- axs["S"].legend()
72
+ axs["S"].set_xlabel("S (%)", fontsize="15")
73
+ axs["S"].legend(fontsize="10")
42
74
 
43
- drop_ids = []
44
- for drop_size_um in plot_drops_with_dry_radii_um:
45
- drop_id = (np.abs(simulation.r_dry - drop_size_um * si.um)).argmin()
46
- drop_ids.append(drop_id)
75
+ drop_ids = find_drop_ids_by_dry_size(
76
+ plot_drops_with_dry_radii_um=plot_drops_with_dry_radii_um,
77
+ simulation_r_dry=simulation.r_dry,
78
+ )
47
79
 
48
80
  for (
49
81
  drop_id
@@ -65,8 +97,14 @@ def figure(
65
97
  )
66
98
  axs["r"].legend()
67
99
  axs["r"].set_xlim(*xlim_r_um)
68
- axs["r"].set_xlabel("r$_c$ (µm)")
69
- axs["r"].set_ylabel("height above cloud base (m)")
100
+ axs["r"].set_xlabel("r$_c$ (µm)", fontsize="15")
101
+ axs["r"].set_ylabel("Height above cloud base (m)", fontsize="15")
102
+ # pyplot.xticks(fontsize=12)
103
+ # pyplot.yticks(fontsize=12)
70
104
 
71
105
  for ax in axs.values():
72
106
  ax.grid()
107
+
108
+ if return_masks:
109
+ return masks
110
+ return None
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from pystrict import strict
2
4
  from PySDM import Formulae
3
5
  from PySDM.physics import si
@@ -11,19 +13,19 @@ INITIAL_ALTITUDE = 600 * si.metres
11
13
 
12
14
  @strict
13
15
  class Settings:
14
- def __init__(self, *, aerosol: str, cloud_type: str):
16
+ def __init__(self, *, aerosol: str, cloud_type: str, dt: Optional[float] = None):
15
17
  self.p0 = INITIAL_PRESSURE
16
18
  self.RH0 = INITIAL_RELATIVE_HUMIDITY
17
19
  self.T0 = INITIAL_TEMPERATURE
18
20
  self.z0 = INITIAL_ALTITUDE
19
21
  self.t_end_of_ascent = 1500 * si.s if cloud_type == "Sc" else None
20
- self.dt = 1 * si.s # TODO #1266: not found in the paper yet
22
+ self.dt = dt or 1 * si.s # TODO #1266: not found in the paper yet
21
23
 
22
24
  self.kappa = 1.28 # Table 1 from Petters & Kreidenweis 2007
23
25
 
24
26
  self.formulae = Formulae(
25
27
  saturation_vapour_pressure="FlatauWalkoCotton", # TODO #1266: Bolton
26
- diffusion_kinetics="JensenAndNugent2017",
28
+ diffusion_kinetics="GrabowskiEtAl2011",
27
29
  diffusion_thermics="GrabowskiEtAl2011",
28
30
  constants={
29
31
  # values from appendix B
@@ -5,9 +5,16 @@ from PySDM_examples.Jensen_and_Nugent_2017 import table_3
5
5
  from PySDM import Builder
6
6
  from PySDM.physics import si
7
7
  from PySDM.backends import CPU
8
- from PySDM.products import PeakSupersaturation, ParcelDisplacement, Time
8
+ from PySDM.products import (
9
+ PeakSupersaturation,
10
+ ParcelDisplacement,
11
+ Time,
12
+ ActivatedMeanRadius,
13
+ RadiusStandardDeviation,
14
+ )
9
15
  from PySDM.environments import Parcel
10
- from PySDM.dynamics import Condensation, AmbientThermodynamics
16
+ from PySDM.dynamics import Condensation, AmbientThermodynamics, Coalescence
17
+ from PySDM.dynamics.collisions.collision_kernels import Geometric
11
18
  from PySDM.initialisation.sampling.spectral_sampling import Logarithmic
12
19
 
13
20
  # note: 100 in caption of Table 1
@@ -15,7 +22,12 @@ N_SD_NON_GCCN = 100
15
22
 
16
23
 
17
24
  class Simulation(BasicSimulation):
18
- def __init__(self, settings: Settings, gccn: bool = False):
25
+ def __init__(
26
+ self,
27
+ settings: Settings,
28
+ gccn: bool = False,
29
+ gravitational_coalsecence: bool = False,
30
+ ):
19
31
  const = settings.formulae.constants
20
32
  pvs_Celsius = settings.formulae.saturation_vapour_pressure.pvs_Celsius
21
33
  initial_water_vapour_mixing_ratio = const.eps / (
@@ -40,7 +52,7 @@ class Simulation(BasicSimulation):
40
52
  environment=env,
41
53
  )
42
54
 
43
- additional_derived_attributes = ("radius",)
55
+ additional_derived_attributes = ("radius", "equilibrium supersaturation")
44
56
  for additional_derived_attribute in additional_derived_attributes:
45
57
  builder.request_attribute(additional_derived_attribute)
46
58
 
@@ -48,6 +60,8 @@ class Simulation(BasicSimulation):
48
60
  AmbientThermodynamics()
49
61
  ) # TODO #1266: order matters here, but error message is not saying it!
50
62
  builder.add_dynamic(Condensation())
63
+ if gravitational_coalsecence:
64
+ builder.add_dynamic(Coalescence(collision_kernel=Geometric()))
51
65
 
52
66
  self.r_dry, n_in_unit_volume = Logarithmic(
53
67
  spectrum=settings.dry_radii_spectrum,
@@ -80,6 +94,12 @@ class Simulation(BasicSimulation):
80
94
  PeakSupersaturation(name="S_max"),
81
95
  ParcelDisplacement(name="z"),
82
96
  Time(name="t"),
97
+ ActivatedMeanRadius(
98
+ name="r_mean_act", count_activated=True, count_unactivated=False
99
+ ),
100
+ RadiusStandardDeviation(
101
+ name="r_std_act", count_activated=True, count_unactivated=False
102
+ ),
83
103
  ),
84
104
  )
85
105
  )
@@ -93,7 +113,9 @@ class Simulation(BasicSimulation):
93
113
  def run(
94
114
  self, *, n_steps: int = 2250, steps_per_output_interval: int = 10
95
115
  ): # TODO #1266: essentially copied from G & P 2023
96
- output_products = super()._run(n_steps, steps_per_output_interval)
116
+ output_products = super()._run(
117
+ nt=n_steps, steps_per_output_interval=steps_per_output_interval
118
+ )
97
119
  return {"products": output_products, "attributes": self.output_attributes}
98
120
 
99
121
  def _save(self, output): # TODO #1266: copied from G&P 2023
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PySDM-examples
3
- Version: 2.49
3
+ Version: 2.52
4
4
  Summary: PySDM usage examples reproducing results from literature and depicting how to use PySDM from Python Jupyter notebooks
5
5
  Home-page: https://github.com/open-atmos/PySDM
6
6
  Author: https://github.com/open-atmos/PySDM/graphs/contributors
@@ -198,14 +198,14 @@ Requires-Dist: nbconvert ; extra == 'tests'
198
198
  [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_1.ipynb)
199
199
  [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_1.ipynb)
200
200
  [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_1.ipynb)
201
- - Fig. 3:
202
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3.ipynb)
203
- [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3.ipynb)
204
- [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3.ipynb)
205
- - Fig. 4:
206
- [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4.ipynb)
207
- [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4.ipynb)
208
- [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4.ipynb)
201
+ - Fig. 3 and Tab. 4 (upper rows):
202
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3_and_Tab_4_upper_rows.ipynb)
203
+ [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3_and_Tab_4_upper_rows.ipynb)
204
+ [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_3_and_Tab_4_upper_rows.ipynb)
205
+ - Fig. 4 and 7, Tab. 4 (bottom rows):
206
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4_and_7_and_Tab_6_bottom_rows.ipynb)
207
+ [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4_and_7_and_Tab_6_bottom_rows.ipynb)
208
+ [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_4_and_7_and_Tab_6_bottom_rows.ipynb)
209
209
  - Fig. 5:
210
210
  [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_5.ipynb)
211
211
  [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_5.ipynb)
@@ -214,6 +214,10 @@ Requires-Dist: nbconvert ; extra == 'tests'
214
214
  [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_6.ipynb)
215
215
  [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_6.ipynb)
216
216
  [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_6.ipynb)
217
+ - Fig. 8:
218
+ [![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_8.ipynb)
219
+ [![launch on mybinder.org](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_8.ipynb)
220
+ [![launch on Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Jensen_and_Nugent_2017/Fig_8.ipynb)
217
221
 
218
222
  ### 0D parcel-model condensation/aqueous-chemistry example:
219
223
  - [Kreidenweis et al. 2003](https://doi.org/10.1029/2002JD002697) (Adiabatic parcel, polydisperse size spectrum, aqueous‐phase SO2 oxidation test case):
@@ -50,9 +50,9 @@ PySDM_examples/Grabowski_and_Pawlowska_2023/simulation.py,sha256=uXH0zfr4M4XZ81u
50
50
  PySDM_examples/Graf_et_al_2019/__init__.py,sha256=nT6uOv3PODePRUzFoyOfH_eOCjJkg5z9qS3tXy3USPc,140
51
51
  PySDM_examples/Jaruga_and_Pawlowska_2018/__init__.py,sha256=VJz_xFOhVvnqYHKbAPRnZQ3Vky6JEOZxBx8kV0kHIcg,161
52
52
  PySDM_examples/Jensen_and_Nugent_2017/__init__.py,sha256=3iMpMdkdy_BEBBhjD9WR-2HbRHn7dop8kEk2uJJYe9U,66
53
- PySDM_examples/Jensen_and_Nugent_2017/plotting.py,sha256=-e6mkOIugGwfydBquGEEaW2JhJ6mI1-pl-7sT1p6v08,2181
54
- PySDM_examples/Jensen_and_Nugent_2017/settings.py,sha256=rok_FJJxfB9kOeWbKPONmtfV1DOX0RRihcBW2HVGeks,2134
55
- PySDM_examples/Jensen_and_Nugent_2017/simulation.py,sha256=g_S1w9vnwzwcpc7U6571zR_fswmHP2bOwTH4r7ZiZ7M,3989
53
+ PySDM_examples/Jensen_and_Nugent_2017/plotting.py,sha256=J0lWibUFQq4aHTAPlql9DNj_JiMinlwZgRlsUs8y-I0,3607
54
+ PySDM_examples/Jensen_and_Nugent_2017/settings.py,sha256=Dz7kZgEWACpl3mNMawfp1aAeIBbjrw1GAVFNni8plSM,2195
55
+ PySDM_examples/Jensen_and_Nugent_2017/simulation.py,sha256=8paqkCVt5XtuVav5e2FM1s98aOw6NE-5oycu7aRHeLM,4722
56
56
  PySDM_examples/Jensen_and_Nugent_2017/table_3.py,sha256=HVhqXwNIqkUyl0k718qVaZaf0lnENWpE-sjqj5b08bc,952
57
57
  PySDM_examples/Kreidenweis_et_al_2003/__init__.py,sha256=9QbrxhPe0QJxboGKeqHhq9rrvQ5VUcjTpqWgWsxnM1E,225
58
58
  PySDM_examples/Kreidenweis_et_al_2003/settings.py,sha256=iS7rZINn4EyxSsy_0CvQeGAz6ZyB-don1OCY7q_M21c,2836
@@ -139,7 +139,7 @@ PySDM_examples/utils/read_vtk_1d.py,sha256=7_3sagEbX_FxqFuGkFWdwQapd1-9echFghU8T
139
139
  PySDM_examples/utils/widgets/__init__.py,sha256=U67WZ2YDcXSocMraI7pzcMxCfcxzXNqehDzoG6ogsh4,519
140
140
  PySDM_examples/utils/widgets/freezer.py,sha256=tFlZWShXUzA2X0cxgeE44N1g9kD33q3KQWZBqkgBP0A,407
141
141
  PySDM_examples/utils/widgets/progbar_updater.py,sha256=3uhG32QkAiSM3dTV7DoROJl7fAUNA6ZsJEIKSg3tdmk,267
142
- PySDM_examples-2.49.dist-info/METADATA,sha256=wDGKl9UYNtJ9Q-iYpsQUjdRX6jcA7FF-BTPfCLL41-8,36124
143
- PySDM_examples-2.49.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
144
- PySDM_examples-2.49.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
145
- PySDM_examples-2.49.dist-info/RECORD,,
142
+ PySDM_examples-2.52.dist-info/METADATA,sha256=xuByUiy34iZpSnggSzaSQDsUATVYE0lKbNcdu_SDhJE,36960
143
+ PySDM_examples-2.52.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
144
+ PySDM_examples-2.52.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
145
+ PySDM_examples-2.52.dist-info/RECORD,,