[FLASH-USERS] How to extract data from HDF5 output and plot linear profiles

Slavin, Jonathan jslavin at cfa.harvard.edu
Mon Jan 29 12:11:55 EST 2024


Mattia,

If you want a profile along a line with arbitrary orientation, I'd
recommend using the ray yt object.
ds = yt.load(filename)
ray = ds.r[(r1,z1,0):(r2,z2,0)]
rsort = np.argsort(ray['t'])
rr = ray['gas','r'][rsort]
zz = ray['gas','z'][rsort]
d = np.sqrt((rr-rr[0])**2 + (zz-zz[0])**2)
dens = ray['gas','density'][rsort]
fig,ax = plt.subplots()
ax.plot(d,dens)
plt.show()

The rsort bit is explained on the yt site. When constructing rays, the
order may not be what you'd expect. the 't' variable of a ray is a
parametric variable that goes from 0 to 1.

Regards,
Jon
-- 
Jonathan D. Slavin (he/him)
Astrophysicist - High Energy Astrophysics Division
Center for Astrophysics | Harvard & Smithsonian
Office: (617) 496-7981 | Cell: (781) 363-0035
60 Garden Street | MS 04 | Cambridge, MA 02138
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://flash.rochester.edu/pipermail/flash-users/attachments/20240129/53d94669/attachment-0001.htm>


More information about the flash-users mailing list