Ejemplo n.º 1
0
def test_header_master_bias_level_returns_2(mock_image):
    maker = BiasMaker(FakeContext())

    maker.do_stage([FakeBiasImage(image_multiplier=2.0) for x in range(6)])

    args, kwargs = mock_image.call_args
    header = kwargs['header']
    assert header['BIASLVL'] == 2.0
Ejemplo n.º 2
0
def test_header_cal_type_bias(mock_image):

    maker = BiasMaker(FakeContext())

    maker.do_stage([FakeBiasImage() for x in range(6)])

    args, kwargs = mock_image.call_args
    header = kwargs['header']
    assert header['OBSTYPE'].upper() == 'BIAS'
Ejemplo n.º 3
0
def test_header_cal_type_bias(mock_frame, mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'

    nx = 101
    ny = 103
    context = make_context_with_master_bias(bias_level=0.0,
                                            readnoise=10.0,
                                            nx=nx,
                                            ny=ny)
    maker = BiasMaker(context)

    images = maker.do_stage([FakeBiasImage(nx=nx, ny=ny) for x in range(6)])
    assert images[0].header['OBSTYPE'].upper() == 'BIAS'
Ejemplo n.º 4
0
def test_makes_a_sensible_master_bias(mock_frame, mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 20
    expected_readnoise = 15.0

    images = [FakeBiasImage() for x in range(nimages)]
    for image in images:
        image.data = np.random.normal(loc=0.0,
                                      scale=expected_readnoise,
                                      size=(image.ny, image.nx))

    maker = BiasMaker(FakeContext(frame_class=FakeBiasImage))
    stacked_images = maker.do_stage(images)
    master_bias = stacked_images[0].data
    assert np.abs(np.mean(master_bias)) < 0.1
    actual_readnoise = np.std(master_bias)
    assert np.abs(actual_readnoise - expected_readnoise / (nimages**0.5)) < 0.2
Ejemplo n.º 5
0
def test_bias_level_is_average_of_inputs(mock_instrument_info, mock_namer):
    mock_namer.return_value = lambda *x: 'foo.fits'
    nimages = 20
    bias_levels = np.arange(nimages, dtype=float)

    images = [FakeBiasImage(bias_level=i) for i in bias_levels]

    mock_instrument_info.return_value = None, None, None
    fake_context = FakeContext()
    fake_context.db_address = ''

    maker = BiasMaker(fake_context)
    master_bias = maker.do_stage(images)[0]

    header = master_bias.header

    assert header['BIASLVL'] == np.mean(bias_levels)
Ejemplo n.º 6
0
def test_makes_a_sensible_master_bias(mock_images):
    nimages = 20
    expected_bias = 1183.0
    expected_readnoise = 15.0

    images = [FakeBiasImage() for x in range(nimages)]
    for image in images:
        image.data = np.random.normal(loc=expected_bias, scale=expected_readnoise,
                                      size=(image.ny, image.nx))

    maker = BiasMaker(FakeContext())
    maker.do_stage(images)

    args, kwargs = mock_images.call_args
    master_bias = kwargs['data']
    assert np.abs(np.mean(master_bias)) < 0.1
    actual_bias = float(kwargs['header']['BIASLVL'])
    assert np.abs(actual_bias - expected_bias) < 0.1
    actual_readnoise = np.std(master_bias)
    assert np.abs(actual_readnoise - expected_readnoise / (nimages ** 0.5)) < 0.2
Ejemplo n.º 7
0
def test_min_images():
    bias_maker = BiasMaker(FakeContext())
    processed_images = bias_maker.do_stage([])
    assert len(processed_images) == 0
Ejemplo n.º 8
0
def test_group_by_attributes():
    maker = BiasMaker(FakeContext())
    assert maker.group_by_attributes() == ['configuration_mode', 'ccdsum']
Ejemplo n.º 9
0
def test_group_by_keywords():
    maker = BiasMaker(None)
    assert maker.group_by_keywords == ['ccdsum']
Ejemplo n.º 10
0
def test_min_images():
    bias_maker = BiasMaker(None)
    processed_images = bias_maker.do_stage([])
    assert len(processed_images) == 0