diff --git a/src/ctapipe/io/__init__.py b/src/ctapipe/io/__init__.py index dbf555a7bd6..7974f1ffaaa 100644 --- a/src/ctapipe/io/__init__.py +++ b/src/ctapipe/io/__init__.py @@ -21,7 +21,7 @@ from .interpolation import ( Interpolator, PointingInterpolator, - GainInterpolator, + FlatFieldInterpolator, PedestalInterpolator, ) @@ -45,5 +45,5 @@ "Interpolator", "PointingInterpolator", "PedestalInterpolator", - "GainInterpolator", + "FlatFieldInterpolator", ] diff --git a/src/ctapipe/io/interpolation.py b/src/ctapipe/io/interpolation.py index dc0953e3892..e82d96b2e9b 100644 --- a/src/ctapipe/io/interpolation.py +++ b/src/ctapipe/io/interpolation.py @@ -165,7 +165,7 @@ class PointingInterpolator(Interpolator): """ telescope_data_group = "/dl0/monitoring/telescope/pointing" - required_columns = {"time", "azimuth", "altitude"} + required_columns = frozenset(["time", "azimuth", "altitude"]) expected_units = {"azimuth": u.rad, "altitude": u.rad} def __call__(self, tel_id, time): @@ -230,16 +230,16 @@ def add_table(self, tel_id, input_table): self._interpolators[tel_id]["alt"] = interp1d(mjd, alt, **self.interp_options) -class GainInterpolator(Interpolator): +class FlatFieldInterpolator(Interpolator): """ - Interpolator for relative gain data + Interpolator for flatfield data """ telescope_data_group = "dl1/calibration/gain" # TBD def __call__(self, tel_id, time): """ - Interpolate pedestal or gain for a given time and tel_id. + Interpolate flatfield data for a given time and tel_id. Parameters ---------- @@ -250,14 +250,14 @@ def __call__(self, tel_id, time): Returns ------- - gain : array [float] - interpolated relative gain + ffield : array [float] + interpolated flatfield data """ self._check_interpolators(tel_id) - gain = self._interpolators[tel_id]["gain"](time) - return gain + ffield = self._interpolators[tel_id]["gain"](time) + return ffield def add_table(self, tel_id, input_table): """ @@ -270,10 +270,10 @@ def add_table(self, tel_id, input_table): input_table : astropy.table.Table Table of pointing values, expected columns are ``time`` as ``Time`` column and "gain" - for the relative gain data + for the flatfield data """ - self.required_columns = {"time", "gain"} + self.required_columns = frozenset(["time", "gain"]) # TBD self._check_tables(input_table) @@ -329,7 +329,7 @@ def add_table(self, tel_id, input_table): for the pedestal data """ - self.required_columns = {"time", "pedestal"} + self.required_columns = frozenset(["time", "pedestal"]) # TBD self._check_tables(input_table) diff --git a/src/ctapipe/io/tests/test_interpolator.py b/src/ctapipe/io/tests/test_interpolator.py index 1279dc5c784..4d41ceeff0b 100644 --- a/src/ctapipe/io/tests/test_interpolator.py +++ b/src/ctapipe/io/tests/test_interpolator.py @@ -6,7 +6,7 @@ from astropy.time import Time from ctapipe.io.interpolation import ( - GainInterpolator, + FlatFieldInterpolator, PedestalInterpolator, PointingInterpolator, ) @@ -108,7 +108,7 @@ def test_bounds(): }, ) - table_gain = Table( + table_flatfield = Table( { "time": np.arange(0.0, 10.1, 2.0), "gain": np.reshape(np.random.normal(1.0, 1.0, 1850 * 6), (6, 1850)), @@ -117,10 +117,10 @@ def test_bounds(): interpolator_pointing = PointingInterpolator() interpolator_pedestal = PedestalInterpolator() - interpolator_gain = GainInterpolator() + interpolator_flatfield = FlatFieldInterpolator() interpolator_pointing.add_table(1, table_pointing) interpolator_pedestal.add_table(1, table_pedestal) - interpolator_gain.add_table(1, table_gain) + interpolator_flatfield.add_table(1, table_flatfield) error_message = "below the interpolation range" @@ -131,7 +131,7 @@ def test_bounds(): interpolator_pedestal(tel_id=1, time=-0.1) with pytest.raises(ValueError, match=error_message): - interpolator_gain(tel_id=1, time=-0.1) + interpolator_flatfield(tel_id=1, time=-0.1) with pytest.raises(ValueError, match="above the interpolation range"): interpolator_pointing(tel_id=1, time=t0 + 10.2 * u.s) @@ -142,21 +142,21 @@ def test_bounds(): pedestal = interpolator_pedestal(tel_id=1, time=1.0) assert all(pedestal == table_pedestal["pedestal"][0]) - gain = interpolator_gain(tel_id=1, time=1.0) - assert all(gain == table_gain["gain"][0]) + flatfield = interpolator_flatfield(tel_id=1, time=1.0) + assert all(flatfield == table_flatfield["gain"][0]) with pytest.raises(KeyError): interpolator_pointing(tel_id=2, time=t0 + 1 * u.s) with pytest.raises(KeyError): interpolator_pedestal(tel_id=2, time=1.0) with pytest.raises(KeyError): - interpolator_gain(tel_id=2, time=1.0) + interpolator_flatfield(tel_id=2, time=1.0) interpolator_pointing = PointingInterpolator(bounds_error=False) interpolator_pedestal = PedestalInterpolator(bounds_error=False) - interpolator_gain = GainInterpolator(bounds_error=False) + interpolator_flatfield = FlatFieldInterpolator(bounds_error=False) interpolator_pointing.add_table(1, table_pointing) interpolator_pedestal.add_table(1, table_pedestal) - interpolator_gain.add_table(1, table_gain) + interpolator_flatfield.add_table(1, table_flatfield) for dt in (-0.1, 10.1) * u.s: alt, az = interpolator_pointing(tel_id=1, time=t0 + dt) @@ -164,7 +164,7 @@ def test_bounds(): assert np.isnan(az.value) assert all(np.isnan(interpolator_pedestal(tel_id=1, time=-0.1))) - assert all(np.isnan(interpolator_gain(tel_id=1, time=-0.1))) + assert all(np.isnan(interpolator_flatfield(tel_id=1, time=-0.1))) interpolator_pointing = PointingInterpolator(bounds_error=False, extrapolate=True) interpolator_pointing.add_table(1, table_pointing)