def miri_image():

    image = IFUImageModel((20, 20))
    image.data = np.random.random((20, 20))
    image.meta.instrument.name = 'MIRI'
    image.meta.instrument.detector = 'MIRIFULONG'
    image.meta.exposure.type = 'MIR_MRS'
    image.meta.instrument.channel = '12'
    image.meta.instrument.band = 'SHORT'
    image.meta.filename = 'test_miri.fits'
    return image
Beispiel #2
0
def miri_mrs_long():
    """ Set up MIRI MRS Long data """

    image = IFUImageModel((30, 30))
    image.data = np.random.random((30, 30))
    image.meta.instrument.name = 'MIRI'
    image.meta.instrument.detector = 'MIRIFULONG'
    image.meta.exposure.type = 'MIR_MRS'
    image.meta.instrument.channel = '34'
    image.meta.instrument.band = 'LONG'
    image.meta.filename = 'test_miri_long.fits'
    return image
Beispiel #3
0
def miri_mrs():
    """ Set up MIRI MRS Short data """

    image = IFUImageModel((20, 20))
    image.data = np.random.random((20, 20))
    image.meta.instrument.name = 'MIRI'
    image.meta.instrument.detector = 'MIRIFUSHORT'
    image.meta.exposure.type = 'MIR_MRS'
    image.meta.instrument.channel = '12'
    image.meta.instrument.band = 'SHORT'
    image.meta.filename = 'test_miri.fits'
    return image
Beispiel #4
0
def test_ifuimage():
    data = np.arange(24, dtype=np.float32).reshape((6, 4))
    im = ImageModel(data=data, err=data / 2, dq=data)
    ifuimage = IFUImageModel(im)
    assert_allclose(im.data, ifuimage.data)
    assert_allclose(im.err, ifuimage.err)
    assert_allclose(im.dq, ifuimage.dq)

    im = ImageModel(ifuimage)
    assert type(im) == ImageModel
Beispiel #5
0
def test_ifuimage():
    data = np.arange(24).reshape((6, 4))
    im = ImageModel(data=data, err=data / 2, dq=data)
    ifuimage = IFUImageModel(im)
    assert_array_equal(im.data, ifuimage.data)
    assert_array_equal(im.err, ifuimage.err)
    assert_array_equal(im.dq, ifuimage.dq)

    im = ImageModel(ifuimage)
    assert type(im) == ImageModel
Beispiel #6
0
    def _setup(shape=(2, 2)):

        input_data = (np.ones(shape[0] * shape[1])).reshape(shape) * 6.
        input_err = rn.random_sample(shape)
        input_model = IFUImageModel(data=input_data, err=input_err)

        fringe_data = (np.ones(shape[0] * shape[1])).reshape(shape) / FRINGE_CONSTANT
        fringe_model = FringeModel(data=fringe_data)

        return input_model, fringe_model
Beispiel #7
0
def test_correct_mrs_modshepard():
    """ Test Correct Straylight routine gives expected results for small region """

    image = IFUImageModel((16,16))
    image.data = np.ones((16,16)) + 30.0

    slice_map = np.ones((16,16))
    # create 2 slice gaps

    image.data[8,8] = 45.6 # set to pass second cr check easily
    slice_map[:,4:7] = 0
    slice_map[:,10:13] = 0
    image.data[:,4:7] = 0.5
    image.data[:,10:13] = 0.5
    roi = 8
    power = 1

    result = correct_mrs_modshepard(image, slice_map, roi, power)
    compare = np.zeros((16,16))
    compare[0,:] = [3.0696348e+01, 3.0638458e+01, 3.0652958e+01, 3.0663357e+01, 2.7708188e-01,
                    1.6659760e-01, 2.7704430e-01, 3.0657593e+01, 3.0652958e+01, 3.0657593e+01,
                    2.7704430e-01, 1.6659760e-01, 2.7708188e-01, 3.0663357e+01, 3.0652958e+01,
                    3.0638458e+01]
    compare[1,:] = [3.0688972e+01, 3.0629198e+01, 3.0642084e+01, 3.0645052e+01, 1.6645306e-01,
                    1.1563802e-03, 1.6646616e-01, 3.0641420e+01, 3.0642084e+01, 3.0641420e+01,
                    1.6646616e-01, 1.1563802e-03, 1.6645306e-01, 3.0645052e+01, 3.0642084e+01,
                    3.0629198e+01]
    compare[2,:] = [3.0682684e+01, 3.0620981e+01, 3.0632751e+01, 3.0632690e+01, 1.6629149e-01,
                    1.1218189e-03, 1.6630261e-01, 3.0629959e+01, 3.0632751e+01, 3.0629959e+01,
                    1.6630261e-01, 1.1218189e-03, 1.6629149e-01, 3.0632690e+01, 3.0632751e+01,
                    3.0620981e+01]
    compare[3,:] = [3.0677645e+01, 3.0614532e+01, 3.0626221e+01, 3.0626003e+01, 1.6621163e-01,
                    1.1279561e-03, 1.6622025e-01, 3.0623276e+01, 3.0626221e+01, 3.0623276e+01,
                    1.6622025e-01, 1.1279561e-03, 1.6621163e-01, 3.0626003e+01, 3.0626221e+01,
                    3.0614532e+01]
    compare[4,:] = [3.0673761e+01, 3.0609789e+01, 3.0621811e+01, 3.0622076e+01, 1.6616508e-01,
                    1.1363822e-03, 1.6617118e-01, 3.0619116e+01, 3.0621811e+01, 3.0619116e+01,
                    1.6617118e-01, 1.1363822e-03, 1.6616508e-01, 3.0622076e+01, 3.0621811e+01,
                    3.0609789e+01]
    compare[5,:] = [3.0666666e+01, 3.0601625e+01, 3.0614611e+01, 3.0616297e+01, 1.6612101e-01,
                    1.0898784e-03, 1.6612145e-01, 3.0612762e+01, 3.0614611e+01, 3.0612762e+01,
                    1.6612145e-01, 1.0898784e-03, 1.6612101e-01, 3.0616297e+01, 3.0614611e+01,
                    3.0601625e+01]

    compare[6:8,:]= compare[5,:]
    compare[8,:] = [3.0666666e+01, 3.0601625e+01, 3.0614611e+01, 3.0616297e+01, 1.6612101e-01,
                    1.0898784e-03, 1.6612145e-01, 3.0612762e+01, 4.5214607e+01, 3.0612762e+01,
                    1.6612145e-01, 1.0898784e-03, 1.6612101e-01, 3.0616297e+01, 3.0614611e+01,
                    3.0601625e+01]

    compare[9:11,:]= compare[5,:]

    compare[11,:] = [3.0673761e+01, 3.0609789e+01, 3.0621811e+01, 3.0622076e+01, 1.6616508e-01,
                     1.1363822e-03, 1.6617118e-01, 3.0619116e+01, 3.0621811e+01, 3.0619116e+01,
                     1.6617118e-01, 1.1363822e-03, 1.6616508e-01, 3.0622076e+01, 3.0621811e+01,
                     3.0609789e+01]
    compare[12,:] = [3.0677645e+01, 3.0614532e+01, 3.0626221e+01, 3.0626003e+01, 1.6621163e-01,
                     1.1279561e-03, 1.6622025e-01, 3.0623276e+01, 3.0626221e+01, 3.0623276e+01,
                     1.6622025e-01, 1.1279561e-03, 1.6621163e-01, 3.0626003e+01, 3.0626221e+01,
                     3.0614532e+01]
    compare[13,:] =  [3.0682684e+01, 3.0620981e+01, 3.0632751e+01, 3.0632690e+01, 1.6629149e-01,
                      1.1218189e-03, 1.6630261e-01, 3.0629959e+01, 3.0632751e+01, 3.0629959e+01,
                      1.6630261e-01, 1.1218189e-03, 1.6629149e-01, 3.0632690e+01, 3.0632751e+01,
                      3.0620981e+01]
    compare[14,:] = [3.0688972e+01, 3.0629198e+01, 3.0642084e+01, 3.0645052e+01, 1.6645306e-01,
                     1.1563802e-03, 1.6646616e-01, 3.0641420e+01, 3.0642084e+01, 3.0641420e+01,
                     1.6646616e-01, 1.1563802e-03, 1.6645306e-01, 3.0645052e+01, 3.0642084e+01,
                     3.0629198e+01]
    compare[15,:] = [3.0696348e+01, 3.0638458e+01, 3.0652958e+01, 3.0663357e+01, 2.7708188e-01,
                     1.6659760e-01, 2.7704430e-01, 3.0657593e+01, 3.0652958e+01, 3.0657593e+01,
                     2.7704430e-01, 1.6659760e-01, 2.7708188e-01, 3.0663357e+01, 3.0652958e+01,
                     3.0638458e+01]

    assert(np.allclose(compare, result.data, rtol=1e-6))