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

Move interpolator from io to monitoring #2615

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/api-reference/monitoring/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Submodules

.. toctree::
:maxdepth: 1
:glob:

aggregator
interpolation
outlier


Expand Down
11 changes: 11 additions & 0 deletions docs/api-reference/monitoring/interpolation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. _monitoring_interpolation:

*************
Interpolation
*************


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

.. automodapi:: ctapipe.monitoring.interpolation
1 change: 1 addition & 0 deletions docs/changes/2615.api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``PointingInterpolator`` was moved from ``ctapipe.io`` to ``ctapipe.monitoring``.
7 changes: 0 additions & 7 deletions src/ctapipe/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

from .datawriter import DATA_MODEL_VERSION, DataWriter

from .interpolation import (
Interpolator,
PointingInterpolator,
)

__all__ = [
"HDF5TableWriter",
"HDF5TableReader",
Expand All @@ -40,6 +35,4 @@
"DataWriter",
"DATA_MODEL_VERSION",
"get_hdf5_datalevels",
"Interpolator",
"PointingInterpolator",
]
7 changes: 3 additions & 4 deletions src/ctapipe/io/hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion src/ctapipe/io/tableloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
23 changes: 23 additions & 0 deletions src/ctapipe/monitoring/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
6 changes: 6 additions & 0 deletions src/ctapipe/monitoring/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
from ctapipe.core import TelescopeComponent
from ctapipe.core.traits import Int

__all__ = [
"StatisticsAggregator",
"PlainAggregator",
"SigmaClippingAggregator",
]


class StatisticsAggregator(TelescopeComponent):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from ctapipe.core import Component, traits

from .astropy_helpers import read_table
__all__ = [
"Interpolator",
"PointingInterpolator",
]


class Interpolator(Component, metaclass=ABCMeta):
Expand Down Expand Up @@ -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}",
Expand Down
13 changes: 6 additions & 7 deletions src/ctapipe/monitoring/outlier.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down