diff --git a/docs/celestial.rst b/docs/celestial.rst index 907b25b49..5b5e9c1ec 100644 --- a/docs/celestial.rst +++ b/docs/celestial.rst @@ -205,14 +205,14 @@ kernel---see below.) The kernel used for interpolation and averaging can be controlled with a set of options. The ``kernel`` argument can be set to 'hann' or 'gaussian' to set the -function being used. The Hann window is the default, and the Gaussian window -improves anti-aliasing and photometric accuracy (or flux conservation, when the -flux-conserving mode is enabled) at the cost of blurring the output image by a -few pixels. The ``kernel_width`` argument sets the width of the Gaussian -kernel, in pixels, and is ignored for the Hann window. This width is measured -between the Gaussian's :math:`\pm 1 \sigma` points. The default value is 1.3 -for the Gaussian, chosen to minimize blurring without compromising accuracy. -Lower values may introduce photometric errors or leave input pixels +function being used. The Gaussian window is the default, as it provides better +anti-aliasing and photometric accuracy (or flux conservation, when the +flux-conserving mode is enabled), though at the cost of blurring the output +image by a few pixels. The ``kernel_width`` argument sets the width of the +Gaussian kernel, in pixels, and is ignored for the Hann window. This width is +measured between the Gaussian's :math:`\pm 1 \sigma` points. The default value +is 1.3 for the Gaussian, chosen to minimize blurring without compromising +accuracy. Lower values may introduce photometric errors or leave input pixels under-sampled, while larger values may improve anti-aliasing behavior but will increase blurring of the output image. Since the Gaussian function has infinite extent, it must be truncated. This is done by sampling within a region of diff --git a/docs/msx_on_2mass_header.fits b/docs/msx_on_2mass_header.fits new file mode 100644 index 000000000..8229d9dc6 Binary files /dev/null and b/docs/msx_on_2mass_header.fits differ diff --git a/reproject/adaptive/core.py b/reproject/adaptive/core.py index 93a27c6ad..9ed89cef5 100644 --- a/reproject/adaptive/core.py +++ b/reproject/adaptive/core.py @@ -34,7 +34,7 @@ def __call__(self, pixel_out): def _reproject_adaptive_2d(array, wcs_in, wcs_out, shape_out, return_footprint=True, center_jacobian=False, roundtrip_coords=True, conserve_flux=False, - kernel='Hann', kernel_width=1.3, + kernel='gaussian', kernel_width=1.3, sample_region_width=4): """ Reproject celestial slices from an n-d array from one WCS to another @@ -105,7 +105,8 @@ def _reproject_adaptive_2d(array, wcs_in, wcs_out, shape_out, transformer = CoordinateTransformer(wcs_in, wcs_out, roundtrip_coords) map_coordinates(array_in, array_out, transformer, out_of_range_nan=True, - center_jacobian=center_jacobian, conserve_flux=conserve_flux, + center_jacobian=center_jacobian, + conserve_flux=conserve_flux, kernel=kernel, kernel_width=kernel_width, sample_region_width=sample_region_width) diff --git a/reproject/adaptive/deforest.pyx b/reproject/adaptive/deforest.pyx index a5de27682..daf4b9961 100644 --- a/reproject/adaptive/deforest.pyx +++ b/reproject/adaptive/deforest.pyx @@ -177,8 +177,8 @@ KERNELS['gaussian'] = 1 def map_coordinates(double[:,:] source, double[:,:] target, Ci, int max_samples_width=-1, int conserve_flux=False, int progress=False, int singularities_nan=False, int x_cyclic=False, int y_cyclic=False, int out_of_range_nan=False, - bint center_jacobian=False, str kernel='Hann', double kernel_width=1.3, - double sample_region_width=4): + bint center_jacobian=False, str kernel='gaussian', + double kernel_width=1.3, double sample_region_width=4): cdef int kernel_flag try: kernel_flag = KERNELS[kernel.lower()] diff --git a/reproject/adaptive/high_level.py b/reproject/adaptive/high_level.py index ffade5fad..da2503bcb 100644 --- a/reproject/adaptive/high_level.py +++ b/reproject/adaptive/high_level.py @@ -9,7 +9,8 @@ def reproject_adaptive(input_data, output_projection, shape_out=None, hdu_in=0, return_footprint=True, center_jacobian=False, roundtrip_coords=True, conserve_flux=False, - kernel='Hann', kernel_width=1.3, sample_region_width=4): + kernel='gaussian', kernel_width=1.3, + sample_region_width=4): """ Reproject a 2D array from one WCS to another using the DeForest (2004) adaptive, anti-aliased resampling algorithm, with optional flux diff --git a/reproject/adaptive/tests/test_core.py b/reproject/adaptive/tests/test_core.py index f40184ac6..187ccdfdd 100644 --- a/reproject/adaptive/tests/test_core.py +++ b/reproject/adaptive/tests/test_core.py @@ -51,7 +51,8 @@ def test_reproject_adaptive_2d(wcsapi, center_jacobian, roundtrip_coords): array_out, footprint_out = reproject_adaptive( (data_in, wcs_in), wcs_out, shape_out=(60, 60), center_jacobian=center_jacobian, - roundtrip_coords=roundtrip_coords) + roundtrip_coords=roundtrip_coords, + kernel='hann') # Check that surface brightness is conserved in the unrotated case assert_allclose(np.nansum(data_in), np.nansum(array_out) * (256 / 60) ** 2, rtol=0.1) @@ -92,7 +93,8 @@ def test_reproject_adaptive_2d_rotated(center_jacobian, roundtrip_coords): array_out, footprint_out = reproject_adaptive( (data_in, wcs_in), wcs_out, shape_out=(60, 60), center_jacobian=center_jacobian, - roundtrip_coords=roundtrip_coords) + roundtrip_coords=roundtrip_coords, + kernel='hann') # ASTROPY_LT_40: astropy v4.0 introduced new default header keywords, # once we support only astropy 4.0 and later we can update the reference @@ -352,7 +354,7 @@ def test_reproject_adaptive_roundtrip(file_format): data, wcs, target_wcs = prepare_test_data(file_format) output, footprint = reproject_adaptive((data, wcs), target_wcs, (128, 128), - center_jacobian=True) + center_jacobian=True, kernel='hann') header_out = target_wcs.to_header() @@ -378,7 +380,7 @@ def test_reproject_adaptive_uncentered_jacobian(): data, wcs, target_wcs = prepare_test_data('fits') output, footprint = reproject_adaptive((data, wcs), target_wcs, (128, 128), - center_jacobian=False) + center_jacobian=False, kernel='hann') header_out = target_wcs.to_header()