コード例 #1
0
ファイル: test_utilities.py プロジェクト: ojhall94/photometry
def test_find_ffi_files():

    files = find_ffi_files(INPUT_DIR)
    assert (len(files) == 8)

    files = find_ffi_files(INPUT_DIR, camera=1)
    assert (len(files) == 4)

    files = find_ffi_files(INPUT_DIR, camera=2)
    assert (len(files) == 4)
コード例 #2
0
ファイル: test_utilities.py プロジェクト: ckm3/photometry
def test_find_ffi_files(SHARED_INPUT_DIR):

    files = u.find_ffi_files(SHARED_INPUT_DIR)
    assert (len(files) == 8)

    files = u.find_ffi_files(SHARED_INPUT_DIR, camera=1)
    assert (len(files) == 4)

    files = u.find_ffi_files(SHARED_INPUT_DIR, camera=3)
    assert (len(files) == 4)
コード例 #3
0
ファイル: test_utilities.py プロジェクト: ojhall94/photometry
def test_load_ffi_files():

    files = find_ffi_files(INPUT_DIR, camera=1)

    img = load_ffi_fits(files[0])
    assert (img.shape == (2048, 2048))

    img, hdr = load_ffi_fits(files[0], return_header=True)
    assert (img.shape == (2048, 2048))
コード例 #4
0
ファイル: test_utilities.py プロジェクト: ckm3/photometry
def test_load_ffi_files(SHARED_INPUT_DIR):

    files = u.find_ffi_files(SHARED_INPUT_DIR, camera=1)

    img = u.load_ffi_fits(files[0])
    assert (img.shape == (2048, 2048))

    img, hdr = u.load_ffi_fits(files[0], return_header=True)
    assert (img.shape == (2048, 2048))
コード例 #5
0
ファイル: test_background.py プロジェクト: ckm3/photometry
def test_background(SHARED_INPUT_DIR):
    """Test of background estimator"""

    # Load the first image in the input directory:
    fname = find_ffi_files(SHARED_INPUT_DIR)[0]
    img, hdr = load_ffi_fits(fname, return_header=True)

    # Estimate the background:
    bck, mask = fit_background(fname)

    # Print some information:
    print(fname)
    print(bck.shape)
    print(mask.shape)

    # Check the sizes of the returned images:
    assert (bck.shape == img.shape)
    assert (mask.shape == img.shape)
コード例 #6
0
ファイル: test_background.py プロジェクト: danhey/photometry
def test_background():
	"""Test of background estimator"""

	# Load the first image in the input directory:
	INPUT_DIR = os.path.join(os.path.dirname(__file__), 'input', 'images')
	fname = find_ffi_files(INPUT_DIR)[0]
	img, hdr = load_ffi_fits(fname, return_header=True)

	# Estimate the background:
	bck, mask = fit_background(fname, )

	# Print some information:
	print(fname)
	print(bck.shape)
	print(mask.shape)

	# Check the sizes of the returned images:
	assert(bck.shape == img.shape)
	assert(mask.shape == img.shape)
コード例 #7
0
ファイル: test_imagemotion.py プロジェクト: danhey/photometry
def test_imagemotion():
    """Test of ImageMovementKernel"""

    # Load the first image in the input directory:
    INPUT_DIR = os.path.join(os.path.dirname(__file__), 'input', 'images')
    files = find_ffi_files(INPUT_DIR, camera=1, ccd=1)
    fname = files[0]

    # Load the image:
    img = load_ffi_fits(fname)

    # Create new image, moved down by one pixel:
    #img2 = np.roll(img, 1, axis=0)

    # Some positions across the image:
    xx, yy = np.meshgrid(
        np.linspace(0, img.shape[0], 5, dtype='float64'),
        np.linspace(0, img.shape[1], 5, dtype='float64'),
    )
    xy = np.column_stack((xx.flatten(), yy.flatten()))
    print("Positions to be tested:")
    print(xy)

    desired1 = np.zeros_like(xy)
    desired2 = np.zeros_like(xy)
    desired2[:, 1] = 1

    for warpmode in ('unchanged', 'translation', 'euclidian'):
        print("Testing warpmode=" + warpmode)

        # Create ImageMovementKernel instance:
        imk = ImageMovementKernel(image_ref=img, warpmode=warpmode)

        # Calculate kernel for the same image:
        kernel = imk.calc_kernel(img)
        print("Kernel:")
        print(kernel)
        assert (len(kernel) == imk.n_params)

        # Calculate the new positions based on the kernel:
        delta_pos = imk(xy, kernel)
        print("Extracted movements:")
        print(delta_pos)

        assert (delta_pos.shape == xy.shape)

        # The movements should all be very close to zero,
        # since we used the same image as the reference:
        np.testing.assert_allclose(delta_pos, desired1, atol=1e-5, rtol=1e-5)
        """
		kernel = imk.calc_kernel(img2)
		print("Kernel 2:")
		print(kernel)

		# Calculate the new positions based on the kernel:
		delta_pos = imk(xy, kernel)
		print("Extracted movements:")
		print(delta_pos)

		assert(delta_pos.shape == xy.shape)

		# The movements should all be very close to zero,
		# since we used the same image as the reference:
		# FIXME: Would LOVE this to be more accurate!
		np.testing.assert_allclose(delta_pos, desired2, atol=1e-3, rtol=1e-2)
		"""

    print("Done")
コード例 #8
0
ファイル: test_imagemotion.py プロジェクト: ckm3/photometry
def test_imagemotion(SHARED_INPUT_DIR, warpmode):
    """Test of ImageMovementKernel"""

    print("Testing warpmode=" + warpmode)

    # Load the first image in the input directory:
    files = find_ffi_files(os.path.join(SHARED_INPUT_DIR, 'images'),
                           camera=1,
                           ccd=1)
    fname = files[0]

    # Load the image:
    img = load_ffi_fits(fname)

    # Create new image, moved down by one pixel:
    #img2 = np.roll(img, 1, axis=0)

    # Some positions across the image:
    xx, yy = np.meshgrid(
        np.linspace(0, img.shape[0], 5, dtype='float64'),
        np.linspace(0, img.shape[1], 5, dtype='float64'),
    )
    xy = np.column_stack((xx.flatten(), yy.flatten()))
    print("Positions to be tested:")
    print(xy)

    desired1 = np.zeros_like(xy)
    desired2 = np.zeros_like(xy)
    desired2[:, 1] = 1

    # Create ImageMovementKernel instance:
    imk = ImageMovementKernel(image_ref=img, warpmode=warpmode)

    # If calling interpolate before defining kernels, we should get an error:
    with pytest.raises(ValueError):
        imk.interpolate(1234, 1234)

    # Calculate kernel for the same image:
    kernel = imk.calc_kernel(img)
    print("Kernel:")
    print(kernel)
    assert (len(kernel) == imk.n_params)

    # Calculate the new positions based on the kernel:
    delta_pos = imk(xy, kernel)
    print("Extracted movements:")
    print(delta_pos)

    assert (delta_pos.shape == xy.shape)

    # The movements should all be very close to zero,
    # since we used the same image as the reference:
    np.testing.assert_allclose(delta_pos, desired1, atol=1e-5, rtol=1e-5)

    #
    with pytest.raises(ValueError) as excinfo:
        imk.load_series([1234, 1235], kernel)

    print(excinfo.value)
    assert str(excinfo.value).startswith('Wrong shape of kernels.')
    """
	kernel = imk.calc_kernel(img2)
	print("Kernel 2:")
	print(kernel)

	# Calculate the new positions based on the kernel:
	delta_pos = imk(xy, kernel)
	print("Extracted movements:")
	print(delta_pos)

	assert(delta_pos.shape == xy.shape)

	# The movements should all be very close to zero,
	# since we used the same image as the reference:
	# FIXME: Would LOVE this to be more accurate!
	np.testing.assert_allclose(delta_pos, desired2, atol=1e-3, rtol=1e-2)
	"""

    print("Done")