Skip to main content

A package for extracting stars and doing photometry from an astronomical image

Project description

Welcome to the STAREXTRACTOR package

PyPI version shields.io PyPI pyversions PyPI status GitHub contributors Maintenance GitHub license Documentation Status Build Status

This package is an archive of scientific routines for astronomical image processing related to the source extraction and photometry. Currently, operations on source extraction include:

  1. Read and parse an astronomical image in follwing formats: .fits, generic image format like .bmp, NumPy-specific binary files like .npy and 2D array;
  2. Estimate the Full width at half maximum (FWHM) of the gaussian kernel for the image.
  3. Extract the centroid coordinates of the star spots using the DAOFIND algorithm implementation from [photutils](Photutils — photutils 1.9.0);
  4. Visualize the grayscale image of original/background/background-subtracted/background noise levels;

Operations on photometry include:

  1. Aperture Photometry. It is widely used in general star field photometry, but less suitble for crowded star fields with light spots overlapped and when stars are located on the image boundaries.

  2. Point Spread Function(PSF)/Pixel Response Function(PRF) Photometry. It solved the problem encountered by the aperture photometry, and can estimate the brightness of stars more accurately.

  3. DAOPHOT Photometry. It is essentially iterative PSF photometry, useful for crowded fields where faint stars are very close to bright stars. The faint stars may not be detected until after the bright stars are subtracted, so it can find more faint stars by a number of iterations.

  4. Show original image with star spots marked;

How to Install

On Linux, macOS and Windows architectures, the binary wheels can be installed using pip by executing one of the following commands:

pip install starextractor
pip install starextractor --upgrade # to upgrade a pre-existing installation

How to use

Read an astronomical image

Currently, supported image formats include .fits, generic image format(such as .bmp), NumPy-specific binary files like.npy, and 2D numpy array.

>>> from starextractor import parse_image
>>> imagefile = 'obs/fits/img_00000.fits' 
>>> #imagefile = 'obs/bmp/img_00000.bmp'
>>> #imagefile = 'obs/npy/img_00000.npy'
>>> data = parse_image(imagefile)
>>> # data = parse_image(image_array)
>>> print(data)

Estimate the Full width at half maximum (FWHM) of the gaussian kernel for the image data.

>>> print(data.fwhm) # in pixels
>>> # 9.439381701950126
>>> print(data.sigma) # Sigma of the gaussian kernel

The relationship between the sigma and FWHM is expressed as

$$ FWHM = 2\sqrt{2\ln2}\sigma ≈ 2.355 \sigma $$

Now, output the attributes associated to the image data.

>>> print(data.image_raw) # Original grayscale image
>>> print(data.bkg) # Grayscale background
>>> print(data.image) # Image of background subtracted
>>> print(data.bkg_rms) # Background noise levels

Show grayscale image

>>> data.show('image_raw') # original image
>>> # data.show('image_raw','figs/raw_image.png') # save to a figure
>>> data.show('image') # background-subtracted
>>> data.show('bkg') # background
>>> data.show('bkg_rms') # background noise levels

Extract centroid coordinates of star spots and do photometry

Using the DAOFIND algorithm to extract centroid coordinates and do photometry with Aperture Photometry method.

>>> sources = data.find_source(phot='aperture',edgemask=True)
>>> print(sources)
>>> # <Source object: NUM = 25 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'APERTURE'>
>>> # Output the centroid coordinates, brightness(sum of gray value within an aperture), and SNR of star spots.
>>> print(sources.xy,sources.brightness,sources.snr)

Use the previously estimated centroid coordinates by DAOFIND algorithm as the prior value, fit the centroid coordinates and do photometry with the PSF Photometry method.

>>> sources = data.find_source(phot='psf',edgemask=True)
>>> print(sources)
>>> # <Source object: NUM = 25 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'PSF'>

Use the previously estimated centroid coordinates by DAOFIND algorithm as the prior value, fit the centroid coordinates and do photometry with the DAOPHOT Photometry method.

>>> sources = data.find_source(phot='dao',edgemask=True)
>>> print(sources)
>>> # <Source object: NUM = 26 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'DAO'>

Show the extracted sources in image

>>> sources.show()
>>> #sources.show('figs/sources.png') # save image to a file

Change log

  • 0.2.0 — Nov 06, 2023

    • Added implementation for automatically estimate the Full width at half maximum (FWHM) of the gaussian kernel for the image.

    • Added implementation for Point Spread Function(PSF)/Pixel Response Function(PRF) Photometry

    • Added implementation for DAOPHOT Photometry

  • 0.1.8 — Oct 22, 2023

    • Added an information-rich string representation of the object and fixed some annotation typos.
  • 0.1.7 — Sep 23, 2023

    • Fixed a warning caused by determining whether an array is empty in Python of version > 3.9.
  • 0.1.6 — Jun 29, 2023

    • Added support for image file formats .npy and numpy array in function AstroImage.read_image()
  • 0.1.5 — May 14, 2023

    • The class Centriod is deprecated, and the class Source is used instead
    • Add method .invariantfeatures() to class Source, which calculates the triangle invariants and constructs a 2D Tree; and records the asterism indices for each triangle.
  • 0.1.0 — Apr 5, 2023

    • The starextractor package was released.

Reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

starextractor-0.2.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file starextractor-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: starextractor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.16

File hashes

Hashes for starextractor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86d1d5b5c1dc9ce32d9950245224c2098c37892991fc29471390a2df62afb9d4
MD5 4289213aeb6691a01e127e046de4f015
BLAKE2b-256 40d066fca7a8511d8d90348c177e36a14d9dcbefb2307490f5c64af3388d6925

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page