Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start refactoring pyIRF #36

Merged
merged 110 commits into from Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
64abee5
Start rewriting pyIRF
maxnoe Sep 18, 2020
194f768
Fix docs and include new pages in it
maxnoe Sep 18, 2020
b5e1630
Remove test for old io
maxnoe Sep 18, 2020
af007e1
Fix unit of PDG spectrum, fix electron class, add example plot
maxnoe Sep 18, 2020
8def2e2
Fix electron spectrum
maxnoe Sep 18, 2020
55ce33a
Fix docstring of lima
maxnoe Sep 18, 2020
8e0240f
Electron spectrum now correct, IRF Document was relying on ROOT inter…
maxnoe Sep 21, 2020
30bd560
Add readthedocs config
maxnoe Sep 21, 2020
c13edb3
Fix indentation in readthedocs config
maxnoe Sep 21, 2020
21ad595
Add test requirements
maxnoe Sep 21, 2020
4eb556a
Add calculating sensitivity for a fixed set of cuts
maxnoe Sep 21, 2020
7f931d3
Merge branch 'master' into rewrite
maxnoe Sep 21, 2020
1ed76c7
Add bin center, improve check
maxnoe Sep 21, 2020
b6a5252
Do not give format, prevents reading root files accidentally
maxnoe Sep 21, 2020
cc58e66
Add flux sensitivity
maxnoe Sep 21, 2020
56de703
Add electrons
maxnoe Sep 21, 2020
8c709ca
Add general function to apply cuts
maxnoe Sep 21, 2020
81e1aa9
Fix typo
maxnoe Sep 21, 2020
2e50c0f
Implement functions to calculate and apply binned cuts
maxnoe Sep 22, 2020
0d6cfe3
Use smaller initial guess in sensitivity
maxnoe Sep 22, 2020
87ca45b
Calculate number of showers from run header info
maxnoe Sep 22, 2020
0288711
Use 40% efficiency gh cut and finer binning for theta cut
maxnoe Sep 22, 2020
380a083
Optmize gh cut
maxnoe Sep 22, 2020
1f03df7
Correct reading of true azimuth for event display data
maxnoe Sep 22, 2020
eeaddde
Recalculate theta cut after optimizing gh cut
maxnoe Sep 22, 2020
cbf3d6a
Use brentq instead of newton for guaranteed convergence
maxnoe Sep 22, 2020
7dd600d
Fix significance for scalar quantitities
maxnoe Sep 22, 2020
170a06c
Scale off region size by alpha=0.2
maxnoe Sep 22, 2020
34691fd
Add repr to LogParabola
maxnoe Sep 22, 2020
35d0ca2
Fix hard coded alpha=1 leftover
maxnoe Sep 23, 2020
8141796
Add some minimum requirements for background statistics
maxnoe Sep 23, 2020
9fb4956
Add calculate_theta function
maxnoe Sep 23, 2020
b66ea82
Calculate Effective Area
maxnoe Sep 23, 2020
c0e15b4
Calculate energy dispersion
maxnoe Sep 23, 2020
d259b51
Calculate energy bias / resolution
maxnoe Sep 23, 2020
92d7823
Try running example script on travis
maxnoe Sep 23, 2020
01d31df
Add curl options
maxnoe Sep 23, 2020
4d5b931
Add psf and angular resolution
maxnoe Sep 23, 2020
5713c22
Update notebook
maxnoe Sep 23, 2020
07ec860
Execute notebook on travis
maxnoe Sep 23, 2020
693fbde
Remove savefigs from notebook
maxnoe Sep 23, 2020
9ba7201
Fix psf normalization
maxnoe Sep 24, 2020
786072e
Fix test, remove unused code
maxnoe Sep 24, 2020
36a18ac
Add test for psf
maxnoe Sep 24, 2020
d53440d
Update notebook and docs
Sep 24, 2020
03948c2
Move notebook out of contribute
maxnoe Sep 24, 2020
4c50171
Build docs on travis
maxnoe Sep 24, 2020
2fa0a5a
Remove material from first version.
Sep 24, 2020
25f02db
Merge branch 'rewrite' of https://github.com/cta-observatory/pyirf in…
Sep 24, 2020
62a8cfd
Simplify function return values and add io for GADF format
maxnoe Sep 24, 2020
52fee6b
Start updating the docs
maxnoe Sep 24, 2020
275617e
Install cython on travis for gammapy
maxnoe Sep 24, 2020
0fbf9a3
Bump version to 0.2
maxnoe Sep 24, 2020
4e696d5
Increase timeout for data download
maxnoe Sep 24, 2020
03ba047
Add some docstrings
maxnoe Sep 24, 2020
3ff5546
Add effective area unit test
maxnoe Sep 24, 2020
1ef961f
Fix warnings for low number of background events
maxnoe Sep 25, 2020
cc820e2
Fix handling of pointing position
maxnoe Sep 25, 2020
80b3583
Start updating the docs
maxnoe Sep 25, 2020
1ecef0e
Fix duplicated changelog entry
maxnoe Sep 25, 2020
df591b2
Add IRF description document
maxnoe Sep 25, 2020
7d168e6
Clear up install docs
maxnoe Sep 25, 2020
9135dc0
Remove leftover file
maxnoe Sep 25, 2020
7f76cee
Cleanup dependencies
maxnoe Sep 25, 2020
60e8bda
Change usage instruction to describe library-like usage
maxnoe Sep 25, 2020
8c60726
Fix duplicated reference
maxnoe Sep 25, 2020
4179fe2
Store radmax table
maxnoe Sep 25, 2020
8c7816b
Add download_test_data
maxnoe Sep 25, 2020
0cca496
Use correct gadf link
maxnoe Sep 25, 2020
bb3affd
Remove zip after unpacking
maxnoe Sep 25, 2020
f3afad8
Fix links in introduction
maxnoe Sep 25, 2020
7b6e8fb
Remove pdf, mention github projects
maxnoe Sep 25, 2020
537b821
Add missing docstrings in pyirf/utils.py
Sep 25, 2020
e65e236
Merge branch 'rewrite' of https://github.com/cta-observatory/pyirf in…
Sep 25, 2020
c947509
Add __all__ magic variable
Sep 25, 2020
fba1cf9
Added utils section of API documentation.
Sep 25, 2020
0253289
Update main index
Sep 25, 2020
583a446
Add docstrings and creation date to GADF HDU
maxnoe Sep 25, 2020
569b8bc
More docstrings
maxnoe Sep 25, 2020
d403011
Fix typo in main index
Sep 25, 2020
847fe5a
Remove old API section for resources
Sep 25, 2020
2a7194b
Update authors copyright
Sep 25, 2020
0acf043
Merge branch 'rewrite' of https://github.com/cta-observatory/pyirf in…
Sep 25, 2020
8ea3d52
Fix headings in IRF index API docs
Sep 25, 2020
062ed35
Fix creation time
maxnoe Sep 25, 2020
4438b67
Remove time arguments from sensitivity, add docstrings
maxnoe Sep 25, 2020
c2edc37
Add docstrings for angular resolution and energy resolution/bias.
Sep 25, 2020
dc3b651
Fix typo in angular_resolution docstring
Sep 25, 2020
ea5d950
Add docstring to pyirf.binning.create_histogram_table
Sep 25, 2020
fb8d8c6
More docs
maxnoe Sep 25, 2020
228e3d1
Add energy dispersion unit test
LukasNickel Sep 25, 2020
09bf11a
Randomly generate energiey and estimate sigma from dispersion matrix
LukasNickel Sep 25, 2020
007e291
Set seed in test, increase N
maxnoe Sep 25, 2020
bde866f
Improve plots in notebook
maxnoe Sep 25, 2020
8482796
Merge pull request #41 from cta-observatory/rewrite_unit_tests
maxnoe Sep 25, 2020
38ed511
Update README.rst
maxnoe Sep 26, 2020
48be1d7
fix some nomenclature in test dispersion
Sep 26, 2020
f6765d8
Global formatting compliant with PEP8 via black.
Sep 26, 2020
645b8a0
Fix bug in plot spectra example
Sep 26, 2020
420ae42
Add examples section to docs
maxnoe Sep 26, 2020
166e920
Calculate PSF on gammas without theta cut, update notebook
maxnoe Sep 26, 2020
7375753
Remove mpl clutter from notebook cell output
maxnoe Sep 26, 2020
7cf1f2d
Fix HDUDOC link for GADF
maxnoe Sep 26, 2020
2c12c54
Make sure uproot is version 3 for the moment
maxnoe Sep 26, 2020
42d88b3
Change author in setup to CTA ASWG
maxnoe Sep 26, 2020
aba7ed4
Transpose irf arrays when writing to fits to match GADF order, add te…
maxnoe Sep 26, 2020
d66fc2f
Add tests for benchmarks
maxnoe Sep 26, 2020
4bd9d37
Update README
Sep 27, 2020
15beef2
Add cython to installation test extras
Sep 27, 2020
7c802a5
Remove cython, does not fix the problem with installing gammapy
maxnoe Sep 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
@@ -1,4 +1,5 @@
# Byte-compiled / optimized / DLL files
data
__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -41,6 +42,10 @@ pip-delete-this-directory.txt
docs/api
docs/_build

# Results and plots
*.fits.gz
*.png

# Unit test / coverage reports
htmlcov/
.tox/
Expand Down
4 changes: 4 additions & 0 deletions .mailmap
@@ -0,0 +1,4 @@
Michele Peresano <michele.peresano@cea.fr> Michele Peresano <michele.peresano@.cea.fr>

Thomas Vuillaume <thomas.vuillaume@lapp.in2p3.fr> vuillaut <thomas.vuillaume@gmail.com>
Thomas Vuillaume <thomas.vuillaume@lapp.in2p3.fr> Thomas Vuillaume <thomas.vuillaume@gmail.com>
11 changes: 11 additions & 0 deletions .readthedocs.yml
@@ -0,0 +1,11 @@
version: 2

python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
- tests
system_packages: false
47 changes: 27 additions & 20 deletions .travis.yml
@@ -1,9 +1,9 @@
language: generic

env:
global:
- PYTHONIOENCODING=UTF8
- MPLBACKEND=Agg
global:
- PYTHONIOENCODING=UTF8
- MPLBACKEND=Agg

matrix:
include:
Expand All @@ -20,28 +20,35 @@ matrix:
- CONDA=true

before_install:

- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- . $HOME/miniconda/etc/profile.d/conda.sh
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda # get latest conda version
- conda info -a # Useful for debugging any issues with conda
- travis_wait 15 ./download_test_data.sh
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- . $HOME/miniconda/etc/profile.d/conda.sh
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda # get latest conda version
- conda info -a # Useful for debugging any issues with conda

install:
- conda env create -f environment.yml
- conda activate pyirf
- pip install travis-sphinx codecov pytest-cov
- python setup.py install
- sed -i -e "s/- python=.*/- python=$PYTHON_VERSION/g" environment.yml
- conda env create -f environment.yml
- conda activate pyirf-dev
# cython needed for building gammapy
- pip install travis-sphinx codecov pytest-cov Cython
- pip install .[all]
- python --version

script:
- pytest --cov=pyirf
- pytest --cov=pyirf --cov-report=xml
- python examples/calculate_eventdisplay_irfs.py
- travis-sphinx -v --outdir=docbuild build --source=docs/

after_script:
- if [[ "$CONDA" == "true" ]];then
conda deactivate
fi
- if [[ "$CONDA" == "true" ]];then
conda deactivate
fi
- python setup.py build_sphinx

after_success:
- codecov
- codecov
- travis-sphinx -v --outdir=docbuild deploy
8 changes: 0 additions & 8 deletions MANIFEST.in

This file was deleted.

22 changes: 7 additions & 15 deletions README.rst
@@ -1,23 +1,15 @@
==================================================
pyirf |travis| |codacy| |coverage| |documentation|
==================================================
==================================
pyirf |travis| |codacy| |coverage|
==================================

HealthyPear marked this conversation as resolved.
Show resolved Hide resolved
.. |travis| image:: https://travis-ci.com/cta-observatory/pyirf.svg?branch=master
:target: https://travis-ci.com/cta-observatory/pyirf
.. |codacy| image:: https://app.codacy.com/project/badge/Grade/669fef80d3d54070960e66351477e383
:target: https://www.codacy.com/gh/cta-observatory/pyirf?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cta-observatory/pyirf&amp;utm_campaign=Badge_Grade
.. |codacy| image:: https://app.codacy.com/project/badge/Grade/669fef80d3d54070960e66351477e383
:target: https://www.codacy.com/gh/cta-observatory/pyirf/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=cta-observatory/pyirf&amp;utm_campaign=Badge_Grade
.. |coverage| image:: https://codecov.io/gh/cta-observatory/pyirf/branch/master/graph/badge.svg
:target: https://codecov.io/gh/cta-observatory/pyirf
.. |documentation| image:: https://readthedocs.org/projects/pyirf/badge/?version=latest
:target: https://pyirf.readthedocs.io/en/latest/?badge=latest


Python IRF builder
Python library to calculate IACT IRFs and Sensitivities.

=== Under construction ====

The current version works only for point sources.

=== Documentation ====

https://pyirf.readthedocs.io/
**Documentation:** https://cta-observatory.github.io/pyirf/
18 changes: 10 additions & 8 deletions docs/AUTHORS.rst
Expand Up @@ -3,14 +3,16 @@
Authors
=======

The following is a complete list of all contributors in alphabetical order by last name:
To see who contributed to ``pyirf``, please visit the
`GitHub contributors page <https://github.com/cta-observatory/pyirf/graphs/contributors>`__
or run

- Lea Jouvin
- Julien Lefacheur (left)
- Maximilian Nöthe <maximilian.noethe@tu-dortmund.de>
- Michele Peresano <michele.peresano@cea.fr>
- Thomas Vuillaume <thomas.vuillaume@lapp.in2p3.fr>
.. code-block:: bash

*pyirf* has been developed starting from part a previous project authored by Julien Lefacheur.
git shortlog -sne

For more details go to the `GitHub contributors page <https://github.com/cta-observatory/pyirf/graphs/contributors>`__.

``pyirf`` started as part of `protopipe <https://github.com/cta-observatory/protopipe/>`__ by Julien Lefaucher,
but was largely rewritten in September 2020, making use of code from the
previous version, the `pyfact <http://github.com/fact-project/pyfact>`__ module and the
`FACT irf <http://github.com/fact-project/irf>`__ package.
11 changes: 11 additions & 0 deletions docs/benchmarks/index.rst
@@ -0,0 +1,11 @@
.. _benchmarks:

Benchmarks
==========

Functions to calculate benchmarks.

-------------

.. automodapi:: pyirf.benchmarks
:no-inheritance-diagram:
11 changes: 11 additions & 0 deletions docs/binning.rst
@@ -0,0 +1,11 @@
.. _binning:

Binning and Histogram Utilities
===============================


Reference/API
-------------

.. automodapi:: pyirf.binning
:no-inheritance-diagram:
20 changes: 9 additions & 11 deletions docs/changelog.rst
Expand Up @@ -3,11 +3,7 @@
Changelog
=========

This is the changelog for *pyirf*.

We use a one-line description of every pull request, roughly in chronological order.
We don't list every pull request.
Maintenance and cleanup changes are not of interest to users and are not listed here.
maxnoe marked this conversation as resolved.
Show resolved Hide resolved
We use a one-line description of every pull request.

.. RELEASE TEMPLATE
..
Expand Down Expand Up @@ -37,22 +33,24 @@ Maintenance and cleanup changes are not of interest to users and are not listed

.. _pyirf_0p3_release:

0.1.0 (Unreleased)
------------------
`0.1.0 <https://github.com/cta-observatory/pyirf/releases/tag/v0.1.0>`__ (2020-09-16)
-------------------------------------------------------------------------------------

This is a pre-release.

- Released September 16th, 2020

. . .

.. _pyirf_0p1p0alpha_prerelease:

`0.1.0-alpha <https://github.com/cta-observatory/pyirf/releases/tag/v0.1.0-alpha>`__ (May 27th, 2020)
-----------------------------------------------------------------------------------------------------
`0.1.0-alpha <https://github.com/cta-observatory/pyirf/releases/tag/v0.1.0-alpha>`__ (2020-05-27)
-------------------------------------------------------------------------------------------------

Summary
+++++++

This is a pre-release.

- This is a pre-release
- Released May 27th, 2020
- 3 contributors

Expand Down
29 changes: 12 additions & 17 deletions docs/conf.py
Expand Up @@ -19,8 +19,8 @@
# -- Project information -----------------------------------------------------

project = "pyirf"
copyright = "2020, Julien Lefaucheur, Michele Peresano, Thomas Vuillaume"
author = "Julien Lefaucheur, Michele Peresano, Thomas Vuillaume"
copyright = "2020, Maximilian Nöthe, Michele Peresano, Thomas Vuillaume"
author = "Maximilian Nöthe, Michele Peresano, Thomas Vuillaume"

# The full version, including alpha/beta/rc tags
version = __version__
Expand All @@ -40,10 +40,9 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"rinoh.frontend.sphinx",
"sphinx_automodapi.automodapi",
"sphinx.ext.autodoc",
"numpydoc",
"nbsphinx",
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
Expand All @@ -55,12 +54,14 @@
"sphinx.ext.napoleon",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting",
]

# nbsphinx
nbsphinx_execute = "never"
# nbsphinx_execute = "never"
nbsphinx_execute_arguments = [
"--InlineBackend.figure_formats={'svg', }",
"--InlineBackend.rc={'figure.dpi': 96}",
]

numpydoc_show_class_members = False
autosummary_generate = True
Expand All @@ -79,17 +80,11 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster"
html_theme = "sphinx_rtd_theme"

html_theme_options = {
"github_user": "cta-observatory",
"github_repo": "pyirf",
"badge_branch": "master",
"codecov_button": "true",
"github_button": "true",
"travis_button": "true",
"sidebar_collapse": "false",
"sidebar_includehidden": "true",
'canonical_url': 'https://cta-observatory.github.io/pyirf',
'display_version': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down
68 changes: 68 additions & 0 deletions docs/contribute.rst
@@ -0,0 +1,68 @@
.. _contribute:

How to contribute
=================


Issue Tracker
-------------

We use the `GitHub issue tracker <https://github.com/cta-observatory/pyirf>`__
for individual issues and the `GitHub Projects page <https://github.com/cta-observatory/pyirf/projects>`_ can give you a quick overview.

If you found a bug or you are missing a feature, please check the existing
issues and then open a new one or contribute to the existing issue.

Development procedure
---------------------


We use the standard `GitHub workflow <https://guides.github.com/introduction/flow/>`__.

If you are not part of the ``cta-observatory`` organization,
you need to fork the repository to contribute.
See the `GitHub tutorial on forks <https://docs.github.com/en/github/getting-started-with-github/fork-a-repo>`__ if you are unsure how to do this.

#. When you find something that is wrong or missing

- Go to the issue tracker and check if an issue already exists for your bug or feature
- In general it is always better to anticipate a PR with a new issue and link the two

#. To work on a bug fix or new feature, create a new branch, add commits and open your pull request

- If you think your pull request is good to go and ready to be reviewed,
you can directly open it as normal pull request.

- You can also open it as a “Draft Pull Request”, if you are not yet finished
but want to get early feedback on your ideas.

- Especially when working on a bug, it makes sense to first add a new
test that fails due to the bug and in a later commit add the fix showing
that the test is then passing.
This helps understanding the bug and will prevent it from reappearing later.

#. Wait for review comments and then implement or discuss requested changes.


We use `Travis CI <https://travis-ci.com/github/cta-observatory/pyirf>`__ to
run the unit tests and documentation building automatically for every pull request.
Passing unit tests and coverage of the changed code are required for all pull requests.

Further details
---------------

Please also have a look at the

- ``ctapipe`` `development guidelines <https://cta-observatory.github.io/ctapipe/development/index.html>`__
- The `Open Gamma-Ray Astronomy data formats <https://gamma-astro-data-formats.readthedocs.io/en/latest/>`__
which also describe the IRF formats and their definitions.
- ``ctools`` `documentation page on IRFs <http://cta.irap.omp.eu/ctools/users/user_manual/irf_cta.html>`__
- `CTA IRF working group wiki (internal) <https://forge.in2p3.fr/projects/instrument-response-functions/wiki>`__

- `CTA IRF Description Document for Prod3b (internal) <https://gitlab.cta-observatory.org/cta-consortium/aswg/documentation/internal_reports/irfs-reports/prod3b-irf-description>`__


Benchmarks
----------

- `Comparison with EventDisplay <../notebooks/comparison_with_EventDisplay.ipynb>`__ | *comparison_with_EventDisplay.ipynb*