예제 #1
0
def plot_image_pixels_in_HPX():
    header = {'NAXIS': 2,
              'CTYPE1': 'RA---HPX',
              'CTYPE2': 'DEC--HPX',
             }
    hpx = WCS(header)

    hdulist = get_stripe82_file(301, 2700, 1, 'g', 18)
    img = WCS(hdulist[0].header)

    origin=0
    xpix, ypix = np.meshgrid(*[np.arange(0, hdulist[0].header[key], 30)
                               for key in ['NAXIS1', 'NAXIS2']])
    Xpix = np.vstack(map(np.ravel, (xpix, ypix))).T

    Xworld = img.wcs_pix2world(Xpix, origin)
    Xhpx = hpx.wcs_world2pix(Xworld, origin)

    x, y = Xhpx.T

    plt.plot(x, y, '.k')
    plt.gca().set_aspect('equal')
    plt.xlim(0, 360)
    plt.ylim(-90, 90)
    plt.show()
예제 #2
0
def plot_image_pixels_in_HPX():
    header = {
        'NAXIS': 2,
        'CTYPE1': 'RA---HPX',
        'CTYPE2': 'DEC--HPX',
    }
    hpx = WCS(header)

    hdulist = get_stripe82_file(301, 2700, 1, 'g', 18)
    img = WCS(hdulist[0].header)

    origin = 0
    xpix, ypix = np.meshgrid(*[
        np.arange(0, hdulist[0].header[key], 30)
        for key in ['NAXIS1', 'NAXIS2']
    ])
    Xpix = np.vstack(map(np.ravel, (xpix, ypix))).T

    Xworld = img.wcs_pix2world(Xpix, origin)
    Xhpx = hpx.wcs_world2pix(Xworld, origin)

    x, y = Xhpx.T

    plt.plot(x, y, '.k')
    plt.gca().set_aspect('equal')
    plt.xlim(0, 360)
    plt.ylim(-90, 90)
    plt.show()
예제 #3
0
def construct_wcs_from_file():
    print "Constructing WCS from a FITS file:"
    # Construct a wcs instance from file
    hdulist = get_stripe82_file(301, 2700, 1, 'g', 18)
    wcs = WCS(hdulist[0].header)
    
    # Test a round-trip from pix to world and back
    origin = 0
    pix_coords = np.arange(1, 11).reshape((5, 2))
    world_coords = wcs.wcs_pix2world(pix_coords, origin)
    pix_coords2 = wcs.wcs_world2pix(world_coords, origin)
    print "  - Round trip matches:", np.allclose(pix_coords, pix_coords2)

    return wcs
예제 #4
0
def construct_wcs_from_file():
    print "Constructing WCS from a FITS file:"
    # Construct a wcs instance from file
    hdulist = get_stripe82_file(301, 2700, 1, 'g', 18)
    wcs = WCS(hdulist[0].header)

    # Test a round-trip from pix to world and back
    origin = 0
    pix_coords = np.arange(1, 11).reshape((5, 2))
    world_coords = wcs.wcs_pix2world(pix_coords, origin)
    pix_coords2 = wcs.wcs_world2pix(world_coords, origin)
    print "  - Round trip matches:", np.allclose(pix_coords, pix_coords2)

    return wcs