PySDM_examples.Szumowski_et_al_1998.gui

 1import os
 2import sys
 3
 4from open_atmos_jupyter_utils import TemporaryFile
 5from PySDM_examples.Szumowski_et_al_1998.gui_controller import GUIController
 6from PySDM_examples.Szumowski_et_al_1998.gui_viewer import GUIViewer
 7from PySDM_examples.utils.widgets import HTML, Tab, VBox, display
 8
 9from PySDM.exporters import NetCDFExporter
10
11
12def launch(settings, simulation, storage):
13    ncdf_file = TemporaryFile(".nc")
14    ncdf_exporter = NetCDFExporter(
15        storage, settings, simulation, ncdf_file.absolute_path
16    )
17
18    vtk_file = TemporaryFile(".zip")
19
20    viewer = GUIViewer(storage, settings)
21    controller = GUIController(simulation, viewer, ncdf_exporter, ncdf_file, vtk_file)
22
23    controller_box = controller.box()
24
25    tabs = Tab([VBox([controller_box, viewer.box()]), settings.box()])
26    tabs.set_title(1, "Settings")
27    tabs.set_title(0, "Simulation")
28    tabs.observe(controller.reinit, "selected_index")
29
30    # https://github.com/googlecolab/colabtools/issues/1302
31    hack = (
32        "<link"
33        ' rel="stylesheet"'
34        ' href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"'
35        "> "
36    )
37    if "google.colab" in sys.modules:
38        display(HTML(hack))
39
40    display(tabs)
41
42    if "CI" in os.environ:
43        controller_box.children[1].click()
def launch(settings, simulation, storage):
13def launch(settings, simulation, storage):
14    ncdf_file = TemporaryFile(".nc")
15    ncdf_exporter = NetCDFExporter(
16        storage, settings, simulation, ncdf_file.absolute_path
17    )
18
19    vtk_file = TemporaryFile(".zip")
20
21    viewer = GUIViewer(storage, settings)
22    controller = GUIController(simulation, viewer, ncdf_exporter, ncdf_file, vtk_file)
23
24    controller_box = controller.box()
25
26    tabs = Tab([VBox([controller_box, viewer.box()]), settings.box()])
27    tabs.set_title(1, "Settings")
28    tabs.set_title(0, "Simulation")
29    tabs.observe(controller.reinit, "selected_index")
30
31    # https://github.com/googlecolab/colabtools/issues/1302
32    hack = (
33        "<link"
34        ' rel="stylesheet"'
35        ' href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"'
36        "> "
37    )
38    if "google.colab" in sys.modules:
39        display(HTML(hack))
40
41    display(tabs)
42
43    if "CI" in os.environ:
44        controller_box.children[1].click()