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
69 stars 68 forks source link

Loading Grids with properties #485

Closed JulienDoerner closed 3 months ago

JulienDoerner commented 5 months ago

Dear all,

this PR introduces the loading of grids with given properties in the header. The first implementation only allows property reading in the TXT files. An example of the properties in the header looks like this

# GridProperties: Type Grid1f   origin: -4.92744e+20 -4.92744e+20 -1.44641e+19  gridsize: 512 512 16    spacing: 1.92855e+18 1.92855e+18 1.92855e+18    reflective: 0       clipVolume: 1   interpolation: TRILINEAR

all units are in SI base units (in this case m). The loading itself has the conversion variable as before. Loading a grid can now be done as

grid = loadGrid3f("myGridFile.txt", 1 * gauss)

I also introduce the possibility to store the properties in the dumpGridToTxt function and additional tests for this grid reading/dumping.

To have an example, I adjusted the notebook with the grid-based glactic gas densities to use the grid property reading. The files on sciebo (additional resources) are already updated (additional line with the properties in the right format).