Exemplo n.º 1
0
def test_astro_image_rotation_full(data_base):
    fits_path = os.path.join(data_base, "test", "wcs_test.fits")

    # Test 90 degree rotation
    ai = AstroImage.initFromFits(fits_path, psf=False)
    default_wcs = ai._getWcs()  # WCS(ai.hdu)
    default_data = ai.hdu.data[:]

    ai.rotate(90)
    rotated_wcs = ai._getWcs()  # WCS(ai.hdu)
    rotated_data = ai.hdu.data[:]

    arr_size_x = ai.hdu.shape[0]
    arr_size_y = ai.hdu.shape[1]

    for x in range(arr_size_x):
        print("Starting Iteration {} of {}".format(x, arr_size_x))
        for y in range(arr_size_y):
            wcs_location = default_wcs.all_pix2world([[y, x]], 0)
            default_value = default_data[y][x]

            y, x = np.round(rotated_wcs.all_world2pix(wcs_location,
                                                      0)).astype(int)[0]
            assert (0 <= x < arr_size_x)
            assert (0 <= y < arr_size_y)
            rotated_value = rotated_data[y][x]

            if not np.isclose(default_value, rotated_value):
                print("Failed Values: ", default_value, rotated_value)
            assert np.isclose(default_value, rotated_value)
Exemplo n.º 2
0
def test_astro_image_rotation_sample(data_base):
    fits_path = os.path.join(data_base, "test", "wcs_test.fits")

    # Test 90 degree rotation
    ai = AstroImage.initFromFits(fits_path, psf=False)
    default_wcs = ai._getWcs()  # WCS(ai.hdu)
    default_data = ai.hdu.data[:]

    ai.rotate(90)
    rotated_wcs = ai._getWcs()  # WCS(ai.hdu)
    rotated_data = ai.hdu.data[:]

    arr_size_x = ai.hdu.shape[0]
    arr_size_y = ai.hdu.shape[1]

    random.seed()

    coords = []

    for x in range(1000):
        coords.append(
            (random.randrange(arr_size_x), random.randrange(arr_size_y)))

    for x, y in coords:
        wcs_location = default_wcs.all_pix2world([[y, x]], 0)
        default_value = default_data[y][x]

        y, x = np.round(rotated_wcs.all_world2pix(wcs_location,
                                                  0)).astype(int)[0]
        assert (0 <= x < arr_size_x)
        assert (0 <= y < arr_size_y)
        rotated_value = rotated_data[y][x]

        if not np.isclose(default_value, rotated_value):
            print("Failed Values: ", default_value, rotated_value)
        assert np.isclose(default_value, rotated_value)
Exemplo n.º 3
0
def new_empty_astro_image(data_base):
    fits_path = os.path.join(data_base, "astro_image", "zero_image.fits")
    print(fits_path)
    return AstroImage.initFromFits(fits_path, psf=False)