Skip to content

Commit

Permalink
Merge branch 'release_v2.0' into JostMigenda/Flavor_Matrix_implementa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Sheshuk committed Jun 7, 2024
2 parents e3982e2 + 65bc4d5 commit d428a6e
Show file tree
Hide file tree
Showing 30 changed files with 697 additions and 411 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ jobs:
run: |
python -m unittest python/snewpy/test/simplerate_integrationtest.py
pytest -m 'snowglobes'
- name: Run Jupyter notebooks
run: |
pip install nbclient ipykernel
jupyter kernelspec list
cd doc/nb/
jupyter execute ccsn/*.ipynb
jupyter execute presn/*.ipynb
jupyter execute AnalyticFluence.ipynb FlavorTransformation.ipynb
# Download necessary progenitor file, before executing the notebook
python -c 'from snewpy.models.ccsn import Zha_2021; from astropy import units as u; _ = Zha_2021(progenitor_mass=17*u.solMass)'
jupyter execute SNOwGLoBES_usage.ipynb
20 changes: 12 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,26 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Check and get Version Number
id: get_version
run: |
pip install .
PYTHON_VERSION=`python -c 'import snewpy; print(snewpy.__version__)'`
echo "PYTHON_VERSION=${PYTHON_VERSION}"
GIT_VERSION=${GITHUB_REF/refs\/tags\/v/}
echo "GIT_VERSION=${GIT_VERSION}"
if [ $PYTHON_VERSION != $GIT_VERSION ]; then exit 1; fi
echo "VERSION=${PYTHON_VERSION}" >> $GITHUB_OUTPUT
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_JM }}
run: |
python -c 'import python.snewpy; python.snewpy._get_model_urls()'
cat python/snewpy/_model_urls.py
pip install .
python -c 'import snewpy; snewpy.get_models(models="Bollig_2016")'
rm -r SNEWPY_models/
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Get Version Number
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Create Draft Release
# Go to https://github.com/SNEWS2/snewpy/releases to edit this draft release and publish it
# Once it is published, the release automatically is pushed to Zenodo: https://doi.org/10.5281/zenodo.4498940
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ jobs:
python -m pip install --upgrade pip
- name: Install SNEWPY
run: |
pip install ".[dev]"
pip install ".[dev,docs]"
# Run the unit tests
- name: Test with pytest
- name: Run unit tests with pytest
run: |
pytest -m 'not snowglobes'
- name: Build HTML docs
run: |
cd doc/
make html
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ dist/
# default directory for downloaded model files
SNEWPY_models/

# snewpy.snowglobes output files
## SNEWPY output files
# snewpy.snowglobes intermediate results
*_SNOprocessed.tar.gz
*.npy
*.npz

# used for integration tests in test_snowglobes.py
fluence_Bollig_2016_s*
# plots generated by FlavorTransformation.ipynb
doc/nb/*_adiabaticmsw*.pdf

# editor-specific
.ipynb_checkpoints/
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SNEWPY: Supernova Neutrino Early Warning Models for Python

<img src="/doc/source/snewpy-logo.png" alt="snewpy logo: The word 'snewpy' in a monospace font, with an explosion emoji inside the letter 'p'." style="width: 300px; max-width: 100%;" />
<img src="https://github.com/SNEWS2/snewpy/blob/v1.4/doc/source/snewpy-logo.png?raw=true" alt="snewpy logo: The word 'snewpy' in a monospace font, with an explosion emoji inside the letter 'p'." style="width: 300px; max-width: 100%;" />

[![DOI](https://zenodo.org/badge/221705586.svg)](https://zenodo.org/badge/latestdoi/221705586)
[![PyPI](https://img.shields.io/pypi/v/snewpy)](https://pypi.org/project/snewpy/)
Expand Down Expand Up @@ -53,9 +53,9 @@ flux = bollig.get_flux(distance=10*u.kpc, transformation=msw_nmo)

You can also calculate the observed event rate in all neutrino detectors supported by SNOwGLoBES, use the included SN models and flavor transformations in event generators like sntools, and much more.

Example scripts which show how SNEWPY can be used are available in the
`python/snewpy/scripts/` subfolder as well as notebooks in `doc/nb/`.
Most downloadable models also include a Jupyter notebook with simple usage examples.
Jupyter notebooks showcasing the downloadable supernova models available through SNEWPY and much of its functionality are available in the `doc/nb/` subfolder.
Additional example scripts are in the
`python/snewpy/scripts/` subfolder.

Papers describing SNEWPY and the underlying physics are published in the Astrophysical Journal ([DOI:10.3847/1538-4357/ac350f](https://dx.doi.org/10.3847/1538-4357/ac350f), [arXiv:2109.08188](https://arxiv.org/abs/2109.08188)) and the Journal of Open Source Software ([DOI:10.21105/joss.03772](https://dx.doi.org/10.21105/joss.03772)).

Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
ALLSPHINXOPTS = -W --keep-going -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

Expand Down
14 changes: 9 additions & 5 deletions doc/nb/FlavorTransformation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@
"outputs": [],
"source": [
"fig = plot_total_flux(model, AdiabaticMSW(), AdiabaticMSW(mh=MassHierarchy.INVERTED) )\n",
"fig.savefig('flux_adiabaticmsw.pdf')\n",
"fig.show()\n",
"# fig.savefig('flux_adiabaticmsw.pdf')\n",
"fig = plot_spectra(model, AdiabaticMSW(), AdiabaticMSW(mh=MassHierarchy.INVERTED), 100*u.ms)\n",
"fig.savefig('spectra_adiabaticmsw.pdf')"
"fig.show()\n",
"# fig.savefig('spectra_adiabaticmsw.pdf')"
]
},
{
Expand All @@ -264,9 +266,11 @@
"xf_imo = AdiabaticMSWes(angles_imo)\n",
"\n",
"fig = plot_total_flux(model, xf_nmo, xf_imo)\n",
"fig.savefig('flux_adiabaticmswes.pdf')\n",
"fig.show()\n",
"# fig.savefig('flux_adiabaticmswes.pdf')\n",
"fig = plot_spectra(model, xf_nmo, xf_imo, 100*u.ms)\n",
"fig.savefig('spectra_adiabaticmswes.pdf')"
"fig.show()\n",
"# fig.savefig('spectra_adiabaticmswes.pdf')"
]
}
],
Expand All @@ -286,7 +290,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.12.3"
},
"vscode": {
"interpreter": {
Expand Down
104 changes: 32 additions & 72 deletions doc/nb/SNOwGLoBES_usage.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit d428a6e

Please sign in to comment.