PySDM-examples 2.119__py3-none-any.whl → 2.121__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.
@@ -0,0 +1,11 @@
1
+ # pylint: disable=invalid-name
2
+ """
3
+ based on the [Jouzel and Merlivat 1984](https://doi.org/10.1029/JD089iD07p11749) calculations
4
+ of delta_{18O} and delta_D used in d-excess formula and solved
5
+ by integration of the eq. (1) in
6
+ [Fisher 1991](https://doi.org/10.3402/tellusb.v43i5.15414) and eq. (3) in Jouzel and Merlivat 1984
7
+
8
+
9
+ fig_2.ipynb:
10
+ .. include:: ./fig_2.ipynb.badges.md
11
+ """
@@ -0,0 +1,11 @@
1
+ # pylint: disable=invalid-name
2
+ """
3
+ kinetic fractionation factors used in modelling isotopic effect
4
+ in snow formation, replacing saturation fractionation factors with
5
+ alpha_{saturation} alpha_{kinetic}
6
+ (see [Jouzel and Merlivat 1984](https://doi.org/10.1029/JD089iD07p11749))
7
+
8
+
9
+ fig_8_9.ipynb:
10
+ .. include:: ./fig_8_9.ipynb.badges.md
11
+ """
@@ -0,0 +1,32 @@
1
+ """
2
+ From [Jouzel & Merlivat 1984](https://doi.org/10.1029/JD089iD07p11749).
3
+ """
4
+
5
+ import numpy as np
6
+ from scipy.interpolate import make_interp_spline
7
+
8
+ from PySDM.physics.constants_defaults import T0
9
+ from PySDM.physics import si
10
+
11
+
12
+ pressure = make_interp_spline(
13
+ x=np.asarray([-10, -20, -30, -40, -50])[::-1] + T0,
14
+ y=np.asarray([925, 780, 690, 630, 600])[::-1] * si.mbar,
15
+ )
16
+ """ Table 1, first two columns: temperature and pressure"""
17
+ pressure.extrapolate = False
18
+
19
+
20
+ def ice_saturation_curve_4(const, T):
21
+ """eq. (15)"""
22
+ return 0.99 - 0.006 * (T - const.T0)
23
+
24
+
25
+ def vapour_mixing_ratio(formulae, T):
26
+ """mixing ratio with saturation wrt ice calculated with curve 4 equation"""
27
+ const = formulae.constants
28
+ svp = formulae.saturation_vapour_pressure
29
+ p_v = ice_saturation_curve_4(const, T) * svp.pvs_ice(T)
30
+ rho_v = p_v / const.Rv / T
31
+ rho_d = (pressure(T) - p_v) / const.Rd / T
32
+ return rho_v / rho_d
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/env pvpython
2
+ import argparse
3
+ from collections import namedtuple
4
+ import pathlib
5
+
6
+ from paraview import simple as pvs # pylint: disable=import-error
7
+
8
+ pvs._DisableFirstRenderCameraReset()
9
+
10
+
11
+ def cli_using_argparse(argp):
12
+ argp.add_argument("product_path", help="path to pvd products file")
13
+ argp.add_argument("attributes_path", help=" path to pvd attributes file")
14
+ argp.add_argument("output_path", help="path where to write output files")
15
+ argp.add_argument(
16
+ "--multiplicity_preset",
17
+ default="Inferno (matplotlib)",
18
+ help="Preset for multiplicity",
19
+ )
20
+ argp.add_argument(
21
+ "--multiplicity_logscale",
22
+ action="store_false",
23
+ help="Use log scale for multiplicity",
24
+ )
25
+ argp.add_argument(
26
+ "--effectiveradius_preset",
27
+ default="Black, Blue and White",
28
+ help="Preset for effectiveradius",
29
+ )
30
+ argp.add_argument(
31
+ "--effectiveradius_logscale",
32
+ action="store_false",
33
+ help="Use log scale for effectiveradius",
34
+ )
35
+ argp.add_argument(
36
+ "--effectiveradius_nan_color",
37
+ nargs=3,
38
+ type=float,
39
+ default=[0.666, 0.333, 1.0],
40
+ help="Nan color in RGB format for effectiveradius",
41
+ )
42
+ argp.add_argument(
43
+ "--sd_products_opacity", type=float, default=0.9, help="Opacity for sd_products"
44
+ )
45
+ argp.add_argument(
46
+ "--calculator1_opacity",
47
+ type=float,
48
+ default=0.19,
49
+ help="Opacity for calculator1",
50
+ )
51
+ argp.add_argument(
52
+ "--sd_attributes_opacity",
53
+ type=float,
54
+ default=0.77,
55
+ help="Opacity for sd_attributes",
56
+ )
57
+ argp.add_argument(
58
+ "--animationframename",
59
+ type=str,
60
+ help="Name of the file with animation last frame",
61
+ )
62
+ argp.add_argument(
63
+ "--animationname",
64
+ type=str,
65
+ help="Name of the file with animation",
66
+ )
67
+ argp.add_argument(
68
+ "--framerate", type=int, help="Number of frame rates.", default=15
69
+ )
70
+
71
+
72
+ ap = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
73
+ cli_using_argparse(ap)
74
+
75
+ args = ap.parse_args()
76
+ sd_productspvd = pvs.OpenDataFile(args.product_path)
77
+ sd_attributespvd = pvs.OpenDataFile(args.attributes_path)
78
+
79
+
80
+ setup = {
81
+ "renderView1": pvs.GetActiveViewOrCreate("RenderView"),
82
+ "sd_attributespvdDisplay": pvs.GetDisplayProperties(
83
+ sd_attributespvd, view=pvs.GetActiveViewOrCreate("RenderView")
84
+ ),
85
+ "effectiveradiusLUT": pvs.GetColorTransferFunction("effectiveradius"),
86
+ "sd_productspvdDisplay": pvs.GetDisplayProperties(
87
+ sd_productspvd, view=pvs.GetActiveViewOrCreate("RenderView")
88
+ ),
89
+ }
90
+
91
+ setup = namedtuple("Setup", setup.keys())(**setup)
92
+
93
+ setup.effectiveradiusLUT.RescaleTransferFunction(0.1380997175392798, 207.7063518856934)
94
+
95
+ setup.renderView1.Update()
96
+
97
+
98
+ def create_new_calculator(
99
+ calcinput,
100
+ representation,
101
+ function,
102
+ color_by1,
103
+ color_by2,
104
+ color_by3,
105
+ scalar_coloring=False,
106
+ hide=False,
107
+ *,
108
+ y,
109
+ registrationame,
110
+ ):
111
+ calculator = pvs.Calculator(registrationName=registrationame, Input=calcinput)
112
+ display = pvs.Show(calculator, y.renderView1, representation)
113
+ calculator.Function = function
114
+ y.renderView1.Update()
115
+ if scalar_coloring is True:
116
+ pvs.ColorBy(display, (color_by1, color_by2, color_by3))
117
+ if hide is True:
118
+ pvs.Hide(calculator, y.renderView1)
119
+ return y.renderView1.Update()
120
+
121
+
122
+ def scalar_bar(name, *, y, erLUT):
123
+ calculator1Display = pvs.Show(
124
+ calculator1, y.renderView1, "UnstructuredGridRepresentation"
125
+ )
126
+ calculator1Display.SetScalarBarVisibility(y.renderView1, True)
127
+ scalarBar = pvs.GetScalarBar(erLUT.effectiveradiusLUT, y.renderView1)
128
+ scalarBar.ComponentTitle = ""
129
+ scalarBar.Title = name
130
+ y.renderView1.Update()
131
+
132
+
133
+ def create_glyph(
134
+ registration_name, put, scale_array1, scale_array2, color_by=False, *, y
135
+ ):
136
+ glyph = pvs.Glyph(registrationName=registration_name, Input=put, GlyphType="Arrow")
137
+ glyphDisplay = pvs.Show(glyph, y.renderView1, "GeometryRepresentation")
138
+ glyphDisplay.Representation = "Surface"
139
+ glyph.ScaleArray = [scale_array1, scale_array2]
140
+ glyph.ScaleFactor = 100
141
+ glyphDisplay.SetScalarBarVisibility(y.renderView1, True)
142
+ if color_by is True:
143
+ glyphDisplay.ColorArrayName = ["POINTS", ""]
144
+ pvs.ColorBy(glyphDisplay, None)
145
+ y.renderView1.Update()
146
+
147
+
148
+ def apply_presets_logscale_opacity_and_update(*, y, attdisplay, erLUT, proddisplay):
149
+ multiplicityLUT = pvs.GetColorTransferFunction("multiplicity")
150
+ multiplicityLUT.RescaleTransferFunction(19951.0, 50461190157.0)
151
+ calculator1Display = pvs.Show(
152
+ calculator1, y.renderView1, "UnstructuredGridRepresentation"
153
+ )
154
+ multiplicityLUT.ApplyPreset(args.multiplicity_preset, True)
155
+ if args.multiplicity_logscale:
156
+ multiplicityLUT.MapControlPointsToLogSpace()
157
+ multiplicityLUT.UseLogScale = 1
158
+ else:
159
+ multiplicityLUT.MapControlPointsToLinearSpace()
160
+ multiplicityLUT.UseLogScale = 0
161
+
162
+ erLUT.effectiveradiusLUT.ApplyPreset(args.effectiveradius_preset, True)
163
+ if args.effectiveradius_logscale:
164
+ erLUT.effectiveradiusLUT.MapControlPointsToLogSpace()
165
+ erLUT.effectiveradiusLUT.UseLogScale = 1
166
+ else:
167
+ erLUT.effectiveradiusLUT.MapControlPointsToLinearSpace()
168
+ erLUT.effectiveradiusLUT.UseLogScale = 0
169
+
170
+ erLUT.effectiveradiusLUT.NanColor = args.effectiveradius_nan_color
171
+
172
+ proddisplay.sd_productspvdDisplay.SetRepresentationType("Surface With Edges")
173
+ proddisplay.sd_productspvdDisplay.Opacity = args.sd_products_opacity
174
+ calculator1Display.Opacity = args.calculator1_opacity
175
+ attdisplay.sd_attributespvdDisplay.Opacity = args.sd_attributes_opacity
176
+
177
+ y.renderView1.Update()
178
+
179
+
180
+ def get_layout(*, y):
181
+ layout1 = pvs.GetLayout()
182
+ layout1.SetSize(1205, 739)
183
+ y.renderView1.Update()
184
+
185
+
186
+ def set_current_camera_placement(*, y):
187
+ y.renderView1.InteractionMode = "2D"
188
+ y.renderView1.CameraPosition = [
189
+ 836.5045867211775,
190
+ 677.8909274570431,
191
+ -4098.0762113533165,
192
+ ]
193
+ y.renderView1.CameraFocalPoint = [836.5045867211775, 677.8909274570431, 0.0]
194
+ y.renderView1.CameraViewUp = [1.0, 0.0, 0.0]
195
+ y.renderView1.CameraParallelScale = 1060.6601717798205
196
+ y.renderView1.Update()
197
+
198
+
199
+ def axes_settings(*, view):
200
+ view.ViewSize = [2000, 800]
201
+ view.Background = [1, 1, 1]
202
+ view.CenterAxesVisibility = True
203
+ view.OrientationAxesVisibility = True
204
+ axesGrid = view.AxesGrid
205
+ axesGrid.Visibility = True
206
+ axesGrid.XTitle = "Z [m]"
207
+ axesGrid.YTitle = "X [m]"
208
+
209
+ axesGrid.XAxisUseCustomLabels = True
210
+ axesGrid.XAxisLabels = [300, 600, 900, 1200]
211
+ axesGrid.YAxisUseCustomLabels = True
212
+ axesGrid.YAxisLabels = [300, 600, 900, 1200]
213
+
214
+ axesGrid.XTitleFontSize = 30
215
+ axesGrid.XLabelFontSize = 30
216
+ axesGrid.YTitleFontSize = 30
217
+ axesGrid.YLabelFontSize = 30
218
+
219
+ axesGrid.XTitleColor = [1.0, 1.0, 1.0]
220
+ axesGrid.XLabelColor = [1.0, 1.0, 1.0]
221
+ axesGrid.YTitleColor = [1.0, 1.0, 1.0]
222
+ axesGrid.YLabelColor = [1.0, 1.0, 1.0]
223
+ axesGrid.GridColor = [0.1, 0.1, 0.1]
224
+ view.CenterAxesVisibility = False
225
+ view.Update()
226
+
227
+
228
+ def time_annotation(*, y):
229
+ time = pvs.AnnotateTimeFilter(
230
+ guiName="AnnotateTimeFilter1", Format="Time:{time:f}s"
231
+ )
232
+ pvs.Show(time, y.renderView1)
233
+ y.renderView1.Update()
234
+
235
+
236
+ def text(text_in, position_y, *, view):
237
+ sentence = pvs.Text()
238
+ sentence.Text = text_in
239
+ textDisplay = pvs.Show(sentence, view)
240
+ textDisplay.Color = [1.0, 1.0, 1.0]
241
+ textDisplay.WindowLocation = "Any Location"
242
+ textDisplay.FontSize = 16
243
+ textDisplay.Position = [0.01, position_y]
244
+
245
+
246
+ def last_anim_frame(animation_frame_name):
247
+ time_steps = sd_productspvd.TimestepValues
248
+ last_time = time_steps[len(time_steps) - 1]
249
+ setup.renderView1.ViewTime = last_time
250
+ for reader in (sd_productspvd,):
251
+ reader.UpdatePipeline(last_time)
252
+ pvs.ExportView(
253
+ filename=str(pathlib.Path(args.output_path) / animation_frame_name),
254
+ view=setup.renderView1,
255
+ Rasterize3Dgeometry=False,
256
+ GL2PSdepthsortmethod="BSP sorting (slow, best)",
257
+ )
258
+ pvs.RenderAllViews()
259
+
260
+
261
+ calculator1 = create_new_calculator(
262
+ sd_attributespvd,
263
+ "UnstructuredGridRepresentation",
264
+ '"relative fall velocity"*(-iHat)',
265
+ "None",
266
+ "None",
267
+ "None",
268
+ y=setup,
269
+ registrationame="Calculator1",
270
+ )
271
+ scalar_bar("effective radius [um]", y=setup, erLUT=setup)
272
+ create_glyph("Glyph1", calculator1, "POINTS", "relative fall velocity", y=setup)
273
+ calculator2 = create_new_calculator(
274
+ sd_productspvd,
275
+ "StructuredGridRepresentation",
276
+ "cx*jHat+cy*iHat",
277
+ "CELLS",
278
+ "Result",
279
+ "Magnitude",
280
+ True,
281
+ True,
282
+ y=setup,
283
+ registrationame="Calculator2",
284
+ )
285
+ apply_presets_logscale_opacity_and_update(
286
+ y=setup, attdisplay=setup, erLUT=setup, proddisplay=setup
287
+ )
288
+ create_glyph("Glyph2", calculator2, "CELLS", "Result", True, y=setup)
289
+ get_layout(y=setup)
290
+ set_current_camera_placement(y=setup)
291
+ axes_settings(view=setup.renderView1)
292
+ time_annotation(y=setup)
293
+ text("Arrows scale with Courant number C=u*Δt/Δx,", 0.7, view=setup.renderView1)
294
+ text("reflecting the grid spacing Δx and Δy.", 0.65, view=setup.renderView1)
295
+ last_anim_frame(animation_frame_name=args.animationframename)
296
+ scene = pvs.GetAnimationScene()
297
+ scene.UpdateAnimationUsingDataTimeSteps()
298
+ pvs.Render(setup.renderView1)
299
+ pvs.SaveAnimation(
300
+ str(pathlib.Path(args.output_path) / args.animationname),
301
+ setup.renderView1,
302
+ FrameRate=args.framerate,
303
+ )
304
+ pvs.RenderAllViews()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pysdm-examples
3
- Version: 2.119
3
+ Version: 2.121
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
@@ -77,7 +77,10 @@ The 2D prescribed-flow framework used here can be traced back to the work of
77
77
  implementation of the <a href="https://doi.org/10.1002/fld.1071">MPDATA numerical scheme of Smolarkiewicz (e.g., 2006)</a>.
78
78
  An animation depicting PySDM simulation capturing <mark>aerosol collisional processing</mark> by warm rain is shown below:
79
79
 
80
- ![animation](https://github.com/open-atmos/PySDM/wiki/files/kinematic_2D_example.gif)
80
+ <video controls style="width:100%">
81
+ <source src="https://github.com/open-atmos/PySDM/releases/download/tip/docs_intro_animation_ubuntu-24.04.mp4" type="video/mp4">
82
+ Your browser does not support the video tag.
83
+ </video>
81
84
 
82
85
  Example notebooks:
83
86
  - <a href="https://open-atmos.github.io/PySDM/PySDM_examples/Arabas_et_al_2015.html">Arabas_et_al_2015</a>
@@ -49,6 +49,7 @@ PySDM_examples/Bulenok_2023_MasterThesis/setups.py,sha256=UVTp0oBMblcR46J29aylfZ
49
49
  PySDM_examples/Bulenok_2023_MasterThesis/utils.py,sha256=T4UfPCPAaSal8paE4i1PTB4YSMEccqHMq-Z6ky9mABI,7813
50
50
  PySDM_examples/Ervens_and_Feingold_2012/__init__.py,sha256=F9Q-77npT6TyIK1vdNS4RPeBb8g4mFBUYz5qg4pj2wo,159
51
51
  PySDM_examples/Ervens_and_Feingold_2012/settings.py,sha256=DtkcDqkcO2WAkH63P1RQ19cejn0oAamdsZefN3y0Gy8,442
52
+ PySDM_examples/Fisher_1991/__init__.py,sha256=o02EkJ4mGIwhL6iUQuLVpnTUG_-hJYL_H2GnY52XA-E,380
52
53
  PySDM_examples/Gedzelman_and_Arnold_1994/__init__.py,sha256=P721EPYBc_zDk2Jb2pPGvTaT76uGzvX6vbpG93hReMw,303
53
54
  PySDM_examples/Gonfiantini_1986/__init__.py,sha256=6nCHStg2YE7FmBLbzqpRyYu4Qed-KhjaL7ddlPfT7PI,312
54
55
  PySDM_examples/Grabowski_and_Pawlowska_2023/__init__.py,sha256=kVhbqVh19GhJSKcXCae2XKaIKFj5-5bRuG2ll8gCTYw,534
@@ -61,6 +62,8 @@ PySDM_examples/Jensen_and_Nugent_2017/plotting.py,sha256=J0lWibUFQq4aHTAPlql9DNj
61
62
  PySDM_examples/Jensen_and_Nugent_2017/settings.py,sha256=Dz7kZgEWACpl3mNMawfp1aAeIBbjrw1GAVFNni8plSM,2195
62
63
  PySDM_examples/Jensen_and_Nugent_2017/simulation.py,sha256=fVeLHWxHq8yPPGBL9hikpv22Mw3XCHMF1z3H3q2oJiw,4870
63
64
  PySDM_examples/Jensen_and_Nugent_2017/table_3.py,sha256=HVhqXwNIqkUyl0k718qVaZaf0lnENWpE-sjqj5b08bc,952
65
+ PySDM_examples/Jouzel_and_Merlivat_1984/__init__.py,sha256=F6dn78N1NfJ7oscex2QQpcjhaLVentTeEbKDyZM1-N8,335
66
+ PySDM_examples/Jouzel_and_Merlivat_1984/thermodynamic_profiles.py,sha256=yUjYZdZr5Vbqc5C350pMXg19TL6bYcNtOrAn5NAKxZQ,928
64
67
  PySDM_examples/Kinzer_And_Gunn_1951/__init__.py,sha256=Lk7NTowyycY5ggzhnaQMlLK6Vn6w6WIhqHIScmng-fw,118
65
68
  PySDM_examples/Kinzer_And_Gunn_1951/table_1_and_2.py,sha256=2ywIQ2EzjdpXF_wjCglDTh9srqoFTxPTaVcethSsu5M,3130
66
69
  PySDM_examples/Kreidenweis_et_al_2003/__init__.py,sha256=0xRsFFFsU05TVO8Ocm7XavOLw2khLUZ27ARbMvGvCpI,276
@@ -152,11 +155,12 @@ PySDM_examples/utils/__init__.py,sha256=kf3zKLHnQkH5inbjfzaapfDy5ACDeU8efmbJtRVJ
152
155
  PySDM_examples/utils/basic_simulation.py,sha256=4EdgD0p8EKNNcqYYVSlGm1MG2ac7_6heQdwS-kp-Tmw,698
153
156
  PySDM_examples/utils/dummy_controller.py,sha256=f1AjVNXPnDhhD15GkBFtJthDf7jZivDrppj79guYc_w,741
154
157
  PySDM_examples/utils/progbar_controller.py,sha256=IXk7rkXUOBKP7EQe6zLHUpnCPwtE2LuEeho5lxdsewA,470
158
+ PySDM_examples/utils/pvanim.py,sha256=ZkYuwCAsvsS4zqX4DMcPH124rzGR-LNvU60iOBMeWfE,9615
155
159
  PySDM_examples/utils/read_vtk_1d.py,sha256=7_3sagEbX_FxqFuGkFWdwQapd1-9echFghU8TSNvGuw,966
156
160
  PySDM_examples/utils/widgets/__init__.py,sha256=U67WZ2YDcXSocMraI7pzcMxCfcxzXNqehDzoG6ogsh4,519
157
161
  PySDM_examples/utils/widgets/freezer.py,sha256=tFlZWShXUzA2X0cxgeE44N1g9kD33q3KQWZBqkgBP0A,407
158
162
  PySDM_examples/utils/widgets/progbar_updater.py,sha256=3uhG32QkAiSM3dTV7DoROJl7fAUNA6ZsJEIKSg3tdmk,267
159
- pysdm_examples-2.119.dist-info/METADATA,sha256=vyLTTd74wkyepPAxq3M8NrLNuYe_qYZLmmEYmjn8fhA,12686
160
- pysdm_examples-2.119.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
161
- pysdm_examples-2.119.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
162
- pysdm_examples-2.119.dist-info/RECORD,,
163
+ pysdm_examples-2.121.dist-info/METADATA,sha256=w9u-T02Ew43i2q07WPNWLY2lpyRRC0d2qzl_3ssfpjU,12822
164
+ pysdm_examples-2.121.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
165
+ pysdm_examples-2.121.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
166
+ pysdm_examples-2.121.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5