Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 32 additions & 62 deletions GoVizzy/GoVizzy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
"execution_count": 1,
"id": "09026008-ce47-49d7-9fca-4b7c123022d1",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/mnt/d/Documents/GoVizzy/s24-slice-n-dice/.venv/lib/python3.11/site-packages/pandas/core/arrays/masked.py:60: UserWarning: Pandas requires version '1.3.6' or newer of 'bottleneck' (version '1.3.5' currently installed).\n",
" from pandas.core import (\n"
]
}
],
"outputs": [],
"source": [
"from widgets import form, test_slider\n",
"from widgets import form\n",
"from GoVizzy import plotting\n",
"import fileInput\n",
"import ipyvolume as ipv\n",
Expand All @@ -26,101 +17,80 @@
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ef52d91c-9d81-41db-953b-78f7ef718f24",
"execution_count": 14,
"id": "fe04527f-62f3-4397-8212-f62f4560b0b0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading data/rhopol.cube ...\n",
"Done.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/mnt/d/Documents/GoVizzy/s24-slice-n-dice/.venv/lib/python3.11/site-packages/ipyvolume/serialize.py:102: RuntimeWarning: invalid value encountered in cast\n",
" subdata[..., i] = ((gradient[i][zindex] / 2.0 + 0.5) * 255).astype(np.uint8)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5b191f581bee4041aab75cf105afc006",
"model_id": "d417625e59e9486f8b411a82d126211a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Container(children=[VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.1, max=1.0, step…"
"Box(children=(Box(children=(Label(value='Path to .cube file'), Textarea(value='')), layout=Layout(display='fle…"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
"cube: Cube = Cube()\n",
"cube.load_cube(\"data/rhopol.cube\")\n",
"visualizer = plotting.Visualizer(cube)\n",
"visualizer.display_cell()"
"form"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b9789df",
"execution_count": 21,
"id": "ef52d91c-9d81-41db-953b-78f7ef718f24",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "55ce3bd73d584814929063685ba6bef1",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Box(children=(Box(children=(Label(value='Path to .cube file'), Textarea(value='')), layout=Layout(display='fle…"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"Loading data/rhopol.cube ...\n",
"Done.\n"
]
}
],
"source": [
"form"
"cube: Cube = Cube()\n",
"cube.load_cube(\"data/rhopol.cube\")\n",
"visualizer = plotting.Visualizer(cube)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "67faad66-2beb-4746-b0a4-21689ddc78d3",
"execution_count": 22,
"id": "228e8c65-6896-448a-a18a-2791af8af5e5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ee19fc3f57014fd8b0ad844a2c0f723b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"5.5"
"Container(children=[VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.03, max=1.0, ste…"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
"output_type": "display_data"
}
],
"source": [
"# When testing, we can manually set slider values in code\n",
"test_slider.value = 5.5\n",
"test_slider.value"
"visualizer.display_cell()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f95553a4-1e87-4e59-bc6c-42b19a551d78",
"id": "1cc1723e-c0d2-43f6-a780-0e8343afe4b8",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -142,7 +112,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
5 changes: 4 additions & 1 deletion GoVizzy/GoVizzy/plotting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from widgets import color
from cube_viskit import Cube
import ipywidgets as widgets
import ipyvolume as ipv
Expand Down Expand Up @@ -95,5 +96,7 @@ def display_cell(self):
"""
cube = self.cube
ipv.figure()
ipv.pylab.volshow(cube.data3D)
transfer = ipv.pylab.transfer_function(level=[0.03, 0.5, 0.47], opacity=[0.05, 0.09, 0.1], level_width=0.1, controls=True)
ipv.style.background_color(color.value)
ipv.pylab.volshow(cube.data3D, ambient_coefficient=0.8, lighting=True, tf=transfer, controls=True)
ipv.show()