Skip to content

Commit 5151e86

Browse files
guillaumegrolleronguillaume.grolleron
andauthored
Unit tests for makers, container and component modules (part 1/X) (#163)
* add arg to load only wfs and do not extract charges * cleaner way to treat containers inside makers * new methods to find computed calibration quatities ds to find computed calibration quatities * update to support new version of EvB v6 * -bug fix SPE combined : method use to update parameters was not the wanted one -update pp and n values to last studies -display wfs -> mean instead of sum -Agg backend is not forced in Pstat calibnration * add find photostat result method * user scripts * add workflow_display to CI * change tests name in user_scripts which is not a test for pytest * fix import errors in TRR exluse user_scripts to pytest * bugfix : logger improvement split_run method * static method decorator were missing * bugfix test containers * unit test fore nectarchain.makers .core * bugfix with new version of LIghtNectarCAMEventSource from ctapipe_io_nectarcam * very small code improvement * Unit test for WaveformsNectarCAMCalibrationTool * Unit test for the ChargesNectarCAMCalibrationTool * formatting * fix test core makers * flake8 formatting * refactoring following pep8 * continue refactoring * dqm flake8 * refactoring containers * fix bug formatting * shitty python formatting * test bugfix * pedestal maker : implementation of I/O with containers * remove LightNectarCamEventSource * bugfix in toml file introduced in previous commits * bugfix : __init__ file in tests repertory * pytest don't like to have 2 test files with same names * specific noqa for unused imports --------- Co-authored-by: guillaume.grolleron <[email protected]>
1 parent 7fb5beb commit 5151e86

File tree

84 files changed

+2395
-1716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2395
-1716
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: CI
22

33
# by not building all branches on push, we avoid the duplicated builds in PRs
44
on:
5+
workflow_dispatch:
56
push:
67
# TODO
78
# Remove comment: just a test to force CI on push

docs/user-guide/env-vars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ However, some environment variables are needed for ``nectarchain`` to work prope
99
Mandatory
1010
---------
1111

12-
:``NECTARCAMDATA``: path to local NectarCAM data. It can contain ``fits.fz`` run files, `~nectarchain.data.container.waveformsContainer.WaveformsContainer` or `~nectarchain.data.container.chargesContainer.ChargesContainer` HDF5 files. This is also where the `~nectarchain.data.management.DataManagement.findrun` method will automatically store NectarCAM run files when fetched from DIRAC.
12+
:``NECTARCAMDATA``: path to local NectarCAM data. It can contain ``fits.fz`` run files, `~nectarchain.data.container.waveforms_container.WaveformsContainer` or `~nectarchain.data.container.charges_container.ChargesContainer` HDF5 files. This is also where the `~nectarchain.data.management.DataManagement.findrun` method will automatically store NectarCAM run files when fetched from DIRAC.
1313

1414
Optional
1515
--------

docs/user-guide/howto-pedestal.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ processed in slices with a fixed number of events set by the
2525

2626
The pedestal
2727
estimation tool inherits the configurable parameters of the
28-
`~nectarchain.makers.component.PedestalComponent.PedestalEstimationComponent`.
28+
`~nectarchain.makers.component.pedestal_component.PedestalEstimationComponent`.
2929
The data can be filtered based on time using the ``ucts_tmin`` and
3030
``ucts_tmax`` parameters and to eliminate outlier waveforms using the ``filter_method`` parameter. Two different methods to exclude outlier
3131
waveforms are implemented:
@@ -46,11 +46,11 @@ To run the example script:
4646
Inspect the results
4747
=========================
4848
The results are stored in a
49-
`~nectarchain.data.container.pedestalContainer.NectarCAMPedestalContainer`. The
49+
`~nectarchain.data.container.pedestal_container.NectarCAMPedestalContainer`. The
5050
results include information on pixels that were flagged as having
5151
an abnormal behavior during the computation of the pedestals. The
5252
flags are defined in in
53-
`~nectarchain.data.container.pedestalContainer.PedestalFlagBits`. The
53+
`~nectarchain.data.container.pedestal_container.PedestalFlagBits`. The
5454
results are accessible on the fly if the tool is run interactively (as in the example above) and stored in a `.h5` file.
5555

5656
The user script `nectarchain/user_scripts/ltibaldo/show_pedestal_output.py` provides an example of how to access the results from disk and produce some plots:

pyproject.toml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ test = [
4545
dev = [
4646
"setuptools_scm",
4747
]
48-
4948
docs = [
5049
"sphinx",
5150
"sphinx-autodoc-typehints",
@@ -55,15 +54,30 @@ docs = [
5554
"numpydoc",
5655
"tomli; python_version < '3.11'"
5756
]
58-
5957
# we can use self-references to simplify all
6058
all = [
6159
"nectarchain[test,docs,dev]",
6260
]
6361

62+
63+
[tool.pytest.ini_options]
64+
addopts = "--ignore=src/nectarchain/user_scripts"
65+
66+
67+
6468
[tool.setuptools.packages.find]
6569
where = ["src"]
6670
exclude = ["nectarchain._dev_version"]
6771

6872
[tool.setuptools_scm]
6973
write_to = "src/nectarchain/_version.py"
74+
75+
[tool.ruff.lint]
76+
select = ["E", "F", "W"] # This ensures it mimics Flake8's error codes.
77+
exclude = ["build/", "dist/", "*.pyc"]
78+
79+
[tool.ruff]
80+
line-length = 88
81+
82+
[tool.black]
83+
line-length = 88

src/nectarchain/data/__init__.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
1-
from .container import *
2-
from .management import *
1+
"""Description: This file is used to import all the classes and functions
2+
from the data module."""
3+
4+
from .container import (
5+
ArrayDataContainer,
6+
ChargesContainer,
7+
ChargesContainers,
8+
GainContainer,
9+
NectarCAMContainer,
10+
NectarCAMPedestalContainer,
11+
SPEfitContainer,
12+
TriggerMapContainer,
13+
WaveformsContainer,
14+
WaveformsContainers,
15+
get_array_keys,
16+
merge_map_ArrayDataContainer,
17+
)
18+
from .management import DataManagement
19+
20+
__all__ = [
21+
"ArrayDataContainer",
22+
"NectarCAMContainer",
23+
"TriggerMapContainer",
24+
"get_array_keys",
25+
"merge_map_ArrayDataContainer",
26+
"ChargesContainer",
27+
"ChargesContainers",
28+
"WaveformsContainer",
29+
"WaveformsContainers",
30+
"GainContainer",
31+
"SPEfitContainer",
32+
"NectarCAMPedestalContainer",
33+
"DataManagement",
34+
]
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1-
from .chargesContainer import *
1+
"""This file is used to import all the containerclasses in the data/container
2+
folder."""
3+
4+
from .charges_container import ChargesContainer, ChargesContainers
25
from .core import (
36
ArrayDataContainer,
47
NectarCAMContainer,
58
TriggerMapContainer,
69
get_array_keys,
710
merge_map_ArrayDataContainer,
811
)
9-
from .eventSource import *
10-
from .gainContainer import *
11-
from .waveformsContainer import *
12-
from .pedestalContainer import *
12+
from .gain_container import GainContainer, SPEfitContainer
13+
from .pedestal_container import (
14+
NectarCAMPedestalContainer,
15+
NectarCAMPedestalContainers,
16+
PedestalFlagBits,
17+
)
18+
from .waveforms_container import WaveformsContainer, WaveformsContainers
19+
20+
__all__ = [
21+
"ArrayDataContainer",
22+
"NectarCAMContainer",
23+
"TriggerMapContainer",
24+
"get_array_keys",
25+
"merge_map_ArrayDataContainer",
26+
"ChargesContainer",
27+
"ChargesContainers",
28+
"WaveformsContainer",
29+
"WaveformsContainers",
30+
"GainContainer",
31+
"SPEfitContainer",
32+
"NectarCAMPedestalContainer",
33+
"NectarCAMPedestalContainers",
34+
"PedestalFlagBits",
35+
]

src/nectarchain/data/container/chargesContainer.py renamed to src/nectarchain/data/container/charges_container.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import logging
22

3-
logging.basicConfig(format="%(asctime)s %(name)s %(levelname)s %(message)s")
4-
log = logging.getLogger(__name__)
5-
log.handlers = logging.getLogger("__main__").handlers
6-
73
import numpy as np
84
from ctapipe.containers import Field, Map, partial
95

106
from .core import ArrayDataContainer, TriggerMapContainer
117

8+
logging.basicConfig(format="%(asctime)s %(name)s %(levelname)s %(message)s")
9+
log = logging.getLogger(__name__)
10+
log.handlers = logging.getLogger("__main__").handlers
11+
12+
1213
__all__ = ["ChargesContainer", "ChargesContainers"]
1314

1415

1516
class ChargesContainer(ArrayDataContainer):
16-
"""
17-
A container that holds information about charges from a specific run.
17+
"""A container that holds information about charges from a specific run.
1818
1919
Fields:
2020
charges_hg (np.ndarray): An array of high gain charges.
@@ -40,13 +40,13 @@ class ChargesContainer(ArrayDataContainer):
4040

4141

4242
class ChargesContainers(TriggerMapContainer):
43-
"""
44-
Class representing a ChargesContainers.
45-
46-
This class inherits from the `TriggerMapContainer` class and is used to store trigger or slices of data mappings of `ChargesContainer`.
43+
"""Class representing a ChargesContainers.This class inherits from the
44+
`TriggerMapContainer` class and is used to store trigger or slices of data
45+
mappings of `ChargesContainer`.
4746
4847
Attributes:
49-
containers (Field): A field representing the trigger or slices of data mapping of `ChargesContainer`.
48+
containers (Field): A field representing the trigger or slices
49+
of data mapping of `ChargesContainer`.
5050
"""
5151

5252
containers = Field(

0 commit comments

Comments
 (0)