Hi, Is there a way to obtain area under the curves for 1D profile plots in yt?
Hi Vadlamani, Yes, there are a few ways to do this. Starting with a 1D profile, like the following: p = yt.ProfilePlot(ds, 'density', 'cell_mass', weight_field=None) If you add the accumulation=True keyword, the profile will be the sum of all values in the previous bins. p = yt.ProfilePlot(ds, 'density', 'cell_mass', weight_field=None, accumulation=True) Additionally, you can access the profile object as p.profiles, which will be a list of all the profiles plotted. You could then get the bin values and profile values by doing the following: p.profiles[0]['cell_mass'] # mass values p.profiles[0].x # density values You can do array summation or use functions like numpy.trapz to do integration. Britton On Thu, Nov 15, 2018 at 4:06 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
Is there a way to obtain area under the curves for 1D profile plots in yt? _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
I see! The accumulation argument does the trick! Thanks
On Thu, 15 Nov 2018 at 6:40 PM, Britton Smith
Hi Vadlamani,
Yes, there are a few ways to do this. Starting with a 1D profile, like the following: p = yt.ProfilePlot(ds, 'density', 'cell_mass', weight_field=None) If you add the accumulation=True keyword, the profile will be the sum of all values in the previous bins. p = yt.ProfilePlot(ds, 'density', 'cell_mass', weight_field=None, accumulation=True)
Additionally, you can access the profile object as p.profiles, which will be a list of all the profiles plotted. You could then get the bin values and profile values by doing the following: p.profiles[0]['cell_mass'] # mass values p.profiles[0].x # density values
You can do array summation or use functions like numpy.trapz to do integration.
Britton
On Thu, Nov 15, 2018 at 4:06 AM Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
Is there a way to obtain area under the curves for 1D profile plots in yt? _______________________________________________ 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)
-
Britton Smith
-
Vadlamani Samhitha