CRPropa / CRPropa3

CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
https://crpropa.desy.de
GNU General Public License v3.0
65 stars 66 forks source link

Grid based density and source position sampling #415

Closed JulienDoerner closed 1 year ago

JulienDoerner commented 1 year ago

This PR has 3 major parts.

  1. An interface to use a Grid1f as a mass distribution is introduced.
  2. A grid feature to restrict a grid to the volume defined by the origin, points and spacing is introduced. This is necessary for mass distribution grids, which should not be repeated.
  3. A source feature for sampling the source position from a given mass distribution via Monte Carlo sampling.

Additionally, all aspects are shown in a new example notebook which uses data for the mass distribution from Mertsch+(2021). This data are added to the additional resources (https://desycloud.desy.de/index.php/s/6zpYsCd29RLbFiA).

lukasmerten commented 1 year ago

I have not yet the code itself, but focused on the docstrings.

JulienDoerner commented 1 year ago

I added the code style comments by @reichherzerp.

JulienDoerner commented 1 year ago

I also added some test for the new feature and added the changes to the CHANGELOG.md

JulienDoerner commented 1 year ago

I also changed the warning behavior of the densities. Until now, warnings are given if one density type is not activated. This causes a lot of warnings if for example only one component of the gas is used. I changed the warnings to occur only if all types are deactivated and the density is accordingly 0.

reichherzerp commented 1 year ago

That's a good idea, and I'll proceed to merge now. Thanks for the contribution!