Skip to content

Commit

Permalink
update subchandra volume rendering scripts (#2557)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Sep 21, 2023
1 parent 2d1a487 commit c09896c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 68 deletions.
33 changes: 14 additions & 19 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,14 +64,16 @@ 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),
label_fontsize="18", label_fmt="%.1f",
sigma_clip=3,
text_annotate=[[(0.05, 0.05),
"t = {}".format(ds.current_time.d),
dict(horizontalalignment="left")],
[(0.5,0.95),
f"t = {ds.current_time.d:6.3f}",
dict(horizontalalignment="left", fontsize="18")],
[(0.5, 0.95),
"Castro simulation of double detonation SN Ia",
dict(color="y", fontsize="24",
horizontalalignment="center")]])
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/subchandra/analysis/vol-enuc-pos-subch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def doit(plotfile):
ds._get_field_info(field).take_log = True

vol = create_volume_source(ds.all_data(), field=field)
vol.use_ghost_zones = True
#vol.use_ghost_zones = True

vals = [18.0, 18.5, 19.0, 19.5, 20.0, 20.5, 21.0, 21.5, 22.0]
sigma = 0.1
Expand Down
31 changes: 13 additions & 18 deletions Exec/science/subchandra/analysis/vol-enuc-subch.py
Original file line number Diff line number Diff line change
@@ -1,20 +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

def _enuc_symlog(field, data):
f = np.log10(np.abs(data["boxlib", "enuc"]))
Expand All @@ -40,12 +39,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,14 +77,16 @@ 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),
label_fontsize="18",
sigma_clip=3,
text_annotate=[[(0.05, 0.05),
"t = {}".format(ds.current_time.d),
dict(horizontalalignment="left")],
[(0.5,0.95),
f"t = {ds.current_time.d:6.3f}",
dict(horizontalalignment="left", fontsize="18")],
[(0.5, 0.95),
"Castro simulation of double detonation SN Ia",
dict(color="y", fontsize="24",
horizontalalignment="center")]])
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,30 @@ 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)
#vol.use_ghost_zones = True

sc.add_source(vol)


# transfer function
vals_tmp = [5.e7, 1.e8, 5.e8, 1.e9, 2.e9, 2.5e9, 3.e9]
_vals = [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.05, 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,14 +71,16 @@ 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),
label_fontsize="18",
sigma_clip=3,
text_annotate=[[(0.05, 0.05),
"t = {}".format(ds.current_time.d),
dict(horizontalalignment="left")],
[(0.5,0.95),
f"t = {ds.current_time.d:6.3f}",
dict(horizontalalignment="left", fontsize="18")],
[(0.5, 0.95),
"Castro simulation of double detonation SN Ia",
dict(color="y", fontsize="24",
horizontalalignment="center")]])
Expand Down

0 comments on commit c09896c

Please sign in to comment.