Hello, When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted? Thanks, Julie
Hi Julia, If I create a ProjectionPlot like so: p = ProjectionPlot(ds, 'z', ('gas', 'density')) Then I can access the image array you are looking for like this: image = p.frb['gas', 'density'] This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages: http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-... http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight... http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht... Hope that helps, Nathan On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu> wrote:
Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Thank you! And I was wondering how exactly the output array corresponds to the image? For example, in the above ImageArray, what do the rows/colums mean? Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-... <http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-...> http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight... <http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight...> http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht... <http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht...>
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org> _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Your image contains the "density" field with a width of 10 in code units along each axis. So each row corresponds to the density value sampled over a 1x1 (in code units) region of your simulation, since you specified that you wanted a 10x10 image. You might find the OffAxisProjectionPlot object to be a bit nicer to work with to make plots: http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots http://yt-project.org/doc/reference/api/yt.visualization.plot_window.html#yt... OffAxisProjectionPlot presents the same interface as ProjectionPlot and will make a plot with axes and labels that should hopefully be easier to understand than the raw image you are dealing with now. On Sun, Jan 21, 2018 at 10:42 AM, Julia Rakas <jrakas@umich.edu> wrote:
Thank you! And I was wondering how exactly the output array corresponds to the image?
For example, in the above ImageArray, what do the rows/colums mean?
Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting. html#fixed-resolution-buffers http://yt-project.org/doc/analyzing/generating_ processed_data.html?highlight=fixedresolutionbuffer#d-image-arrays http://yt-project.org/doc/reference/api/yt.visualization.fixed_ resolution.html#yt.visualization.fixed_resolution.FixedResolutionBuffer
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu> wrote:
Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ 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
Hi, So I did what was suggested and made a fixed resolution buffer and got this: What do the dots mean? And I guess the main thing is that I want to be able to modify the array and be able to, for example, multiply the values by a conversion factor, normalize some values if they are below a threshold etc using matplotlib and I’m not quite sure how to interpret the results in order to do so. Any help would be greatly appreciated. Thanks so much! Julie
On Jan 21, 2018, at 12:04 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Your image contains the "density" field with a width of 10 in code units along each axis. So each row corresponds to the density value sampled over a 1x1 (in code units) region of your simulation, since you specified that you wanted a 10x10 image.
You might find the OffAxisProjectionPlot object to be a bit nicer to work with to make plots:
http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots> http://yt-project.org/doc/reference/api/yt.visualization.plot_window.html#yt... <http://yt-project.org/doc/reference/api/yt.visualization.plot_window.html#yt...>
OffAxisProjectionPlot presents the same interface as ProjectionPlot and will make a plot with axes and labels that should hopefully be easier to understand than the raw image you are dealing with now.
On Sun, Jan 21, 2018 at 10:42 AM, Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Thank you! And I was wondering how exactly the output array corresponds to the image?
<Screenshot 2018-01-12 19.38.46.png>
For example, in the above ImageArray, what do the rows/colums mean?
Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com <mailto:nathan12343@gmail.com>> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-... <http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-...> http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight... <http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight...> http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht... <http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht...>
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org> _______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
On Mon, Jan 22, 2018 at 12:07 AM, Julia Rakas <jrakas@umich.edu> wrote:
Hi,
So I did what was suggested and made a fixed resolution buffer and got this:
What do the dots mean?
That's how big arrays (bigger than can fit on your display) are printed by NumPy. The default plot resolution is 800x800 so that's way bigger than can fit on your screen.
And I guess the main thing is that I want to be able to modify the array and be able to, for example, multiply the values by a conversion factor, normalize some values if they are below a threshold etc using matplotlib and I’m not quite sure how to interpret the results in order to do so. Any help would be greatly appreciated.
The image array you get back acts just like a normal numpy array. You can multiply by conversion factors and do boolean logic just like any other array. I'd use matplotlib's imshow command to display the image. One wrinkle though, matplotlib will raise errors when you pass a yt ImageArray to the imshow command. This is fixed on some versions of matplotlib, although I just tested the latest version and it seems to have hapenned again. The fix is just to cast the ImageArray to a numpy ndarray: import numpy as np p = ProjectionPlot(...) image = p.frb[field] ndarray_image = np.array(image) Here's a worked example: https://gist.github.com/b6a4393a0ea1ca2630a1dfd43d087ec4
Thanks so much! Julie
On Jan 21, 2018, at 12:04 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Your image contains the "density" field with a width of 10 in code units along each axis. So each row corresponds to the density value sampled over a 1x1 (in code units) region of your simulation, since you specified that you wanted a 10x10 image.
You might find the OffAxisProjectionPlot object to be a bit nicer to work with to make plots:
http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots http://yt-project.org/doc/reference/api/yt.visualization.plot_window. html#yt.visualization.plot_window.OffAxisProjectionPlot
OffAxisProjectionPlot presents the same interface as ProjectionPlot and will make a plot with axes and labels that should hopefully be easier to understand than the raw image you are dealing with now.
On Sun, Jan 21, 2018 at 10:42 AM, Julia Rakas <jrakas@umich.edu> wrote:
Thank you! And I was wondering how exactly the output array corresponds to the image?
<Screenshot 2018-01-12 19.38.46.png>
For example, in the above ImageArray, what do the rows/colums mean?
Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting.html# fixed-resolution-buffers http://yt-project.org/doc/analyzing/generating_processed_ data.html?highlight=fixedresolutionbuffer#d-image-arrays http://yt-project.org/doc/reference/api/yt.visualization. fixed_resolution.html#yt.visualization.fixed_resolution.Fixe dResolutionBuffer
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu> wrote:
Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ 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
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Hello, So I did as you suggested and cast my image array to a normal python array, but for some reason when I try to do an imshow, it doesn’t seem to recognize any of the values because I get this: This is the frb that I made Do you know why this might be? Thanks, Julie
On Jan 22, 2018, at 11:49 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
On Mon, Jan 22, 2018 at 12:07 AM, Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Hi,
So I did what was suggested and made a fixed resolution buffer and got this:
What do the dots mean?
That's how big arrays (bigger than can fit on your display) are printed by NumPy. The default plot resolution is 800x800 so that's way bigger than can fit on your screen.
And I guess the main thing is that I want to be able to modify the array and be able to, for example, multiply the values by a conversion factor, normalize some values if they are below a threshold etc using matplotlib and I’m not quite sure how to interpret the results in order to do so. Any help would be greatly appreciated.
The image array you get back acts just like a normal numpy array. You can multiply by conversion factors and do boolean logic just like any other array. I'd use matplotlib's imshow command to display the image. One wrinkle though, matplotlib will raise errors when you pass a yt ImageArray to the imshow command. This is fixed on some versions of matplotlib, although I just tested the latest version and it seems to have hapenned again. The fix is just to cast the ImageArray to a numpy ndarray:
import numpy as np
p = ProjectionPlot(...) image = p.frb[field]
ndarray_image = np.array(image)
Here's a worked example:
https://gist.github.com/b6a4393a0ea1ca2630a1dfd43d087ec4 <https://gist.github.com/b6a4393a0ea1ca2630a1dfd43d087ec4>
Thanks so much! Julie
On Jan 21, 2018, at 12:04 PM, Nathan Goldbaum <nathan12343@gmail.com <mailto:nathan12343@gmail.com>> wrote:
Your image contains the "density" field with a width of 10 in code units along each axis. So each row corresponds to the density value sampled over a 1x1 (in code units) region of your simulation, since you specified that you wanted a 10x10 image.
You might find the OffAxisProjectionPlot object to be a bit nicer to work with to make plots:
http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots <http://yt-project.org/doc/visualizing/plots.html#off-axis-projection-plots> http://yt-project.org/doc/reference/api/yt.visualization.plot_window.html#yt... <http://yt-project.org/doc/reference/api/yt.visualization.plot_window.html#yt...>
OffAxisProjectionPlot presents the same interface as ProjectionPlot and will make a plot with axes and labels that should hopefully be easier to understand than the raw image you are dealing with now.
On Sun, Jan 21, 2018 at 10:42 AM, Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Thank you! And I was wondering how exactly the output array corresponds to the image?
<Screenshot 2018-01-12 19.38.46.png>
For example, in the above ImageArray, what do the rows/colums mean?
Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com <mailto:nathan12343@gmail.com>> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-... <http://yt-project.org/doc/visualizing/manual_plotting.html#fixed-resolution-...> http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight... <http://yt-project.org/doc/analyzing/generating_processed_data.html?highlight...> http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht... <http://yt-project.org/doc/reference/api/yt.visualization.fixed_resolution.ht...>
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu <mailto:jrakas@umich.edu>> wrote: Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org> _______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
_______________________________________________ yt-users mailing list -- yt-users@python.org <mailto:yt-users@python.org> To unsubscribe send an email to yt-users-leave@python.org <mailto:yt-users-leave@python.org>
On Tue, Jan 30, 2018 at 10:50 AM, Julia Rakas <jrakas@umich.edu> wrote:
Hello,
So I did as you suggested and cast my image array to a normal python array, but for some reason when I try to do an imshow, it doesn’t seem to recognize any of the values because I get this:
It looks like there is some structure in that image, it's just low contrast. You probably just need to use a log-scale colormap: from matplotlib.colors import LogNorm plt.imshow(np.array(density_plot.frb['density']), norm=LogNorm()) It helps to also display the colorbar with plt.colorbar().
This is the frb that I made
Do you know why this might be?
Thanks, Julie
On Jan 22, 2018, at 11:49 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
On Mon, Jan 22, 2018 at 12:07 AM, Julia Rakas <jrakas@umich.edu> wrote:
Hi,
So I did what was suggested and made a fixed resolution buffer and got this:
What do the dots mean?
That's how big arrays (bigger than can fit on your display) are printed by NumPy. The default plot resolution is 800x800 so that's way bigger than can fit on your screen.
And I guess the main thing is that I want to be able to modify the array and be able to, for example, multiply the values by a conversion factor, normalize some values if they are below a threshold etc using matplotlib and I’m not quite sure how to interpret the results in order to do so. Any help would be greatly appreciated.
The image array you get back acts just like a normal numpy array. You can multiply by conversion factors and do boolean logic just like any other array. I'd use matplotlib's imshow command to display the image. One wrinkle though, matplotlib will raise errors when you pass a yt ImageArray to the imshow command. This is fixed on some versions of matplotlib, although I just tested the latest version and it seems to have hapenned again. The fix is just to cast the ImageArray to a numpy ndarray:
import numpy as np
p = ProjectionPlot(...) image = p.frb[field]
ndarray_image = np.array(image)
Here's a worked example:
https://gist.github.com/b6a4393a0ea1ca2630a1dfd43d087ec4
Thanks so much! Julie
On Jan 21, 2018, at 12:04 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Your image contains the "density" field with a width of 10 in code units along each axis. So each row corresponds to the density value sampled over a 1x1 (in code units) region of your simulation, since you specified that you wanted a 10x10 image.
You might find the OffAxisProjectionPlot object to be a bit nicer to work with to make plots:
http://yt-project.org/doc/visualizing/plots.html#off-axis- projection-plots http://yt-project.org/doc/reference/api/yt.visualization. plot_window.html#yt.visualization.plot_window.OffAxisProjectionPlot
OffAxisProjectionPlot presents the same interface as ProjectionPlot and will make a plot with axes and labels that should hopefully be easier to understand than the raw image you are dealing with now.
On Sun, Jan 21, 2018 at 10:42 AM, Julia Rakas <jrakas@umich.edu> wrote:
Thank you! And I was wondering how exactly the output array corresponds to the image?
<Screenshot 2018-01-12 19.38.46.png>
For example, in the above ImageArray, what do the rows/colums mean?
Thanks again, Julie
On Jan 21, 2018, at 8:45 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Julia,
If I create a ProjectionPlot like so:
p = ProjectionPlot(ds, 'z', ('gas', 'density'))
Then I can access the image array you are looking for like this:
image = p.frb['gas', 'density']
This is using the FixedResolutionBuffer object that is associated with the ProjectionPlot. You also don't need to create a ProjectionPlot to do this, you can instead manually create a FixedResolutionBuffer object. See the following doc pages:
http://yt-project.org/doc/visualizing/manual_plotting.html#f ixed-resolution-buffers http://yt-project.org/doc/analyzing/generating_processed_dat a.html?highlight=fixedresolutionbuffer#d-image-arrays http://yt-project.org/doc/reference/api/yt.visualization.fix ed_resolution.html#yt.visualization.fixed_resolution.FixedRe solutionBuffer
Hope that helps,
Nathan
On Sun, Jan 21, 2018 at 12:47 AM Julia Rakas <jrakas@umich.edu> wrote:
Hello,
When I do yt.off_axis_projection(…) I get an array as an output. My question is how I can get an output array for regular projection plots? And does the output array correspond to the actual image that it otherwise would have plotted?
Thanks, Julie _______________________________________________ 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
_______________________________________________ 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)
-
Julia Rakas
-
Nathan Goldbaum