Creating a sequence of volume renders of the enzo test problem: amr_simulation
I've just recently compiled enzo with grackle and run the enzo test problem: amr_cosmology. I've loaded the results using: ts = yt.load("/home/ian/enzo-grackle/run/CosmologySimulation/amr_cosmology/DD*/DD*") Inspecting ts, I see that it is a DatasetSeries object, with outputs: [DD0000, DD0000.boundary, DD0000.boundary.hdf, DD0000.configure, DD0000.cpu0000, DD0000.hierarchy, DD0000.memorymap, DD0001, DD0001.boundary, DD0001.boundary.hdf, DD0001.configure, DD0001.cpu0000, DD0001.hierarchy, DD0001.memorymap, DD0002, DD0002.boundary, DD0002.boundary.hdf, DD0002.configure, DD0002.cpu0000, DD0002.hierarchy, DD0002.memorymap, etc] As a first step in learning how to work with DatasetSeries, I'd like to generate a sequence of volume renders of density for each DD step. I presume that this will require me to access DD0000, DD0001, DD0002...etc sequentially inside a loop or iteration, while skipping the intervening DD.boundary, DD.boundary.hdf, DD.configure, DD.cpu0000, DD.hierarchy and DD.memorymap outputs at each step. I'm struggling to work out how to do this. Is anyone able to help me with a line or so of code to show me the way? Thanks Ian
Hi Ian, You can use ?s for a wildcard for individual characters. For your case, you'd do ts = yt.load("/home/ian/enzo-grackle/run/CosmologySimulation/amr_cosmology/DD????/DD????") Thanks, John On 8/26/21 6:55 AM, Ian Woodward wrote:
I've just recently compiled enzo with grackle and run the enzo test problem: amr_cosmology.
I've loaded the results using: ts = yt.load("/home/ian/enzo-grackle/run/CosmologySimulation/amr_cosmology/DD*/DD*")
Inspecting ts, I see that it is a DatasetSeries object, with outputs:
[DD0000, DD0000.boundary, DD0000.boundary.hdf, DD0000.configure, DD0000.cpu0000, DD0000.hierarchy, DD0000.memorymap, DD0001, DD0001.boundary, DD0001.boundary.hdf, DD0001.configure, DD0001.cpu0000, DD0001.hierarchy, DD0001.memorymap, DD0002, DD0002.boundary, DD0002.boundary.hdf, DD0002.configure, DD0002.cpu0000, DD0002.hierarchy, DD0002.memorymap, etc]
As a first step in learning how to work with DatasetSeries, I'd like to generate a sequence of volume renders of density for each DD step.
I presume that this will require me to access DD0000, DD0001, DD0002...etc sequentially inside a loop or iteration, while skipping the intervening DD.boundary, DD.boundary.hdf, DD.configure, DD.cpu0000, DD.hierarchy and DD.memorymap outputs at each step.
I'm struggling to work out how to do this. Is anyone able to help me with a line or so of code to show me the way?
Thanks
Ian _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: jwise@physics.gatech.edu
-- John Wise Professor of Physics Center for Relativistic Astrophysics, Georgia Tech http://cosmo.gatech.edu
Thanks John - yes, the DD????/DD???? format works the same way as the DD*/DD* format I'm using. I could load the data ok. My query was about accessing the DatasetSeries elements afterwards. I should have thought about it more before I posted. I had wrongly assumed that I needed to do something special because it was a DatasetSeries object but I've now realised that the object is just a list, so I've now achieved what I wanted simply with: for i in range(0, len(ts) - 1, 7): sc = yt.create_scene(ts[i], 'Density') sc.show() Thanks & cheers Ian
Whoops, it was every simpler. I didn't need to step: for i in range(len(ts) - 1): sc = yt.create_scene(ts[i], 'Density') sc.show() sc.save("/home/ian/enzo_test_problems/amr_simulation_step_by_step/step_%04i.png" % i)
The idiom that's used around in the docs is: for ds in ts: sc = yt.create_scene(ds, ("gas", "density")) ... e.g. https://yt-project.org/docs/dev/quickstart/data_objects_and_time_series.html Cheers, Kacper On 8/26/21 5:26 PM, Ian Woodward wrote:
Whoops, it was every simpler. I didn't need to step:
for i in range(len(ts) - 1): sc = yt.create_scene(ts[i], 'Density') sc.show() sc.save("/home/ian/enzo_test_problems/amr_simulation_step_by_step/step_%04i.png" % i) _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: xarthisius.kk@gmail.com
Thanks Kacper - that's definitely the way to do it. My naive way worked for small DatasetSeries but I found that for a ts with a large number of DDs in it my loop terminated early with a "weakly referenced object no longer exists" error, whereas using for ds in ts I have no such problems. (Why I would have gotten that error is way beyond my programming knowledge!) Cheers Ian
participants (3)
-
Ian Woodward
-
John Wise
-
Kacper Kowalik