diff --git a/docs/api-reference/monitoring/index.rst b/docs/api-reference/monitoring/index.rst index 51268d35fc8..c38bf7bb3a9 100644 --- a/docs/api-reference/monitoring/index.rst +++ b/docs/api-reference/monitoring/index.rst @@ -18,9 +18,9 @@ Submodules .. toctree:: :maxdepth: 1 - :glob: aggregator + interpolation outlier diff --git a/docs/api-reference/monitoring/interpolation.rst b/docs/api-reference/monitoring/interpolation.rst new file mode 100644 index 00000000000..7fab95f007f --- /dev/null +++ b/docs/api-reference/monitoring/interpolation.rst @@ -0,0 +1,11 @@ +.. _monitoring_interpolation: + +************* +Interpolation +************* + + +Reference/API +============= + +.. automodapi:: ctapipe.monitoring.interpolation diff --git a/docs/changes/2615.api.rst b/docs/changes/2615.api.rst new file mode 100644 index 00000000000..969bf7d58dc --- /dev/null +++ b/docs/changes/2615.api.rst @@ -0,0 +1 @@ +The ``PointingInterpolator`` was moved from ``ctapipe.io`` to ``ctapipe.monitoring``. diff --git a/src/ctapipe/io/__init__.py b/src/ctapipe/io/__init__.py index 28603643160..cfb5fc5501e 100644 --- a/src/ctapipe/io/__init__.py +++ b/src/ctapipe/io/__init__.py @@ -18,11 +18,6 @@ from .datawriter import DATA_MODEL_VERSION, DataWriter -from .interpolation import ( - Interpolator, - PointingInterpolator, -) - __all__ = [ "HDF5TableWriter", "HDF5TableReader", @@ -40,6 +35,4 @@ "DataWriter", "DATA_MODEL_VERSION", "get_hdf5_datalevels", - "Interpolator", - "PointingInterpolator", ] diff --git a/src/ctapipe/io/hdf5eventsource.py b/src/ctapipe/io/hdf5eventsource.py index eb91b216c27..0cb47d1aee8 100644 --- a/src/ctapipe/io/hdf5eventsource.py +++ b/src/ctapipe/io/hdf5eventsource.py @@ -7,9 +7,7 @@ from astropy.table import QTable from astropy.utils.decorators import lazyproperty -from ctapipe.atmosphere import AtmosphereDensityProfile -from ctapipe.instrument.optics import FocalLengthKind - +from ..atmosphere import AtmosphereDensityProfile from ..containers import ( ArrayEventContainer, CameraHillasParametersContainer, @@ -48,11 +46,12 @@ from ..core import Container, Field from ..core.traits import UseEnum from ..instrument import SubarrayDescription +from ..instrument.optics import FocalLengthKind +from ..monitoring.interpolation import PointingInterpolator from .astropy_helpers import read_table from .datalevels import DataLevel from .eventsource import EventSource from .hdf5tableio import HDF5TableReader -from .interpolation import PointingInterpolator from .tableloader import DL2_SUBARRAY_GROUP, DL2_TELESCOPE_GROUP, POINTING_GROUP __all__ = ["HDF5EventSource"] diff --git a/src/ctapipe/io/tableloader.py b/src/ctapipe/io/tableloader.py index 6da74b6f081..2b10ad96506 100644 --- a/src/ctapipe/io/tableloader.py +++ b/src/ctapipe/io/tableloader.py @@ -13,8 +13,8 @@ from ..core import Component, Provenance, traits from ..instrument import FocalLengthKind, SubarrayDescription +from ..monitoring.interpolation import PointingInterpolator from .astropy_helpers import join_allow_empty, read_table -from .interpolation import PointingInterpolator __all__ = ["TableLoader"] diff --git a/src/ctapipe/monitoring/__init__.py b/src/ctapipe/monitoring/__init__.py new file mode 100644 index 00000000000..cb102f768cf --- /dev/null +++ b/src/ctapipe/monitoring/__init__.py @@ -0,0 +1,23 @@ +""" +Module for handling monitoring data. +""" +from .aggregator import PlainAggregator, SigmaClippingAggregator, StatisticsAggregator +from .interpolation import Interpolator, PointingInterpolator +from .outlier import ( + MedianOutlierDetector, + OutlierDetector, + RangeOutlierDetector, + StdOutlierDetector, +) + +__all__ = [ + "PlainAggregator", + "SigmaClippingAggregator", + "StatisticsAggregator", + "OutlierDetector", + "RangeOutlierDetector", + "MedianOutlierDetector", + "StdOutlierDetector", + "Interpolator", + "PointingInterpolator", +] diff --git a/src/ctapipe/monitoring/aggregator.py b/src/ctapipe/monitoring/aggregator.py index 5f2e5933bbf..ee8b5566c7c 100644 --- a/src/ctapipe/monitoring/aggregator.py +++ b/src/ctapipe/monitoring/aggregator.py @@ -25,6 +25,12 @@ from ctapipe.core import TelescopeComponent from ctapipe.core.traits import Int +__all__ = [ + "StatisticsAggregator", + "PlainAggregator", + "SigmaClippingAggregator", +] + class StatisticsAggregator(TelescopeComponent): """ diff --git a/src/ctapipe/io/interpolation.py b/src/ctapipe/monitoring/interpolation.py similarity index 97% rename from src/ctapipe/io/interpolation.py rename to src/ctapipe/monitoring/interpolation.py index 82de9f0bd19..84064cbc1a3 100644 --- a/src/ctapipe/io/interpolation.py +++ b/src/ctapipe/monitoring/interpolation.py @@ -9,7 +9,10 @@ from ctapipe.core import Component, traits -from .astropy_helpers import read_table +__all__ = [ + "Interpolator", + "PointingInterpolator", +] class Interpolator(Component, metaclass=ABCMeta): @@ -103,6 +106,9 @@ def _check_interpolators(self, tel_id): raise KeyError(f"No table available for tel_id {tel_id}") def _read_parameter_table(self, tel_id): + # prevent circular import between io and monitoring + from ..io import read_table + input_table = read_table( self.h5file, f"{self.telescope_data_group}/tel_{tel_id:03d}", diff --git a/src/ctapipe/monitoring/outlier.py b/src/ctapipe/monitoring/outlier.py index 71bcfd36c86..4ac387bbcd3 100644 --- a/src/ctapipe/monitoring/outlier.py +++ b/src/ctapipe/monitoring/outlier.py @@ -1,6 +1,12 @@ """ Outlier detection algorithms to identify faulty pixels """ +from abc import abstractmethod + +import numpy as np + +from ctapipe.core import TelescopeComponent +from ctapipe.core.traits import Float, List __all__ = [ "OutlierDetector", @@ -9,13 +15,6 @@ "StdOutlierDetector", ] -from abc import abstractmethod - -import numpy as np - -from ctapipe.core import TelescopeComponent -from ctapipe.core.traits import Float, List - class OutlierDetector(TelescopeComponent): """ diff --git a/src/ctapipe/io/tests/test_interpolator.py b/src/ctapipe/monitoring/tests/test_interpolator.py similarity index 98% rename from src/ctapipe/io/tests/test_interpolator.py rename to src/ctapipe/monitoring/tests/test_interpolator.py index 02f4c4ce306..782aeae7435 100644 --- a/src/ctapipe/io/tests/test_interpolator.py +++ b/src/ctapipe/monitoring/tests/test_interpolator.py @@ -5,9 +5,7 @@ from astropy.table import Table from astropy.time import Time -from ctapipe.io.interpolation import ( - PointingInterpolator, -) +from ctapipe.monitoring.interpolation import PointingInterpolator t0 = Time("2022-01-01T00:00:00")