PySDM-examples 2.126__py3-none-any.whl → 2.128__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.
@@ -26,6 +26,8 @@ class SpectrumPlotter(SuperSpectrumPlotter):
26
26
  self.ticks()
27
27
  show_plot()
28
28
 
29
- def plot(self, spectrum, t):
29
+ def plot(
30
+ self, spectrum, t, label=None, color=None, title=None, add_error_to_label=False
31
+ ):
30
32
  settings = self.settings
31
- self.plot_data(settings, t, spectrum)
33
+ self.plot_data(settings, t, spectrum, label, color)
@@ -81,12 +81,16 @@ class SpectrumPlotter:
81
81
  self.finish()
82
82
  pyplot.savefig(file, format=self.format)
83
83
 
84
- def plot(self, spectrum, t):
85
- error = self.plot_analytic_solution(self.settings, t, spectrum)
86
- self.plot_data(self.settings, t, spectrum)
84
+ def plot(
85
+ self, spectrum, t, label=None, color=None, title=None, add_error_to_label=False
86
+ ):
87
+ error = self.plot_analytic_solution(self.settings, t, spectrum, title)
88
+ if label is not None and add_error_to_label:
89
+ label += f" error={error:.4g}"
90
+ self.plot_data(self.settings, t, spectrum, label, color)
87
91
  return error
88
92
 
89
- def plot_analytic_solution(self, settings, t, spectrum=None):
93
+ def plot_analytic_solution(self, settings, t, spectrum, title):
90
94
  if t == 0:
91
95
  analytic_solution = settings.spectrum.size_distribution
92
96
  else:
@@ -123,11 +127,13 @@ class SpectrumPlotter:
123
127
  if spectrum is not None:
124
128
  y = spectrum * si.kilograms / si.grams
125
129
  error = error_measure(y, y_true, x)
126
- self.title = f"error measure: {error:.2f}" # TODO #327 relative error
130
+ self.title = (
131
+ title or f"error measure: {error:.2f}"
132
+ ) # TODO #327 relative error
127
133
  return error
128
134
  return None
129
135
 
130
- def plot_data(self, settings, t, spectrum):
136
+ def plot_data(self, settings, t, spectrum, label, color):
131
137
  if self.smooth:
132
138
  scope = self.smooth_scope
133
139
  if t != 0:
@@ -144,18 +150,16 @@ class SpectrumPlotter:
144
150
  self.ax.plot(
145
151
  (x[:-1] + dx / 2) * si.metres / si.micrometres,
146
152
  spectrum[:-scope] * si.kilograms / si.grams,
147
- label=f"t = {t}s",
148
- color=self.colors(
149
- t / (self.settings.output_steps[-1] * self.settings.dt)
150
- ),
153
+ label=label or f"t = {t}s",
154
+ color=color
155
+ or self.colors(t / (self.settings.output_steps[-1] * self.settings.dt)),
151
156
  )
152
157
  else:
153
158
  self.ax.step(
154
159
  settings.radius_bins_edges[:-1] * si.metres / si.micrometres,
155
160
  spectrum * si.kilograms / si.grams,
156
161
  where="post",
157
- label=f"t = {t}s",
158
- color=self.colors(
159
- t / (self.settings.output_steps[-1] * self.settings.dt)
160
- ),
162
+ label=label or f"t = {t}s",
163
+ color=color
164
+ or self.colors(t / (self.settings.output_steps[-1] * self.settings.dt)),
161
165
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pysdm-examples
3
- Version: 2.126
3
+ Version: 2.128
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
@@ -37,7 +37,7 @@ PySDM_examples/Berry_1967/__init__.py,sha256=V_JEnFtNsts2m6K7MYiXiq1nnCfRVp74-Ix
37
37
  PySDM_examples/Berry_1967/example.py,sha256=r0WlZ0R4Y4RiDIsLlq3RG_R9YSvCSrizWGjg3mh0WgQ,2506
38
38
  PySDM_examples/Berry_1967/example_fig_6.py,sha256=z9CzfCIlsB-OFfsS2fPZ5eE3C_Clx0CCRwD11c42JC8,3101
39
39
  PySDM_examples/Berry_1967/settings.py,sha256=9VmVS4zBTGQff-xBdxb9AjUB9iNNm-qMznURH0ESfwE,1617
40
- PySDM_examples/Berry_1967/spectrum_plotter.py,sha256=uwSZJQ2G3zuxml3on9IMCiWIldv7gIzWOqNw75hLFmI,1016
40
+ PySDM_examples/Berry_1967/spectrum_plotter.py,sha256=DsY5nDl3Kczbyo2Jl8H_cUvxFktVlBllM9TY0S9368M,1106
41
41
  PySDM_examples/Bieli_et_al_2022/__init__.py,sha256=23wE81iNNkeNmr3PRTs0WC29gEfTDAZCNv7x0BuI2IU,205
42
42
  PySDM_examples/Bieli_et_al_2022/settings.py,sha256=qJxoGChzqta-c_O2yv4E3wEM4yoECa2dyhKmE8AGrtI,1679
43
43
  PySDM_examples/Bieli_et_al_2022/simulation.py,sha256=4L0AxnpGjfWqIUgVdZdH1PgXzrx4yXEeJ8_WaWsksy8,1324
@@ -100,7 +100,7 @@ PySDM_examples/Shima_et_al_2009/error_measure.py,sha256=YkaGvvest25O5TYV3_jBt1ow
100
100
  PySDM_examples/Shima_et_al_2009/example.py,sha256=Pdf8YYO-OVHSEhIarl7Nu80vOAKX6l9sAlFPhKZySJo,2351
101
101
  PySDM_examples/Shima_et_al_2009/example_timing.py,sha256=ArX9MGIxHnNX3OWYMbI_kKlnJpCtkgMMrYdOOqXzBE4,1816
102
102
  PySDM_examples/Shima_et_al_2009/settings.py,sha256=X9YI5OrBXJk68vE0HDeQxc1yk_gVUjZ7UhMUKugEHa0,1176
103
- PySDM_examples/Shima_et_al_2009/spectrum_plotter.py,sha256=hoqj14hA1gWbrNOwaYQRche9y5_LOSZaE84kFp4cCHo,5381
103
+ PySDM_examples/Shima_et_al_2009/spectrum_plotter.py,sha256=98y_ofVp8qm60xVDQ-llPm9kqaBXKDh5AZpZXTZ0_-c,5623
104
104
  PySDM_examples/Shima_et_al_2009/tutorial_example.py,sha256=GQp-sHFVHOXgETTTcme5p5h0R2iTRkz_i1HxuHAheC4,1623
105
105
  PySDM_examples/Shima_et_al_2009/tutorial_plotter.py,sha256=5gV9T0YnUFKuAL77ci0cmYMi6h9IvNi-X_J3_Nv6tIs,4191
106
106
  PySDM_examples/Shima_et_al_2009/tutorial_settings.py,sha256=nTe_rKAIPpXwnh52mDBrU4_We5lLu_1140jzXIlLY84,1176
@@ -159,7 +159,7 @@ PySDM_examples/utils/kinematic_2d/storage.py,sha256=NaGoujCRLubSEbhLA0QZDaSkATpJ
159
159
  PySDM_examples/utils/widgets/__init__.py,sha256=U67WZ2YDcXSocMraI7pzcMxCfcxzXNqehDzoG6ogsh4,519
160
160
  PySDM_examples/utils/widgets/freezer.py,sha256=tFlZWShXUzA2X0cxgeE44N1g9kD33q3KQWZBqkgBP0A,407
161
161
  PySDM_examples/utils/widgets/progbar_updater.py,sha256=3uhG32QkAiSM3dTV7DoROJl7fAUNA6ZsJEIKSg3tdmk,267
162
- pysdm_examples-2.126.dist-info/METADATA,sha256=W25mcgg7qG4IPe-HRx7rKo3uy8wZ2FQOWuh8jQe4iK4,12977
163
- pysdm_examples-2.126.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
- pysdm_examples-2.126.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
165
- pysdm_examples-2.126.dist-info/RECORD,,
162
+ pysdm_examples-2.128.dist-info/METADATA,sha256=dU8trAgiJ8FCeGFZ3zkLXLV5Dd_h_52B-5tThp2nUe8,12977
163
+ pysdm_examples-2.128.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
+ pysdm_examples-2.128.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
165
+ pysdm_examples-2.128.dist-info/RECORD,,