def test_pattern_noise_on_2d_image(set_random_seed): image = FakeImage() image.data = generate_data(has_pattern_noise=True) detector = pattern_noise.PatternNoiseDetector(None) logger.error = mock.MagicMock() detector.do_stage(image) assert logger.error.called
def test_pattern_noise_does_not_detect_stars(set_random_seed): data = generate_data() for i in range(5): x = np.random.uniform(low=0.0, high=100) y = np.random.uniform(low=0.0, high=100) brightness = np.random.uniform(low=1000., high=5000.) data += gaussian2d(data.shape, x, y, brightness, 3.5) detector = pattern_noise.PatternNoiseDetector(None) assert detector.check_for_pattern_noise(data)[0] == False
def test_pattern_noise_on_3d_image(mock_save_qc): data = 100.0 * np.sin(np.arange(1000000 * 4) / 0.1) + 1000.0 + np.random.normal(0.0, 10.0, size=1000000 * 4) data = data.reshape(4, 1000, 1000) image = FakeImage() image.data = data detector = pattern_noise.PatternNoiseDetector(None) _ = detector.do_stage([image]) assert mock_save_qc.called
def test_pattern_noise_in_only_one_quadrant(mock_save_qc): data = np.random.normal(0.0, 10.0, size=1000000 * 4) + 1000.0 data = data.reshape(4, 1000, 1000) data[3] += 100.0 * np.sin(np.arange(1e6) / 0.1).reshape(1000, 1000) image = FakeImage() image.data = data detector = pattern_noise.PatternNoiseDetector(None) _ = detector.do_stage([image]) assert mock_save_qc.called
def test_group_by_keywords(): detector = pattern_noise.PatternNoiseDetector(None) assert detector.group_by_keywords is None
def test_no_input_images(): detector = pattern_noise.PatternNoiseDetector(None) images = detector.do_stage([]) assert len(images) == 0
def test_pattern_noise_does_not_detect_white_noise(set_random_seed): data = generate_data() detector = pattern_noise.PatternNoiseDetector(None) assert detector.check_for_pattern_noise(data)[0] == False
def test_pattern_noise_detects_noise_when_it_should(set_random_seed): data = generate_data(has_pattern_noise=True) detector = pattern_noise.PatternNoiseDetector(None) assert detector.check_for_pattern_noise(data)[0]
def test_null_input_image(): detector = pattern_noise.PatternNoiseDetector(None) image = detector.run(None) assert image is None