예제 #1
0
def test_sip_irac():
    """Test forward and inverse SIP againts astropy.wcs"""

    test_file = get_pkg_data_filename(os.path.join('data', 'irac_sip.hdr'))
    hdr = fits.Header.fromtextfile(test_file)
    crpix1 = hdr['CRPIX1']
    crpix2 = hdr['CRPIX2']
    wobj = wcs.WCS(hdr)
    a_pars = dict(**hdr['A_*'])
    b_pars = dict(**hdr['B_*'])
    ap_pars = dict(**hdr['AP_*'])
    bp_pars = dict(**hdr['BP_*'])
    a_order = a_pars.pop('A_ORDER')
    b_order = b_pars.pop('B_ORDER')
    ap_order = ap_pars.pop('AP_ORDER')
    bp_order = bp_pars.pop('BP_ORDER')
    del a_pars['A_DMAX']
    del b_pars['B_DMAX']
    pix = [200, 200]
    rel_pix = [200 - crpix1, 200 - crpix2]
    sip = SIP([crpix1, crpix2],
              a_order,
              b_order,
              a_pars,
              b_pars,
              ap_order=ap_order,
              ap_coeff=ap_pars,
              bp_order=bp_order,
              bp_coeff=bp_pars)

    foc = wobj.sip_pix2foc([pix], 1)
    newpix = wobj.sip_foc2pix(foc, 1)[0]
    assert_allclose(sip(*pix), foc[0] - rel_pix)
    assert_allclose(sip.inverse(*foc[0]) + foc[0] - rel_pix, newpix - pix)
예제 #2
0
def test_sip_irac():
    """Test forward and inverse SIP against astropy.wcs"""

    test_file = get_pkg_data_filename(os.path.join('data', 'irac_sip.hdr'))
    hdr = fits.Header.fromtextfile(test_file)
    crpix1 = hdr['CRPIX1']
    crpix2 = hdr['CRPIX2']
    wobj = wcs.WCS(hdr)
    a_pars = dict(**hdr['A_*'])
    b_pars = dict(**hdr['B_*'])
    ap_pars = dict(**hdr['AP_*'])
    bp_pars = dict(**hdr['BP_*'])
    a_order = a_pars.pop('A_ORDER')
    b_order = b_pars.pop('B_ORDER')
    ap_order = ap_pars.pop('AP_ORDER')
    bp_order = bp_pars.pop('BP_ORDER')
    del a_pars['A_DMAX']
    del b_pars['B_DMAX']
    pix = [200, 200]
    rel_pix = [200 - crpix1, 200 - crpix2]
    sip = SIP([crpix1, crpix2], a_order, b_order, a_pars, b_pars,
              ap_order=ap_order, ap_coeff=ap_pars, bp_order=bp_order,
              bp_coeff=bp_pars)

    foc = wobj.sip_pix2foc([pix], 1)
    newpix = wobj.sip_foc2pix(foc, 1)[0]
    assert_allclose(sip(*pix), foc[0] - rel_pix)
    assert_allclose(sip.inverse(*foc[0]) +
                    foc[0] - rel_pix, newpix - pix)

    # Test inverse representations
    assert repr(sip.inverse) ==\
        "<InverseSIP([<Polynomial2D(2, c0_0=0., c1_0=0.0000114, c2_0=0.00002353, " +\
        "c0_1=-0.00000546, c0_2=-0.00000667, c1_1=-0.00001801)>, " +\
        "<Polynomial2D(2, c0_0=0., c1_0=-0.00001495, c2_0=0.00000122, c0_1=0.00001975, " +\
        "c0_2=-0.00002601, c1_1=0.00002944)>])>"
    assert str(sip.inverse) ==\
        "Model: InverseSIP\n" +\
        "    Model: Polynomial2D\n" +\
        "    Inputs: ('x', 'y')\n" +\
        "    Outputs: ('z',)\n" +\
        "    Model set size: 1\n" +\
        "    Degree: 2\n" +\
        "    Parameters:\n" +\
        "        c0_0   c1_0      c2_0      c0_1       c0_2       c1_1   \n" +\
        "        ---- -------- --------- ---------- ---------- ----------\n" +\
        "         0.0 1.14e-05 2.353e-05 -5.463e-06 -6.666e-06 -1.801e-05\n" +\
        "\n" +\
        "    Model: Polynomial2D\n" +\
        "    Inputs: ('x', 'y')\n" +\
        "    Outputs: ('z',)\n" +\
        "    Model set size: 1\n" +\
        "    Degree: 2\n" +\
        "    Parameters:\n" +\
        "        c0_0    c1_0       c2_0      c0_1      c0_2       c1_1  \n" +\
        "        ---- ---------- --------- --------- ---------- ---------\n" +\
        "         0.0 -1.495e-05 1.225e-06 1.975e-05 -2.601e-05 2.944e-05\n"