コード例 #1
0
ファイル: test_workload.py プロジェクト: OSSOS/MOP
 def setUp(self):
     self.testfile = self.get_input_file()
     parser = AstromParser()
     self.data = parser.parse(self.get_abs_path(self.testfile))
     self.progress_manager = Mock(spec=LocalProgressManager)
     self.progress_manager.get_processed_indices.return_value = []
     self.output_context = Mock(spec=WorkingContext)
コード例 #2
0
ファイル: test_workload.py プロジェクト: sevenlin123/MOP
 def setUp(self):
     self.testfile = "data/1584431p15.measure3.cands.astrom"
     parser = AstromParser()
     self.data = parser.parse(self.get_abs_path(self.testfile))
     self.progress_manager = Mock(spec=ProgressManager)
     self.progress_manager.get_processed_indices.return_value = []
     self.writer = Mock()
コード例 #3
0
 def setUp(self):
     self.testfile = self.get_input_file()
     parser = AstromParser()
     self.data = parser.parse(self.get_abs_path(self.testfile))
     self.progress_manager = Mock(spec=LocalProgressManager)
     self.progress_manager.get_processed_indices.return_value = []
     self.output_context = Mock(spec=WorkingContext)
コード例 #4
0
ファイル: test_focus.py プロジェクト: ijiraq/MOP
    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)
コード例 #5
0
ファイル: test_downloads.py プロジェクト: sevenlin123/MOP
    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.needs_apcor = False
        self.callback = Mock()
コード例 #6
0
ファイル: test_downloads.py プロジェクト: sevenlin123/MOP
    def test_download_callback(self):
        astrom_data = AstromParser().parse(
            self.get_abs_path("data/1616681p22.measure3.cands.astrom"))

        source = astrom_data.get_sources()[0]
        reading = source.get_reading(0)

        callback = Mock()

        downloadable_item = DownloadableItem(reading, source, True, callback)

        self.undertest.do_download(downloadable_item)

        callback.assert_called_once_with(reading, self.downloaded_image)
コード例 #7
0
ファイル: app.py プロジェクト: stephengwyn/MOP
 def _create_workunit_builder(self, input_context, output_context,
                              progress_manager):
     return RealsWorkUnitBuilder(AstromParser(),
                                 input_context,
                                 output_context,
                                 progress_manager,
                                 dry_run=self.dry_run)
コード例 #8
0
ファイル: test_snapshot.py プロジェクト: R136a1-/MOP
    def setUp(self):
        test_file = "data/image_reading/realstest2.measure3.reals.astrom"
        astrom_data = AstromParser().parse(self.get_abs_path(test_file))

        self.reading = astrom_data.get_sources()[0].get_reading(0)
        self.original_observed_x = self.reading.x
        self.original_observed_y = self.reading.y

        self.offset_x = 10
        self.offset_y = 15
        coordinate_converter = CoordinateConverter(self.offset_x, self.offset_y)

        self.undertest = SourceCutout(self.reading, Mock(), coordinate_converter)

        self.mock_update_ra_dec = Mock()
        self.undertest._update_ra_dec = self.mock_update_ra_dec
コード例 #9
0
ファイル: test_models.py プロジェクト: austinbeauch/octarine
    def setUp(self):
        events.unsub_all()
        self.workunit_provider = Mock(spec=PreFetchingWorkUnitProvider)
        self.image_manager = Mock(spec=ImageManager)
        self.synchronization_manager = Mock(spec=SynchronizationManager)
        self.model = TransAckValidationModel(self.workunit_provider,
                                             self.image_manager,
                                             self.synchronization_manager)

        self.data = AstromParser().parse(
            self.get_abs_path(
                "data/model_testdir_1/1584431p15.measure3.reals.astrom"))
        self.output_context = Mock(spec=LocalDirectoryWorkingContext)
        self.progress_manager = MagicMock(spec=LocalProgressManager)

        self.sources = self.data.get_sources()
コード例 #10
0
    def setUp(self):
        events.unsub_all()

        parser = AstromParser()
        directory_manager = LocalDirectoryWorkingContext(
            self._get_working_dir())
        self.context = directory_manager
        progress_manager = LocalProgressManager(directory_manager)
        workunit_provider = WorkUnitProvider(
            tasks.get_suffix(self._get_task()), directory_manager,
            progress_manager,
            self._get_workunit_builder(parser, progress_manager))

        self.workunit_provider = workunit_provider
        self.progress_manager = progress_manager

        self.singlet_download_manager = Mock(spec=AsynchronousDownloadManager)
        self.triplet_download_manager = Mock(spec=AsynchronousDownloadManager)
        self.image_manager = ImageManager(self.singlet_download_manager,
                                          self.triplet_download_manager)

        self.model = ValidationModel(self.workunit_provider,
                                     self.image_manager, None)

        self.custom_setup()

        self.model.start_work()
コード例 #11
0
ファイル: app.py プロジェクト: sevenlin123/MOP
    def __init__(self, taskname, working_directory):
        wx_app = wx.App(False)

        debug_mode = config.read("DEBUG")
        if debug_mode:
            wx.lib.inspection.InspectionTool().Show()

        try:
            factory = self.task_name_mapping[taskname]()
        except KeyError:
            raise ValueError("Unknown task: %s" % taskname)

        parser = AstromParser()
        error_handler = DownloadErrorHandler(self)
        downloader = ImageSliceDownloader()
        download_manager = AsynchronousImageDownloadManager(
            downloader, error_handler)

        directory_context = DirectoryContext(working_directory)
        progress_manager = ProgressManager(directory_context)
        builder = factory.create_workunit_builder(parser, progress_manager)
        workunit_provider = WorkUnitProvider(tasks.get_suffix(taskname),
                                             directory_context,
                                             progress_manager, builder)
        model = UIModel(workunit_provider, progress_manager, download_manager)
        controller = factory.create_controller(model)

        self.model = model
        self.view = controller.get_view()

        wx_app.MainLoop()
コード例 #12
0
ファイル: test_snapshot.py プロジェクト: ijiraq/MOP
    def setUp(self):
        test_file = "data/image_reading/realstest2.measure3.reals.astrom"
        astrom_data = AstromParser().parse(self.get_abs_path(test_file))

        self.reading = astrom_data.get_sources()[0].get_reading(0)
        self.original_observed_x = self.reading.x
        self.original_observed_y = self.reading.y

        self.offset_x = 10
        self.offset_y = 15
        coordinate_converter = CoordinateConverter(self.offset_x,
                                                   self.offset_y)

        self.undertest = SourceCutout(self.reading, Mock())

        self.mock_update_ra_dec = Mock()
        self.undertest._update_ra_dec = self.mock_update_ra_dec
コード例 #13
0
 def setUp(self):
     working_directory = self.get_directory_to_clean()
     context = LocalDirectoryWorkingContext(working_directory)
     progress_manager = InMemoryProgressManager(context)
     parser = AstromParser()
     builder = RealsWorkUnitBuilder(parser, context, context,
                                    progress_manager)
     undertest = WorkUnitProvider(tasks.get_suffix(tasks.REALS_TASK),
                                  context, progress_manager, builder)
     self.progress_manager = progress_manager
     self.undertest = undertest
コード例 #14
0
    def setUp(self):
        WxWidgetTestCase.setUp(self)

        parser = AstromParser()
        context = LocalDirectoryWorkingContext(
            self.get_abs_path("data/controller_testdir"))
        progress_manager = LocalProgressManager(context)
        workunit_provider = WorkUnitProvider(tasks.get_suffix(tasks.REALS_TASK),
                                             context, progress_manager,
                                             RealsWorkUnitBuilder(
                                                 parser,
                                                 context,
                                                 context,
                                                 progress_manager))

        image_manager = Mock(spec=ImageManager)

        self.model = ValidationModel(workunit_provider, image_manager, None)
        self.model.start_work()

        self.model.get_writer = Mock(return_value=Mock(spec=mpc.MPCWriter))

        # We don't actually have any images loaded, so mock this out
        source_cutout = Mock(spec=SourceCutout)
        source_cutout.pixel_x = 11
        source_cutout.pixel_y = 50
        self.model.get_current_cutout = Mock(return_value=source_cutout)

        x_cen = 10
        y_cen = 50
        mag = 24.0
        self.model.get_current_source_observed_magnitude = Mock(return_value=(x_cen, y_cen, mag))

        self.model.is_current_source_adjusted = Mock(return_value=False)
        self.model.get_current_fits_header = Mock()

        self.name_generator = Mock(spec=ProvisionalNameGenerator)
        self.name_generator.generate_name.return_value = TEST_PROVISIONAL_NAME

        class TestFactory(object):
            def __init__(self, model, name_generator):
                self.model = model
                self.name_generator = name_generator

            def create_controller(self, view):
                return ProcessRealsController(self.model, view,
                                              self.name_generator)

        self.view = ApplicationView(
            TestFactory(self.model, self.name_generator))
        self.controller = self.view.controller
        self.controller.display_current_image = Mock()
コード例 #15
0
ファイル: test_snapshot.py プロジェクト: stephengwyn/MOP
    def setUp(self):
        test_file = self.path("realstest2.measure3.reals.astrom")
        astrom_data = AstromParser().parse(test_file)

        self.reading = astrom_data.get_sources()[0].get_reading(0)

        # Load the real image
        hdulist = fits.open(self.path("cutout-1616687p.fits"))

        with open(self.path("1616687p10.apcor")) as fh:
            apcor = ApcorData.from_string(fh.read())

        # NOTE: the test image
        # vos://cadc.nrc.ca~vospace/OSSOS/dbimages/1616687/1616687p.fits
        # has cutout: [11][1449:1199,1429:1179] and is inverted.
        #
        # Therefore the first reading at (772.13, 3334.70) in observed
        # coordinates is at
        # (NAX1 - max cutout x, NAX2 - max cutout y)
        #  = (2112 - 1449, 4644 - 1429) = (663, 3215)
        self.original_pixel_x = 663
        self.original_pixel_y = 3215

        self.original_observed_x = 772.13
        self.original_observed_y = 3334.70

        x_offset = self.original_observed_x - self.original_pixel_x
        y_offset = self.original_observed_y - self.original_pixel_y

        self.undertest = SourceCutout(self.reading, hdulist,
                                      CoordinateConverter(x_offset, y_offset),
                                      apcor=apcor)

        assert_that(self.undertest.observed_x, equal_to(self.original_observed_x))
        assert_that(self.undertest.observed_y, equal_to(self.original_observed_y))

        assert_that(self.undertest.pixel_x, equal_to(self.original_pixel_x))
        assert_that(self.undertest.pixel_y, equal_to(self.original_pixel_y))
コード例 #16
0
ファイル: test_models.py プロジェクト: OSSOS/MOP
    def setUp(self):
        events.unsub_all()
        self.workunit_provider = Mock(spec=PreFetchingWorkUnitProvider)
        self.image_manager = Mock(spec=ImageManager)
        self.synchronization_manager = Mock(spec=SynchronizationManager)
        self.model = TransAckValidationModel(self.workunit_provider, self.image_manager,
                                             self.synchronization_manager)

        self.data = AstromParser().parse(
            self.get_abs_path("data/model_testdir_1/1584431p15.measure3.reals.astrom"))
        self.output_context = Mock(spec=LocalDirectoryWorkingContext)
        self.progress_manager = MagicMock(spec=LocalProgressManager)

        self.sources = self.data.get_sources()
コード例 #17
0
ファイル: test_models.py プロジェクト: sevenlin123/MOP
    def setUp(self):
        events.unsub_all()

        parser = AstromParser()
        directory_manager = DirectoryContext(self._get_working_dir())
        progress_manager = ProgressManager(directory_manager)
        workunit_provider = WorkUnitProvider(
            tasks.get_suffix(self._get_task()), directory_manager,
            progress_manager,
            self._get_workunit_builder(parser, progress_manager))

        self.workunit_provider = workunit_provider
        self.progress_manager = progress_manager
        self.download_manager = Mock(spec=AsynchronousImageDownloadManager)

        self.model = self.get_model()
コード例 #18
0
ファイル: test_controllers.py プロジェクト: sevenlin123/MOP
    def setUp(self):
        WxWidgetTestCase.setUp(self)

        parser = AstromParser()
        directory_manager = DirectoryContext(
            self.get_abs_path("data/controller_testdir"))
        progress_manager = ProgressManager(directory_manager)
        workunit_provider = WorkUnitProvider(tasks.get_suffix(tasks.REALS_TASK),
                                             directory_manager, progress_manager,
                                             RealsWorkUnitBuilder(parser, progress_manager))

        download_manager = Mock(spec=AsynchronousImageDownloadManager)

        self.model = UIModel(workunit_provider, progress_manager, download_manager)

        self.name_generator = Mock()
        self.controller = ProcessRealsController(self.model, self.name_generator)
コード例 #19
0
ファイル: test_astrom.py プロジェクト: OSSOS/MOP
 def test_get_reading_count(self):
     astrom_data = AstromParser().parse(self.get_abs_path(TEST_FILE_1))
     assert_that(astrom_data.get_reading_count(), equal_to(9))
コード例 #20
0
ファイル: test_astrom.py プロジェクト: OSSOS/MOP
 def setUp(self):
     self.parser = AstromParser()
コード例 #21
0
ファイル: test_astrom.py プロジェクト: OSSOS/MOP
class ParserTest(FileReadingTestCase):
    def setUp(self):
        self.parser = AstromParser()

    def parse(self, filename):
        return self.parser.parse(self.get_abs_path(filename))

    def test_parse_observation_rawnames(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.observations, has_length(3))
        assert_that(astrom_data.observations[0].rawname, equal_to("1584431p15"))
        assert_that(astrom_data.observations[1].rawname, equal_to("1584449p15"))
        assert_that(astrom_data.observations[2].rawname, equal_to("1584453p15"))

    def test_parse_observation_basic_details(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        assert_that(obs0.expnum, equal_to("1584431"))
        assert_that(obs0.ftype, equal_to("p"))
        assert_that(obs0.ccdnum, equal_to("15"))
        assert_that(obs0.is_fake(), equal_to(False))

        assert_that(obs1.expnum, equal_to("1584449"))
        assert_that(obs1.ftype, equal_to("p"))
        assert_that(obs1.ccdnum, equal_to("15"))
        assert_that(obs1.is_fake(), equal_to(False))

        assert_that(obs2.expnum, equal_to("1584453"))
        assert_that(obs2.ftype, equal_to("p"))
        assert_that(obs2.ccdnum, equal_to("15"))
        assert_that(obs2.is_fake(), equal_to(False))

    def test_parse_observation_headers(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        assert_that(obs0.header, has_length(18))
        assert_that(
            obs0.header,
            has_entries(
                {
                    "MOPversion": "1.20",
                    "MJD_OBS_CENTER": "2012 10 21.40516",
                    "EXPTIME": "320.14",
                    "THRES": "2.70",
                    "FWHM": "2.90",
                    "MAXCOUNT": "30000.0",
                    "CRVAL1": "26.92871",
                    "CRVAL2": "29.01125",
                    "EXPNUM": "1584431",
                    "SCALE": "0.185",
                    "CHIP": "16",
                    "CRPIX1": "-3227.00",
                    "CRPIX2": "-75.96",
                    "NAX1": "2112",
                    "NAX2": "4644",
                    "DETECTOR": "MegaPrime",
                    "PHADU": "1.60",
                    "RDNOIS": "3.00",
                }
            ),
        )

        assert_that(obs1.header, has_length(18))
        assert_that(obs2.header, has_length(18))

    def test_parse_sys_header(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.sys_header, has_length(4))
        assert_that(
            astrom_data.sys_header, has_entries({"RMIN": "0.5", "RMAX": "10.3", "ANGLE": "-19.9", "AWIDTH": "22.3"})
        )

    def test_parse_sources(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.sources, has_length(3))

        ## Test source 0
        source0 = astrom_data.sources[0]
        assert_that(source0.num_readings(), equal_to(3))

        # Source 0 reading 0
        data00 = source0.get_reading(0)
        assert_that(data00.x, equal_to(911.00))
        assert_that(data00.y, equal_to(3967.12))
        assert_that(data00.x0, equal_to(911.00))
        assert_that(data00.y0, equal_to(3967.12))
        assert_that(data00.ra, equal_to(26.6833367))
        assert_that(data00.dec, equal_to(29.2203532))
        assert_that(data00.xref, equal_to(911.00))
        assert_that(data00.yref, equal_to(3967.12))

        # Source 0 reading 1
        data01 = source0.get_reading(1)
        assert_that(data01.x, equal_to(944.25))
        assert_that(data01.y, equal_to(3964.03))
        assert_that(data01.x0, equal_to(938.93))
        assert_that(data01.y0, equal_to(3965.78))
        assert_that(data01.ra, equal_to(26.6816808))
        assert_that(data01.dec, equal_to(29.2202748))
        assert_that(data01.xref, equal_to(911.00))
        assert_that(data01.yref, equal_to(3967.12))

        # Source 0 reading 2
        data02 = source0.get_reading(2)
        assert_that(data02.x, equal_to(949.76))
        assert_that(data02.y, equal_to(3963.12))
        assert_that(data02.x0, equal_to(943.91))
        assert_that(data02.y0, equal_to(3965.20))
        assert_that(data02.ra, equal_to(26.6813840))
        assert_that(data02.dec, equal_to(29.2202469))
        assert_that(data02.xref, equal_to(911.00))
        assert_that(data02.yref, equal_to(3967.12))

        ## Test source 1
        assert_that(astrom_data.sources[1].num_readings(), equal_to(3))

        ## Test source 2
        source2 = astrom_data.sources[2]
        assert_that(source2.num_readings(), equal_to(3))

        # Source 2 reading 2
        data22 = source2.get_reading(2)
        assert_that(data22.x, equal_to(1800.48))
        assert_that(data22.y, equal_to(1843.53))
        assert_that(data22.x0, equal_to(1795.10))
        assert_that(data22.y0, equal_to(1845.71))
        assert_that(data22.ra, equal_to(26.6311063))
        assert_that(data22.dec, equal_to(29.1102185))
        assert_that(data22.xref, equal_to(1698.04))
        assert_that(data22.yref, equal_to(1842.46))

    def test_parse_source_readings_have_observations(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        source0 = astrom_data.sources[0]
        assert_that(source0.get_reading(0).obs, same_instance(obs0))
        assert_that(source0.get_reading(1).obs, same_instance(obs1))
        assert_that(source0.get_reading(2).obs, same_instance(obs2))

        source1 = astrom_data.sources[1]
        assert_that(source1.get_reading(0).obs, same_instance(obs0))
        assert_that(source1.get_reading(1).obs, same_instance(obs1))
        assert_that(source1.get_reading(2).obs, same_instance(obs2))

        source2 = astrom_data.sources[2]
        assert_that(source2.get_reading(0).obs, same_instance(obs0))
        assert_that(source2.get_reading(1).obs, same_instance(obs1))
        assert_that(source2.get_reading(2).obs, same_instance(obs2))

    def test_parse_file2_had_neg_crval2(self):
        astrom_data = self.parse(TEST_FILE_2)

        assert_that(astrom_data.sources, has_length(1))
        assert_that(astrom_data.observations, has_length(3))

        obs_names = [obs.rawname for obs in astrom_data.observations]
        assert_that(obs_names, contains("1616681p22", "1616692p22", "1616703p22"))

    def test_parse_source_reference_point(self):
        astrom_data = self.parse(TEST_FILE_2)
        source = astrom_data.get_sources()[0]

        reading0 = source.get_reading(0)
        reading1 = source.get_reading(1)
        reading2 = source.get_reading(2)

        delta = 0.00000001
        assert_that(reading0.reference_source_point[0], close_to(560.06, delta))
        assert_that(reading0.reference_source_point[1], close_to(406.51, delta))
        assert_that(reading1.reference_source_point[0], close_to(562.82, delta))
        assert_that(reading1.reference_source_point[1], close_to(406.68, delta))
        assert_that(reading2.reference_source_point[0], close_to(564.44, delta))
        assert_that(reading2.reference_source_point[1], close_to(406.03, delta))

    def test_reading_coordinate_offsets(self):
        astrom_data = self.parse(TEST_FILE_2)

        source = astrom_data.get_sources()[0]

        reading0 = source.get_reading(0)
        reading1 = source.get_reading(1)
        reading2 = source.get_reading(2)

        delta = 0.00000001
        assert_that(reading0.get_coordinate_offset(reading0)[0], close_to(0, delta))
        assert_that(reading0.get_coordinate_offset(reading0)[1], close_to(0, delta))
        assert_that(reading0.get_coordinate_offset(reading1)[0], close_to(-2.76, delta))
        assert_that(reading0.get_coordinate_offset(reading1)[1], close_to(-0.17, delta))
        assert_that(reading0.get_coordinate_offset(reading2)[0], close_to(-4.38, delta))
        assert_that(reading0.get_coordinate_offset(reading2)[1], close_to(0.48, delta))

    def test_parse_fake_file(self):
        astrom_data = self.parse(FK_FILE)

        assert_that(astrom_data.observations, has_length(3))
        assert_that(astrom_data.get_sources(), has_length(21))

        obs0 = astrom_data.observations[0]

        assert_that(obs0.rawname, equal_to("fk1616682s00"))
        assert_that(obs0.expnum, equal_to("1616682"))
        assert_that(obs0.ftype, equal_to("s"))
        assert_that(obs0.ccdnum, equal_to("00"))
        assert_that(obs0.is_fake(), equal_to(True))
コード例 #22
0
ファイル: test_astrom.py プロジェクト: ijiraq/MOP
class ParserTest(FileReadingTestCase):
    def setUp(self):
        self.parser = AstromParser()

    def parse(self, filename):
        return self.parser.parse(self.get_abs_path(filename))

    def test_parse_observation_rawnames(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.observations, has_length(3))
        assert_that(astrom_data.observations[0].rawname,
                    equal_to("1584431p15"))
        assert_that(astrom_data.observations[1].rawname,
                    equal_to("1584449p15"))
        assert_that(astrom_data.observations[2].rawname,
                    equal_to("1584453p15"))

    def test_parse_observation_basic_details(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        assert_that(obs0.expnum, equal_to("1584431"))
        assert_that(obs0.ftype, equal_to("p"))
        assert_that(obs0.ccdnum, equal_to("15"))
        assert_that(obs0.is_fake(), equal_to(False))

        assert_that(obs1.expnum, equal_to("1584449"))
        assert_that(obs1.ftype, equal_to("p"))
        assert_that(obs1.ccdnum, equal_to("15"))
        assert_that(obs1.is_fake(), equal_to(False))

        assert_that(obs2.expnum, equal_to("1584453"))
        assert_that(obs2.ftype, equal_to("p"))
        assert_that(obs2.ccdnum, equal_to("15"))
        assert_that(obs2.is_fake(), equal_to(False))

    def test_parse_observation_headers(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        assert_that(obs0.header, has_length(18))
        assert_that(obs0.header, has_entries(
            {"MOPversion": "1.20",
             "MJD_OBS_CENTER": "2012 10 21.40516",
             "EXPTIME": "320.14",
             "THRES": "2.70",
             "FWHM": "2.90",
             "MAXCOUNT": "30000.0",
             "CRVAL1": "26.92871",
             "CRVAL2": "29.01125",
             "EXPNUM": "1584431",
             "SCALE": "0.185",
             "CHIP": "16",
             "CRPIX1": "-3227.00",
             "CRPIX2": "-75.96",
             "NAX1": "2112",
             "NAX2": "4644",
             "DETECTOR": "MegaPrime",
             "PHADU": "1.60",
             "RDNOIS": "3.00"}
        ))

        assert_that(obs1.header, has_length(18))
        assert_that(obs2.header, has_length(18))

    def test_parse_sys_header(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.sys_header, has_length(4))
        assert_that(astrom_data.sys_header, has_entries(
            {"RMIN": "0.5",
             "RMAX": "10.3",
             "ANGLE": "-19.9",
             "AWIDTH": "22.3"}
        ))

    def test_parse_sources(self):
        astrom_data = self.parse(TEST_FILE_1)

        assert_that(astrom_data.sources, has_length(3))

        ## Test source 0
        source0 = astrom_data.sources[0]
        assert_that(source0.num_readings(), equal_to(3))

        # Source 0 reading 0
        data00 = source0.get_reading(0)
        assert_that(data00.x, equal_to(911.00))
        assert_that(data00.y, equal_to(3967.12))
        assert_that(data00.x0, equal_to(911.00))
        assert_that(data00.y0, equal_to(3967.12))
        assert_that(data00.ra, equal_to(26.6833367))
        assert_that(data00.dec, equal_to(29.2203532))
        assert_that(data00.xref, equal_to(911.00))
        assert_that(data00.yref, equal_to(3967.12))

        # Source 0 reading 1
        data01 = source0.get_reading(1)
        assert_that(data01.x, equal_to(944.25))
        assert_that(data01.y, equal_to(3964.03))
        assert_that(data01.x0, equal_to(938.93))
        assert_that(data01.y0, equal_to(3965.78))
        assert_that(data01.ra, equal_to(26.6816808))
        assert_that(data01.dec, equal_to(29.2202748))
        assert_that(data01.xref, equal_to(911.00))
        assert_that(data01.yref, equal_to(3967.12))

        # Source 0 reading 2
        data02 = source0.get_reading(2)
        assert_that(data02.x, equal_to(949.76))
        assert_that(data02.y, equal_to(3963.12))
        assert_that(data02.x0, equal_to(943.91))
        assert_that(data02.y0, equal_to(3965.20))
        assert_that(data02.ra, equal_to(26.6813840))
        assert_that(data02.dec, equal_to(29.2202469))
        assert_that(data02.xref, equal_to(911.00))
        assert_that(data02.yref, equal_to(3967.12))

        ## Test source 1
        assert_that(astrom_data.sources[1].num_readings(), equal_to(3))

        ## Test source 2
        source2 = astrom_data.sources[2]
        assert_that(source2.num_readings(), equal_to(3))

        # Source 2 reading 2
        data22 = source2.get_reading(2)
        assert_that(data22.x, equal_to(1800.48))
        assert_that(data22.y, equal_to(1843.53))
        assert_that(data22.x0, equal_to(1795.10))
        assert_that(data22.y0, equal_to(1845.71))
        assert_that(data22.ra, equal_to(26.6311063))
        assert_that(data22.dec, equal_to(29.1102185))
        assert_that(data22.xref, equal_to(1698.04))
        assert_that(data22.yref, equal_to(1842.46))

    def test_parse_source_readings_have_observations(self):
        astrom_data = self.parse(TEST_FILE_1)

        obs0 = astrom_data.observations[0]
        obs1 = astrom_data.observations[1]
        obs2 = astrom_data.observations[2]

        source0 = astrom_data.sources[0]
        assert_that(source0.get_reading(0).obs, same_instance(obs0))
        assert_that(source0.get_reading(1).obs, same_instance(obs1))
        assert_that(source0.get_reading(2).obs, same_instance(obs2))

        source1 = astrom_data.sources[1]
        assert_that(source1.get_reading(0).obs, same_instance(obs0))
        assert_that(source1.get_reading(1).obs, same_instance(obs1))
        assert_that(source1.get_reading(2).obs, same_instance(obs2))

        source2 = astrom_data.sources[2]
        assert_that(source2.get_reading(0).obs, same_instance(obs0))
        assert_that(source2.get_reading(1).obs, same_instance(obs1))
        assert_that(source2.get_reading(2).obs, same_instance(obs2))

    def test_parse_file2_had_neg_crval2(self):
        astrom_data = self.parse(TEST_FILE_2)

        assert_that(astrom_data.sources, has_length(1))
        assert_that(astrom_data.observations, has_length(3))

        obs_names = [obs.rawname for obs in astrom_data.observations]
        assert_that(obs_names, contains("1616681p22", "1616692p22", "1616703p22"))

    def test_parse_source_reference_point(self):
        astrom_data = self.parse(TEST_FILE_2)
        source = astrom_data.get_sources()[0]

        reading0 = source.get_reading(0)
        reading1 = source.get_reading(1)
        reading2 = source.get_reading(2)

        delta = 0.00000001
        assert_that(reading0.reference_source_point[0], close_to(560.06, delta))
        assert_that(reading0.reference_source_point[1], close_to(406.51, delta))
        assert_that(reading1.reference_source_point[0], close_to(562.82, delta))
        assert_that(reading1.reference_source_point[1], close_to(406.68, delta))
        assert_that(reading2.reference_source_point[0], close_to(564.44, delta))
        assert_that(reading2.reference_source_point[1], close_to(406.03, delta))

    def test_reading_coordinate_offsets(self):
        astrom_data = self.parse(TEST_FILE_2)

        source = astrom_data.get_sources()[0]

        reading0 = source.get_reading(0)
        reading1 = source.get_reading(1)
        reading2 = source.get_reading(2)

        delta = 0.00000001
        assert_that(reading0.get_coordinate_offset(reading0)[0], close_to(0, delta))
        assert_that(reading0.get_coordinate_offset(reading0)[1], close_to(0, delta))
        assert_that(reading0.get_coordinate_offset(reading1)[0], close_to(-2.76, delta))
        assert_that(reading0.get_coordinate_offset(reading1)[1], close_to(-0.17, delta))
        assert_that(reading0.get_coordinate_offset(reading2)[0], close_to(-4.38, delta))
        assert_that(reading0.get_coordinate_offset(reading2)[1], close_to(0.48, delta))

    def test_parse_fake_file(self):
        astrom_data = self.parse(FK_FILE)

        assert_that(astrom_data.observations, has_length(3))
        assert_that(astrom_data.get_sources(), has_length(21))

        obs0 = astrom_data.observations[0]

        assert_that(obs0.rawname, equal_to("fk1616682s00"))
        assert_that(obs0.expnum, equal_to("1616682"))
        assert_that(obs0.ftype, equal_to("s"))
        assert_that(obs0.ccdnum, equal_to("00"))
        assert_that(obs0.is_fake(), equal_to(True))
コード例 #23
0
ファイル: test_astrom.py プロジェクト: ijiraq/MOP
 def setUp(self):
     self.parser = AstromParser()
コード例 #24
0
ファイル: test_astrom.py プロジェクト: ijiraq/MOP
 def setUp(self):
     self.parser = AstromParser()
     self.outputfile = tempfile.NamedTemporaryFile(suffix=".astrom",
                                                   mode="a+b")
コード例 #25
0
ファイル: test_models.py プロジェクト: austinbeauch/octarine
class TransitionAcknowledgementModelTest(FileReadingTestCase):
    def setUp(self):
        events.unsub_all()
        self.workunit_provider = Mock(spec=PreFetchingWorkUnitProvider)
        self.image_manager = Mock(spec=ImageManager)
        self.synchronization_manager = Mock(spec=SynchronizationManager)
        self.model = TransAckValidationModel(self.workunit_provider,
                                             self.image_manager,
                                             self.synchronization_manager)

        self.data = AstromParser().parse(
            self.get_abs_path(
                "data/model_testdir_1/1584431p15.measure3.reals.astrom"))
        self.output_context = Mock(spec=LocalDirectoryWorkingContext)
        self.progress_manager = MagicMock(spec=LocalProgressManager)

        self.sources = self.data.get_sources()

    def use_reals_workunit(self):
        self.workunit = RealsWorkUnit("file", self.data, self.progress_manager,
                                      self.output_context)
        self.model.add_workunit(self.workunit)
        assert_that(self.model.get_current_reading(),
                    equal_to(self.sources[0].get_reading(0)))

    def use_cands_workunit(self):
        self.workunit = CandidatesWorkUnit("file", self.data,
                                           self.progress_manager,
                                           self.output_context)
        self.workunit.get_writer = Mock()
        self.model.add_workunit(self.workunit)
        assert_that(self.model.get_current_reading(),
                    equal_to(self.sources[0].get_reading(0)))

    def test_ignores_change_observations_while_transitioning_observations(
            self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)
        third_reading = self.sources[0].get_reading(2)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.previous_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.acknowledge_image_displayed()

        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(third_reading))

    def test_ignores_change_sources_while_transitioning_sources(self):
        self.use_reals_workunit()

        first_source = self.sources[0]
        second_source = self.sources[1]
        third_source = self.sources[2]

        assert_that(self.model.get_current_source(), equal_to(first_source))

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.previous_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.acknowledge_image_displayed()

        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(third_source))

    def test_ignores_next_item_while_transitioning_items(self):
        self.use_cands_workunit()

        first_source = self.sources[0]
        second_source = self.sources[1]
        third_source = self.sources[2]

        assert_that(self.model.get_current_source(), equal_to(first_source))

        # This should cause the model to enter the waiting state.
        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.acknowledge_image_displayed()

        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(third_source))

    def test_reals_ignores_accept_while_transitioning_observations(self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_reals_ignores_reject_while_transitioning_observations(self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_allow_accept_while_transitioning_observations(self):
        self.use_cands_workunit()

        self.model.next_obs()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_allow_reject_while_transitioning_observations(self):
        self.use_cands_workunit()

        self.model.next_obs()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_ignore_accept_while_transitioning_sources(self):
        self.use_cands_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_ignore_reject_while_transitioning_sources(self):
        self.use_cands_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    @patch("daomop.gui.models.validation.events")
    def test_additional_change_image_events_not_sent_when_waiting(
            self, events_mock):
        self.use_reals_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(1))

        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(1))

        self.model.acknowledge_image_displayed()

        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(2))
コード例 #26
0
ファイル: test_models.py プロジェクト: OSSOS/MOP
class TransitionAcknowledgementModelTest(FileReadingTestCase):
    def setUp(self):
        events.unsub_all()
        self.workunit_provider = Mock(spec=PreFetchingWorkUnitProvider)
        self.image_manager = Mock(spec=ImageManager)
        self.synchronization_manager = Mock(spec=SynchronizationManager)
        self.model = TransAckValidationModel(self.workunit_provider, self.image_manager,
                                             self.synchronization_manager)

        self.data = AstromParser().parse(
            self.get_abs_path("data/model_testdir_1/1584431p15.measure3.reals.astrom"))
        self.output_context = Mock(spec=LocalDirectoryWorkingContext)
        self.progress_manager = MagicMock(spec=LocalProgressManager)

        self.sources = self.data.get_sources()

    def use_reals_workunit(self):
        self.workunit = RealsWorkUnit("file", self.data, self.progress_manager,
                                      self.output_context)
        self.model.add_workunit(self.workunit)
        assert_that(self.model.get_current_reading(), equal_to(self.sources[0].get_reading(0)))

    def use_cands_workunit(self):
        self.workunit = CandidatesWorkUnit("file", self.data, self.progress_manager,
                                           self.output_context)
        self.workunit.get_writer = Mock()
        self.model.add_workunit(self.workunit)
        assert_that(self.model.get_current_reading(), equal_to(self.sources[0].get_reading(0)))

    def test_ignores_change_observations_while_transitioning_observations(self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)
        third_reading = self.sources[0].get_reading(2)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.previous_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        self.model.acknowledge_image_displayed()

        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(third_reading))

    def test_ignores_change_sources_while_transitioning_sources(self):
        self.use_reals_workunit()

        first_source = self.sources[0]
        second_source = self.sources[1]
        third_source = self.sources[2]

        assert_that(self.model.get_current_source(), equal_to(first_source))

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.previous_source()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.acknowledge_image_displayed()

        self.model.next_source()

        assert_that(self.model.get_current_source(), equal_to(third_source))

    def test_ignores_next_item_while_transitioning_items(self):
        self.use_cands_workunit()

        first_source = self.sources[0]
        second_source = self.sources[1]
        third_source = self.sources[2]

        assert_that(self.model.get_current_source(), equal_to(first_source))

        # This should cause the model to enter the waiting state.
        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(second_source))

        self.model.acknowledge_image_displayed()

        self.model.next_item()

        assert_that(self.model.get_current_source(), equal_to(third_source))

    def test_reals_ignores_accept_while_transitioning_observations(self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_reals_ignores_reject_while_transitioning_observations(self):
        self.use_reals_workunit()

        first_reading = self.sources[0].get_reading(0)
        second_reading = self.sources[0].get_reading(1)

        assert_that(self.model.get_current_reading(), equal_to(first_reading))

        # This should cause the model to enter the waiting state.
        self.model.next_obs()

        assert_that(self.model.get_current_reading(), equal_to(second_reading))

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_allow_accept_while_transitioning_observations(self):
        self.use_cands_workunit()

        self.model.next_obs()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_allow_reject_while_transitioning_observations(self):
        self.use_cands_workunit()

        self.model.next_obs()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_ignore_accept_while_transitioning_sources(self):
        self.use_cands_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.accept_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    def test_cands_ignore_reject_while_transitioning_sources(self):
        self.use_cands_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_source()

        assert_that(self.model.get_num_items_processed(), equal_to(0))
        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(0))

        self.model.acknowledge_image_displayed()

        self.model.reject_current_item()
        assert_that(self.model.get_num_items_processed(), equal_to(1))

    @patch("ossos.gui.models.validation.events")
    def test_additional_change_image_events_not_sent_when_waiting(self, events_mock):
        self.use_reals_workunit()

        # This should cause the model to enter the waiting state.
        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(1))

        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(1))

        self.model.acknowledge_image_displayed()

        self.model.next_item()

        assert_that(events_mock.send.call_count, equal_to(2))
コード例 #27
0
ファイル: test_astrom.py プロジェクト: ijiraq/MOP
 def parse(self, filename=TEST_FILE_1):
     return AstromParser().parse(self.get_abs_path(filename))
コード例 #28
0
ファイル: test_astrom.py プロジェクト: ijiraq/MOP
 def test_get_reading_count(self):
     astrom_data = AstromParser().parse(self.get_abs_path(TEST_FILE_1))
     assert_that(astrom_data.get_reading_count(), equal_to(9))
コード例 #29
0
ファイル: test_naming.py プロジェクト: austinbeauch/octarine
 def parse_astrom_header(
         self, filename="data/naming/E+3+0_21.measure3.cands.astrom"):
     return AstromParser().parse(
         self.get_abs_path(filename)).get_sources()[0].get_reading(
             0).get_observation_header()