Skip to content
Advertisement

Panda dataframe of distribution of particles: group by ID and find the half flux and the half flux radius

I am using Panda dataframe; I have a distribution of particles, their distance from the center of the distribution, and the associated fluxes. I want to find the total flux enclosed in the “half flux radius” (or “half light radius”), which is the radius that encloses half of the flux, by definition. I make you an example and then I ask you If you have any idea of how to make it.

Here I list 2 distribution of particles, identified by dist_ID, the distance of each particle from the center of the distribution R, and the flux of each particle.

JavaScript

For example, considering the particle distribution with dist_ID=702641.0, the total flux of the particle distribution is the sum of “flux”: total_flux=0.48; the half flux is half_flux=total_flux/2.=0.24; the radius that encloses half of the flux is R_2<R_hf<R_3 (where R_2=3.25 of particle 2; R_3=8.29 of particle 3), so I would consider R_h as the upper limit of that interval, i.e. R_hf=R_3.

I want a way, grouping by dist_ID with Panda dataframe, half_flux and R_hf of each distribution. Thanks

Advertisement

Answer

Can be done in this way:

JavaScript

Upper code output this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement