Skip to content

Commit

Permalink
add .editorconfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmeagher committed Nov 30, 2023
1 parent 9b02750 commit 82ec3ae
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 132 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: © 2023 The SimWeights Contributors
#
# SPDX-License-Identifier: BSD-2-Clause

# see https://editorconfig.org/ for how to use of this file

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.py]
indent_size = 4

[Makefile]
indent_style = tab
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
run: |
tar -czvf simweights_docs.tar.gz -C_build/html .
curl -XPUT -i --data-binary @simweights_docs.tar.gz https://docs.icecube.aq/api/upload?path=simweights/${{ github.ref_name }} -u icecube:${{ secrets.ICECUBE_PASSWORD }}
- name: Check Links
working-directory: ./docs
env:
ICECUBE_PASSWORD: ${{ secrets.ICECUBE_PASSWORD }}
run: make linkcheck SPHINXOPTS="-W --keep-going"
# - name: Check Links
# working-directory: ./docs
# env:
# ICECUBE_PASSWORD: ${{ secrets.ICECUBE_PASSWORD }}
# run: make linkcheck SPHINXOPTS="-W --keep-going"
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: blacken-docs
args: [-l 100]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
rev: v1.7.1
hooks:
- id: mypy
files: simweights
Expand Down Expand Up @@ -85,3 +85,8 @@ repos:
args: [--pytest-test-first]
- id: trailing-whitespace
exclude: \.svg$
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: "2.7.3"
hooks:
- id: editorconfig-checker
alias: ec
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
.. |LICENSE| image:: https://img.shields.io/badge/License-BSD_2--Clause-orange.svg
:target: https://opensource.org/licenses/BSD-2-Clause
.. |pre-commit.ci| image:: https://results.pre-commit.ci/badge/github/icecube/simweights/main.svg
:target: https://results.pre-commit.ci/latest/github/icecube/simweights/main
:alt: pre-commit.ci status
:target: https://results.pre-commit.ci/latest/github/icecube/simweights/main
:alt: pre-commit.ci status
.. |pypi| image:: https://badge.fury.io/py/simweights.svg
:target: https://pypi.org/project/simweights/
:alt: PyPi
:target: https://pypi.org/project/simweights/
:alt: PyPi

.. badge-break
Expand Down
14 changes: 7 additions & 7 deletions docs/apireference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
API Reference
-------------

.. automodule:: simweights
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
:special-members: __add__ __mul__
.. automodule:: simweights
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
:special-members: __add__ __mul__

.. automodule:: simweights._fluxes._references
.. automodule:: simweights._fluxes._references
20 changes: 10 additions & 10 deletions docs/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ is shown below.
$ simweights Level2_IC86.2016_corsika.020789.000000.hdf5 -f GaisserH3a
< GenerationSurfaceCollection
PPlus : N=636650.0 PowerLaw(-2.65 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
He4Nucleus : N=350000.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
N14Nucleus : N=171100.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
Al27Nucleus : N=186650.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
Fe56Nucleus : N=155550.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
PPlus : N=636650.0 PowerLaw(-2.65 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
He4Nucleus : N=350000.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
N14Nucleus : N=171100.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
Al27Nucleus : N=186650.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
Fe56Nucleus : N=155550.0 PowerLaw(-2.6 ,30000.0, 1000000.0) NaturalRateCylinder(1200.0, 600.0, 0.00017457020856805793, 1.0)
>
{'energy': ('PolyplopiaPrimary', 'energy'),
'event_weight': None,
'pdgid': ('PolyplopiaPrimary', 'type'),
'zenith': ('PolyplopiaPrimary', 'zenith')}
{ 'energy': ('PolyplopiaPrimary', 'energy'),
'event_weight': None,
'pdgid': ('PolyplopiaPrimary', 'type'),
'zenith': ('PolyplopiaPrimary', 'zenith')}
Number of Events : 38444
Effective Area : 289893 m²
Using flux model : GaisserH3a
Expand All @@ -33,5 +33,5 @@ is shown below.
The complete command line options are show below:

.. literalinclude:: cmdline.txt
.. literalinclude:: cmdline.txt
:language: none
94 changes: 47 additions & 47 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,53 @@
..
.. SPDX-License-Identifier: BSD-2-Clause
.. include:: ../README.rst
:start-after: badge-break
:end-before: doc-break

.. toctree::
:maxdepth: 1

getting_started
contributing
changelog

.. toctree::
:maxdepth: 1
:caption: Tutorials

corsika_tutorial
nugen_tutorial
icetop_tutorial

.. toctree::
:maxdepth: 1
:caption: How-To Guides

combining_datasets
nugen_nuflux
effective_area
livetime
additional_flux_params
without_tableio

.. toctree::
:maxdepth: 1
:caption: Explanations

weights_in_simulation
weights_in_icecube
spatial
reading_files
reading_nugen
units

.. toctree::
:maxdepth: 1
:caption: Reference

apireference
cmdline
.. include:: ../README.rst
:start-after: badge-break
:end-before: doc-break

.. toctree::
:maxdepth: 1

getting_started
contributing
changelog

.. toctree::
:maxdepth: 1
:caption: Tutorials

corsika_tutorial
nugen_tutorial
icetop_tutorial

.. toctree::
:maxdepth: 1
:caption: How-To Guides

combining_datasets
nugen_nuflux
effective_area
livetime
additional_flux_params
without_tableio

.. toctree::
:maxdepth: 1
:caption: Explanations

weights_in_simulation
weights_in_icecube
spatial
reading_files
reading_nugen
units

.. toctree::
:maxdepth: 1
:caption: Reference

apireference
cmdline

The layout and organization of this documentation is based on
`The Documentation System <https://documentation.divio.com/>`_.
6 changes: 3 additions & 3 deletions docs/nugen_nuflux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SimWeights will detect that it is a nuflux model and do the correct thing.
This example creates a number of nuflux models and compares them with a custom
flux model from the IceCube northern track result.

.. literalinclude:: ../examples/nugen_nuflux.py
:start-after: start-box1
:end-before: end-box1
.. literalinclude:: ../examples/nugen_nuflux.py
:start-after: start-box1
:end-before: end-box1

.. figure:: nugen_nuflux.svg
82 changes: 41 additions & 41 deletions src/simweights/_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,45 +394,45 @@ def __call__(self: FixedFractionFlux, energy: ArrayLike, pdgid: ArrayLike) -> ND
class _references:
"""References.
.. [#Hoerandel] J. R. Hörandel, "On the knee in the energy spectrum of cosmic rays,"
`Astropart. Phys. 19, 193 (2003)
<https://doi.org/10.1016/S0927-6505(02)00198-6>`_.
`astro-ph/0210453 <https://arxiv.org/abs/astro-ph/0210453>`_.
.. [#Becherini] Y. Becherini et al.,
"A parameterisation of single and multiple muons in the deep water or ice,"
`Astropart. Phys. 25, 1 (2006)
<https://doi.org/10.1016/j.astropartphys.2005.10.005>`_.
`hep-ph/0507228 <https://arxiv.org/abs/hep-ph/0507228>`_.
.. [#Schoenwald] A. Schoenwald, ``http://www.ifh.de/~arnes/Forever/Hoerandel_Plots/`` [Dead Link]
.. [#Gaisser1] T. Gaisser,
"Cosmic ray spectrum and composition > 100 TeV," IceCube Internal Report
`icecube/201102004-v2
<https://internal-apps.icecube.wisc.edu/reports/details.php?type=report&id=icecube%2F201102004>`_
(2011).
.. [#Gaisser2] T. Gaisser,
"Spectrum of cosmic-ray nucleons and the atmospheric muon charge ratio,"
`Astropart. Phys. 35, 801 (2012)
<https://doi.org/10.1016/j.astropartphys.2012.02.010>`_.
`arXiv:1111.6675v2 <https://arxiv.org/abs/1111.6675v2>`_.
.. [#Aartsen] M. G. Aartsen et al. "Measurement of the cosmic ray energy spectrum with IceTop-73,"
`Phys. Rev. D 88, 042004 (2013) <https://doi.org/10.1103/PhysRevD.88.042004>`_.
`arXiv:1307.3795v1 <https://arxiv.org/abs/1307.3795v1>`_.
.. [#Honda] M. Honda, T. Kajita, K. Kasahara, and S. Midorikawa,
"New calculation of the atmospheric neutrino flux in a three-dimensional scheme,"
`Phys. Rev. D 70, 043008 (2004) <https://doi.org/10.1103/PhysRevD.70.043008>`_.
`astro-ph/0404457v4 <https://arxiv.org/abs/astro-ph/0404457v4>`_.
.. [#Enberg] R. Enberg, M. H. Reno, I. Sarcevic, "Prompt neutrino fluxes from atmospheric charm,"
`Phys. Rev. D 78, 043005 (2008) <https://doi.org/10.1103/PhysRevD.78.043005>`_.
`arXiv:0806.0418 <https://arxiv.org/abs/0806.0418>`_.
.. [#Thunman] M. Thunman, G. Ingelman, P. Gondolo,
"Charm Production and High Energy Atmospheric Muon and Neutrino Fluxes,"
`Astropart. Phys. 5, 309 (1996) <https://doi.org/10.1016/0927-6505(96)00033-3>`_.
`hep-ph/9505417 <https://arxiv.org/abs/hep-ph/9505417>`_.
.. [#GaisserStanevTilav] T. K. Gaisser, T. Stanev, and S. Tilav,
"Cosmic ray energy spectrum from measurements of air showers,"
`Frontiers of Physics 8, 748 (2013) <https://doi.org/10.1007/s11467-013-0319-7>`_.
`arXiv:1303.3565 <https://arxiv.org/abs/1303.3565v1>`_.
.. [#GSFDembinski] H. Dembinski et al.,
"Data-driven model of the cosmic-ray flux and mass composition from 10 GeV to $10^{11} $ GeV."
`arXiv:1711.11432 <https://arxiv.org/abs/1711.11432>`_.
.. [#Hoerandel] J. R. Hörandel, "On the knee in the energy spectrum of cosmic rays,"
`Astropart. Phys. 19, 193 (2003)
<https://doi.org/10.1016/S0927-6505(02)00198-6>`_.
`astro-ph/0210453 <https://arxiv.org/abs/astro-ph/0210453>`_.
.. [#Becherini] Y. Becherini et al.,
"A parameterisation of single and multiple muons in the deep water or ice,"
`Astropart. Phys. 25, 1 (2006)
<https://doi.org/10.1016/j.astropartphys.2005.10.005>`_.
`hep-ph/0507228 <https://arxiv.org/abs/hep-ph/0507228>`_.
.. [#Schoenwald] A. Schoenwald, ``http://www.ifh.de/~arnes/Forever/Hoerandel_Plots/`` [Dead Link]
.. [#Gaisser1] T. Gaisser,
"Cosmic ray spectrum and composition > 100 TeV," IceCube Internal Report
`icecube/201102004-v2
<https://internal-apps.icecube.wisc.edu/reports/details.php?type=report&id=icecube%2F201102004>`_
(2011).
.. [#Gaisser2] T. Gaisser,
"Spectrum of cosmic-ray nucleons and the atmospheric muon charge ratio,"
`Astropart. Phys. 35, 801 (2012)
<https://doi.org/10.1016/j.astropartphys.2012.02.010>`_.
`arXiv:1111.6675v2 <https://arxiv.org/abs/1111.6675v2>`_.
.. [#Aartsen] M. G. Aartsen et al. "Measurement of the cosmic ray energy spectrum with IceTop-73,"
`Phys. Rev. D 88, 042004 (2013) <https://doi.org/10.1103/PhysRevD.88.042004>`_.
`arXiv:1307.3795v1 <https://arxiv.org/abs/1307.3795v1>`_.
.. [#Honda] M. Honda, T. Kajita, K. Kasahara, and S. Midorikawa,
"New calculation of the atmospheric neutrino flux in a three-dimensional scheme,"
`Phys. Rev. D 70, 043008 (2004) <https://doi.org/10.1103/PhysRevD.70.043008>`_.
`astro-ph/0404457v4 <https://arxiv.org/abs/astro-ph/0404457v4>`_.
.. [#Enberg] R. Enberg, M. H. Reno, I. Sarcevic, "Prompt neutrino fluxes from atmospheric charm,"
`Phys. Rev. D 78, 043005 (2008) <https://doi.org/10.1103/PhysRevD.78.043005>`_.
`arXiv:0806.0418 <https://arxiv.org/abs/0806.0418>`_.
.. [#Thunman] M. Thunman, G. Ingelman, P. Gondolo,
"Charm Production and High Energy Atmospheric Muon and Neutrino Fluxes,"
`Astropart. Phys. 5, 309 (1996) <https://doi.org/10.1016/0927-6505(96)00033-3>`_.
`hep-ph/9505417 <https://arxiv.org/abs/hep-ph/9505417>`_.
.. [#GaisserStanevTilav] T. K. Gaisser, T. Stanev, and S. Tilav,
"Cosmic ray energy spectrum from measurements of air showers,"
`Frontiers of Physics 8, 748 (2013) <https://doi.org/10.1007/s11467-013-0319-7>`_.
`arXiv:1303.3565 <https://arxiv.org/abs/1303.3565v1>`_.
.. [#GSFDembinski] H. Dembinski et al.,
"Data-driven model of the cosmic-ray flux and mass composition from 10 GeV to $10^{11} $ GeV."
`arXiv:1711.11432 <https://arxiv.org/abs/1711.11432>`_.
"""
2 changes: 1 addition & 1 deletion src/simweights/_powerlaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PowerLaw:
.. math::
pdf(x, \gamma) = A x^{\gamma}\quad\mathrm{for}\quad a \le x \le b.
pdf(x, \gamma) = A x^{\gamma}\quad\mathrm{for}\quad a \le x \le b.
Args:
g (float): Power-law index
Expand Down
4 changes: 2 additions & 2 deletions src/simweights/_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class UniformSolidAngleCylinder(CylinderBase):
.. math::
I \propto \cos\theta
I \propto \cos\theta
"""

Expand All @@ -106,7 +106,7 @@ class NaturalRateCylinder(CylinderBase):
.. math::
I \propto \pi\cdot r^2\cdot\sin\theta\cdot(\cos\theta+2/\pi\cdot l/r\cdot\sin\theta)
I \propto \pi\cdot r^2\cdot\sin\theta\cdot(\cos\theta+2/\pi\cdot l/r\cdot\sin\theta)
"""

def __init__(self: NaturalRateCylinder, length: float, radius: float, cos_zen_min: float, cos_zen_max: float) -> None:
Expand Down
27 changes: 16 additions & 11 deletions src/simweights/_weighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ def get_weights(self: Weighter, flux: Any) -> NDArray[np.float64]:
"""Calculate the weights for the sample for the given flux.
Args:
flux : flux
An object representing the flux. It can be one of several types:
* An instance of :py:class:`nuflux.FluxFunction` from
`nuflux <https://github.com/icecube/nuflux>`_
* A callable where the names of the arguments match the weight objects weighting columns.
* An iterable with the same length as the data sample. If you have other means of calculating
the flux for each event than the above options this can be useful.
* A scalar number. This calculates the unrealistic scenario where all events have the same
flux, this can be useful for testing or calculating effective areas. For neutrinos, If the
value is 1 then the return value will be the well known quantity OneWeight.
flux (Callable | FluxFunction | ArrayLike ):
A model describing the flux of the primaries to weight against
The Flux argument can be one of several types:
* An instance of :py:class:`nuflux.FluxFunction` from
`nuflux <https://github.com/icecube/nuflux>`_.
* A callable where the names of the arguments match the weight objects weighting
columns.
* An iterable with the same length as the data sample. If you have other means
of calculating the flux for each event than the above options this can be
useful.
* A scalar number, this calculates the unrealistic scenario where all events
have the same flux, this can be useful for testing or calculating effective
areas. For neutrinos, If the value is 1 then the return value will be the
well known quantity OneWeight.
"""
event_col = {k: self.get_weight_column(k) for k in ["energy", "pdgid", "cos_zen"]}

Expand Down

0 comments on commit 82ec3ae

Please sign in to comment.