First, forgive me if this is an obvious question; I'm still pretty new to FLASH (the source of my hdf5 AMR data) and even newer to yt. I'm trying to find a good way to plot a 2-dimensional color-mapped plot of some of the data in the file (["flash","tele"],["flash","dens"],etc), and I've encountered a few methods but, as much as it annoys me to say it, none of them has been better (when weighted for end-user convenience) than VisIt so far. The yt-native SlicePlot command is... fine, but hindered by the need to re-run the script with an edited filename for each plot count increment. So I've been trying to get my data into an array form that MatPlotLib will accept (not that that fixes my file issue, but I know MatPlotLib better). Unfortunately, this means fighting with the imshow command if I want a colorbar at all. The meat of my question, then, is: what's the best way to rip all of a given data field from an hdf5 file in a way that will produce an nxn array of equal spacing? Currently, I've found I can brute-force a solution by defining a covering grid over my data (level 0) using data_dimensions, finding the shape of my desired field, finding the minimum array length of that field, and defining a new covering grid (also level 0) limited to that minimum length in both of my relevant dimensions (my FLASH sims are only 2D), and using np.squeeze to pull out the size-1 z-index, but the most I've ever seen that output is 32 data points, and commonly only 16, which yields terrible plot resolution. I assume there's a better way of doing this; does anyone more experienced than me have a good way of getting this to work? I'm in azimuthally-symmetric cylindrical geometry, to specify. Hence why I actively don't want the third data axis.
Hi! I'm not exactly sure I completely understand the question. There are a few things that might help: - You should be able to save a plot using ".save()" with no argument to get a filename generated that should be mostly-unique and will take into account the name of the dataset - Your approach using covering grids might be simplified using the ds.r object. You can supply complex values for step sizes to give array lengths. For instance, ds.r[0.5, 0.0:1.0:128j, 0.0:1.0:128j] would give a slice at 0.5 in x, with 128 cells for each of the other two axes. (With flash you will have different units, but you can also use the 'full dimension' slice with :: or specify units like 'unitary'.) Hope that helps, Matt On Fri, Jun 27, 2025 at 3:46 PM <bcurlee@xcimer.net> wrote:
First, forgive me if this is an obvious question; I'm still pretty new to FLASH (the source of my hdf5 AMR data) and even newer to yt. I'm trying to find a good way to plot a 2-dimensional color-mapped plot of some of the data in the file (["flash","tele"],["flash","dens"],etc), and I've encountered a few methods but, as much as it annoys me to say it, none of them has been better (when weighted for end-user convenience) than VisIt so far. The yt-native SlicePlot command is... fine, but hindered by the need to re-run the script with an edited filename for each plot count increment. So I've been trying to get my data into an array form that MatPlotLib will accept (not that that fixes my file issue, but I know MatPlotLib better). Unfortunately, this means fighting with the imshow command if I want a colorbar at all. The meat of my question, then, is: what's the best way to rip all of a given data field from an hdf5 file in a way that will produce an nxn array of equal spacing? Currentl y, I've found I can brute-force a solution by defining a covering grid over my data (level 0) using data_dimensions, finding the shape of my desired field, finding the minimum array length of that field, and defining a new covering grid (also level 0) limited to that minimum length in both of my relevant dimensions (my FLASH sims are only 2D), and using np.squeeze to pull out the size-1 z-index, but the most I've ever seen that output is 32 data points, and commonly only 16, which yields terrible plot resolution. I assume there's a better way of doing this; does anyone more experienced than me have a good way of getting this to work? I'm in azimuthally-symmetric cylindrical geometry, to specify. Hence why I actively don't want the third data axis. _______________________________________________ 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: matthewturk@gmail.com
Hi, Matt; thanks for answering. It seems like, in my desire to provide enough background information, I didn't include enough information on what exactly I'm trying to do with Yt. I'll address your two points before I try to clarify anything: .save() has been a great help in producing good color plots with Yt, and, the more time I spend combing through SlicePlot documentation, the better they get, but more on that shortly. I'm unfamiliar with the ds.r command you mention, but that looks like it could be very helpful, so thank you for pointing that out to me. I'll need to look at in some depth, but it might solve this problem. The original reason I wrote the first post is that I'm trying to plot electron temperature data onto an x-y grid with a color bar. SlicePlot spits out a nice plot and the colorbar is fairly easy to format. The problem is, the only unit Yt recognizes as valid for temperature is Kelvin, and it would make for much more readable data if I could get that into electron volts. Any chance you know a workaround for that, or would that merit its own thread?
participants (2)
-
bcurlee@xcimer.net -
Matthew Turk