Beispiel #1
0
def create_datamodel(hdul):
    im = ImageModel(hdul)
    ref = create_reference_files(im)
    pipeline = miri.create_pipeline(im, ref)
    wcsobj = wcs.WCS(pipeline)
    im.meta.wcs = wcsobj
    return im
Beispiel #2
0
def test_miri_mrs_1A():
    #ref = {}
    ref = {
        'distortion': '',
        'regions': '',
        'specwcs': '',
        'v2v3': '',
        'wavelengthrange': ''
    }
    im = ImageModel()
    im.meta.instrument.name = 'MIRI'
    im.meta.instrument.detector = 'MIRIFUSHORT'
    im.meta.instrument.channel = '12'
    im.meta.instrument.band = 'SHORT'
    im.meta.exposure.type = 'MIR_MRS'
    step = AssignWcsStep()
    for reftype in refs:
        ref[reftype] = step.get_reference_file(im, reftype)

    pipeline = miri.create_pipeline(im, ref)
    wcsobj = wcs.WCS(pipeline)

    for ch in im.meta.instrument.channel:
        ref_data = mrs_ref_data[ch + band_mapping[im.meta.instrument.band]]
        #ref_data = mrs_ref_data[im.meta.instrument.channel + band_mapping[im.meta.instrument.band]]
        #x = np.trunc(ref_data['x']).astype(np.int)
        #y = np.trunc(ref_data['y']).astype(np.int)
        for i, s in enumerate(ref_data['s']):
            sl = int(ch) * 100 + s
            detector_to_alpha_beta = wcsobj.get_transform(
                'detector', 'alpha_beta')
            alpha, beta, lam = detector_to_alpha_beta.set_input(sl)(
                ref_data['x'][i], ref_data['y'][i])
            ##xan, yan, lam = wcsobj.forward_transform.set_input(sl)(ref_data['x'][i], ref_data['y'][i])
            utils.assert_allclose(alpha, ref_data['alpha'][i], atol=10**-5)
            utils.assert_allclose(beta, ref_data['beta'][i], atol=10**-5)
            utils.assert_allclose(lam, ref_data['lam'][i], atol=10**-5)
            detector_to_xan_yan = wcsobj.get_transform('detector', 'Xan_Yan')
            xan, yan, lam = wcsobj(ref_data['x'], ref_data['y'])
            utils.assert_allclose(xan, ref_data['v2'][i], atol=10**-5)
            utils.assert_allclose(yan, ref_data['v3'][i], atol=10**-5)
            utils.assert_allclose(lam, ref_data['lam'][i], atol=10**-5)
Beispiel #3
0
def test_miri_mrs_1C():
    ref = {}

    im = ImageModel()
    im.meta.instrument.name = 'MIRI'
    im.meta.instrument.detector = 'MIRIFUSHORT'
    im.meta.instrument.channel = '12'
    im.meta.instrument.band = 'LONG'
    im.meta.exposure.type = 'MIR_MRS'
    step = AssignWcsStep()
    for reftype in refs:
        ref[reftype] = step.get_reference_file(im, reftype)

    pipeline = miri.create_pipeline(im, ref)
    wcsobj = wcs.WCS(pipeline)

    for ch in im.meta.instrument.channel:
        ref_data = mrs_ref_data[ch + band_mapping[im.meta.instrument.band]]
    for i, s in enumerate(ref_data['s']):
        sl = int(ch) * 100 + s
        xan, yan, lam = wcsobj.forward_transform.set_input(sl)(
            ref_data['x'][i], ref_data['y'][i])
        utils.assert_allclose(xan, ref_data['v2'][i], atol=10**-5)
        utils.assert_allclose(yan, ref_data['v3'][i], atol=10**-5)
        utils.assert_allclose(lam, ref_data['lam'][i], atol=10**-5)
    for i, s in enumerate(ref_data['s']):
        sl = int(ch) * 100 + s
        xan, yan, lam = wcsobj.forward_transform(ref_data['x'][i],
                                                 ref_data['y'][i])
        utils.assert_allclose(xan, ref_data['v2'][i], atol=10**-5)
        utils.assert_allclose(yan, ref_data['v3'][i], atol=10**-5)
        utils.assert_allclose(lam, ref_data['lam'][i], atol=10**-5)
        xin, yin = wcsobj.backward_transform(ref_data['v2'][i],
                                             ref_data['v3'][i],
                                             ref_data['lam'][i])
        utils.assert_allclose(xin, ref_data['x'][i], atol=10**-5)
        utils.assert_allclose(y, ref_data['y'][i], atol=10**-5)