예제 #1
0
def test_gain_header_0():
    gain_normalizer = GainNormalizer(None)
    fake_images = [FakeGainImage() for x in range(6)]
    for image in fake_images:
        image.gain = 0.0
    images = gain_normalizer.do_stage(fake_images)
    assert len(images) == 0
예제 #2
0
def test_gain_is_empty_list():
    gain_normalizer = GainNormalizer(None)
    fake_images = [FakeGainImage() for x in range(6)]
    for image in fake_images:
        image.gain = []
    images = gain_normalizer.do_stage(fake_images)
    assert len(images) == 0
예제 #3
0
def test_gain_is_empty_list():
    gain_normalizer = GainNormalizer(None)
    fake_images = [FakeGainImage() for x in range(6)]
    for image in fake_images:
        image.gain = []
    images = gain_normalizer.do_stage(fake_images)
    assert len(images) == 0
예제 #4
0
def test_gain_header_0():
    gain_normalizer = GainNormalizer(None)
    fake_images = [FakeGainImage() for x in range(6)]
    for image in fake_images:
        image.gain = 0.0
    images = gain_normalizer.do_stage(fake_images)
    assert len(images) == 0
예제 #5
0
def test_gain_datacube(set_random_seed):
    n_amplifiers = 4
    nx, ny = 101, 103
    saturation = 65536
    max_linearity = 60000
    # These tests will fail if the gain is a numpy array because it will try to check element by
    # element which raises and exception here.
    input_gains = list(np.random.uniform(0.5, 2.5, size=n_amplifiers))
    input_data = np.random.normal(10, 1, size=(n_amplifiers, ny, nx))

    image = FakeGainImage(nx=nx, ny=ny)

    image.gain = input_gains
    image.data = input_data.copy()
    image.header['SATURATE'] = saturation
    image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(image)

    for i in range(n_amplifiers):
        np.testing.assert_allclose(image.data[i],
                                   input_data[i] * input_gains[i])
    np.testing.assert_allclose(image.header['SATURATE'],
                               saturation * min(input_gains))
    np.testing.assert_allclose(image.header['MAXLIN'],
                               max_linearity * min(input_gains))
예제 #6
0
def test_gain_datacube():
    n_amplifiers = 4
    nx, ny = 101, 103
    n_images = 6
    saturation = 65536
    max_linearity = 60000
    # These tests will fail if the gain is a numpy array because it will try to check element by
    # element which raises and exception here.
    input_gains = [list(np.random.uniform(0.5, 2.5, size=n_amplifiers)) for i in range(n_images)]
    input_data = [np.random.normal(10, 1, size=(n_amplifiers, ny, nx)) for i in range(n_images)]

    fake_images = [FakeGainImage(nx=nx, ny=ny) for i in range(n_images)]

    for i, image in enumerate(fake_images):
        image.gain = input_gains[i]
        image.data = input_data[i].copy()
        image.header['SATURATE'] = saturation
        image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    output_images = gain_normalizer.do_stage(fake_images)

    for i, image in enumerate(output_images):
        for j in range(n_amplifiers):
            np.testing.assert_allclose(image.data[j], input_data[i][j] * input_gains[i][j])
        np.testing.assert_allclose(image.header['SATURATE'], saturation * min(input_gains[i]))
        np.testing.assert_allclose(image.header['MAXLIN'], max_linearity * min(input_gains[i]))
예제 #7
0
def test_gain_1d():
    nx, ny = 101, 103
    n_images = 6
    saturation = 65536
    max_linearity = 60000
    input_gains = np.random.uniform(0.5, 2.5, size=n_images)
    input_data = [
        np.random.normal(10, 1, size=(ny, nx)) for i in range(n_images)
    ]

    fake_images = [FakeGainImage(nx=nx, ny=ny) for x in range(n_images)]

    for i, image in enumerate(fake_images):
        image.gain = input_gains[i]
        image.data = input_data[i].copy()
        image.header['SATURATE'] = saturation
        image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    output_images = gain_normalizer.do_stage(fake_images)

    for i, image in enumerate(output_images):
        np.testing.assert_allclose(image.data, input_data[i] * input_gains[i])
        np.testing.assert_allclose(image.header['SATURATE'],
                                   saturation * input_gains[i])
        np.testing.assert_allclose(image.header['MAXLIN'],
                                   max_linearity * input_gains[i])
예제 #8
0
def test_gain_1d(set_random_seed):
    nx, ny = 101, 103
    saturation = 65536
    max_linearity = 60000
    input_gains = np.random.uniform(0.5, 2.5)
    input_data = np.random.normal(10, 1, size=(ny, nx))

    image = FakeGainImage(nx=nx, ny=ny)

    image.gain = input_gains
    image.data = input_data.copy()
    image.header['SATURATE'] = saturation
    image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(image)

    np.testing.assert_allclose(image.data, input_data * input_gains)
    np.testing.assert_allclose(image.header['SATURATE'], saturation * input_gains)
    np.testing.assert_allclose(image.header['MAXLIN'], max_linearity * input_gains)
예제 #9
0
def test_gain_1d(set_random_seed):
    nx, ny = 101, 103
    saturation = 65536
    max_linearity = 60000
    input_gains = np.random.uniform(0.5, 2.5)
    input_data = np.random.normal(10, 1, size=(ny, nx))

    image = FakeGainImage(nx=nx, ny=ny)

    image.gain = input_gains
    image.data = input_data.copy()
    image.header['SATURATE'] = saturation
    image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(image)

    np.testing.assert_allclose(image.data, input_data * input_gains)
    np.testing.assert_allclose(image.header['SATURATE'],
                               saturation * input_gains)
    np.testing.assert_allclose(image.header['MAXLIN'],
                               max_linearity * input_gains)
예제 #10
0
def test_gain_1d():
    nx, ny = 101, 103
    n_images = 6
    saturation = 65536
    max_linearity = 60000
    input_gains = np.random.uniform(0.5, 2.5, size=n_images)
    input_data = [np.random.normal(10, 1, size=(ny, nx)) for i in range(n_images)]

    fake_images = [FakeGainImage(nx=nx, ny=ny) for x in range(n_images)]

    for i, image in enumerate(fake_images):
        image.gain = input_gains[i]
        image.data = input_data[i].copy()
        image.header['SATURATE'] = saturation
        image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    output_images = gain_normalizer.do_stage(fake_images)

    for i, image in enumerate(output_images):
        np.testing.assert_allclose(image.data, input_data[i] * input_gains[i])
        np.testing.assert_allclose(image.header['SATURATE'], saturation * input_gains[i])
        np.testing.assert_allclose(image.header['MAXLIN'], max_linearity * input_gains[i])
예제 #11
0
def test_gain_datacube():
    n_amplifiers = 4
    nx, ny = 101, 103
    n_images = 6
    saturation = 65536
    max_linearity = 60000
    # These tests will fail if the gain is a numpy array because it will try to check element by
    # element which raises and exception here.
    input_gains = [
        list(np.random.uniform(0.5, 2.5, size=n_amplifiers))
        for i in range(n_images)
    ]
    input_data = [
        np.random.normal(10, 1, size=(n_amplifiers, ny, nx))
        for i in range(n_images)
    ]

    fake_images = [FakeGainImage(nx=nx, ny=ny) for i in range(n_images)]

    for i, image in enumerate(fake_images):
        image.gain = input_gains[i]
        image.data = input_data[i].copy()
        image.header['SATURATE'] = saturation
        image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    output_images = gain_normalizer.do_stage(fake_images)

    for i, image in enumerate(output_images):
        for j in range(n_amplifiers):
            np.testing.assert_allclose(image.data[j],
                                       input_data[i][j] * input_gains[i][j])
        np.testing.assert_allclose(image.header['SATURATE'],
                                   saturation * min(input_gains[i]))
        np.testing.assert_allclose(image.header['MAXLIN'],
                                   max_linearity * min(input_gains[i]))
예제 #12
0
def test_gain_datacube(set_random_seed):
    n_amplifiers = 4
    nx, ny = 101, 103
    saturation = 65536
    max_linearity = 60000
    # These tests will fail if the gain is a numpy array because it will try to check element by
    # element which raises and exception here.
    input_gains = list(np.random.uniform(0.5, 2.5, size=n_amplifiers))
    input_data = np.random.normal(10, 1, size=(n_amplifiers, ny, nx))

    image = FakeGainImage(nx=nx, ny=ny)

    image.gain = input_gains
    image.data = input_data.copy()
    image.header['SATURATE'] = saturation
    image.header['MAXLIN'] = max_linearity

    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(image)

    for i in range(n_amplifiers):
        np.testing.assert_allclose(image.data[i], input_data[i] * input_gains[i])
    np.testing.assert_allclose(image.header['SATURATE'], saturation * min(input_gains))
    np.testing.assert_allclose(image.header['MAXLIN'], max_linearity * min(input_gains))
예제 #13
0
def test_gain_header_0():
    gain_normalizer = GainNormalizer(None)
    image = FakeGainImage()
    image.gain = 0.0
    image = gain_normalizer.do_stage(image)
    assert image is None
예제 #14
0
def test_null_input_image():
    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.run(None)
    assert image is None
예제 #15
0
def test_gain_header_0():
    gain_normalizer = GainNormalizer(None)
    image = FakeGainImage()
    image.gain = 0.0
    image = gain_normalizer.do_stage(image)
    assert image is None
예제 #16
0
def test_gain_is_empty_list():
    gain_normalizer = GainNormalizer(None)
    image = FakeGainImage()
    image.gain = []
    image = gain_normalizer.do_stage(image)
    assert image is None
예제 #17
0
def test_null_input_image():
    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.run(None)
    assert image is None
예제 #18
0
def test_gain_header_missing():
    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(FakeGainImage())
    assert image is None
예제 #19
0
def test_no_input_images():
    gain_normalizer = GainNormalizer(None)
    images = gain_normalizer.do_stage([])
    assert len(images) == 0
예제 #20
0
def test_gain_is_empty_list():
    gain_normalizer = GainNormalizer(None)
    image = FakeGainImage()
    image.gain = []
    image = gain_normalizer.do_stage(image)
    assert image is None
예제 #21
0
def test_group_by_keywords():
    gain_normalizer = GainNormalizer(None)
    assert gain_normalizer.group_by_keywords is None
예제 #22
0
def test_gain_header_missing():
    gain_normalizer = GainNormalizer(None)
    images = gain_normalizer.do_stage([FakeGainImage() for x in range(6)])
    assert len(images) == 0
예제 #23
0
def test_gain_header_missing():
    gain_normalizer = GainNormalizer(None)
    images = gain_normalizer.do_stage([FakeGainImage() for x in range(6)])
    assert len(images) == 0
예제 #24
0
def test_no_input_images():
    gain_normalizer = GainNormalizer(None)
    images = gain_normalizer.do_stage([])
    assert len(images) == 0
예제 #25
0
def test_gain_header_missing():
    gain_normalizer = GainNormalizer(None)
    image = gain_normalizer.do_stage(FakeGainImage())
    assert image is None