Hello all,
I have two questions:
1. When executing the script below, and printing
out the scene object (output summarized below script),
it shows two sources in the scene object. They're named
'source_00' and 'source_01' and
they appear to contain the same information. Does this
mean I have somehow accidentally created two sources
when only one would suffice?
2. Is there a way to render text inside a volume
rendering rather than on top? I'd like to put text in
the plot in the 3D coordinate space rather than the
flattened 2D space and place it so that it rotates and
moves with the camera.
Take care,
Andrew
--
Andrew W. Steiner
Joint Faculty Asst. Prof. at UTK/ORNL
https://neutronstars.utk.edu/
-------------------------------------------------------------------
import yt
import numpy as np
import h5py
import math
# Generate the data, a sum of two Gaussians centered at (0.4,0.3,0.2)
# and (0.4,0.3,0.8).
grid=128
arr=np.zeros(shape=(grid,grid,grid))
width=0.3
for i in range(0,grid):
x=i/127
for j in range(0,grid):
y=j/127
for k in range(0,grid):
z=k/127
arr[i][j][k]=(math.exp(-(x-0.4)**2/width**2-(y-0.3)**2/width**2-
(z-0.2)**2/width**2)+
math.exp(-(x-0.4)**2/width**2-(y-0.3)**2/width**2-
(z-0.8)**2/width**2))
# Create the data structure
data=dict(density=arr)
bbox=np.array([[0.0,1.0],[0.0,1.0],[0.0,1.0]])
ds=yt.load_uniform_grid(data,arr.shape,length_unit='cm',
bbox=bbox,periodicity=(False,False,False),
unit_system='cgs')
# Create the scene
sc=yt.create_scene(ds,'density')
source=sc[0]
source.log_field=False
tf_min=0.49
tf_max=0.51
tf=yt.ColorTransferFunction((tf_min,tf_max),grey_opacity=False)
tf.map_to_colormap(tf_min,tf_max,scale=1.0,colormap='algae')
source.set_transfer_function(tf)
sc.add_source(source)
# Create the camera
cam=sc.add_camera()
# Define the width of the image
cam.width=1.5*ds.domain_width[0]
# Specify the position and focus of the camera
cam.position=[0.2,0.3,0.1]
cam.focus=ds.domain_center
# Print out some of the details
print('-------------------------------------------------------------------')
print('Scene:')
print(sc)
print('-------------------------------------------------------------------')
# Draw the edges of the computational domain
sc.annotate_domain(ds,color=[1,1,1,0.01])
sc.save('temp.png',sigma_clip=1.0)
# End of python script
-------------------------------------------------------------------
Scene:
<Scene Object>:
Sources:
source_00: <Volume Source>:YTRegion (UniformGridData): ,
center=[0.5 0.5 0.5] cm, left_edge=[0. 0. 0.] cm, right_edge=[1. 1. 1.]
cm transfer_function:<Color Transfer Function Object>:
x_bounds:[0.49, 0.51] nbins:256 features:
('map_to_colormap', 'start(x):0.49', 'stop(x):0.51', 'value(y): 1')
source_01: <Volume Source>:YTRegion (UniformGridData): ,
center=[0.5 0.5 0.5] cm, left_edge=[0. 0. 0.] cm, right_edge=[1. 1. 1.]
cm transfer_function:<Color Transfer Function Object>:
x_bounds:[0.49, 0.51] nbins:256 features:
('map_to_colormap', 'start(x):0.49', 'stop(x):0.51', 'value(y): 1')
Camera:
...etc...
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org