What’s New in Photutils 2.3?#
Here we highlight some of the new functionality of the 2.3 release. In addition to these changes, Photutils 2.3 includes several smaller improvements and bug fixes, which are described in the full Changelog.
Dependency Version Updates#
Photutils 2.3 bumps the minimum required versions of several key dependencies to provide users with access to the latest features and performance improvements:
NumPy minimum version is now 1.25
SciPy minimum version is now 1.11.1
Matplotlib minimum version is now 3.8
scikit-image minimum version is now 0.21
PSF Photometry Improvements#
Enhanced Error Handling and Validation#
The PSF photometry classes have been significantly improved with better error handling and validation:
These classes no longer fail for invalid sources (those with no overlap with the input data, completely masked sources, or sources with too few unmasked pixels for fitting). Instead, they assign specific flag values (64, 128, 256) to identify these conditions.
PSFPhotometryandIterativePSFPhotometrynow raise an error if the inputerrorarray contains non-finite or zero values, preventing silent failures during fitting.A new
group_warning_thresholdkeyword has been added to control when warnings are issued about source grouping.
Improved Performance and Memory Usage#
When using Astropy 7.0+, the fitter object in
PSFPhotometryandIterativePSFPhotometrynow modifies the PSF model in place instead of creating copies, resulting in improved performance and significantly reduced memory usage.For source groups, the PSF photometry classes now use a dynamically generated “flat model” approach instead of deeply nested compound models. This eliminates recursion limits that could cause failures with groups containing hundreds of sources, while providing dramatic performance improvements (up to 10x faster model creation and 50x less memory usage for large groups).
New Reduced Chi-squared Fit Statistic#
The PSF photometry classes now return a reduced chi-squared statistic
(reduced_chi2 column) in the results table.
New Methods#
The PSF photometry classes now include new methods for flexible output formatting:
results_to_init_params: Converts fit results to initialization parameter formatresults_to_model_params: Converts fit results to model parameter format
Enhanced Flexibility#
GriddedPSFModelcan now be used with a single input ePSF model, making it equivalent toImagePSFfor simpler use cases.The
findercallable input toPSFPhotometryandIterativePSFPhotometrynow can return more flexible column names beyond the previously required'xcentroid'and'ycentroid'.
New Utility Functions#
decode_psf_flags: A utility function for decoding PSF photometry bit flags.PSF_FLAGSobject: Provides readable, named constants for each PSF photometry bit flag and includes helper utilities for decoding.
Isophote Package Improvements#
The
build_ellipse_modelfunction in the isophote module has been Cythonized, making it considerably faster.The
build_ellipse_modelfunction now includes an optionalsma_intervalkeyword argument that was previously hardcoded.
Segmentation Enhancements#
SegmentationImage Improvements#
The
to_regionsmethod now supports agroupkeyword for better control over region grouping.The
polygonsattribute can now handle non-contiguous segments, returning either ShapelyPolygonorMultiPolygonobjects as appropriate.The
to_patchesandplot_patchesmethods now returnmatplotlib.patches.PathPatchobjects for improved rendering.The
to_regionsmethod now stores segment labels in the region object’smetadictionary for easy identification.
SourceCatalog Features#
The
make_cutoutsmethod now includes an optionalarraykeyword for more flexible cutout generation.
API Changes#
Background2D now raises an explicit ValueError if the input data
contains all non-finite values.
Breaking Changes#
The GriddedPSFModel data and grid_xypos attributes are now
read-only to prevent accidental modification.
Deprecations and Removals#
The
PSFPhotometryfit_paramattribute is now deprecated. Use the newresults_to_init_paramsmethod instead.The deprecated
PSFPhotometryfit_resultsattribute has been removed.