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

Add new script for benchmarking #157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ee0b7dd
add benchmarking configuration file
HealthyPear Aug 25, 2021
1076ae1
add new script to launch and produce benchmark notebooks as HTML pages
HealthyPear Aug 25, 2021
7391c2e
add papermill as a development dependency
HealthyPear Aug 25, 2021
fe06d2a
add new associated entry point protopipe-BENCHMARK
HealthyPear Aug 25, 2021
f661f3e
Update benchmarks.yaml
HealthyPear Aug 30, 2021
b66fc2d
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Aug 31, 2021
aba8bb1
Use single quotes for compatibility with GRID interface
HealthyPear Sep 6, 2021
a512b0c
Merge branch 'feature-add_protopipe_BENCHMARK' of https://github.com/…
HealthyPear Sep 6, 2021
2312755
improve comments in config file
HealthyPear Sep 7, 2021
3caab3b
Update launch_benchmark.py
HealthyPear Sep 27, 2021
9ae3a97
Update benchmarks.yaml
HealthyPear Sep 27, 2021
2379629
Require jupyter lab >=3.1.10
HealthyPear Sep 27, 2021
3437fdc
Create benchmark.rst
HealthyPear Sep 27, 2021
35bb202
Update index.rst
HealthyPear Sep 27, 2021
7c1d790
Fix error message formatting
HealthyPear Sep 27, 2021
5bf39ca
Properly ignore benchmark plots
HealthyPear Sep 29, 2021
fe06e75
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Sep 29, 2021
6a232cc
Ignore also log files
HealthyPear Sep 29, 2021
6662279
Update launch_benchmark.py
HealthyPear Oct 1, 2021
777730d
Update benchmarks.yaml
HealthyPear Oct 1, 2021
1007aba
Update setup.py for benchmark test
HealthyPear Oct 1, 2021
52e73b5
Update .gitignore
HealthyPear Jan 22, 2022
30a053c
Update documentation about protopipe-BENCHMARK
HealthyPear Jan 22, 2022
c4b8381
Refactor input functions
HealthyPear Jan 22, 2022
c3f0ee5
Improve new benchmarking script
HealthyPear Jan 22, 2022
7841958
Update setup.py
HealthyPear Jan 22, 2022
c3d042d
Update benchmarking configuration file
HealthyPear Jan 22, 2022
ce3300b
Update data_training.py and write_dl2.py for test pipeline
HealthyPear Jan 24, 2022
89fca27
import load_config and get_camera_names from protopipe.pipeline.io
HealthyPear Jan 24, 2022
dd9ef55
Update config
HealthyPear Feb 15, 2022
d604946
Update docs: script page
HealthyPear Feb 15, 2022
c8d82a7
Update docs
HealthyPear Feb 15, 2022
50892c1
Add support for analysis' Jupyter Book
HealthyPear Feb 28, 2022
efd17e3
Update docs
HealthyPear Feb 28, 2022
b0dc131
Merge branch 'master' into feature-add_protopipe_BENCHMARK
HealthyPear Mar 1, 2022
2e300aa
fixes/updates to the docs
HealthyPear Mar 1, 2022
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
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Welcome to protopipe's documentation!
(CTA) based on the `ctapipe <https://cta-observatory.github.io/ctapipe>`__ library.
The package has been developed and tested in the department of astrophysics at
`CEA-Saclay/IRFU <http://irfu.cea.fr/dap/en/index.php>`__,
but since Sep 23, 2019 is also open for development by other members of the CTA consortium.
but since September 2019 has been open for development to all members of the CTA consortium.

The source code is currently hosted on a `GitHub repository <https://github.com/cta-observatory/protopipe>`__
to which this documentation is linked.
It will soon migrate to the CTAO-GitLab installation under the ASWG group
It is planned to migrate it to the CTAO-GitLab installation under the ASWG group
repository (`link <https://gitlab.cta-observatory.org/cta-consortium/aswg>`__).

Current performance is stored internally at `this RedMine page <https://forge.in2p3.fr/projects/benchmarks-reference-analysis/wiki/Protopipe_performance_data>`__.
Expand Down
2 changes: 1 addition & 1 deletion docs/install/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Development version
===================

1. `fork <https://help.github.com/en/articles/fork-a-repo>`__ the `repository <https://github.com/cta-observatory/protopipe>`_
2. create a virtual environment if necessary (Anaconda users can use the ``environment_development.yml`` file)
2. if necessary, create a virtual environment (Anaconda users can use the ``environment_development.yml`` file found at the root of the repository)
3. ``pip install -e '.[all]'``

The ``all`` keyword will install all extra requirements,
Expand Down
56 changes: 15 additions & 41 deletions docs/install/grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,14 @@ are the following,
Even if *protopipe* itself allows for Python 3.7, the minimum version required to use
Dirac is 3.8.

For convenience, a ready-to-use conda environment recipe is reported below.
You can also find it in the `root directory of the interface <https://github.com/HealthyPear/protopipe-grid-interface>`_.
An example base conda environment recipe can be found
`here <https://github.com/HealthyPear/protopipe-grid-interface/blob/master/environment_development.yaml>`_.
You can create the corresponding environment with a command like this,

``conda env create -f my_env_recipe.yml -n my_env``
``conda env create -f environment_development.yaml``

.. code-block:: yaml

name: protopipe-CTADIRAC
channels:
- conda-forge
dependencies:
- python>=3.8
- pip
- dirac-grid
- voms
- pytables
- pyyaml
- eventio # required for protopipe with ctapipe <0.12.0
- gammapy=0.18 # required for protopipe with ctapipe <0.12.0
- pip:
- CTADIRAC

In this environment you can then install first protopipe and then the interface.

If you want to install them in their released versions, integrate the ``pip`` section
with,

- ``protopipe``/``protopipe=x.y.z`` for a latest/specific released version of protopipe,
- ``git+https://github.com/HealthyPear/[email protected]`` for a released version of its interface.

An overview of the versioning between the two sofware is described below (:ref:`versioning`)

If you are a developer, or you want to work with the development version,
please refer to the development installation instructions for protopipe (:ref:`install-development`)
and its interface (:ref:`install-grid-dev`).
In this environment you can then install first *protopipe* and then its interface
following the respective instructions.

DIRAC GRID certificate
----------------------
Expand All @@ -81,8 +53,9 @@ The interface
Getting a released version
--------------------------

For versions >=0.4.0 you can install it as a Python3-based package in your environment as explained
above.
For versions >=0.4.0 you can install it as a Python3-based package in your environment,

``pip install git+https://github.com/HealthyPear/[email protected]``

The following table refers to all versions and their compatibility with _protopipe_.

Expand All @@ -102,29 +75,30 @@ The following table refers to all versions and their compatibility with _protopi
* - v0.2.X
- v0.2.X

The latest released version of the interface is also compatible with
The latest released version of the interface is always compatible with
the development version of *protopipe*.

.. warning::

After the Python3 upgrade of DIRAC and CTADIRAC,
the interface installation and usage have changed considerably,
while its relation with _protopipe_ has only improved.
while its relation with *protopipe* has only improved.
It is very unlikely that you will ever need to work with a version older than v0.4.0,
but if this were to happen, please check older versions of this documentation
either from readthedocs or from the repository of _protopipe_.
either from readthedocs or from the repository of *protopipe*.

.. _install-grid-dev:

Getting the development version
-------------------------------

This version is:

- always compatible with the development version of *protopipe*,
- possibly compatible with the latest release of *protopipe*,

The procedure to install with this version is similar to the same one
for _protopipe_:
for *protopipe*:

- ``git clone https://github.com/HealthyPear/protopipe-grid-interface.git``
- ``cd protopipe-grid-interface``
Expand All @@ -151,8 +125,8 @@ You will be asked to generate your proxy and then to choose the ``Setup`` and th
You need to choose the default values.

.. warning::
The defaults right now are lacking redundance in the configuration system.
It is suggested to edit the configuration file that you can find inside your conda enviroment
The configuration system defaults could lack redundance depending on the version of CTADIRAC.
It is suggested to check or edit the configuration file that you can find inside your conda enviroment
under ``etc/dirac.cfg`` like the following,

.. code-block::
Expand Down
45 changes: 28 additions & 17 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,37 @@ Some use-cases could be the following,
Docker
++++++

The container used by the interface requires the `installation of Docker <https://docs.docker.com/get-docker/>`_.
The `installation of Docker <https://docs.docker.com/get-docker/>`_ is a requirement.

To enter the container (and the first time downloading the image),
Two docker containers are provided for development and released content respectively.

``docker run --rm -v $HOME/.globus:/home/dirac/.globus -v $PWD/shared_folder:/home/dirac/shared_folder -v [...]/protopipe:/home/dirac/protopipe -v [...]/protopipe-grid-interface:/home/dirac/protopipe-grid-interface -it ctadirac/client``
To enter the *development* container,

``docker run --rm -v $HOME/.globus:/home/dirac/.globus -v [...]/protopipe:/home/cta/protopipe -v [...]/protopipe-grid-interface:/home/cta/protopipe-grid-interface -it mperesano/protopipe-ctadirac-dev``

where,

- ``[...]`` is the path of your source code on the host,
- the ``--rm`` flag will erase the container at exit if you don't want to persist it in order to save disk space (any data produced will not disappear if you use a bind-mount).

To enter the *release* container,

``docker run --rm -v $HOME/.globus:/home/dirac/.globus -it mperesano/protopipe-ctadirac:tag``

where ``tag`` if omitted will always refer to the latest release, otherwise you will need to specify it.

where ``[...]`` is the path of your source code on the host and the ``--rm`` flag will erase the container at exit
to save disk space (the data stored in the ``shared_folder`` won't disappear).
Please, refer to the Docker documentation for other use cases.

**WARNING**
If you are using *macos* you could encounter some disk space issues.
Please check `this <https://docs.docker.com/docker-for-mac/space/>`_ and `also this <https://djs55.github.io/jekyll/update/2017/11/27/docker-for-mac-disk-space.html>`_ on how to manage disk space.
.. warning::
If you are using *macos* you could encounter some disk space issues.
Please check `this <https://docs.docker.com/docker-for-mac/space/>`_ and `also this <https://djs55.github.io/jekyll/update/2017/11/27/docker-for-mac-disk-space.html>`_ on how to manage disk space.

Vagrant
+++++++

**NOTE**
Only required for users that want to use a *Singularity*
container on a *macos* and *Microsoft Windows* machine.
.. note::
Only required for users that want to use a *Singularity*
container on a *macos* and *Microsoft Windows* machine.

All users, regardless of their operative systems, can use protopipe and its interface via
`Vagrant <https://www.vagrantup.com/>`_.
Expand All @@ -126,9 +137,9 @@ used by the interface to setup the analysis.
Singularity
+++++++++++

**WARNING**
Support for *Singularity* has been dropped by the mantainers of *CTADIRAC*.
The following solutions have not been tested in all possible cases.
.. warning::
Support for *Singularity* has been dropped by the mantainers of *CTADIRAC*.
The following solutions have not been tested in all possible cases.

- **macos / Microsoft Windows**

Expand Down Expand Up @@ -183,9 +194,9 @@ but the recipe for the container has been saved here.
In this case you won't need to do ``. /home/dirac/dirac_env.sh``: the
commands will be already stored in your ``$PATH``.

**WARNING**
The recipe ``CTADIRAC_singularity`` is maintained by the author; if any bug arises,
reverting to the methods described above (if possible) will provide you with a working environment.
.. warning::
The recipe ``CTADIRAC_singularity`` is not currently maintained; if any bug arises,
reverting to the methods described above (if possible) will provide you with a working environment.

If you have root privileges you can just build your own image with,

Expand Down
3 changes: 2 additions & 1 deletion docs/install/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ If you prefer to work from an Anaconda virtual environment you can create it wit

``conda env create -f environment_latest_release.yml``

or any other compatible virtual environment, depending on your needs.
The recipe can be found in the root folder of the project repository,
but any other compatible virtual environment can be used, depending on your needs.

For previous releases,

Expand Down
17 changes: 10 additions & 7 deletions docs/mva/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ Multivariate analysis (``protopipe.mva``)
Introduction
------------

`protopipe.mva` contains utilities to build models for regression or
classification problems. It is based on machine learning methods available in
`protopipe.mva` contains utilities to build models for regression and
classification. It is based on machine learning methods available in
scikit-learn_. Internally, the tables are dealt with the Pandas_ Python module.

For each type of camera a regressor/classifier should be trained.
For both type of models an average of the image estimates is later computed to

For both type of models an average of the image estimates is computed
during the :ref:`data_training` and/or :ref:`DL2` steps to
determine a global output for the event (energy or score/gammaness).

Details
-------

Data is split in train and test subsamples by single telescope images.

The class ```TrainModel``` uses a training sample composed of gamma-rays for a
regression model. In addition of a gamma-ray sample, a sample of
protons is also used to build a classifier.
The class ```TrainModel``` uses a training sample composed of

- signal for a regression model,
- signal and background for a classifier.

The training of a model can be done also via the GridSearchCV_ algorithm which
allows to find the best hyper-parameters of the models.

Supported models:
Currently tested models:

- ``sklearn.ensemble.RandomForestClassifier``
- ``sklearn.ensemble.RandomForestRegressor``
Expand Down
13 changes: 5 additions & 8 deletions docs/perf/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,31 @@ Performance generation (``protopipe.perf``)
Introduction
------------

The DL2-to-DL3 step of the *protopipe* pipeline is now based on the
The DL2-to-DL3 step of the *protopipe* pipeline is based on the
`pyirf <https://cta-observatory.github.io/pyirf/>`_ library.

The ``protopipe.perf`` module contains utility tools used to interface with this
library, mainly to translate the DL2 data in the internal nomenclature used by
*pyirf* to produce the DL3 file.

In general this step takes care of
In general this step takes care of,

* handling the determination of the best-cutoffs to separate gamma and
the background (protons + electrons),
* estimating the sensitivity from the optimized cuts,
* producing the instrument response functions (IRFs).


Provided that a performance script makes used of
Provided that a performance script makes use of
``protopipe.perf.utils.read_DL2_pyirf``, *protopipe* supports the addition and
testing of multiple scripts based on pyirf.

.. note::
Some functions are discontinued or will be with the next release
and they will be removed.
and should be removed.

The current approach is based on the EventDisplay historical pipeline for which
The current approach is based on the *EventDisplay* historical pipeline for which
the following main points apply,

- minimum telescope multiplicity cut set to 3 (for 30' and 100'' exposures)
and 4 (for 5h and 50h exposures),
- maximum signal efficiency set to 80%,
- optimisation cuts are performed following these steps,
- applying a global cut of 40% signal efficiency,
Expand Down
4 changes: 2 additions & 2 deletions docs/pipeline/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Event reconstruction (``protopipe.pipeline``)
Introduction
------------

``protopipe.pipeline`` contains classes that are used in scripts to produce
``protopipe.pipeline`` contains classes that are used in scripts to produce,

- tables with images information (DL1), typically for g/h classifier and energy regressor,
- tables with event information, typically used for performance estimation (DL2).
Expand Down Expand Up @@ -45,7 +45,7 @@ Management of events, triggers and images
In case ``LST_stereo`` is set to ``True``, events with,

- 1 LST trigger and less than 2 triggers from any other telescope type will not
be processed after DL1b
be processed after DL1b,
- 1 LST trigger and at least 2 triggers from any other telescope type will get processed
at DL2a **without** the single-LST image and provided the remaining
images are still at least 2 after the image quality cuts have been taken into
Expand Down
Loading