{"id":9277,"library":"reproject","title":"reproject","description":"The `reproject` package is a Python library designed for re-gridding astronomical images from one World Coordinate System (WCS) to another. It provides a uniform interface for various reprojection techniques, including interpolation-based methods, the adaptive and anti-aliased algorithm by DeForest (2004), and flux-conserving spherical polygon intersection. The library also supports reprojection to and from HEALPIX projections through integration with `astropy-healpix`. It is currently at version 0.19.0 and is actively maintained as part of the Astropy project, with a regular release cadence aligned with Astropy's development cycle.","status":"active","version":"0.19.0","language":"en","source_language":"en","source_url":"https://github.com/astropy/reproject","tags":["astronomy","image processing","WCS","reprojection","astropy"],"install":[{"cmd":"pip install reproject","lang":"bash","label":"PyPI (recommended)"},{"cmd":"conda install -c conda-forge reproject","lang":"bash","label":"Conda-forge"}],"dependencies":[{"reason":"Runtime environment","package":"Python","version":">=3.11"},{"reason":"Core array manipulation","package":"Numpy","version":">=1.20"},{"reason":"World Coordinate System (WCS) handling and core astronomical utilities","package":"Astropy","version":">=5.0"},{"reason":"Interpolation and image processing algorithms","package":"Scipy","version":">=1.5"},{"reason":"Required for HEALPIX image reprojection functionality","package":"astropy-healpix","version":">=0.6","optional":true},{"reason":"Optional, for parallel and out-of-core processing with `block_size`","package":"dask","version":">=2021.8","optional":true},{"reason":"Optional, for Dask array support","package":"zarr","optional":true},{"reason":"Optional, for Dask array support","package":"fsspec","optional":true},{"reason":"Optional, for some mosaicking functionality","package":"shapely","version":">=1.6","optional":true}],"imports":[{"symbol":"reproject_interp","correct":"from reproject import reproject_interp"},{"symbol":"reproject_adaptive","correct":"from reproject import reproject_adaptive"},{"symbol":"reproject_exact","correct":"from reproject import reproject_exact"},{"symbol":"reproject_from_healpix","correct":"from reproject import reproject_from_healpix"},{"symbol":"reproject_to_healpix","correct":"from reproject import reproject_to_healpix"}],"quickstart":{"code":"import numpy as np\nfrom astropy.wcs import WCS\nfrom reproject import reproject_interp\nimport matplotlib.pyplot as plt\n\n# 1. Create dummy input data and WCS\ndata_in = np.arange(100.0).reshape((10, 10)) + 100.0\nwcs_in = WCS(naxis=2)\nwcs_in.wcs.crpix = [5, 5]\nwcs_in.wcs.cdelt = np.array([-0.1, 0.1])\nwcs_in.wcs.crval = [0, 0]\nwcs_in.wcs.ctype = [\"RA---TAN\", \"DEC--TAN\"]\n\n# 2. Create target output WCS with a different projection/scale/rotation\nwcs_out = WCS(naxis=2)\nwcs_out.wcs.crpix = [10, 10]\nwcs_out.wcs.cdelt = np.array([-0.05, 0.05]) # Different pixel scale\nwcs_out.wcs.crval = [0, 0]\nwcs_out.wcs.ctype = [\"RA---TAN\", \"DEC--TAN\"]\nwcs_out.wcs.pc = [[np.cos(np.deg2rad(15)), -np.sin(np.deg2rad(15))],\n                  [np.sin(np.deg2rad(15)), np.cos(np.deg2rad(15))]] # 15-deg rotation\n\nshape_out = (20, 20) # Target output shape\n\n# 3. Reproject the data using interpolation\ndata_out, footprint = reproject_interp((data_in, wcs_in), wcs_out, shape_out=shape_out)\n\n# 4. Visualize the results (optional)\nplt.figure(figsize=(10, 5))\nplt.subplot(1, 2, 1, projection=wcs_in)\nplt.imshow(data_in, origin='lower', cmap='viridis')\nplt.title('Original Data')\nplt.xlabel('X (pixels)')\nplt.ylabel('Y (pixels)')\n\nplt.subplot(1, 2, 2, projection=wcs_out)\nplt.imshow(data_out, origin='lower', cmap='viridis')\nplt.title('Reprojected Data')\nplt.xlabel('X (pixels)')\nplt.ylabel('Y (pixels)')\n\nplt.tight_layout()\nplt.show()","lang":"python","description":"This quickstart demonstrates how to reproject a simple 2D NumPy array from one Astropy WCS object to another using the `reproject_interp` function. It creates dummy input data and WCS, defines a target WCS with a different scale and rotation, performs the reprojection, and then visualizes both the original and reprojected images. For real-world applications, input data often comes from FITS files."},"warnings":[{"fix":"Ensure your input data has correct and well-defined WCS information before using `reproject`. If alignment is needed, perform image registration with other tools first.","message":"The `reproject` library assumes that the input World Coordinate System (WCS) information is accurate. It performs image re-gridding, not image registration (alignment of images where WCS might be inaccurate).","severity":"gotcha","affected_versions":"All versions"},{"fix":"For flux-conserving reprojection, use `reproject_exact` or `reproject_adaptive` with the `conserve_flux=True` parameter. Be aware that these methods are computationally more intensive.","message":"Interpolation-based reprojection (`reproject_interp`) is generally faster but does not guarantee flux conservation by default. For scientific applications requiring precise flux preservation, this can lead to incorrect results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For large arrays, consider setting `block_size='auto'` or a specific tuple, and `parallel=True` (which requires `dask` to be installed) to enable chunked processing and reduce memory footprint.","message":"When dealing with very large datasets, direct reprojection can consume significant memory. The `block_size` and `parallel` parameters are available for out-of-core and multi-threaded processing.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify that your `WCS` object is correctly initialized with `naxis=2` (or the appropriate number of celestial axes) and that the celestial projection axes align with the dimensions of your input data array. When passing `(data, wcs)`, ensure `wcs` corresponds to the celestial dimensions of `data`.","cause":"The `astropy.wcs.WCS` object provided for the input data does not have the expected number of celestial dimensions (typically 2 for images) that match the actual data array used for reprojection.","error":"ValueError: The input WCS does not contain enough dimensions (expected 2, got X)"},{"fix":"Carefully inspect both the input and output `astropy.wcs.WCS` objects. Check all relevant FITS keywords (`CRVAL`, `CRPIX`, `CDELT`, `CTYPE`, `PC`, `CUNIT`, `RADECSYS`, `EQUINOX`) for correctness. Ensure consistent coordinate frames. If dealing with different datums, confirm that `astropy` is configured to handle the transformations correctly. Small errors in the WCS can lead to significant shifts.","cause":"This is often caused by inaccuracies in the input or output WCS definitions, discrepancies in coordinate system datums (e.g., ICRS vs. FK5), or issues with the spherical representation of coordinates during transformation. It can also stem from an incorrect understanding of how projections work versus reprojection.","error":"Reprojected image appears shifted, distorted, or misaligned from its expected position."}]}