Пример #1
0
    def download_triplets_for_source(self, source, needs_apcor=False):
        focus_calculator = TripletFocusCalculator(source)
        grid = CutoutGrid(source)

        def create_callback(frame_index, time_index):
            def callback(cutout):
                grid.add_cutout(cutout, frame_index, time_index)

                if grid.is_filled():
                    self._cutout_grids[grid.source] = grid
                    events.send(events.IMG_LOADED, grid.source)
                    logger.info("Triplet grid finished downloading.")

            return callback

        for time_index, reading in enumerate(source.get_readings()):
            for frame_index in range(source.num_readings()):
                callback = create_callback(frame_index, time_index)

                focus = focus_calculator.calculate_focus(reading, frame_index)
                self._triplet_download_manager.submit_request(
                    DownloadRequest(reading,
                                    needs_apcor=needs_apcor,
                                    focus=focus,
                                    callback=callback)
                )
Пример #2
0
    def setUp(self):
        astrom_data = AstromParser().parse(
            self.get_abs_path("data/1616681p22.measure3.cands.astrom"))
        self.source = astrom_data.get_sources()[0]
        self.reading0 = self.source.get_reading(0)
        self.reading1 = self.source.get_reading(1)
        self.reading2 = self.source.get_reading(2)

        self.undertest = TripletFocusCalculator(self.source)
Пример #3
0
class TripletFocusCalculatorTest(FileReadingTestCase):
    def setUp(self):
        astrom_data = AstromParser().parse(
            self.get_abs_path("data/1616681p22.measure3.cands.astrom"))
        self.source = astrom_data.get_sources()[0]
        self.reading0 = self.source.get_reading(0)
        self.reading1 = self.source.get_reading(1)
        self.reading2 = self.source.get_reading(2)

        self.undertest = TripletFocusCalculator(self.source)

    def test_calculate_focal_points(self):
        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading0, 0),
            (560.06, 406.51))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading1, 0),
            (562.82, 406.68))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading2, 0),
            (564.44, 406.03))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading0, 1),
            (583.42, 408.46))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading1, 1),
            (586.18, 408.63))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading2, 1),
            (587.80, 407.98))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading0, 2),
            (608.48, 407.17))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading1, 2),
            (611.24, 407.34))

        assert_tuples_almost_equal(
            self.undertest.calculate_focus(self.reading2, 2),
            (612.86, 406.69))