A high-performance Python package for reprojecting astronomical images between different coordinate systems with support for SIP distortion correction.
Project description
dfreproject
A high-performance Python package for reprojecting astronomical images between different coordinate systems with support for SIP distortion correction.
The idea behind this package was to make a stripped down version of the reproject package by astropy in order to reduce computational time.
We achieve approximately 20X faster computations with this package using the GPU and 10X using the CPU for images taken by the Dragonfly Telescopic Array. Take a look at the demos for an example.
Features
- Fast reprojection of astronomical images between different WCS frames
- Support for Simple Imaging Polynomial (SIP) distortion correction
- GPU acceleration using PyTorch
- Multiple interpolation methods (nearest neighbor, bilinear, bicubic)
- Simple high-level API and detailed low-level control
Installation
Using PyPi
If you want to install using PyPi (which is certainly the easiest way), you can simply run
pip install dfreproject
Requirements
- Python 3.7+
- NumPy
- Astropy
- PyTorch
- Matplotlib
- cmcrameri
Installing from Source
For the latest development version, install directly from the GitHub repository:
git clone https://github.com/DragonflyTelescope/dfreproject.git
cd dfreproject
pip install -e .
For development installation with documentation dependencies:
pip install -e ".[docs]"
Quick Start
from astropy.io import fits
from astropy.wcs import WCS
from reprojection import calculate_reprojection
# Load source and target images
source_hdu = fits.open('source_image.fits')[0]
target_hdu = fits.open('target_grid.fits')[0]
target_wcs = WCS(target_hdu.header)
# Perform dfreproject with bilinear interpolation
reprojected = calculate_reprojection(
source_hdus=source_hdu,
target_wcs=target_wcs,
shape_out=target_hdu.data.shape,
order='bilinear'
)
# Save as FITS
output_hdu = fits.PrimaryHDU(data=reprojected)
output_hdu.header.update(target_wcs.to_header())
output_hdu.writeto('reprojected_image.fits', overwrite=True)
The arguments for calculate_reprojection are the same as for the standard reprojection options in the reproject package such as reproject_interp, reproject_adaptive, or reproject_exact.
Therefore, it can be directly swapped for one of these by simply importing it with from dfreproject import calculate_reprojection and then using calculate_reproject instead of reproject_interp.
This comes with the caveat that the flux calculation most closely mimics that to reproject_interp.
Demos and Examples
A collection of example notebooks and scripts is available in the demos folder to help you get started:
reprojection-comparison.ipynb- Simple example of reprojecting between two WCS frames and comparing the result of our implementation with thereprojectpackage.Coordinate-Comparison.ipynb' - A step-by-step walkthrough of our coordinate transformations with a comparison toastropy.wcs`.
To run the demos:
cd demos
jupyter notebook
Documentation
Comprehensive documentation is available at https://dfreproject.readthedocs.io/
The documentation includes:
- API reference
- Mathematical details of the reprojection process
- Tutorials and examples
- Performance tips
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Citation
If you use this package in your research, please cite: TBD
Acknowledgments
- Based on the FITS WCS standard and SIP convention
- Inspired by Astropy's reproject package
- Accelerated with PyTorch
- Documentation aided by Claude.ai
The License for all past and present versions is the GPL-3.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dfreproject-1.0.0.tar.gz.
File metadata
- Download URL: dfreproject-1.0.0.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f12857efeaae958f6ec04add5c4d076181dfd056faba869710711ed052644b4
|
|
| MD5 |
ce84402dca65675470cc939f25c95120
|
|
| BLAKE2b-256 |
dc7a84a1b7e2c6f8ca5936b522a96e3235ebc4b89fee84500650959c18801209
|
File details
Details for the file dfreproject-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dfreproject-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6fcc0415a0f10105b688c445efd43423173372ab1edf915effba56985991feb
|
|
| MD5 |
8ccf13faeda885c7b837585cb1793d21
|
|
| BLAKE2b-256 |
65190de46edfdfcf8023d0703d6150d1f741c340e208b80448efcacc030e23e3
|