Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
39fa467
change ubuntu-20 to ubuntu-24 on ARM
JulienDoerner Jun 10, 2025
3e6c603
remove python-setuptools, move to python-dev--is-python3
JulienDoerner Jun 10, 2025
ff7f6cd
fix python path
JulienDoerner Jun 10, 2025
256a79f
remove SIMD from test
JulienDoerner Jun 10, 2025
9ae662a
testcase for numpy
JulienDoerner Jun 10, 2025
8a4d171
fix numpy include dir
JulienDoerner Jun 10, 2025
d6dfa03
fix syntax
JulienDoerner Jun 10, 2025
01f8df9
add support for numpy 2, move numpy array handling into Vector3.h
JulienDoerner Jun 11, 2025
a497c01
add constructor from numpy array
JulienDoerner Jun 11, 2025
cd8eb7c
move set/get for numpy array
JulienDoerner Jun 11, 2025
e98b5d9
add tests for Vector3 to numpy interface
JulienDoerner Jun 11, 2025
d2feb04
change numpy.math.erf to math.erf
JulienDoerner Jun 11, 2025
c615672
disable lenses for numpy >= 2
JulienDoerner Jun 11, 2025
c1b8625
update tests for numpy >= 2.0
JulienDoerner Jun 11, 2025
f8e707c
catch error due to missing ParticleMapsContainer
JulienDoerner Jun 12, 2025
df154f2
fix for deprecated numpy api version
JulienDoerner Jun 12, 2025
d946f41
add FIND_FRAMEWORK to configuration
JulienDoerner Jun 12, 2025
9747dd8
more pathes for the python environment
JulienDoerner Jun 12, 2025
a7aaaa9
update with Ubuntu24 test on ARM and x64
JulienDoerner Jun 12, 2025
3af3266
update installation flags as shown in the documentation
JulienDoerner Jun 12, 2025
8524ba7
explicit reinstall for llvm and python, add numpy include dir
JulienDoerner Jun 12, 2025
a44c912
more debug information
JulienDoerner Jun 12, 2025
b12aca7
restructure workflow
JulienDoerner Jun 12, 2025
70716a4
update omp flags
JulienDoerner Jun 12, 2025
a2e9364
add matrix statement again
JulienDoerner Jun 12, 2025
cc82543
update OMP path
JulienDoerner Jun 12, 2025
6b02446
fix test name
JulienDoerner Jun 12, 2025
1312201
update
JulienDoerner Jun 12, 2025
80156ff
disable tests for Vector3 to numpy array conversion
JulienDoerner Jul 19, 2025
98e68c2
clean up
JulienDoerner Jul 19, 2025
690e1ff
debug infos from python version
JulienDoerner Jul 21, 2025
2d50978
disable other workflows on puhs
JulienDoerner Jul 21, 2025
6f90103
change python dir
JulienDoerner Jul 21, 2025
5d18c43
more strucutred debug information
JulienDoerner Jul 22, 2025
7b8e730
add OMP version into path
JulienDoerner Jul 22, 2025
17e0bbc
change omp dir
JulienDoerner Jul 22, 2025
88f570c
re-add lib names for OMP
JulienDoerner Jul 22, 2025
a3d7d6b
add file type for libomp
JulienDoerner Jul 22, 2025
807e570
add check for deactivated partilce
JulienDoerner Jul 22, 2025
86436a4
always perform interaction
JulienDoerner Jul 22, 2025
2474738
add warnings for not tablulated energies and NaN values in the sampling
JulienDoerner Jul 22, 2025
9c7f236
run process to avoid out of bound error.
JulienDoerner Jul 22, 2025
a1ef5cb
enable tests on push
JulienDoerner Jul 22, 2025
7c00a32
catch erros from first bin in sampling
JulienDoerner Jul 23, 2025
ca598f2
Merge branch 'CRPropa:master' into numpy2
JulienDoerner Jul 23, 2025
5939f40
remove null character from getDataPath, needed for building conda pac…
JulienDoerner Oct 28, 2025
47fa72a
check weather crpropa is build with python
JulienDoerner Oct 28, 2025
0e8e786
update for python3.14 in OSX test
JulienDoerner Oct 28, 2025
2c21218
fix for installation without python
JulienDoerner Oct 28, 2025
b3bc836
fix path for numpy
JulienDoerner Oct 30, 2025
0f8a05c
export pathes for LLVM
JulienDoerner Oct 30, 2025
e11a6be
add c++ std to macos test
JulienDoerner Feb 13, 2026
4d866b6
now with CXX STANDARD flag
JulienDoerner Feb 13, 2026
83bd23b
use as base directory; use venv installation
JulienDoerner Feb 13, 2026
23acf2b
fix typo
JulienDoerner Feb 13, 2026
e0a726c
add CXX flags
JulienDoerner Feb 13, 2026
da826f1
add mcpu to CXX flags
JulienDoerner Feb 13, 2026
19a193a
remove SIMD option
JulienDoerner Feb 13, 2026
4fe3402
update test to numpy >= 2
JulienDoerner Feb 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions .github/workflows/testing_OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
cc: "clang"
fc: "gfortran-14"
swig_builtin: "On" #uses swig 4.0.2
py: "/usr/bin/python3"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Preinstall
run: |
brew install hdf5 fftw cfitsio muparser libomp swig python3
brew reinstall python@3.13 llvm@15
brew install hdf5 fftw cfitsio muparser libomp swig
pip install numpy==1.26.4 cmake
pip show numpy # cross-check numpy version for Python_Numpy_INCLUDE_DIR
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
Expand All @@ -30,7 +31,35 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"

# define paths for LLVM, Python, and OpenMP
export LLVM_DIR=$(brew --prefix llvm@15)
export PYTHON_VERSION=3.13
export LLVM_VERSION=15.0.7
export OMP_VERSION=$(brew list --versions libomp | awk '{print $2}')
export OMP_DIR=$(brew --prefix libomp)
export PYTHON_DIR=/Library/Frameworks/Python.framework/Versions/3.13/

# print paths for debugging
echo "Using LLVM_DIR: $LLVM_DIR"
echo "Using OMP_DIR: $OMP_DIR"
echo "python version: $(python --version) from $(which python)"
echo "Using Python_DIR: $PYTHON_DIR"

cmake .. \
-DCMAKE_INSTALL_PREFIX=/Users/runner/work/CRPropa3/CRPropa3/build \
-DPython_EXECUTABLE=$PYTHON_DIR/bin/python$PYTHON_VERSION \
-DPython_LIBRARY=$PYTHON_DIR/lib/libpython$PYTHON_VERSION.dylib \
-DPython_INCLUDE_PATH=$PYTHON_DIR/include/python$PYTHON_VERSION \
-DCMAKE_C_COMPILER=$LLVM_DIR/bin/clang \
-DCMAKE_CXX_COMPILER=$LLVM_DIR/bin/clang++ \
-DOpenMP_CXX_FLAGS="-fopenmp -I${OMP_DIR}/include" \
-DOpenMP_C_FLAGS="-fopenmp =libomp -I$OMP_DIR/include" \
-DOpenMP_libomp_LIBRARY=$OMP_DIR/$OMP_VERSION/lib/libomp.dylib \
-DOpenMP_C_LIB_NAMES=libomp.dylib \
-DOpenMP_CXX_LIB_NAMES=libomp.dylib \
-DNO_TCMALLOC=TRUE \
-DPython_NumPy_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/numpy/core/include
- name: Build CRPropa
run: |
cd build
Expand Down
47 changes: 0 additions & 47 deletions .github/workflows/testing_ubuntu20.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/testing_ubuntu22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
- name: Preinstall
run: |
sudo apt-get update
sudo apt-get install libmuparser-dev python3 python3-numpy python3-setuptools libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
sudo apt-get install libmuparser-dev python3 python3-setuptools libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
pip install --upgrade pip
pip install numpy
pip show numpy
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/testing_ubuntu24.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: crpropa-testing_ubuntu24
on: [push, pull_request]

jobs:
x64:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "ubuntu-24"
os: ubuntu-24.04
cxx: "g++-14"
cc: "gcc-14"
fc: "gfortran-14"
swig_builtin: "On"
py: "/usr/bin/python3"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Preinstall
run: |
sudo apt-get update
sudo apt-get install libmuparser-dev python-dev-is-python3 libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
pip install numpy
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
CC: ${{ matrix.config.cc }}
FC: ${{ matrix.config.fc }}
run: |
mkdir build
cd build
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"
- name: Build CRPropa
run: |
cd build
make
- name: Run tests
run: |
cd build
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: "test-report_${{matrix.config.os}}"
path: build/Testing/Temporary/LastTest.log
arm:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "ubuntu-24"
os: ubuntu-24.04-arm
cxx: "g++-14"
cc: "gcc-14"
fc: "gfortran-14"
swig_builtin: "On"
py: "/usr/bin/python3"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Preinstall
run: |
sudo apt-get update
sudo apt-get install libmuparser-dev python-dev-is-python3 libhdf5-serial-dev libomp5 libomp-dev libfftw3-dev libcfitsio-dev lcov
pip install numpy
pip show numpy
- name: Set up the build
env:
CXX: ${{ matrix.config.cxx }}
CC: ${{ matrix.config.cc }}
FC: ${{ matrix.config.fc }}
run: |
mkdir build
cd build
cmake .. -DENABLE_PYTHON=True -DENABLE_TESTING=On -DENABLE_SWIG_BUILTIN=${{ matrix.config.swig_builtin }} -DSIMD_EXTENSIONS="none"
- name: Build CRPropa
run: |
cd build
make
- name: Run tests
run: |
cd build
make test
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: "test-report_${{matrix.config.os}}"
path: build/Testing/Temporary/LastTest.log
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ list(APPEND CRPROPA_EXTRA_LIBRARIES sophia gfortran)
list(APPEND CRPROPA_EXTRA_INCLUDES libs/sophia)

# Galactic magnetic lenses
option(ENABLE_GALACTICMAGNETICLENS "Galactic Magnetic Lens" ON)
option(ENABLE_GALACTICMAGNETICLENS "Galactic Magnetic Lens" OFF)
option(INSTALL_EIGEN "Install provided EIGEN headers" OFF)
SET(EIGEN_PATH "" CACHE STRING "Use EIGEN from this path instead of the version shipped with CRPropa")
SET(WITH_GALACTIC_LENSES FALSE)
Expand Down Expand Up @@ -467,23 +467,29 @@ if(ENABLE_PYTHON AND Python_FOUND)
message(STATUS " development libraries: NOT found!")
endif(Python_Development_FOUND)


# use Python_INSTALL_PACKAGE_DIR if provided; otherwise, install in Python_SITELIB
set(Python_INSTALL_PACKAGE_DIR "${Python_SITELIB}" CACHE PATH "folder in which the python package is installed")
message(STATUS " package install directory: ${Python_INSTALL_PACKAGE_DIR}")



# look for NumPy
if(Python_NumPy_FOUND)
set(CMAKE_SWIG_FLAGS -DWITHNUMPY ${CRP})
list(APPEND CRPROPA_SWIG_DEFINES -DWITHNUMPY)
include_directories(${Python_NumPy_INCLUDE_DIRS})
message(STATUS "NumPy: Found!")
message(STATUS " headers: ${Python_NumPy_INCLUDE_DIRS} (version ${Python_NumPy_VERSION})")
set(CMAKE_SWIG_FLAGS -DWITHNUMPY ${CRP})
list(APPEND CRPROPA_SWIG_DEFINES -DWITHNUMPY)
include_directories(${Python_NumPy_INCLUDE_DIRS})
message(STATUS "NumPy: Found!")
message(STATUS " headers: ${Python_NumPy_INCLUDE_DIRS} (version ${Python_NumPy_VERSION})")
elseif(Python_NumPy_FOUND)
message(STATUS "NumPy: NOT found!")
message(STATUS " CRPropa might work just fine with Python, but features like Galactic lenses will not be available.")
message(STATUS "NumPy: NOT found!")
message(STATUS " CRPropa might work just fine with Python, but features like Galactic lenses will not be available.")
endif(Python_NumPy_FOUND)

# deactivate lenses if NumPy version is >= 2.0
if(Python_NumPy_VERSION VERSION_GREATER_EQUAL 2.0 AND WITH_GALACTIC_LENSES)
set(WITH_GALACTIC_LENSES FALSE CACHE BOOL "" FORCE)
set(ENABLE_GALACTICMAGNETICLENS OFF CACHE BOOL "" FORCE)
message(WARNING "NumPy version >= 2.0 detected, disabling Galactic lenses support")
endif()

if(SWIG_VERSION VERSION_GREATER 4.0)
# Use swig 4 builtin doxygen instead of external program
Expand Down
59 changes: 31 additions & 28 deletions doc/pages/example_notebooks/targeting/Targeting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,46 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import healpy as hp\n",
"import matplotlib.pylab as plt\n",
"import crpropa as crp\n",
"\n",
"crdata = np.genfromtxt('TargetedEmission.txt')\n",
"Id = crdata[:,3]\n",
"E = crdata[:,4] * EeV\n",
"px = crdata[:,8]\n",
"py = crdata[:,9]\n",
"pz = crdata[:,10]\n",
"w = crdata[:,29]\n",
"lons = np.arctan2(-1. * py, -1. *px)\n",
"lats = np.pi / 2 - np.arccos( -pz / np.sqrt(px*px + py*py+ pz*pz) )\n",
"# If CRPropa was compiled without the GalacticMagneticLens the ParticleMapsContainer does not exist\n",
"if hasattr(crp, 'ParticleMapsContainer'):\n",
" crdata = np.genfromtxt('TargetedEmission.txt')\n",
" Id = crdata[:,3]\n",
" E = crdata[:,4] * EeV\n",
" px = crdata[:,8]\n",
" py = crdata[:,9]\n",
" pz = crdata[:,10]\n",
" w = crdata[:,29]\n",
" lons = np.arctan2(-1. * py, -1. *px)\n",
" lats = np.pi / 2 - np.arccos( -pz / np.sqrt(px*px + py*py+ pz*pz) )\n",
"\n",
"M = ParticleMapsContainer()\n",
"for i in range(len(E)):\n",
" M.addParticle(int(Id[i]), E[i], lons[i], lats[i], w[i])\n",
" M = ParticleMapsContainer()\n",
" for i in range(len(E)):\n",
" M.addParticle(int(Id[i]), E[i], lons[i], lats[i], w[i])\n",
"\n",
"###################################################################\n",
"# WARNING\n",
"# The calls M.getEnergies()/getParticleIds()/getMap() all segfault.\n",
"################################################################### \n",
" ###################################################################\n",
" # WARNING\n",
" # The calls M.getEnergies()/getParticleIds()/getMap() all segfault.\n",
" ################################################################### \n",
"\n",
"#stack all maps\n",
"#crMap = np.zeros(49152)\n",
"#for pid in M.getParticleIds():\n",
" #energies = M.getEnergies(int(pid))\n",
" #for i, energy in enumerate(energies):\n",
" #continue\n",
" #crMap += M.getMap(int(pid), energy * eV )\n",
"#\n",
"##plot maps using healpy\n",
"#hp.mollview(map=crMap, title='Targeted emission')\n",
"#plt.show()"
" #stack all maps\n",
" #crMap = np.zeros(49152)\n",
" #for pid in M.getParticleIds():\n",
" #energies = M.getEnergies(int(pid))\n",
" #for i, energy in enumerate(energies):\n",
" #continue\n",
" #crMap += M.getMap(int(pid), energy * eV )\n",
" #\n",
" ##plot maps using healpy\n",
" #hp.mollview(map=crMap, title='Targeted emission')\n",
" #plt.show()"
]
},
{
Expand Down
Loading