diff --git a/pygac/calibration/noaa.py b/pygac/calibration/noaa.py index e707ca4..285ee69 100644 --- a/pygac/calibration/noaa.py +++ b/pygac/calibration/noaa.py @@ -525,8 +525,8 @@ def calibrate_thermal(counts, prt, ict, space, line_numbers, channel, cal): nonzeros = np.logical_not(zeros) space[zeros] = np.interp((zeros).nonzero()[0], - (nonzeros).nonzero()[0], - space[nonzeros]) + (nonzeros).nonzero()[0], + space[nonzeros]) # convolving and smoothing PRT, ICT and SPACE values if lines > 51: diff --git a/pygac/tests/test_klm.py b/pygac/tests/test_klm.py index 2074a50..fc71e95 100644 --- a/pygac/tests/test_klm.py +++ b/pygac/tests/test_klm.py @@ -181,13 +181,15 @@ def test_get_ch3_switch(self): def test_calibrate_channels(self): """Test channel calibration.""" + # Switch on 3b + self.reader.scans["scan_line_bit_field"] = 0 # ICT self.reader.scans["back_scan"] = 400 - self.reader.scans["back_scan"][0::5, :] = 0 + self.reader.scans["back_scan"][50, :, :] = 0 # Space self.reader.scans["space_data"] = 400 - self.reader.scans["space_data"][0::5, :] = 0 - + self.reader.scans["space_data"][50, :, :] = 0 + self.reader.get_calibrated_channels() assert np.any(np.isfinite(self.reader.get_calibrated_channels())) def test_calibrate_inactive_3b(self): diff --git a/pygac/tests/test_reader.py b/pygac/tests/test_reader.py index 16f2534..c1f627e 100644 --- a/pygac/tests/test_reader.py +++ b/pygac/tests/test_reader.py @@ -86,11 +86,25 @@ def get_header_timestamp(self): def get_telemetry(self): """Get the telemetry.""" - prt = 51 * np.ones(self.along_track) # prt threshold is 50 - prt[::5] = 0 - ict = 101 * np.ones((self.along_track, 3)) # ict threshold is 100 - space = 101 * np.ones((self.along_track, 3)) # space threshold is 100 - return prt, ict, space + prt = 51 * np.ones((self.along_track, 3)) # prt threshold is 50 + prt[::5, :] = 0 + ict = 101 * np.ones((self.along_track, 10, 3)) # ict threshold is 100 + space = 101 * np.ones((self.along_track, 10, 5)) # space threshold is 100 + + prt_counts = xr.DataArray(prt, + dims=["scan_line_index", "PRT_measurement"]) + + # getting ICT counts + ict_counts = xr.DataArray(ict, + dims=["scan_line_index", "back_scan", "channel_name"], + coords=dict(channel_name=["3", "4", "5"])) + + # getting space counts + space_counts = xr.DataArray(self.split_array_along_channel_3(space), + dims=["scan_line_index", "back_scan", "channel_name"], + coords=dict(channel_name=["1", "2", "3", "4", "5"])) + + return xr.Dataset(dict(PRT=prt_counts, ICT=ict_counts, space_counts=space_counts)) def _adjust_clock_drift(self): pass @@ -835,9 +849,10 @@ def test_read_to_dataset_is_a_dataset_including_channels_and_telemetry(pod_file_ assert "times" in dataset.coords assert "scan_line_index" in dataset.coords assert "channel_name" in dataset.coords - assert dataset["prt_counts"].shape == (3,) - assert dataset["ict_counts"].shape == (3, 3) - assert dataset["space_counts"].shape == (3, 3) + assert dataset["PRT"].shape == (3, 3) + assert dataset["ICT"].shape == (3, 10, 5) + np.testing.assert_array_equal(dataset["ICT"].sel(channel_name=["1", "2"]), np.nan) + assert dataset["space_counts"].shape == (3, 10, 5) def test_read_to_dataset_without_interpolation(pod_file_with_tbm_header, pod_tle):