{"library":"photutils","title":"Photutils","description":"Photutils is an Astropy package for detecting and performing photometry on astronomical sources in image data. It provides tools for source detection, background estimation, aperture and PSF photometry, and image segmentation. Photutils is actively maintained, with new minor versions typically released every 1-3 months, following Astropy's release cycle. The current stable version is 2.3.0.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install photutils"],"cli":null},"imports":["from photutils.detection import DAOStarFinder","from photutils.detection import IRAFStarFinder","from photutils.background import Background2D","from photutils.background import MedianBackground","from photutils.segmentation import detect_sources","from photutils.segmentation import deblend_sources","from photutils.aperture import CircularAperture","from photutils.aperture import aperture_photometry","from photutils.segmentation import PropertiesCatalog","from astropy.modeling.models import Gaussian2D"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom astropy.stats import sigma_clipped_stats\nfrom photutils.detection import DAOStarFinder\nfrom photutils.background import Background2D, MedianBackground\nfrom photutils.aperture import CircularAperture, aperture_photometry\n\n# Create dummy data (replace with your actual FITS data)\ndata = np.random.rand(100, 100) * 100\ny, x = np.mgrid[0:100, 0:100]\ndata += 500 * np.exp(-((x - 20)**2 + (y - 20)**2) / (2 * 5**2)) # Add a star\ndata += 700 * np.exp(-((x - 70)**2 + (y - 80)**2) / (2 * 7**2)) # Add another star\n\n# 1. Estimate background\nmean_bkg, median_bkg, std_bkg = sigma_clipped_stats(data, sigma=3.0)\nbkg = Background2D(data, (50, 50), filter_size=(3, 3),\n                   bkg_estimator=MedianBackground())\ndata_subtracted = data - bkg.background\n\n# 2. Detect sources\nfinder = DAOStarFinder(fwhm=5.0, threshold=3.0 * std_bkg)\nsources = finder(data_subtracted)\n\nif sources is None:\n    print(\"No sources found. Adjust DAOStarFinder parameters.\")\nelse:\n    print(f\"Detected {len(sources)} sources:\")\n    for col in sources.colnames:\n        sources[col].info.format = '%.8g'  # for consistent output\n    print(sources)\n\n    # 3. Perform aperture photometry\n    positions = (sources['xcentroid'], sources['ycentroid'])\n    aperture = CircularAperture(positions, r=8.0)\n    phot_table = aperture_photometry(data_subtracted, aperture)\n\n    print(\"\\nAperture Photometry:\")\n    for col in phot_table.colnames:\n        phot_table[col].info.format = '%.8g'  # for consistent output\n    print(phot_table)","lang":"python","description":"This quickstart demonstrates a basic `photutils` workflow: generating synthetic image data, estimating and subtracting the background, detecting point sources using DAOStarFinder, and performing aperture photometry on the detected sources. This covers fundamental steps in analyzing astronomical images.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}