Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
os: [ubuntu-24.04]
include:
- python-version: "3.13"
- python-version: "3.14"
os: macos-15-intel
- python-version: "3.13"
- python-version: "3.14"
os: macos-14
- python-version: "3.13"
- python-version: "3.14"
os: macos-15
- python-version: "3.13"
- python-version: "3.14"
os: macos-26
steps:
- uses: actions/checkout@v6
Expand All @@ -50,7 +50,7 @@ jobs:
SIMWEIGHTS_TESTDATA: .
run: python3 -m pytest --cov-report=xml --junit-xml=test-results-${{matrix.os}}-${{matrix.python-version}}.junit.xml
- name: Upload Test Results
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
if: always()
with:
if-no-files-found: error
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
SIMWEIGHTS_TESTDATA: .
run: /opt/icetray/bin/icetray-shell python -m pytest --junit-xml=test-results-icetray.junit.xml
- name: Upload Test Results
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
if: always()
with:
if-no-files-found: error
Expand All @@ -105,7 +105,7 @@ jobs:
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
path: .
pattern: test-results-*
Expand Down
15 changes: 4 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
hooks:
- id: yamlfmt
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
rev: v2.16.0
hooks:
- id: pretty-format-toml
args: [--autofix]
Expand All @@ -27,22 +27,15 @@ repos:
hooks:
- id: blacken-docs
args: [-l 100]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
files: simweights
additional_dependencies: [numpy]
exclude: ^contrib/
- repo: https://github.com/pycqa/pylint
rev: v4.0.4
rev: v4.0.5
hooks:
- id: pylint
files: simweights
exclude: ^contrib/
additional_dependencies: [numpy, pandas]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
rev: v0.15.4
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand All @@ -62,7 +55,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
rev: v1.5.6
hooks:
- id: forbid-crlf
- id: forbid-tabs
Expand Down
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ classifiers = [
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Scientific/Engineering :: Physics'
]
dependencies = ["numpy>=1.21.2", "scipy"]
dependencies = ["numpy>=2", "scipy"]
dynamic = ["version", "description"]
keywords = ["python", "science", "astronomy", "astrophysics", "IceCube", "neutrino", "simulation"]
license = {file = "LICENSES/BSD-2-Clause.txt"}
Expand All @@ -33,7 +34,7 @@ readme = "README.rst"
requires-python = "~=3.8"

[project.optional-dependencies]
dev = ["pytest", "pre-commit", "reuse", "black", "ruff", "pylint", "mypy"]
dev = ["pytest", "pre-commit", "reuse", "ruff", "pylint"]
docs = ["sphinx", "sphinx-rtd-theme", "pandas"]
examples = ['matplotlib']
test = [
Expand Down Expand Up @@ -68,11 +69,6 @@ source = ["simweights"]
[tool.doc8]
max-line-length = 128

[tool.mypy]
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
strict = true
warn_unreachable = true

[tool.pylint.format]
max-line-length = "128"

Expand Down
88 changes: 53 additions & 35 deletions src/simweights/_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,31 @@ class GaisserH3a(CosmicRayFlux):

pdgids = PDGID_5COMP
_funcs = (
lambda E: 0.7860 * E**-2.66 * exp(-E / (4e6 * 1))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 1))
+ 0.00017 * E**-2.4 * exp(-E / (2e9 * 1)),
lambda E: 0.3550 * E**-2.58 * exp(-E / (4e6 * 2))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 2))
+ 0.00017 * E**-2.4 * exp(-E / (2e9 * 2)),
lambda E: 0.2200 * E**-2.63 * exp(-E / (4e6 * 7))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 7))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 7)),
lambda E: 0.1430 * E**-2.67 * exp(-E / (4e6 * 13))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 13))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 13)),
lambda E: 0.2120 * E**-2.63 * exp(-E / (4e6 * 26))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 26))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 26)),
lambda E: (
0.7860 * E**-2.66 * exp(-E / (4e6 * 1))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 1))
+ 0.00017 * E**-2.4 * exp(-E / (2e9 * 1))
),
lambda E: (
0.3550 * E**-2.58 * exp(-E / (4e6 * 2))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 2))
+ 0.00017 * E**-2.4 * exp(-E / (2e9 * 2))
),
lambda E: (
0.2200 * E**-2.63 * exp(-E / (4e6 * 7))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 7))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 7))
),
lambda E: (
0.1430 * E**-2.67 * exp(-E / (4e6 * 13))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 13))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 13))
),
lambda E: (
0.2120 * E**-2.63 * exp(-E / (4e6 * 26))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 26))
+ 0.000114 * E**-2.4 * exp(-E / (2e9 * 26))
),
)


Expand All @@ -212,9 +222,9 @@ class GaisserH4a(CosmicRayFlux):

pdgids = PDGID_5COMP
_funcs = (
lambda E: 0.7860 * E**-2.66 * exp(-E / (4e6 * 1))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 1))
+ 0.0200 * E**-2.6 * exp(-E / 6e10),
lambda E: (
0.7860 * E**-2.66 * exp(-E / (4e6 * 1)) + 0.0020 * E**-2.4 * exp(-E / (3e7 * 1)) + 0.0200 * E**-2.6 * exp(-E / 6e10)
),
lambda E: 0.3550 * E**-2.58 * exp(-E / (4e6 * 2)) + 0.002 * E**-2.4 * exp(-E / (3e7 * 2)),
lambda E: 0.2200 * E**-2.63 * exp(-E / (4e6 * 7)) + 0.00134 * E**-2.4 * exp(-E / (3e7 * 7)),
lambda E: 0.1430 * E**-2.67 * exp(-E / (4e6 * 13)) + 0.00134 * E**-2.4 * exp(-E / (3e7 * 13)),
Expand All @@ -233,14 +243,16 @@ class GaisserH4a_IT(CosmicRayFlux):
# pylint: disable=invalid-name
pdgids = PDGID_4COMP
_funcs = (
lambda E: 0.7860 * E**-2.66 * exp(-E / (4e6 * 1))
+ 0.0020 * E**-2.4 * exp(-E / (3e7 * 1))
+ 0.0200 * E**-2.6 * exp(-E / 6e10),
lambda E: (
0.7860 * E**-2.66 * exp(-E / (4e6 * 1)) + 0.0020 * E**-2.4 * exp(-E / (3e7 * 1)) + 0.0200 * E**-2.6 * exp(-E / 6e10)
),
lambda E: 0.3550 * E**-2.58 * exp(-E / (4e6 * 2)) + 0.0020 * E**-2.4 * exp(-E / (3e7 * 2)),
lambda E: 0.2200 * E**-2.63 * exp(-E / (4e6 * 7))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 7))
+ 0.1430 * E**-2.67 * exp(-E / (4e6 * 13))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 13)),
lambda E: (
0.2200 * E**-2.63 * exp(-E / (4e6 * 7))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 7))
+ 0.1430 * E**-2.67 * exp(-E / (4e6 * 13))
+ 0.00134 * E**-2.4 * exp(-E / (3e7 * 13))
),
lambda E: 0.2120 * E**-2.63 * exp(-E / (4e6 * 26)) + 0.00134 * E**-2.4 * exp(-E / (3e7 * 26)),
)

Expand Down Expand Up @@ -304,9 +316,11 @@ class GlobalFitGST(CosmicRayFlux):
lambda E: 0.32 * E**-2.58 * exp(-E / 1.2e5 / 2) + 0.0065 * E**-2.3 * exp(-E / 4e6 / 2),
lambda E: 0.01 * E**-2.40 * exp(-E / 1.2e5 / 7) + 0.0006 * E**-2.3 * exp(-E / 4e6 / 7),
lambda E: 0.013 * E**-2.40 * exp(-E / 1.2e5 / 13) + 0.0007 * E**-2.3 * exp(-E / 4e6 / 13),
lambda E: 0.006 * E**-2.30 * exp(-E / 1.2e5 / 26)
+ 0.00023 * E**-2.2 * exp(-E / 4e6 / 26)
+ 0.0000025 * E**-2.2 * exp(-E / 1.3e9 / 26),
lambda E: (
0.006 * E**-2.30 * exp(-E / 1.2e5 / 26)
+ 0.00023 * E**-2.2 * exp(-E / 4e6 / 26)
+ 0.0000025 * E**-2.2 * exp(-E / 1.3e9 / 26)
),
)


Expand All @@ -320,13 +334,17 @@ class GlobalFitGST_IT(CosmicRayFlux): # pylint: disable=invalid-name
_funcs = (
lambda E: 0.7 * E**-2.66 * exp(-E / 1.2e5) + 0.015 * E**-2.4 * exp(-E / 4e6) + 0.0014 * E**-2.4 * exp(-E / 1.3e9),
lambda E: 0.32 * E**-2.58 * exp(-E / 1.2e5 / 2) + 0.0065 * E**-2.3 * exp(-E / 4e6 / 2),
lambda E: 0.01 * E**-2.40 * exp(-E / 1.2e5 / 7)
+ 0.0006 * E**-2.3 * exp(-E / 4e6 / 7)
+ 0.013 * E**-2.40 * exp(-E / 1.2e5 / 13)
+ 0.0007 * E**-2.3 * exp(-E / 4e6 / 13),
lambda E: 0.006 * E**-2.30 * exp(-E / 1.2e5 / 26)
+ 0.00023 * E**-2.2 * exp(-E / 4e6 / 26)
+ 0.0000025 * E**-2.2 * exp(-E / 1.3e9 / 26),
lambda E: (
0.01 * E**-2.40 * exp(-E / 1.2e5 / 7)
+ 0.0006 * E**-2.3 * exp(-E / 4e6 / 7)
+ 0.013 * E**-2.40 * exp(-E / 1.2e5 / 13)
+ 0.0007 * E**-2.3 * exp(-E / 4e6 / 13)
),
lambda E: (
0.006 * E**-2.30 * exp(-E / 1.2e5 / 26)
+ 0.00023 * E**-2.2 * exp(-E / 4e6 / 26)
+ 0.0000025 * E**-2.2 * exp(-E / 1.3e9 / 26)
),
)


Expand Down
4 changes: 2 additions & 2 deletions src/simweights/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def has_column(table: Any, name: str) -> bool:

def get_column(table: Any, name: str) -> Any:
"""Helper function getting a column from a table, works with h5py, pytables, and pandas."""
if hasattr(table, "arrays"):
return table.arrays(library="np")[name]
if hasattr(table, "cols"):
return np.asarray(getattr(table.cols, name)[:], dtype=np.float64)
if hasattr(table, name):
Expand All @@ -92,8 +94,6 @@ def get_column(table: Any, name: str) -> Any:
if hasattr(table, "primary") and hasattr(table.primary.dir, name):
return np.asarray(np.atleast_1d(getattr(table.primary.dir, name)), dtype=np.float64)
column = table[name]
if hasattr(column, "array") and callable(column.array):
return np.asarray(column.array(library="np"), dtype=np.float64)
return np.asarray(np.atleast_1d(column), dtype=np.float64)


Expand Down