dfreproject: A Python package for astronomical reprojection
dfreproject: A Python package for astronomical reprojection - Published in JOSS (2025)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords from Contributors
Repository
homegrown reprojection algorithm using torch
Basic Info
- Host: GitHub
- Owner: DragonflyTelescope
- License: gpl-3.0
- Language: Python
- Default Branch: master
- Homepage: https://dfreproject.readthedocs.io/en/latest/
- Size: 25.6 MB
Statistics
- Stars: 10
- Watchers: 5
- Forks: 5
- Open Issues: 2
- Releases: 0
Metadata Files
README.md
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 affiliated with 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 Telephoto Array. Take a look at the demos for an example.
We note that the only projection we currently support is the Tangential Gnomonic projection which is the most popular in optical astronomy.
If you have need for this package to work with another projection geometry, please open a GitHub issue.
Features
- Fast reprojection of astronomical images between different WCS frames
- Flux conservation is the default
- 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
bash
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:
bash
git clone https://github.com/DragonflyTelescope/dfreproject.git
cd dfreproject
pip install -e .
For development installation with documentation dependencies:
bash
pip install -e ".[docs]"
Quick Start
```python from astropy.io import fits from astropy.wcs import WCS from dfreproject import calculate_reprojection
Load source and target images
sourcehdu = fits.open('sourceimage.fits')[0] targethdu = fits.open('targetgrid.fits')[0] targetwcs = WCS(targethdu.header)
Perform dfreproject with bilinear interpolation
reprojected = calculatereprojection( sourcehdus=sourcehdu, targetwcs=targetwcs, shapeout=target_hdu.data.shape, order='bilinear' )
Save as FITS
outputhdu = fits.PrimaryHDU(data=reprojected) outputhdu.header.update(targetwcs.toheader()) outputhdu.writeto('reprojectedimage.fits', overwrite=True) ```
The arguments for calculate_reprojection are the same as for the standard reprojection options in the reproject package, i.e. reproject_interp, reproject_adaptive, or reproject_exact.
In another scenario, it may be more advantageous to pass a tuple of a data array and a header object that have already been loaded into memory (i.e. not an HDU object). In that case, follow this example:
```python from astropy.io import fits from astropy.wcs import WCS from dfreproject import calculate_reprojection
Load source and target images
sourcehdu = fits.open('sourceimage.fits')[0] sourcedata = sourcehdu.data targethdu = fits.open('targetgrid.fits')[0] targetwcs = WCS(targethdu.header)
Perform dfreproject with bilinear interpolation
reprojected = calculatereprojection( sourcehdus=(sourcedata, sourcehdu.header), targetwcs=targetwcs, shapeout=targethdu.data.shape, order='bilinear' )
Save as FITS
outputhdu = fits.PrimaryHDU(data=reprojected) outputhdu.header.update(targetwcs.toheader()) outputhdu.writeto('reprojectedimage.fits', overwrite=True) ```
The calculate_reprojection function will internally handle all the translation so that the inputs are properly handled.
Flux Conservation
Flux conservation is the default behavior for dfreproject. Two options are available for flux conservation:
1. Local flux density conservation: The image and a "ones" tensor are interpolated together, and the interpolated image is divided by the interpolated ones tensor (footprint) to correct for any flux density spreading during interpolation. This can affect the results at the edges of the interpolation.
2. Jacobian correction for full flux conservation: Multiply the footprint-corrected flux by the determinant of the Jacobian to handle changes in area during the reprojection.
Local flux conservation is the default option; however, users can change this behavior by setting conserve_flux=False. If the transformation between one coordinate system and another is truly linear (i.e., there are no distortions such as SIP distortions), then the local flux convervation computed with the footprint is sufficient. If this is the case, then the user can set compute_jacobian=False. However, this only achieves very modest gains in computation time so we suggest users leave this feature on.
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.reprojection-comparison-mini.ipynb- Example demonstrating the differences betweendfreprojectandreprojectusing different interpolation schema.Coordinate-Comparison.ipynb- A step-by-step walkthrough of our coordinate transformations with a comparison toastropy.wcs.
To run the demos:
bash
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
Running Tests
The unit tests can be run using the following command:
bash
pytest
The default settings are in the pytest.ini file.
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 our zenodo DOI:
https://doi.org/10.5281/zenodo.15170605
Acknowledgments
- Based on the FITS WCS standard and SIP convention
- Inspired by Astropy's reproject package
- Accelerated with PyTorch
The License for all past and present versions is the GPL-3.0.
AI Disclaimer
Claude.ai was used to improve the documentation and help write the unit tests. The only portion of the code that Claude.ai wrote is related to the chunking of data to respect memory requirements.
Owner
- Name: DragonflyTelescope
- Login: DragonflyTelescope
- Kind: organization
- Repositories: 1
- Profile: https://github.com/DragonflyTelescope
JOSS Publication
dfreproject: A Python package for astronomical reprojection
Authors
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, Centre de Recherche en Astrophysique du Québec (CRAQ), Québec, QC G1V 0A6, Canada
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, Astronomy Department, Yale University, 219 Prospect St, New Haven, CT 06511, USA
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, Astronomy Department, Yale University, 219 Prospect St, New Haven, CT 06511, USA
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, David A. Dunlap Department of Astronomy & Astrophysics, University of Toronto, 50 St. George Street, Toronto, ON M5S 3H4, Canada, Dunlap Institute for Astronomy & Astrophysics, University of Toronto, 50 St. George Street, Toronto, ON M5S 3H4, Canada
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, Astronomy Department, Yale University, 219 Prospect St, New Haven, CT 06511, USA
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, NRC Herzberg Astronomy & Astrophysics Research Centre, 5071 West Saanich Road, Victoria, BC V9E 2E7, Canada
Dragonfly Focused Research Organization, 150 Washington Avenue, Santa Fe, 87501, NM, USA, David A. Dunlap Department of Astronomy & Astrophysics, University of Toronto, 50 St. George Street, Toronto, ON M5S 3H4, Canada, Dunlap Institute for Astronomy & Astrophysics, University of Toronto, 50 St. George Street, Toronto, ON M5S 3H4, Canada
Tags
astronomy reprojection PyTorch Dragonfly Telephoto ArrayGitHub Events
Total
- Create event: 6
- Issues event: 13
- Release event: 1
- Watch event: 8
- Delete event: 4
- Issue comment event: 17
- Public event: 1
- Push event: 77
- Pull request review event: 8
- Pull request review comment event: 2
- Pull request event: 29
- Fork event: 2
Last Year
- Create event: 6
- Issues event: 13
- Release event: 1
- Watch event: 8
- Delete event: 4
- Issue comment event: 17
- Public event: 1
- Push event: 77
- Pull request review event: 8
- Pull request review comment event: 2
- Pull request event: 29
- Fork event: 2
Committers
Last synced: 4 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| carterrhea | c****3@g****m | 110 |
| Steven Janssens | s****s@d****m | 12 |
| Nathaniel Laurent | n****t@g****m | 9 |
| dependabot[bot] | 4****]@u****m | 5 |
| Adam Ginsburg | k****h@g****m | 3 |
| StepSecurity Bot | b****t@s****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 14
- Total pull requests: 27
- Average time to close issues: 4 days
- Average time to close pull requests: 1 day
- Total issue authors: 5
- Total pull request authors: 5
- Average comments per issue: 1.64
- Average comments per pull request: 0.3
- Merged pull requests: 20
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 14
- Pull requests: 27
- Average time to close issues: 4 days
- Average time to close pull requests: 1 day
- Issue authors: 5
- Pull request authors: 5
- Average comments per issue: 1.64
- Average comments per pull request: 0.3
- Merged pull requests: 20
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- keflavich (5)
- svank (3)
- stevenrjanssens (3)
- crhea93 (2)
- amunozj (1)
Pull Request Authors
- crhea93 (12)
- stevenrjanssens (10)
- nathaniellaurent (2)
- keflavich (2)
- dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 41 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 5
- Total maintainers: 1
pypi.org: dfreproject
A high-performance Python package for reprojecting astronomical images between different coordinate systems with support for SIP distortion correction.
- Homepage: https://github.com/DragonflyTelescope/dfreproject
- Documentation: https://dfreproject.readthedocs.io/
- License: gpl-3.0
-
Latest release: 1.3.0
published 4 months ago