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

Unit tests for makers, container and component modules (part 1/X) #163

Merged
merged 39 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eb8db7f
add arg to load only wfs and do not extract charges
Jun 23, 2024
2b8b613
cleaner way to treat containers inside makers
Jun 26, 2024
5f30851
new methods to find computed calibration quatities
Jun 26, 2024
d8aa001
update to support new version of EvB v6
Jun 26, 2024
d183536
-bug fix SPE combined : method use to update parameters was not the w…
Jun 26, 2024
175afa9
Merge branch 'main' into dev_test_doc
Dec 9, 2024
b46a959
add find photostat result method
Dec 9, 2024
75f6b34
user scripts
Dec 9, 2024
04d60f6
Merge branch 'dev_test_doc' of github.com:guillaumegrolleron/nectarch…
Dec 9, 2024
7452e60
add workflow_display to CI
Jan 6, 2025
5f98800
change tests name in user_scripts which is not a test for pytest
Jan 6, 2025
08b956c
fix import errors in TRR
Jan 6, 2025
2dfdd82
bugfix : logger
Jan 7, 2025
c5d4419
static method decorator were missing
Jan 7, 2025
404f189
bugfix test containers
Jan 7, 2025
8c2ac41
unit test fore nectarchain.makers .core
Jan 7, 2025
413c9b4
bugfix with new version of LIghtNectarCAMEventSource from ctapipe_io_…
Jan 8, 2025
f023695
very small code improvement
Jan 8, 2025
37141c2
Unit test for WaveformsNectarCAMCalibrationTool
Jan 8, 2025
7308cda
Unit test for the ChargesNectarCAMCalibrationTool
Jan 8, 2025
9e9ee9e
formatting
Jan 8, 2025
f11d0c6
fix test core makers
Jan 8, 2025
e944206
formatting
Jan 8, 2025
02ee8c3
formatting
Jan 8, 2025
d392b4c
flake8 formatting
Jan 8, 2025
d40c122
refactoring folling pep8
Jan 8, 2025
65c196d
folling refactring
Jan 8, 2025
24d8ce4
dqm flake8
Jan 8, 2025
d571cb3
refactoring containers
Jan 8, 2025
9b9a63c
fix bug formatting
Jan 8, 2025
532f961
shitty python formatting
Jan 8, 2025
f6cf972
test bugfix
Jan 8, 2025
f950359
pedestal maker : implementation of I/O with containers
Jan 9, 2025
c9f331c
remove LightNectarCamEventSource
Jan 9, 2025
3629461
Merge branch 'main' into dev_test_doc
Jan 9, 2025
617d8f2
bugfix in toml file introduced in previous commits
Jan 9, 2025
a9df416
bugfix : __init__ file in tests repertory
Jan 9, 2025
36a7737
pytest don't like to have 2 test files with same names
Jan 9, 2025
6dd1e8d
specific noqa
Jan 9, 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

# by not building all branches on push, we avoid the duplicated builds in PRs
on:
workflow_dispatch:
push:
# TODO
# Remove comment: just a test to force CI on push
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/env-vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ However, some environment variables are needed for ``nectarchain`` to work prope
Mandatory
---------

:``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.
:``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.

Optional
--------
Expand Down
6 changes: 3 additions & 3 deletions docs/user-guide/howto-pedestal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ processed in slices with a fixed number of events set by the

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

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:
Expand Down
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ test = [
dev = [
"setuptools_scm",
]

docs = [
"sphinx",
"sphinx-autodoc-typehints",
Expand All @@ -55,15 +54,30 @@ docs = [
"numpydoc",
"tomli; python_version < '3.11'"
]

# we can use self-references to simplify all
all = [
"nectarchain[test,docs,dev]",
]


[tool.pytest.ini_options]
addopts = "--ignore=src/nectarchain/user_scripts"



[tool.setuptools.packages.find]
where = ["src"]
exclude = ["nectarchain._dev_version"]

[tool.setuptools_scm]
write_to = "src/nectarchain/_version.py"

[tool.ruff.lint]
jlenain marked this conversation as resolved.
Show resolved Hide resolved
select = ["E", "F", "W"] # This ensures it mimics Flake8's error codes.
exclude = ["build/", "dist/", "*.pyc"]

[tool.ruff]
line-length = 88

[tool.black]
line-length = 88
jlenain marked this conversation as resolved.
Show resolved Hide resolved
36 changes: 34 additions & 2 deletions src/nectarchain/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
from .container import *
from .management import *
"""Description: This file is used to import all the classes and functions
from the data module."""

from .container import (
ArrayDataContainer,
ChargesContainer,
ChargesContainers,
GainContainer,
NectarCAMContainer,
NectarCAMPedestalContainer,
SPEfitContainer,
TriggerMapContainer,
WaveformsContainer,
WaveformsContainers,
get_array_keys,
merge_map_ArrayDataContainer,
)
from .management import DataManagement

__all__ = [
"ArrayDataContainer",
"NectarCAMContainer",
"TriggerMapContainer",
"get_array_keys",
"merge_map_ArrayDataContainer",
"ChargesContainer",
"ChargesContainers",
"WaveformsContainer",
"WaveformsContainers",
"GainContainer",
"SPEfitContainer",
"NectarCAMPedestalContainer",
"DataManagement",
]
33 changes: 28 additions & 5 deletions src/nectarchain/data/container/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
from .chargesContainer import *
"""This file is used to import all the containerclasses in the data/container
folder."""

from .charges_container import ChargesContainer, ChargesContainers
from .core import (
ArrayDataContainer,
NectarCAMContainer,
TriggerMapContainer,
get_array_keys,
merge_map_ArrayDataContainer,
)
from .eventSource import *
from .gainContainer import *
from .waveformsContainer import *
from .pedestalContainer import *
from .gain_container import GainContainer, SPEfitContainer
from .pedestal_container import (
NectarCAMPedestalContainer,
NectarCAMPedestalContainers,
PedestalFlagBits,
)
from .waveforms_container import WaveformsContainer, WaveformsContainers

__all__ = [
"ArrayDataContainer",
"NectarCAMContainer",
"TriggerMapContainer",
"get_array_keys",
"merge_map_ArrayDataContainer",
"ChargesContainer",
"ChargesContainers",
"WaveformsContainer",
"WaveformsContainers",
"GainContainer",
"SPEfitContainer",
"NectarCAMPedestalContainer",
"NectarCAMPedestalContainers",
"PedestalFlagBits",
]
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import logging

logging.basicConfig(format="%(asctime)s %(name)s %(levelname)s %(message)s")
log = logging.getLogger(__name__)
log.handlers = logging.getLogger("__main__").handlers

import numpy as np
from ctapipe.containers import Field, Map, partial

from .core import ArrayDataContainer, TriggerMapContainer

logging.basicConfig(format="%(asctime)s %(name)s %(levelname)s %(message)s")
log = logging.getLogger(__name__)
log.handlers = logging.getLogger("__main__").handlers


__all__ = ["ChargesContainer", "ChargesContainers"]


class ChargesContainer(ArrayDataContainer):
"""
A container that holds information about charges from a specific run.
"""A container that holds information about charges from a specific run.

Fields:
charges_hg (np.ndarray): An array of high gain charges.
Expand All @@ -40,13 +40,13 @@ class ChargesContainer(ArrayDataContainer):


class ChargesContainers(TriggerMapContainer):
"""
Class representing a ChargesContainers.

This class inherits from the `TriggerMapContainer` class and is used to store trigger or slices of data mappings of `ChargesContainer`.
"""Class representing a ChargesContainers.This class inherits from the
`TriggerMapContainer` class and is used to store trigger or slices of data
mappings of `ChargesContainer`.

Attributes:
containers (Field): A field representing the trigger or slices of data mapping of `ChargesContainer`.
containers (Field): A field representing the trigger or slices
of data mapping of `ChargesContainer`.
"""

containers = Field(
Expand Down
Loading
Loading