How to get the np.array of profile plots

Hi, all, I am trying to use matlibplot to plot the profile of a sphere object, so I need to get the np.array of profile plots. I know that we can use "slc.frb" to get the np.array of SlicePlot. However, I don't find the simliar function in profile plots, how can I get the np.array of a sphere object's profile? Thanks a lot for every suggestion or help. best wishes, Yifeng He

Hi there! You can get it by accessing the .x attribute for the bins and then the dict-like access on the profile for the actual y values. For instance: import yt ds = yt.load_sample("IsolatedGalaxy") p = ds.r[:].profile("density", "temperature", weight_field="mass") now you can get p.x and p["temperature"]. Or, if you have a phase plot: p = ds.r[:].profile(["density", "temperature"], "mass", weight_field=None) You can access p.x, p.y, and p["mass"]. -Matt On Fri, May 24, 2024 at 11:42 PM <hyf@stu.pku.edu.cn> wrote:
Hi, all,
I am trying to use matlibplot to plot the profile of a sphere object, so I need to get the np.array of profile plots.
I know that we can use "slc.frb" to get the np.array of SlicePlot.
However, I don't find the simliar function in profile plots, how can I get the np.array of a sphere object's profile?
Thanks a lot for every suggestion or help.
best wishes, Yifeng He _______________________________________________ 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

Dear Matthew, Thanks for your help, and I can deal with the sphere object now. But I donot know how to do these similar things with function "ParticlePhasePlot", Or how to directly turn the particle data into np.array can you give some suggestions, thanks a lot! best wishes, Yifeng He

Hi, If you want the particle data itself into an array, you can access it using the sphere object like you would access a field. For instance, sp = ds.sphere( ... sp["all", "particle_velocity"] would get you velocity of all of the particles. If you want to access these off of a ParticlePhasePlot, it's a subclass of PhasePlot and should have the .x and .y and [] attributes I mentioned earlier. -Matt On Tue, May 28, 2024 at 6:14 AM <hyf@stu.pku.edu.cn> wrote:
Dear Matthew,
Thanks for your help, and I can deal with the sphere object now.
But I donot know how to do these similar things with function "ParticlePhasePlot", Or how to directly turn the particle data into np.array
can you give some suggestions, thanks a lot!
best wishes, Yifeng He _______________________________________________ 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

Dear Matthew, I print all the attributes of a ParticlePhasePlot by calling, it seems .x and .y and [] are not included: ['__abstractmethods__', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_callbacks', '_colorbar_label', '_colorbar_valid', '_default_figure_size', '_default_font_size', '_font_color', '_font_properties', '_get_axes_labels', '_get_axes_unit_labels', '_get_default_handlers', '_get_field_label', '_get_field_log', '_get_field_title', '_initfinished', '_initialize_dataset', '_initialize_instance', '_minorticks', '_plot_dict_type', '_plot_text', '_plot_type', '_plot_valid', '_profile', '_profile_valid', '_recreate_profile', '_repr_html_', '_set_figure_size', '_set_font_properties', '_setup_plots', '_shading', '_switch_ds', '_text_kwargs', '_text_xpos', '_text_ypos', '_xlabel', '_xlim', '_ylabel', '_ylim', 'annotate_text', 'annotate_title', 'data_source', 'display', 'ds', 'fields', 'figure_size', 'from_profile', 'get_log', 'hide_axes', 'hide_colorbar', 'plot_title', 'plots', 'profile', 'refresh', 'render', 'reset_plot', 'save', 'set_background_color', 'set_cmap', 'set_colorbar_label', 'set_colorbar_minorticks', 'set_figure_size', 'set_font', 'set_font_size', 'set_log', 'set_minorticks', 'set_norm', 'set_title', 'set_transform', 'set_unit', 'set_xlabel', 'set_xlim', 'set_ylabel', 'set_ylim', 'set_zlim', 'show', 'show_axes', 'show_colorbar', 'ts', 'x_log', 'y_log', 'z_log', 'z_title'] or if it is because I am missing something here is the codes to generate a ParticlePhasePlot: ptcslc = yt.ParticlePhasePlot( ds, ptc_xname, ptc_yname, [ptc_zname], color=ptc_colorname, weight_field=('particles', 'Ones'), x_bins=400, y_bins=400 ) print(dir(ptcslc)) best wishes, Yifeng He

On 5/29/24 01:42, hyf@stu.pku.edu.cn wrote:
Dear Matthew,
I print all the attributes of a ParticlePhasePlot by calling, it seems .x and .y and [] are not included:
here is the codes to generate a ParticlePhasePlot:
ptcslc = yt.ParticlePhasePlot( ds, ptc_xname, ptc_yname, [ptc_zname], color=ptc_colorname, weight_field=('particles', 'Ones'), x_bins=400, y_bins=400 ) print(dir(ptcslc))
You need to access 'profile' property first: ptcslc.profile.x and ptcslc.profile.y Cheers, Kacper
participants (3)
-
hyf@stu.pku.edu.cn
-
Kacper Kowalik
-
Matthew Turk