Skip to content

Commit

Permalink
update the volume rendering scripts for the subchandra problem
Browse files Browse the repository at this point in the history
these seem to work
  • Loading branch information
zingale committed Sep 17, 2023
1 parent 4fdc98e commit 7685d7c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 57 deletions.
25 changes: 9 additions & 16 deletions Exec/science/subchandra/analysis/vol-abar-subch.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env python

import matplotlib
matplotlib.use('agg')

import numpy as np
# render Abar for the subchandra problem setup

import sys

import matplotlib
import numpy as np

import yt
from yt.frontends.boxlib.api import CastroDataset
import numpy as np
#from yt.visualization.volume_rendering.render_source import VolumeSource
from yt.visualization.volume_rendering.api import create_volume_source, Scene
from yt.units import cm
#from yt.visualization.volume_rendering.render_source import VolumeSource
from yt.visualization.volume_rendering.api import Scene, create_volume_source

matplotlib.use('agg')

# this is for the wdconvect problem

def doit(plotfile):

Expand All @@ -26,13 +26,6 @@ def doit(plotfile):

sc = Scene()


# add a volume: select a sphere
#center = (0, 0, 0)
#R = (5.e8, 'cm')

#dd = ds.sphere(center, R)

vol = create_volume_source(ds.all_data(), field=field)
sc.add_source(vol)

Expand Down Expand Up @@ -71,7 +64,7 @@ def doit(plotfile):

cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.])
cam.set_width(ds.domain_width)
#cam.zoom(3.0)
cam.zoom(3.0)
sc.camera = cam

sc.save_annotated("{}_abar_annotated.png".format(plotfile),
Expand Down
23 changes: 9 additions & 14 deletions Exec/science/subchandra/analysis/vol-enuc-subch.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env python

import matplotlib
matplotlib.use('agg')

import numpy as np
# render enuc for the subchandra problem setup

import sys

import matplotlib
import numpy as np

import yt
from yt.frontends.boxlib.api import CastroDataset
import numpy as np
#from yt.visualization.volume_rendering.render_source import VolumeSource
from yt.visualization.volume_rendering.api import create_volume_source, Scene
from yt.units import cm
from yt.visualization.volume_rendering.api import Scene, create_volume_source

matplotlib.use('agg')


# this is for the wdconvect problem

Expand Down Expand Up @@ -40,12 +41,6 @@ def doit(plotfile):
sc = Scene()


# add a volume: select a sphere
#center = (0, 0, 0)
#R = (5.e8, 'cm')

#dd = ds.sphere(center, R)

vol = create_volume_source(ds.all_data(), field=field)
sc.add_source(vol)

Expand Down Expand Up @@ -84,7 +79,7 @@ def doit(plotfile):

cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.])
cam.set_width(ds.domain_width)
#cam.zoom(3.0)
cam.zoom(3.0)
sc.camera = cam

sc.save_annotated("{}_enuc_annotated.png".format(plotfile),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env python

import matplotlib
matplotlib.use('agg')

import numpy as np
# render Temperature for the subchandra problem setup

import sys

import matplotlib
import numpy as np

import yt
from yt.frontends.boxlib.api import CastroDataset
import numpy as np
#from yt.visualization.volume_rendering.render_source import VolumeSource
from yt.visualization.volume_rendering.api import create_volume_source, Scene
from yt.units import cm
#from yt.visualization.volume_rendering.render_source import VolumeSource
from yt.visualization.volume_rendering.api import Scene, create_volume_source

matplotlib.use('agg')

# this is for the wdconvect problem

def doit(plotfile):

Expand All @@ -26,38 +26,28 @@ def doit(plotfile):

sc = Scene()


# add a volume: select a sphere
#center = (0, 0, 0)
#R = (5.e8, 'cm')

#dd = ds.sphere(center, R)

vol = create_volume_source(ds.all_data(), field=field)
sc.add_source(vol)


# transfer function
vals_tmp = [5.e7, 1.e8, 5.e8, 1.e9, 2.e9, 2.5e9, 3.e9]
_vals = [5.e7, 1.e8, 2.e8, 5.e8, 1.e9, 2.e9, 5.e9]
vals = []
for v in vals_tmp:
for v in _vals:
vals.append(np.log10(v))

alpha = [0.1, 0.1, 0.2, 0.3, 0.3, 0.4, 0.5]

sigma = 0.05

tf = yt.ColorTransferFunction((min(vals), max(vals)))

tf.clear()

cmap = "viridis"

for v in vals:
if v < 9.01:
alpha = 0.25
else:
alpha = 0.75
cmap = "Oranges"

tf.sample_colormap(v, sigma**2, alpha=alpha, colormap=cmap)
for v, a in zip(vals, alpha):
tf.sample_colormap(v, sigma**2, alpha=a, colormap=cmap)

sc.get_source(0).transfer_function = tf

Expand All @@ -79,10 +69,10 @@ def doit(plotfile):

cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.])
cam.set_width(ds.domain_width)
#cam.zoom(3.0)
cam.zoom(3.0)
sc.camera = cam

sc.save_annotated("{}_Hnuc_annotated.png".format(plotfile),
sc.save_annotated("{}_Temp_annotated.png".format(plotfile),
text_annotate=[[(0.05, 0.05),
"t = {}".format(ds.current_time.d),
dict(horizontalalignment="left")],
Expand Down

0 comments on commit 7685d7c

Please sign in to comment.