Exemplo n.º 1
0
def get_arc_conv(w: wcs.WCS):
    """ Gets pixels to arc-seconds conversion scale (Number of arcseconds per pixel) """
    pix_x, pix_y = 1, 1
    ra_1, dec_1 = w.wcs_pix2world(pix_x, pix_y, 0)
    ra_2, dec_2 = w.wcs_pix2world(pix_x + 1, pix_y + 1, 0)
    diff_1 = abs(ra_1 - ra_2) * 3600
    diff_2 = abs(dec_1 - dec_2) * 3600
    return (diff_1 + diff_2) / 2
Exemplo n.º 2
0
def wcsTest():
    wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
    header = readHeader(wcsPath)
    
    # the pixel coordinates of which we want the world coordinates
    x, y = np.meshgrid(np.arange(0,4000), np.arange(0,2000))
    x = x.ravel()
    y = y.ravel()
    
    # first, calculate using astropy as reference
    wcs = WCS(header)
    t0 = time.time()
    ra_astropy, dec_astropy = wcs.wcs_pix2world(x, y, 0)
    print('astropy wcs:', time.time()-t0, 's')
    
    # now, check against our own implementation
    #tan_pix2world(header, x, y, 0) # warmup
    t0 = time.time()
    ra, dec = tan_pix2world(header, x, y, 0)
    print('own wcs:', time.time()-t0, 's')
    
    assert_almost_equal([ra, dec], [ra_astropy, dec_astropy])