Example #1
0
    def test_select_targets_gives_Nsel_objects_in_output(
            self, inputs_for_select_targets, Nsel):
        """
        When there are many untiled things in a field, check that our tiles contain NSel galaxies
        """

        proximity = 200
        tile_members, isels = T.select_targets(**inputs_for_select_targets,
                                               proximity=proximity,
                                               Nsel=Nsel,
                                               selection_type='random',
                                               fill_spares_with_repeats=False)

        assert (len(tile_members) == Nsel)
Example #2
0
    def test_select_targets_raises_error_when_wrong_selection_type(
            self, inputs_for_select_targets):
        """
        When we add in a selection type which isn't 'random' or 'clashing', check this raises an error
        """

        proximity = 200
        Nsel = 19

        with pytest.raises(NameError):
            tile_members, isels = T.select_targets(
                **inputs_for_select_targets,
                proximity=proximity,
                Nsel=Nsel,
                selection_type='wrong_value',
                fill_spares_with_repeats=False)
Example #3
0
    def test_select_targets_doesnt_raise_value_error(
            self, inputs_for_select_targets):
        """
        Make sure that select targets doesn't raise a value error when it checks that our tile doesn't clash with itself
        """
        proximity = 200
        Nsel = 19

        try:
            tile_members, isels = T.select_targets(
                **inputs_for_select_targets,
                proximity=proximity,
                Nsel=Nsel,
                selection_type='random',
                fill_spares_with_repeats=False)
        except ValueError:
            pytest.fail(
                "Value error raised implies our tile clashes with itself!")
Example #4
0
    def test_fill_with_repeats_being_false_doesnt_add_galaxies_to_fill_tile(
            self, inputs_for_select_targets):
        """
        When there are fewer than Nsel things left to tile in a field, check that not having the fill_spares_with_repeats flag means that we only return the number of unobserved galaxies for this tile
        """
        proximity = 200
        Nsel = 19
        # Make it so that everything in this field has been observed except one galaxy
        targets_df = inputs_for_select_targets['all_targets_df']
        targets_df['COMPLETED'] = True
        targets_df.loc[targets_df.CATAID == 8706, 'COMPLETED'] = False
        priorities = inputs_for_select_targets['priorities']

        tile_members, isels = T.select_targets(all_targets_df=targets_df,
                                               priorities=priorities,
                                               proximity=proximity,
                                               Nsel=Nsel,
                                               selection_type='random',
                                               fill_spares_with_repeats=False)

        assert len(tile_members) == 1
Example #5
0
    def test_fill_with_repeats_adds_galaxies_to_fill_tile(
            self, inputs_for_select_targets):
        """
        When there are fewer than Nsel things left to tile in the field, check that the 'fill_spares_with_repeats' flag does add in spare galaxies to reach Nsel targets
        """
        proximity = 200
        Nsel = 19
        # Make it so that everything in this field has been observed except one galaxy
        targets_df = inputs_for_select_targets['all_targets_df']
        targets_df['COMPLETED'] = True
        targets_df.loc[targets_df.CATAID == 8706, 'COMPLETED'] = False
        priorities = inputs_for_select_targets['priorities']

        tile_members, isels = T.select_targets(all_targets_df=targets_df,
                                               priorities=priorities,
                                               proximity=proximity,
                                               Nsel=Nsel,
                                               selection_type='random',
                                               fill_spares_with_repeats=True)

        assert len(tile_members) == Nsel