forked from yt-project/yt_idv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
committing some lingering changes, prob dont want to merge
- Loading branch information
1 parent
1d2961c
commit 2564a96
Showing
7 changed files
with
3,764 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
yt\_idv package | ||
=============== | ||
|
||
Subpackages | ||
----------- | ||
|
||
.. toctree:: | ||
:maxdepth: 4 | ||
|
||
yt_idv.cameras | ||
yt_idv.rendering_contexts | ||
yt_idv.scene_annotations | ||
yt_idv.scene_components | ||
yt_idv.scene_data | ||
yt_idv.shaders | ||
|
||
Submodules | ||
---------- | ||
|
||
yt\_idv.cli module | ||
------------------ | ||
|
||
.. automodule:: yt_idv.cli | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.constants module | ||
------------------------ | ||
|
||
.. automodule:: yt_idv.constants | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.gui\_support module | ||
--------------------------- | ||
|
||
.. automodule:: yt_idv.gui_support | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.opengl\_support module | ||
------------------------------ | ||
|
||
.. automodule:: yt_idv.opengl_support | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.scene\_graph module | ||
--------------------------- | ||
|
||
.. automodule:: yt_idv.scene_graph | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.shader\_objects module | ||
------------------------------ | ||
|
||
.. automodule:: yt_idv.shader_objects | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.simple\_gui module | ||
-------------------------- | ||
|
||
.. automodule:: yt_idv.simple_gui | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.traitlets\_support module | ||
--------------------------------- | ||
|
||
.. automodule:: yt_idv.traitlets_support | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.utilities module | ||
------------------------ | ||
|
||
.. automodule:: yt_idv.utilities | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.utilities module | ||
------------------------ | ||
|
||
.. automodule:: yt_idv.utilities | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.utilities module | ||
------------------------ | ||
|
||
.. automodule:: yt_idv.utilities | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.utilities module | ||
------------------------ | ||
|
||
.. automodule:: yt_idv.utilities | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
yt\_idv.yt\_idv module | ||
---------------------- | ||
|
||
.. automodule:: yt_idv.yt_idv | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: yt_idv | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
yt\_idv.shaders package | ||
======================= | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: yt_idv.shaders | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import yt | ||
|
||
import yt_idv | ||
|
||
ds = yt.load_sample("IsolatedGalaxy") | ||
c = ds.domain_center | ||
le = c - ds.quan(.05, 'code_length') | ||
re = c + ds.quan(.05, 'code_length') | ||
r = ds.region(c, le, re) | ||
rc = yt_idv.render_context(height=800, width=800, gui=True) | ||
sg = rc.add_scene(r, "density", no_ghost=True) | ||
rc.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# https://github.com/pyimgui/pyimgui/blob/master/doc/examples/integrations_pyglet.py | ||
from __future__ import absolute_import | ||
from pyglet import gl | ||
from testwindow import show_test_window | ||
import pyglet | ||
import imgui | ||
import sys | ||
|
||
|
||
# Note that we could explicitly choose to use PygletFixedPipelineRenderer | ||
# or PygletProgrammablePipelineRenderer, but create_renderer handles the | ||
# version checking for us. | ||
from imgui.integrations.pyglet import create_renderer | ||
|
||
|
||
def main(): | ||
|
||
window = pyglet.window.Window(width=1280, height=720, resizable=True) | ||
gl.glClearColor(1, 1, 1, 1) | ||
imgui.create_context() | ||
impl = create_renderer(window) | ||
|
||
global show_custom_window | ||
show_custom_window = True | ||
|
||
def update(dt): | ||
impl.process_inputs() | ||
imgui.new_frame() | ||
if imgui.begin_main_menu_bar(): | ||
if imgui.begin_menu("File", True): | ||
|
||
clicked_quit, selected_quit = imgui.menu_item( | ||
"Quit", "Cmd+Q", False, True | ||
) | ||
|
||
if clicked_quit: | ||
sys.exit(0) | ||
|
||
imgui.end_menu() | ||
imgui.end_main_menu_bar() | ||
|
||
show_test_window() | ||
# imgui.show_test_window() | ||
|
||
global show_custom_window | ||
if show_custom_window: | ||
is_expand, show_custom_window = imgui.begin("Custom window", True) | ||
if is_expand: | ||
imgui.text("Bar") | ||
imgui.text_colored("Eggs", 0.2, 1.0, 0.0) | ||
|
||
imgui.text_ansi("B\033[31marA\033[mnsi ") | ||
imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1.0, 0.0) | ||
|
||
imgui.end() | ||
|
||
def draw(dt): | ||
update(dt) | ||
window.clear() | ||
imgui.render() | ||
impl.render(imgui.get_draw_data()) | ||
|
||
pyglet.clock.schedule_interval(draw, 1 / 120.0) | ||
pyglet.app.run() | ||
impl.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import sys | ||
|
||
import numpy as np | ||
import yt | ||
|
||
import yt_idv | ||
|
||
# yt reminder: phi is the polar angle (0 to 2pi) | ||
# theta is the angle from north (0 to pi) | ||
|
||
|
||
# coord ordering here will be r, phi, theta | ||
|
||
bbox_options = { | ||
"partial": np.array([[0.5, 1.0], [0.0, np.pi / 4], [np.pi / 4, np.pi / 2]]), | ||
"whole": np.array([[0.1, 1.0], [0.0, 2 * np.pi], [0, np.pi]]), | ||
"north_hemi": np.array([[0.1, 1.0], [0.0, 2 * np.pi], [0, 0.5 * np.pi]]), | ||
"south_hemi": np.array([[0.1, 1.0], [0.0, 2 * np.pi], [0.5 * np.pi, np.pi]]), | ||
"ew_hemi": np.array([[0.1, 1.0], [0.0, np.pi], [0.0, np.pi]]), | ||
} | ||
|
||
bbox = bbox_options['whole'] | ||
sz = (256, 256, 256) | ||
fake_data = {"density": np.random.random(sz)} | ||
|
||
def _neato(field, data): | ||
r = data['index', 'r'].d | ||
theta = data['index', 'theta'].d | ||
phi = data['index', 'phi'].d | ||
phi_c = 0.25 * np.pi | ||
theta_c = 0.5 * np.pi | ||
|
||
# decay away from phi_c, theta_c | ||
fac = np.exp(-((phi_c - phi) / 0.5) ** 2) * np.exp(-((theta_c - theta) / 0.5) ** 2) | ||
# cos^2 variation in r with slight increase towards rmin | ||
rfac = np.cos((r - 0.1)/0.9 * 3 * np.pi)**2 * (1 - 0.25 * (r - 0.1)/0.9) | ||
field = fac * rfac + 0.1 * np.random.random(r.shape) | ||
|
||
# field = field * (theta <= 2.0) * (phi < 1.25) | ||
return field | ||
|
||
yt.add_field( | ||
name=("stream", "neat"), | ||
function=_neato, | ||
sampling_type="local", | ||
units="", | ||
) | ||
|
||
|
||
ds = yt.load_uniform_grid( | ||
fake_data, | ||
sz, | ||
bbox=bbox, | ||
nprocs=4096, | ||
geometry=("spherical", ("r", "phi", "theta")), | ||
length_unit="m", | ||
) | ||
|
||
rc = yt_idv.render_context(height=800, width=800, gui=True) | ||
dd = ds.all_data() | ||
dd.max_level = 1 | ||
sg = rc.add_scene(ds, ("stream", "neat"), no_ghost=True) | ||
# sg = rc.add_scene(ds, ("index", "theta"), no_ghost=True) | ||
# sg = rc.add_scene(ds, ("index", "phi"), no_ghost=True) | ||
sg.camera.focus = [0.0, 0.0, 0.0] | ||
rc.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
import yt | ||
|
||
import yt_idv | ||
|
||
# Spherical Test (to line 20) | ||
|
||
NDIM = 32 | ||
|
||
# default ordering: r, theta (0 to pi angle), phi (0 to 2pi angle) | ||
# bbox = np.array( | ||
# [[0.0, 0.5], [np.pi / 8, 2 * np.pi / 8], [2 * np.pi / 8, 3 * np.pi / 8]] | ||
# ) | ||
bbox = np.array( | ||
[[0.0, 0.5], [0.1, 2*np.pi-0.1], [0.1, np.pi-0.1]] | ||
) | ||
|
||
fake_data = {"density": np.random.random((NDIM, NDIM, NDIM))} | ||
ds = yt.load_uniform_grid( | ||
fake_data, | ||
[NDIM, NDIM, NDIM], | ||
bbox=bbox, | ||
geometry="spherical", | ||
) | ||
|
||
rc = yt_idv.render_context(height=800, width=800, gui=True) | ||
dd = ds.all_data() | ||
dd.max_level = 1 | ||
sg = rc.add_scene(ds, ("index", "r"), no_ghost=True) | ||
sg.camera.focus = [0.0, 0.0, 0.0] | ||
rc.run() | ||
|
||
# Cartesian Test (to line 25) | ||
# ds = yt.load_sample("IsolatedGalaxy") | ||
# rc = yt_idv.render_context(height=800, width=800, gui=True) | ||
# sg = rc.add_scene(ds, "density", no_ghost=True) | ||
# rc.run() |
Oops, something went wrong.