SciPy 2024

Development of AstroPhot: Fitting Everything Everywhere all at Once in Astronomical Images
07-10, 13:15–13:45 (US/Pacific), Room 317

We present AstroPhot, a tool to accelerate the analysis of astronomical images. AstroPhot allows for simultaneously modelling images with galaxies and point sources in multi-band and time domain data. In this talk I will the benefits and challenges of how we used PyTorch (a differentiable and GPU accelerated scientific python library) to allow for fast development without sacrificing numerical performance. I will detail our development process as well as how we encourage users of all skill levels to engage with our documentation/tools.


We present AstroPhot, a tool to accelerate the analysis of astronomical images (https://autostronomy.github.io/AstroPhot/). In this talk I will discuss the development process and documentation of our image processing package using PyTorch as a numerical library; including its benefits and challenges. I will begin by explaining the basics of astronomical image processing for a broad audience. With a basic foundation in place I can explain why GPUs are ideally suited for this task, and why a differentiable code gives us easy access to powerful numerical techniques. The bulk of the talk will then be devoted to the package development, API design, and documentation to suit the scientific needs of our community; with a focus on lessons that apply generally to scientific python development.

While writing the package we aimed to meet the needs of users at all levels, and so we have developed an API which is an evolution from previous widely used packages. We include a configuration file interface, an object oriented interface, and a plugin capability to allow for users to seamlessly transition from beginners to power users. The configuration file interface allows users to begin applying AstroPhot to their own data within minutes, though it's flexibility is limited. The object oriented framework allows for complex modelling and advanced scientific analyses. The plugin interface allows for development of entirely new models, while exploiting a robust and well tested core functionality.

Our documentation takes the form of extensive tutorials which display simplified versions of the most common analysis problems (https://autostronomy.github.io/AstroPhot/GettingStarted.html). These notebooks can be a welcome mat for new users who want to learn about lensing; they are also convenient Lego pieces for advanced users to quickly develop new ideas. We are working with AstroPhot users to share notebooks detailing more advanced analysis. This supports reproducibility and provides more materials for new users.

Overall, our development approach has been to make a clean, complete, and reliable code to meet the needs of the astronomical community. Our team has learned many lessons along the way which I would like to share in this talk to encourage a discussion on best practices for development of workhorse scientific python packages.

I have given numerous talks before, here is a selection of slides from last year:
https://docs.google.com/presentation/d/1kmUQx9JpceHQDL2g-d387REo4Fv6c6c7o6JDz3YnUYk/edit?usp=sharing
https://docs.google.com/presentation/d/1xhZphgw46wb7iKPY-2YyWkNuT1yb8H-RdcLClYIGRPs/edit?usp=sharing
https://drive.google.com/file/d/1_YwRY5GJzY5HBfJ5xy2bpgepfxDg2yI_/view?usp=sharing
https://docs.google.com/presentation/d/13COYyj7_FUXmirivS_m8cui-MgdozzANVy8Y7UjahUc/edit?usp=sharing

I am a postdoctoral fellow at the Université de Montréal in Canada. I apply statistics to astronomical problems and I'm not afraid to develop some open source software along the way! I study Galaxies, strong gravitational lensing, and machine learning.