Skip to content

Commit

Permalink
remove leftovers and add todo for binder
Browse files Browse the repository at this point in the history
  • Loading branch information
AgnieszkaZaba committed Jan 6, 2025
1 parent 3a91b9b commit 57117fb
Showing 1 changed file with 79 additions and 91 deletions.
170 changes: 79 additions & 91 deletions examples/PySDM_examples/_HOWTOs/paraview_hello_world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,49 @@
"id": "35dba30bf42bd326",
"metadata": {},
"source": [
"# TODO #1417\n",
"### TODO #1417 add description\n",
"### TODO #1490 fix installation on binder\n",
"For more informations about Paraview please refere to [Paraview documentation](https://docs.paraview.org/en/latest/Tutorials/SelfDirectedTutorial/)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "93289adf665b5c7f",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T14:57:08.851435Z",
"start_time": "2025-01-04T14:57:08.842847Z"
"end_time": "2025-01-06T20:42:41.598955Z",
"start_time": "2025-01-06T20:42:41.591955Z"
}
},
"outputs": [],
"source": [
"import sys\n",
"if 'google.colab' in sys.modules:\n",
" !pip --quiet install open-atmos-jupyter-utils\n",
" from open_atmos_jupyter_utils import pip_install_on_colab\n",
" pip_install_on_colab('PySDM-examples')"
],
"outputs": [],
"execution_count": 1
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e3537b5faa81e11f",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T14:57:10.031680Z",
"start_time": "2025-01-04T14:57:08.863432Z"
"end_time": "2025-01-06T20:42:48.835403Z",
"start_time": "2025-01-06T20:42:42.286569Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"paraview version 5.13.1\n"
]
}
],
"source": [
"import os\n",
"import subprocess\n",
Expand All @@ -64,19 +75,19 @@
"# check if Paraview's pvpython works\n",
"assert subprocess.check_call(['pvpython', '--version'], env=SUBPROCESS_ENV) == 0\n",
"assert subprocess.check_call(['pvpython', '-c', 'import paraview'], env=SUBPROCESS_ENV) == 0"
],
"outputs": [],
"execution_count": 2
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ee889545",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T14:57:15.918262Z",
"start_time": "2025-01-04T14:57:10.295179Z"
"end_time": "2025-01-06T20:42:48.845075Z",
"start_time": "2025-01-06T20:42:48.842291Z"
}
},
"outputs": [],
"source": [
"from PySDM_examples.Arabas_et_al_2015 import Settings, SpinUp\n",
"from PySDM_examples.Szumowski_et_al_1998 import Simulation, Storage\n",
Expand All @@ -85,26 +96,24 @@
"from PySDM import products as PySDM_products\n",
"import glob\n",
"import platform"
],
"outputs": [],
"execution_count": 3
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f0d2581f",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T14:57:15.945363Z",
"start_time": "2025-01-04T14:57:15.933868Z"
"end_time": "2025-01-06T20:42:49.673689Z",
"start_time": "2025-01-06T20:42:49.664256Z"
}
},
"outputs": [],
"source": [
"products = [\n",
" PySDM_products.EffectiveRadius(unit='um')\n",
"]"
],
"outputs": [],
"execution_count": 4
]
},
{
"cell_type": "markdown",
Expand All @@ -116,41 +125,41 @@
},
{
"cell_type": "code",
"execution_count": 5,
"id": "74c00944",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:03:18.403970Z",
"start_time": "2025-01-04T14:57:15.965579Z"
"end_time": "2025-01-06T20:43:31.937868Z",
"start_time": "2025-01-06T20:42:51.814553Z"
}
},
"source": [
"settings = Settings()\n",
"storage = Storage()\n",
"simulation = Simulation(settings, storage, SpinUp=SpinUp)\n",
"simulation.reinit(products)\n",
"\n",
"vtk_exporter = VTKExporter(path='.') \n",
"\n",
"simulation.run(ProgBarController(\"progress:\"), vtk_exporter=vtk_exporter)\n",
"vtk_exporter.write_pvd()"
],
"outputs": [
{
"data": {
"text/plain": [
"FloatProgress(value=0.0, description='progress:', max=1.0)"
],
"application/vnd.jupyter.widget-view+json": {
"model_id": "f9d581fdc60345ff804d5265fc156e1c",
"version_major": 2,
"version_minor": 0,
"model_id": "f013821cddf341048a3c20161a40854b"
}
"version_minor": 0
},
"text/plain": [
"FloatProgress(value=0.0, description='progress:', max=1.0)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": 5
"source": [
"settings = Settings()\n",
"storage = Storage()\n",
"simulation = Simulation(settings, storage, SpinUp=SpinUp)\n",
"simulation.reinit(products)\n",
"\n",
"vtk_exporter = VTKExporter(path='.') \n",
"\n",
"simulation.run(ProgBarController(\"progress:\"), vtk_exporter=vtk_exporter)\n",
"vtk_exporter.write_pvd()"
]
},
{
"cell_type": "markdown",
Expand All @@ -162,34 +171,23 @@
},
{
"cell_type": "code",
"id": "94041d98fa896fba",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:03:18.439457Z",
"start_time": "2025-01-04T15:03:18.425464Z"
}
},
"source": [
"if 'google.colab' in sys.modules:\n",
" !apt-get -qq install python3-paraview\n",
" \n",
" # Workaround for a bug in Ubuntu package described here\n",
" # (https://discourse.paraview.org/t/paraview-error-while-loading-shared-libraries-libpdal-base-so-13-cannot-open-shared-object-file/14000);\n",
" # with solution taken from that comment: https://github.com/qgis/QGIS/issues/52433#issuecomment-1792285094.\n",
" ! if [ ! -f /usr/lib/libpdal_base.so.13 ]; then ln -s /usr/lib/libpdal_base.so.15 /usr/lib/libpdal_base.so.13; fi "
],
"outputs": [],
"execution_count": 6
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2030d8e7",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:03:18.482635Z",
"start_time": "2025-01-04T15:03:18.467440Z"
"end_time": "2025-01-06T20:43:32.052989Z",
"start_time": "2025-01-06T20:43:32.046624Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting pvscript.py\n"
]
}
],
"source": [
"%%writefile pvscript.py\n",
"\n",
Expand Down Expand Up @@ -326,17 +324,7 @@
" Rasterize3Dgeometry= False,\n",
" GL2PSdepthsortmethod= 'BSP sorting (slow, best)',\n",
" )"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing pvscript.py\n"
]
}
],
"execution_count": 7
]
},
{
"cell_type": "markdown",
Expand All @@ -348,29 +336,29 @@
},
{
"cell_type": "code",
"execution_count": 7,
"id": "79477d3d",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:04:44.043703Z",
"start_time": "2025-01-04T15:03:18.514614Z"
"end_time": "2025-01-06T20:44:22.171797Z",
"start_time": "2025-01-06T20:43:32.099529Z"
}
},
"source": [
"subprocess.run(['pvpython', '--force-offscreen-rendering', 'pvscript.py'], check=platform.system() != 'Windows', env=SUBPROCESS_ENV)"
],
"outputs": [
{
"data": {
"text/plain": [
"CompletedProcess(args=['pvpython', '--force-offscreen-rendering', 'pvscript.py'], returncode=0)"
]
},
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 8
"source": [
"subprocess.run(['pvpython', '--force-offscreen-rendering', 'pvscript.py'], check=platform.system() != 'Windows', env=SUBPROCESS_ENV)"
]
},
{
"cell_type": "markdown",
Expand All @@ -382,34 +370,34 @@
},
{
"cell_type": "code",
"execution_count": 8,
"id": "23e0cf61",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:04:44.161581Z",
"start_time": "2025-01-04T15:04:44.148424Z"
"end_time": "2025-01-06T20:44:32.623050Z",
"start_time": "2025-01-06T20:44:22.257021Z"
}
},
"outputs": [],
"source": [
"if platform.system() != 'Windows':\n",
" for file in glob.glob('output/anim_frame_*.pdf'):\n",
" subprocess.run(['ps2pdf', file, file+'_'], capture_output=True, check=True)\n",
" subprocess.run(['mv', file+'_', file], check=True)"
],
"outputs": [],
"execution_count": 9
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d3e4a35",
"metadata": {
"ExecuteTime": {
"end_time": "2025-01-04T15:04:44.232427Z",
"start_time": "2025-01-04T15:04:44.228714Z"
"end_time": "2025-01-06T20:42:10.669031Z",
"start_time": "2025-01-06T20:42:10.667667Z"
}
},
"source": [],
"outputs": [],
"execution_count": null
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 57117fb

Please sign in to comment.