Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ac0d718
Add function to compute selection cuts
mdebony Feb 20, 2025
17f0ed0
Make a component for event selection
mdebony Feb 20, 2025
dbce02b
Generalise behaviour
mdebony Feb 20, 2025
7606d22
Update event loader in the view of using it for DL3 production
mdebony Feb 20, 2025
5111d1f
change the output format of get simulation
mdebony Feb 20, 2025
47fc14d
Fix cicular depedency
mdebony Feb 20, 2025
1b26017
Update documentation of cuts
mdebony Feb 20, 2025
1af4094
Update event processor to support gamaness event selection
mdebony Feb 20, 2025
62df524
Update event loader for gamma event selection
mdebony Feb 20, 2025
50c1af4
Update path criteria for input
mdebony Feb 20, 2025
aa64f93
Further update to prepare for DL3
mdebony Feb 21, 2025
207cb7c
Skeleton for creating DL3
mdebony Feb 21, 2025
2ea79cc
Basic DL3 structure
mdebony Feb 21, 2025
7811ab1
Add option for optional DL3 columns
mdebony Mar 3, 2025
861d2fa
Change option for flag
mdebony Mar 3, 2025
bf0cd86
Fix the option
mdebony Mar 3, 2025
4b3765c
Add DL3 and IRF mode for preprocessor
mdebony Mar 3, 2025
9ff2f21
Adapt preprocessor columns request
mdebony Mar 3, 2025
912d871
Add option to skip missing optional column
mdebony Mar 3, 2025
8336606
Allow for variation of the pointing for DL3
mdebony Mar 3, 2025
636fbae
Move the derived columns function
mdebony Mar 6, 2025
15e089f
Update make_derived_columns function for producing columns needed for…
mdebony Mar 6, 2025
df6a9c6
Update columns selection for DL3 production
mdebony Mar 6, 2025
8dcfea5
Update table creation
mdebony Mar 6, 2025
3fcfe22
Correct handling of optional columns for DL3
mdebony Mar 6, 2025
0f795b4
Fix on optional columns
mdebony Mar 6, 2025
f3ba314
Format column for DL3 format
mdebony Mar 6, 2025
aedf6d8
Change x max for h max
mdebony Mar 6, 2025
e2a119b
Set base object for DL3 formating
mdebony Mar 6, 2025
475a4bd
Update message
mdebony Mar 6, 2025
fa25592
Compute average uncertainty on core position
mdebony Mar 6, 2025
9b0c9f9
Switch to fully use the object for DL3 format
mdebony Mar 6, 2025
8e45123
Fix setter
mdebony Mar 6, 2025
5c06050
Fix getter
mdebony Mar 6, 2025
e06054f
Add edisp getter and setter
mdebony Mar 6, 2025
0a1d94b
Direct access for overwrite
mdebony Mar 10, 2025
60f14aa
Add a base abstract class for generic DL3 format
mdebony Mar 10, 2025
d2d87ff
Add loading of location and gti
mdebony Mar 10, 2025
663faf4
Fix
mdebony Mar 10, 2025
0f712c6
Update headers of the DL3 file
mdebony Mar 11, 2025
a9ca20c
Update way of reading metainformation of the runs
mdebony Mar 11, 2025
e8e3d0a
Merge branch 'table_loader_schedule_block' into create_dl3
mdebony Mar 11, 2025
09e9ce5
Merge branch 'table_loader_schedule_block' into create_dl3
mdebony Mar 11, 2025
74cca7f
Add reading of additional observation metadata from dl2 file
mdebony Mar 12, 2025
681ce64
Add new metadata to dl3 class
mdebony Mar 12, 2025
1ce26f5
Add dead time fraction as metadata
mdebony Mar 12, 2025
25f8f8b
Proper selection of mandatory only columns
mdebony Mar 12, 2025
8e03bdb
Add metadata header to the DL3 file
mdebony Mar 12, 2025
df027d1
Add GTI table in the DL3 file
mdebony Mar 12, 2025
3223155
Add pointing table and header to the DL3 file
mdebony Mar 12, 2025
e3c5245
Fix interpolation
mdebony Mar 12, 2025
ae70fd4
Add docstring to the dl3.py file
mdebony Mar 13, 2025
e3c5af9
Merge remote-tracking branch 'upstream/main' into create_dl3
mdebony Mar 13, 2025
917240f
Fix errors encountered in automatic tests
mdebony Mar 17, 2025
58ecd82
Multiple fix
mdebony Mar 21, 2025
0fde645
Add docstring
mdebony Mar 21, 2025
3de36aa
Multiple fix
mdebony Mar 24, 2025
5017133
Merge branch 'main' into create_dl3
mdebony Mar 25, 2025
7914648
Fix configurations
mdebony Mar 25, 2025
46b5a9b
Add X max calculation
mdebony Mar 26, 2025
e099c12
Switch time scale to TAI
mdebony Mar 26, 2025
bd20df6
Add configurable reference time
mdebony Mar 26, 2025
2606c13
Speed improvement
mdebony Jul 1, 2025
11eb32a
Speed improvement
mdebony Jul 1, 2025
8017443
Basic documentation of code for the creation of DL3
mdebony Sep 22, 2025
8d48b41
Merge branch 'main' into create_dl3
mdebony Sep 22, 2025
9fa377e
Add guide for the user
mdebony Sep 24, 2025
177e9f0
Solved a few issues with DL3 guide in documentation
mdebony Sep 24, 2025
bb02977
Small bug fix
mdebony Sep 24, 2025
fc813ec
Docstrings improvement
mdebony Sep 24, 2025
2e365a0
Change way to handle lack of cuts file in the EventSelection
mdebony Dec 9, 2025
61903e7
Implementation of the test for TestDL3GADF
mdebony Dec 11, 2025
564a672
Rename of the class for writing DL3
mdebony Dec 11, 2025
b31f026
Direct use of quantity from QTable
mdebony Dec 11, 2025
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
1 change: 1 addition & 0 deletions .codespell-ignores
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ usera
nd
studi
referenc
livetime
27 changes: 27 additions & 0 deletions docs/api-reference/irf/cuts/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. _irf:

**********************************************
Cuts (`~ctapipe.irf.cuts`)
**********************************************

.. currentmodule:: ctapipe.irf.cuts

This sub-module contains functionalities representing and applying cuts.

:ref:`quality_cuts` is for quality selection of the events and :ref:`selection_cuts` contain the 'gamma-like' events selections

Submodules
==========

.. toctree::
:maxdepth: 1

quality_cuts
selection_cuts


Reference/API
=============

.. automodapi:: ctapipe.irf.cuts
:no-inheritance-diagram:
12 changes: 12 additions & 0 deletions docs/api-reference/irf/cuts/quality_cuts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _preprocessing:

*******************************
Quality cuts
*******************************


Reference/ API
==============

.. automodapi:: ctapipe.irf.cuts.quality_cuts
:no-inheritance-diagram:
12 changes: 12 additions & 0 deletions docs/api-reference/irf/cuts/selection_cuts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _preprocessing:

*******************************
Selection cuts
*******************************


Reference/ API
==============

.. automodapi:: ctapipe.irf.cuts.selection_cuts
:no-inheritance-diagram:
12 changes: 12 additions & 0 deletions docs/api-reference/irf/dl3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _dl3:

*******
DL3
*******


Reference/ API
==============

.. automodapi:: ctapipe.irf.dl3
:no-inheritance-diagram:
4 changes: 3 additions & 1 deletion docs/api-reference/irf/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ Submodules
.. toctree::
:maxdepth: 1

optimize
optimize/index
cuts/index
irfs
dl3
benchmarks
binning
preprocessing
Expand Down
12 changes: 0 additions & 12 deletions docs/api-reference/irf/optimize.rst

This file was deleted.

12 changes: 12 additions & 0 deletions docs/api-reference/irf/optimize/algorithm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _preprocessing:

*******************************
Cuts Optimization Results
*******************************


Reference/ API
==============

.. automodapi:: ctapipe.irf.optimize.algorithm
:no-inheritance-diagram:
30 changes: 30 additions & 0 deletions docs/api-reference/irf/optimize/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _irf:

**********************************************
Cuts optimization (`~ctapipe.irf.optimize`)
**********************************************

.. currentmodule:: ctapipe.irf.optimize

This sub-module contains functionalities for optimizing cuts.

The cut optimization as well as the calculations of the irf components and the benchmarks
are done using the `pyirf <https://pyirf.readthedocs.io/en/stable/>`_ package.

:ref:`algorithm` contain the algorithm for computing the cuts while :ref:`results` contain the object storing the optimize cuts

Submodules
==========

.. toctree::
:maxdepth: 1

algorithm
results


Reference/API
=============

.. automodapi:: ctapipe.irf.optimize
:no-inheritance-diagram:
12 changes: 12 additions & 0 deletions docs/api-reference/irf/optimize/results.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _preprocessing:

*******************************
Cuts Optimization Results
*******************************


Reference/ API
==============

.. automodapi:: ctapipe.irf.optimize.results
:no-inheritance-diagram:
3 changes: 3 additions & 0 deletions docs/api-reference/tools/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ Reference/API
.. automodapi:: ctapipe.tools.compute_irf
:no-inheritance-diagram:

.. automodapi:: ctapipe.tools.create_dl3
:no-inheritance-diagram:

.. automodapi:: ctapipe.tools.dump_instrument
:no-inheritance-diagram:

Expand Down
97 changes: 97 additions & 0 deletions docs/user-guide/tools/dl3_guide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. _dl3_guide:

***************************************************************
How to produce DL3 for observations using ``ctapipe`` tools
***************************************************************

The guide explains how to obtain a DL3 file (gamma-like events with IRFs) for your observations.

.. note::
* This guide assumes you have Monte Carlo simulations processed to obtain RF and IRFs. For more details, see :doc:`IRF guide <irf_guide>` and :doc:`DL2 guide <dl2_guide>`.
* Use the same ctapipe configuration files for processing MC and observations in all steps, ensuring the same processing is applied to both.

Setup
=====

First define the following environment variables:

* ``DL0_FOLDER`` — directory with the DL0 data
* ``DL1_FOLDER`` — directory with the DL1 data
* ``DL2_FOLDER`` — directory with the DL2 data
* ``DL3_FOLDER`` — directory with the DL3 data
* ``RF_FOLDER`` — directory with the random forest models for the reconstruction
* ``IRF_FOLDER`` — directory with the IRFs and associated cuts file
* ``CONFIG_DL1`` — configuration file for the DL0→DL1 processing, e.g. ``optimize_dl0_to_d1.yaml``
* ``CONFIG_DL3`` — configuration file for the DL2→DL3 processing of observations
(quality cuts must be identical to those used for optimized cuts and IRFs),
e.g. ``optimize_dl2_to_d3_obs.yaml``

Running the tools
=================

1) DL0 → DL1
------------

Process your DL0 file to DL1 level:

.. code-block:: bash

ctapipe-process \
--input "$DL0_FOLDER/MyRun_subrun_xxx.dl0.h5" \
--output "$DL1_FOLDER/MyRun_subrun_xxx.dl1.h5" \
--config "$CONFIG_DL1" \
--provenance-log "$DL1_FOLDER/MyRun_subrun_xxx.dl1.provenance.log" \
--log-file "$DL1_FOLDER/MyRun_subrun_xxx.dl1.log"

If your observation is divided into subruns, merge them:

.. code-block:: bash

ctapipe-merge --progress \
--telescope-events \
--dl1-parameters \
--no-dl1-images \
--single-ob \
-i "$DL1_FOLDER" \
-o "$DL1_FOLDER/MyRun.dl1.h5" \
-l "$DL1_FOLDER/MyRun_subrun_xxx.dl1.log"

2) DL1 → DL2 (apply RF models)
------------------------------

Apply the RF models trained on MC to reconstruct events and obtain the DL2 file:

.. code-block:: bash

ctapipe-apply-models \
--input "$DL1_FOLDER/MyRun.dl1.h5" \
--output "$DL2_FOLDER/MyRun.dl2.h5" \
--reconstructor "$RF_FOLDER/energy_regressor.pkl" \
--reconstructor "$RF_FOLDER/particle_classifier.pkl" \
--reconstructor "$RF_FOLDER/disp_reconstructor.pkl" \
--provenance-log "$DL2_FOLDER/MyRun.provenance.log" \
--log-file "$DL2_FOLDER/MyRun.dl2.log" \
--log-level INFO

.. note::
The option ``--reconstructor "$RF_FOLDER/particle_classifier.pkl"`` is only required for **monoscopic** reconstructions.

3) DL2 → DL3
------------

You could finally produce your DL3 file:

.. code-block:: bash

ctapipe-create-dl3 \
--dl2-file "$DL2_FOLDER/MyRun.dl2.h5" \
--output "$DL3_FOLDER/MyRun.dl3.fits.gz" \
--irfs-file "$IRF_FOLDER/MyIRFs.fits" \
--cuts "$IRF_FOLDER/MyCuts.fits" \
-c "$CONFIG_DL3" \
--no-optional-columns \
--provenance-log "$DL3_FOLDER/MyRun.dl3.provenance.log" \
--log-file "$DL3_FOLDER/MyRun.dl3.log" \
--log-level INFO

The DL3 file is now ready to be used for high level analysis.
2 changes: 2 additions & 0 deletions docs/user-guide/tools/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Data Processing Tools
Calculate gamma/hadron and direction cuts (e.g. for IRF calculation).
* `ctapipe-compute-irf <ctapipe.tools.compute_irf.IrfTool>`: Calculate an IRF with or without applying a direction cut
and optionally benchmarks.
* `ctapipe-create-dl3 <ctapipe.tools.create_dl3.DL3Tool>`: Create a DL3 file (gamma-like events and IRFs) from a DL2 file and an IRF fits file
* `ctapipe-store-astropy-cache <ctapipe.tools.store_astropy_cache.main>`: Store astropy downloadable data
in a given directory. Useful to run ctapipe in clusters where worker nodes might not have internet access.

Expand All @@ -52,3 +53,4 @@ The following pages contain examples on how to use the command-line tools.

dl2_guide
irf_guide
dl3_guide
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ ctapipe-process = "ctapipe.tools.process:main"
ctapipe-merge = "ctapipe.tools.merge:main"
ctapipe-optimize-event-selection = "ctapipe.tools.optimize_event_selection:main"
ctapipe-compute-irf = "ctapipe.tools.compute_irf:main"
ctapipe-create-dl3 = "ctapipe.tools.create_dl3:main"
ctapipe-fileinfo = "ctapipe.tools.fileinfo:main"
ctapipe-quickstart = "ctapipe.tools.quickstart:main"
ctapipe-calculate-pixel-statistics = "ctapipe.tools.calculate_pixel_stats:main"
Expand Down
Loading