Error making a movie with RAMSES data
Hi, I'm trying to make a movie by depositing particles on to the mesh:
import yt
from yt.visualization.volume_rendering.api import MeshSource
from yt.units import Myr
import yt.visualization.eps_writer as eps
from yt.data_objects.particle_filters import add_particle_filter
import pylab as plt
plt.switch_backend('agg')
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter = age.in_units('Myr') > 0
return filter
add_particle_filter("new_stars", function=star_filter, filtered_type="all", requires=["particle_age"])
ini=19
fin=21
CMAP = 'hot'
VMIN = 1e3
VMAX = 1e10
for x in range(ini, fin):
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_%0*d/info_%0*d.txt" % (5,x,5,x) ds=yt.load(filename) time = ds.current_time ds.add_particle_filter("new_stars") ms =MeshSource(ds, ('deposit', 'new_stars_density')) sc.add_camera(ds) camera_position = ds.arr([0, 0, 0], 'code_length') cam.focus = ds.domain_center north_vector = ds.arr([0, 0, 0], 'dimensionless') cam.width = ds.arr([ 400, 400, 400], 'kpc') cam.resolution = (800, 800)
cam.set_position(camera_position, north_vector)
# actually make the image here im = ms.render(cam, cmap=CMAP, color_bounds=(VMIN, VMAX)) plt.clf() fig = plt.gcf() ax = plt.gca() ax.imshow(im, interpolation='nearest', origin='lower') p = ax.imshow(ms.data, visible=False, cmap=CMAP, vmin=VMIN, vmax=VMAX) cb = fig.colorbar(p) cb.set_label(field_name[1]) ax.text(25, 750, 'time = %.2e' % time, color='k')
ax.axes.get_xaxis().set_visible(False)
plt.savefig('movie_frames/test_%.3d' % x) But ending up with error: Traceback (most recent call last): File "movie_new_stars.py", line 32, in <module> ms =MeshSource(ds, ('deposit', 'new_stars_density')) File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 536, in __init__ self.build_volume_embree() File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 593, in build_volume_embree mesh_id = int(ftype[-1]) - 1
ValueError: invalid literal for int() with base 10: 't'
Any leads on this are highly appreciated.
This failure is happening because the MeshSource only works with unstructured mesh data. It will not work with your RAMSES AMR data. Your best bet for volume rendering RAMSES data is to first deposit the data onto a uniform resolution mesh, reaload that data using yt.load_uniform_grid, and volume render the reloaded dataset. We currently do not support volume rendering RAMSES data. We realize this is something that a lot of users want but unfortunately do not have funded developer time right now for working on fixing that situation. Apologies for the trouble, hopefully this makes more sense now. -Nathan On Mon, Jan 7, 2019 at 4:30 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi, I'm trying to make a movie by depositing particles on to the mesh:
import yt
from yt.visualization.volume_rendering.api import MeshSource
from yt.units import Myr
import yt.visualization.eps_writer as eps
from yt.data_objects.particle_filters import add_particle_filter
import pylab as plt
plt.switch_backend('agg')
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter = age.in_units('Myr') > 0
return filter
add_particle_filter("new_stars", function=star_filter, filtered_type= "all", requires=["particle_age"])
ini=19
fin=21
CMAP = 'hot'
VMIN = 1e3
VMAX = 1e10
for x in range(ini, fin):
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_%0*d/info_%0*d.txt" % (5,x,5,x)
ds=yt.load(filename)
time = ds.current_time
ds.add_particle_filter("new_stars")
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
sc.add_camera(ds)
camera_position = ds.arr([0, 0, 0], 'code_length')
cam.focus = ds.domain_center
north_vector = ds.arr([0, 0, 0], 'dimensionless')
cam.width = ds.arr([ 400, 400, 400], 'kpc')
cam.resolution = (800, 800)
cam.set_position(camera_position, north_vector)
# actually make the image here
im = ms.render(cam, cmap=CMAP, color_bounds=(VMIN, VMAX))
plt.clf()
fig = plt.gcf()
ax = plt.gca()
ax.imshow(im, interpolation='nearest', origin='lower')
p = ax.imshow(ms.data, visible=False, cmap=CMAP, vmin=VMIN, vmax=VMAX)
cb = fig.colorbar(p)
cb.set_label(field_name[1])
ax.text(25, 750, 'time = %.2e' % time, color='k')
ax.axes.get_xaxis().set_visible(False)
plt.savefig('movie_frames/test_%.3d' % x)
But ending up with error:
Traceback (most recent call last):
File "movie_new_stars.py", line 32, in <module>
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 536, in __init__
self.build_volume_embree()
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 593, in build_volume_embree
mesh_id = int(ftype[-1]) - 1
ValueError: invalid literal for int() with base 10: 't'
Any leads on this are highly appreciated.
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Thanks for the suggestion. However, this is how I'm doing it, but not sure if this is the right way to proceed as I end up with an error:
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_00051/info_00051.txt"
ds=yt.load(filename
ad=ds.all_data()
dd=ds.arbitrary_grid(left_edge=[0,0,0], right_edge=[1,1,1], dims=[ 512,512,512])
data=dd[('deposit', 'new_stars_density')]
bbox=np.array([[0,1],[0,1],[0,1]])
ds=yt.load_uniform_grid(data, data.shape, bbox)
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
ERROR:
Traceback (most recent call last):
File "movie_new_stars.py", line 36, in <module>
ds=yt.load_uniform_grid(data, data.shape, bbox)
File
"/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py",
line 666, in load_uniform_grid
data, grid_dims=tuple(domain_dimensions))
File
"/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py",
line 477, in process_data
for field, val in data.items():
Thanks!
On Mon, Jan 7, 2019 at 7:27 PM Nathan Goldbaum
This failure is happening because the MeshSource only works with unstructured mesh data. It will not work with your RAMSES AMR data.
Your best bet for volume rendering RAMSES data is to first deposit the data onto a uniform resolution mesh, reaload that data using yt.load_uniform_grid, and volume render the reloaded dataset.
We currently do not support volume rendering RAMSES data. We realize this is something that a lot of users want but unfortunately do not have funded developer time right now for working on fixing that situation.
Apologies for the trouble, hopefully this makes more sense now.
-Nathan
On Mon, Jan 7, 2019 at 4:30 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi, I'm trying to make a movie by depositing particles on to the mesh:
import yt
from yt.visualization.volume_rendering.api import MeshSource
from yt.units import Myr
import yt.visualization.eps_writer as eps
from yt.data_objects.particle_filters import add_particle_filter
import pylab as plt
plt.switch_backend('agg')
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter = age.in_units('Myr') > 0
return filter
add_particle_filter("new_stars", function=star_filter, filtered_type= "all", requires=["particle_age"])
ini=19
fin=21
CMAP = 'hot'
VMIN = 1e3
VMAX = 1e10
for x in range(ini, fin):
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_%0*d/info_%0*d.txt" % (5,x,5,x)
ds=yt.load(filename)
time = ds.current_time
ds.add_particle_filter("new_stars")
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
sc.add_camera(ds)
camera_position = ds.arr([0, 0, 0], 'code_length')
cam.focus = ds.domain_center
north_vector = ds.arr([0, 0, 0], 'dimensionless')
cam.width = ds.arr([ 400, 400, 400], 'kpc')
cam.resolution = (800, 800)
cam.set_position(camera_position, north_vector)
# actually make the image here
im = ms.render(cam, cmap=CMAP, color_bounds=(VMIN, VMAX))
plt.clf()
fig = plt.gcf()
ax = plt.gca()
ax.imshow(im, interpolation='nearest', origin='lower')
p = ax.imshow(ms.data, visible=False, cmap=CMAP, vmin=VMIN, vmax=VMAX)
cb = fig.colorbar(p)
cb.set_label(field_name[1])
ax.text(25, 750, 'time = %.2e' % time, color='k')
ax.axes.get_xaxis().set_visible(False)
plt.savefig('movie_frames/test_%.3d' % x)
But ending up with error:
Traceback (most recent call last):
File "movie_new_stars.py", line 32, in <module>
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 536, in __init__
self.build_volume_embree()
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 593, in build_volume_embree
mesh_id = int(ftype[-1]) - 1
ValueError: invalid literal for int() with base 10: 't'
Any leads on this are highly appreciated.
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Did you cut off the error message? I think there are more lines. The problem here is that "data" should be a dictionary mapping a field name to a 3D array: data = {'star_density': dd[('deposit', 'new_stars_density')]} That should get past the error you are currently seeing. You will then hit another error because the MeshSource is only appropriate to use with unstructured mesh data. Take a look at the volume rendering documentation for more detail about how to use the volume renderer: http://yt-project.org/doc/visualizing/volume_rendering.html In particular you should be able to use yt.create_scene with the reloaded dataset. -Nathan On Tue, Jan 8, 2019 at 11:45 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the suggestion. However, this is how I'm doing it, but not sure if this is the right way to proceed as I end up with an error:
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_00051/info_00051.txt"
ds=yt.load(filename
ad=ds.all_data()
dd=ds.arbitrary_grid(left_edge=[0,0,0], right_edge=[1,1,1], dims=[512,512,512])
data=dd[('deposit', 'new_stars_density')]
bbox=np.array([[0,1],[0,1],[0,1]])
ds=yt.load_uniform_grid(data, data.shape, bbox)
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
ERROR:
Traceback (most recent call last):
File "movie_new_stars.py", line 36, in <module>
ds=yt.load_uniform_grid(data, data.shape, bbox)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py", line 666, in load_uniform_grid
data, grid_dims=tuple(domain_dimensions))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py", line 477, in process_data for field, val in data.items(): Thanks!
On Mon, Jan 7, 2019 at 7:27 PM Nathan Goldbaum
wrote: This failure is happening because the MeshSource only works with unstructured mesh data. It will not work with your RAMSES AMR data.
Your best bet for volume rendering RAMSES data is to first deposit the data onto a uniform resolution mesh, reaload that data using yt.load_uniform_grid, and volume render the reloaded dataset.
We currently do not support volume rendering RAMSES data. We realize this is something that a lot of users want but unfortunately do not have funded developer time right now for working on fixing that situation.
Apologies for the trouble, hopefully this makes more sense now.
-Nathan
On Mon, Jan 7, 2019 at 4:30 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi, I'm trying to make a movie by depositing particles on to the mesh:
import yt
from yt.visualization.volume_rendering.api import MeshSource
from yt.units import Myr
import yt.visualization.eps_writer as eps
from yt.data_objects.particle_filters import add_particle_filter
import pylab as plt
plt.switch_backend('agg')
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter = age.in_units('Myr') > 0
return filter
add_particle_filter("new_stars", function=star_filter, filtered_type= "all", requires=["particle_age"])
ini=19
fin=21
CMAP = 'hot'
VMIN = 1e3
VMAX = 1e10
for x in range(ini, fin):
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_%0*d/info_%0*d.txt" % (5,x,5,x)
ds=yt.load(filename)
time = ds.current_time
ds.add_particle_filter("new_stars")
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
sc.add_camera(ds)
camera_position = ds.arr([0, 0, 0], 'code_length')
cam.focus = ds.domain_center
north_vector = ds.arr([0, 0, 0], 'dimensionless')
cam.width = ds.arr([ 400, 400, 400], 'kpc')
cam.resolution = (800, 800)
cam.set_position(camera_position, north_vector)
# actually make the image here
im = ms.render(cam, cmap=CMAP, color_bounds=(VMIN, VMAX))
plt.clf()
fig = plt.gcf()
ax = plt.gca()
ax.imshow(im, interpolation='nearest', origin='lower')
p = ax.imshow(ms.data, visible=False, cmap=CMAP, vmin=VMIN, vmax=VMAX)
cb = fig.colorbar(p)
cb.set_label(field_name[1])
ax.text(25, 750, 'time = %.2e' % time, color='k')
ax.axes.get_xaxis().set_visible(False)
plt.savefig('movie_frames/test_%.3d' % x)
But ending up with error:
Traceback (most recent call last):
File "movie_new_stars.py", line 32, in <module>
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 536, in __init__
self.build_volume_embree()
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 593, in build_volume_embree
mesh_id = int(ftype[-1]) - 1
ValueError: invalid literal for int() with base 10: 't'
Any leads on this are highly appreciated.
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
I see. I will try this. However, I noticed another issue with the 'data' where printing it gives me a zero array
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter=age.in_units('Myr')>0
return filter
data={'star_density':dd[('deposit', 'new_stars_density')]} print(data)
I tried replacing the 'deposit' field with a particle field
('particle_position_x') and I get non-zero values. Any suggestions in this
issue? I am basically trying to make a movie of new star particles
spawning and disappearing after certain time and appreciate if there's any
simpler alternative in yt to do this. Thanks!
On Tue, Jan 8, 2019 at 6:52 PM Nathan Goldbaum
Did you cut off the error message? I think there are more lines.
The problem here is that "data" should be a dictionary mapping a field name to a 3D array:
data = {'star_density': dd[('deposit', 'new_stars_density')]}
That should get past the error you are currently seeing.
You will then hit another error because the MeshSource is only appropriate to use with unstructured mesh data.
Take a look at the volume rendering documentation for more detail about how to use the volume renderer:
http://yt-project.org/doc/visualizing/volume_rendering.html
In particular you should be able to use yt.create_scene with the reloaded dataset.
-Nathan
On Tue, Jan 8, 2019 at 11:45 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Thanks for the suggestion. However, this is how I'm doing it, but not sure if this is the right way to proceed as I end up with an error:
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_00051/info_00051.txt"
ds=yt.load(filename
ad=ds.all_data()
dd=ds.arbitrary_grid(left_edge=[0,0,0], right_edge=[1,1,1], dims=[512,512,512])
data=dd[('deposit', 'new_stars_density')]
bbox=np.array([[0,1],[0,1],[0,1]])
ds=yt.load_uniform_grid(data, data.shape, bbox)
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
ERROR:
Traceback (most recent call last):
File "movie_new_stars.py", line 36, in <module>
ds=yt.load_uniform_grid(data, data.shape, bbox)
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py", line 666, in load_uniform_grid
data, grid_dims=tuple(domain_dimensions))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/frontends/stream/data_structures.py", line 477, in process_data for field, val in data.items(): Thanks!
On Mon, Jan 7, 2019 at 7:27 PM Nathan Goldbaum
wrote: This failure is happening because the MeshSource only works with unstructured mesh data. It will not work with your RAMSES AMR data.
Your best bet for volume rendering RAMSES data is to first deposit the data onto a uniform resolution mesh, reaload that data using yt.load_uniform_grid, and volume render the reloaded dataset.
We currently do not support volume rendering RAMSES data. We realize this is something that a lot of users want but unfortunately do not have funded developer time right now for working on fixing that situation.
Apologies for the trouble, hopefully this makes more sense now.
-Nathan
On Mon, Jan 7, 2019 at 4:30 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi, I'm trying to make a movie by depositing particles on to the mesh:
import yt
from yt.visualization.volume_rendering.api import MeshSource
from yt.units import Myr
import yt.visualization.eps_writer as eps
from yt.data_objects.particle_filters import add_particle_filter
import pylab as plt
plt.switch_backend('agg')
def star_filter(pfilter,data):
age = data["all", "particle_age"]
filter = age.in_units('Myr') > 0
return filter
add_particle_filter("new_stars", function=star_filter, filtered_type= "all", requires=["particle_age"])
ini=19
fin=21
CMAP = 'hot'
VMIN = 1e3
VMAX = 1e10
for x in range(ini, fin):
filename= "/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_%0*d/info_%0*d.txt" % (5,x,5,x)
ds=yt.load(filename)
time = ds.current_time
ds.add_particle_filter("new_stars")
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
sc.add_camera(ds)
camera_position = ds.arr([0, 0, 0], 'code_length')
cam.focus = ds.domain_center
north_vector = ds.arr([0, 0, 0], 'dimensionless')
cam.width = ds.arr([ 400, 400, 400], 'kpc')
cam.resolution = (800, 800)
cam.set_position(camera_position, north_vector)
# actually make the image here
im = ms.render(cam, cmap=CMAP, color_bounds=(VMIN, VMAX))
plt.clf()
fig = plt.gcf()
ax = plt.gca()
ax.imshow(im, interpolation='nearest', origin='lower')
p = ax.imshow(ms.data, visible=False, cmap=CMAP, vmin=VMIN, vmax=VMAX)
cb = fig.colorbar(p)
cb.set_label(field_name[1])
ax.text(25, 750, 'time = %.2e' % time, color='k')
ax.axes.get_xaxis().set_visible(False)
plt.savefig('movie_frames/test_%.3d' % x)
But ending up with error:
Traceback (most recent call last):
File "movie_new_stars.py", line 32, in <module>
ms =MeshSource(ds, ('deposit', 'new_stars_density'))
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 536, in __init__
self.build_volume_embree()
File "/home/samvad/yt-conda/lib/python3.6/site-packages/yt/visualization/volume_rendering/render_source.py", line 593, in build_volume_embree
mesh_id = int(ftype[-1]) - 1
ValueError: invalid literal for int() with base 10: 't'
Any leads on this are highly appreciated.
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (2)
-
Nathan Goldbaum
-
Vadlamani Samhitha