{"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.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install reproject"],"cli":null},"imports":["from reproject import reproject_interp","from reproject import reproject_adaptive","from reproject import reproject_exact","from reproject import reproject_from_healpix","from reproject import reproject_to_healpix"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}