Esempio n. 1
0
def test_fitswcs_non_celestial():
    # non-celestial WCS
    w = fitswcs.WCS(naxis=3)
    with pytest.raises(ValueError):
        tpwcs.FITSWCS(w)

    # invalid WCS
    with pytest.raises(ValueError):
        tpwcs.FITSWCS(None)
Esempio n. 2
0
def test_fitswcs_unaccounted_dist(mock_fits_wcs):
    w = copy.deepcopy(mock_fits_wcs)
    w.pix2foc = lambda x, o: x + 3
    with pytest.raises(ValueError):
        tpwcs.FITSWCS(w)

    w = copy.deepcopy(mock_fits_wcs)
    f = w.all_world2pix
    w.all_world2pix = lambda x, o: f(x, o) + 2
    with pytest.raises(ValueError):
        tpwcs.FITSWCS(w)
Esempio n. 3
0
def test_fitswcs_coord_transforms(mock_fits_wcs):
    w = fitswcs.WCS(naxis=2)
    w.wcs.cd = build_fit_matrix(0, 1e-5)
    w.wcs.crval = [12, 24]
    w.wcs.crpix = [500, 512]
    w.wcs.ctype = ['RA---TAN', 'DEC--TAN']
    w.pixel_shape = [1024, 2048]
    w.wcs.set()

    wc = tpwcs.FITSWCS(w)
    wc.set_correction()

    assert np.allclose(wc.det_to_world(499, 511), (12, 24), atol=_ATOL)
    assert np.allclose(wc.world_to_det(12, 24), (499, 511), atol=_ATOL)
    assert np.allclose(wc.det_to_tanp(499, 511), (0, 0), atol=_ATOL)
    assert np.allclose(wc.tanp_to_det(0, 0), (499, 511), atol=_ATOL)
    assert np.allclose(wc.world_to_tanp(12, 24), (0, 0), atol=1e-8)
    assert np.allclose(wc.tanp_to_world(0, 0), (12, 24), atol=_ATOL)
Esempio n. 4
0
def test_fitswcs_bbox(mock_fits_wcs):
    w = copy.deepcopy(mock_fits_wcs)
    wc = tpwcs.FITSWCS(w)
    wc.set_correction()

    assert np.allclose(wc.bounding_box,
                       ((-0.5, 1024 - 0.5), (-0.5, 2048 - 0.5)),
                       atol=_ATOL)

    wc._owcs.pixel_bounds = None
    assert np.allclose(wc.bounding_box,
                       ((-0.5, 1024 - 0.5), (-0.5, 2048 - 0.5)),
                       atol=_ATOL)

    wc._owcs.bounding_box = None
    assert np.allclose(wc.bounding_box,
                       ((-0.5, 1024 - 0.5), (-0.5, 2048 - 0.5)),
                       atol=_ATOL)

    wc._owcs.array_shape = None
    assert wc.bounding_box is None
Esempio n. 5
0
def test_fitswcs_1(mock_fits_wcs):
    wc = tpwcs.FITSWCS(mock_fits_wcs)
    wc.set_correction()