starextractor


Namestarextractor JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/lcx366/STAREXTRACTOR
SummaryA package for extracting stars and doing photometry from an astronomical image
upload_time2023-11-06 01:38:05
maintainer
docs_urlNone
authorChunxiao Li
requires_python>=3.10
licenseMIT
keywords source extraction photometry psf daofind fwhm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Welcome to the STAREXTRACTOR package

[![PyPI version shields.io](https://img.shields.io/pypi/v/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![PyPI status](https://img.shields.io/pypi/status/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![GitHub contributors](https://img.shields.io/github/contributors/lcx366/STAREXTRACTOR.svg)](https://GitHub.com/lcx366/STAREXTRACTOR/graphs/contributors/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/lcx366/STAREXTRACTOR/graphs/commit-activity) [![GitHub license](https://img.shields.io/github/license/lcx366/STAREXTRACTOR.svg)](https://github.com/lcx366/STAREXTRACTOR/blob/master/LICENSE) [![Documentation Status](https://readthedocs.org/projects/starextractor/badge/?version=latest)](http://starextractor.readthedocs.io/?badge=latest) [![Build Status](https://travis-ci.org/lcx366/starextractor.svg?branch=master)](https://travis-ci.org/lcx366/starextractor)

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](https://photutils.readthedocs.io/en/stable/index.html#));
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.

```python
>>> 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.

```python
>>> 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.

```python
>>> 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

```python
>>> 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
```

<p align="middle">
  <img src="readme_figs/image_raw.png" width="300" />
  <img src="readme_figs/image.png" width="300" />
</p>

<p align="middle">
  <img src="readme_figs/bkg.png" width="300" />
  <img src="readme_figs/bkg_rms.png" width="300" />
</p>

### Extract centroid coordinates of star spots and do photometry

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

```python
>>> 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.

```python
>>> 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.

```python
>>> 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

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

<p align="middle">
  <img src="readme_figs/centroids.png" width="500" />
</p>

## 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

- [photutils](https://photutils.readthedocs.io/en/stable/index.html)
- [Photometry Methods](http://srmastro.uvacreate.virginia.edu/astr313/lectures/photometry/photometry_methods.html)
- [Astroalign](https://astroalign.quatrope.org/en/latest/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lcx366/STAREXTRACTOR",
    "name": "starextractor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "source extraction,photometry,psf,daofind,fwhm",
    "author": "Chunxiao Li",
    "author_email": "lcx366@126.com",
    "download_url": "",
    "platform": null,
    "description": "# Welcome to the STAREXTRACTOR package\n\n[![PyPI version shields.io](https://img.shields.io/pypi/v/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![PyPI status](https://img.shields.io/pypi/status/starextractor.svg)](https://pypi.python.org/pypi/starextractor/) [![GitHub contributors](https://img.shields.io/github/contributors/lcx366/STAREXTRACTOR.svg)](https://GitHub.com/lcx366/STAREXTRACTOR/graphs/contributors/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/lcx366/STAREXTRACTOR/graphs/commit-activity) [![GitHub license](https://img.shields.io/github/license/lcx366/STAREXTRACTOR.svg)](https://github.com/lcx366/STAREXTRACTOR/blob/master/LICENSE) [![Documentation Status](https://readthedocs.org/projects/starextractor/badge/?version=latest)](http://starextractor.readthedocs.io/?badge=latest) [![Build Status](https://travis-ci.org/lcx366/starextractor.svg?branch=master)](https://travis-ci.org/lcx366/starextractor)\n\nThis package is an archive of scientific routines for astronomical image processing related to the source extraction and photometry.\nCurrently, operations on source extraction include:\n\n1. Read and parse an astronomical image in follwing formats: `.fits`, generic image format like `.bmp`,  NumPy-specific binary files like `.npy` and 2D array;\n2. Estimate the Full width at half maximum (FWHM) of the gaussian kernel for the image.\n3. Extract the centroid coordinates of the star spots using the DAOFIND algorithm  implementation from [`photutils`]([Photutils &#8212; photutils 1.9.0](https://photutils.readthedocs.io/en/stable/index.html#));\n4. Visualize the grayscale image of original/background/background-subtracted/background noise levels;\n\nOperations on photometry include:\n\n1. **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.\n\n2. **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.\n\n3. **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.\n\n4. Show original image with star spots marked;\n\n## How to Install\n\nOn Linux, macOS and Windows architectures, the binary wheels can be installed using `pip` by executing one of the following commands:\n\n```\npip install starextractor\npip install starextractor --upgrade # to upgrade a pre-existing installation\n```\n\n## How to use\n\n### Read an astronomical image\n\nCurrently, supported image formats include `.fits`, generic image format(such as `.bmp`), NumPy-specific binary files like`.npy`, and 2D numpy array.\n\n```python\n>>> from starextractor import parse_image\n>>> imagefile = 'obs/fits/img_00000.fits' \n>>> #imagefile = 'obs/bmp/img_00000.bmp'\n>>> #imagefile = 'obs/npy/img_00000.npy'\n>>> data = parse_image(imagefile)\n>>> # data = parse_image(image_array)\n>>> print(data)\n```\n\nEstimate the Full width at half maximum (FWHM) of the gaussian kernel for the image data.\n\n```python\n>>> print(data.fwhm) # in pixels\n>>> # 9.439381701950126\n>>> print(data.sigma) # Sigma of the gaussian kernel\n```\n\nThe relationship between the sigma and FWHM is expressed as\n\n$$\nFWHM = 2\\sqrt{2\\ln2}\\sigma \u2248 2.355 \\sigma\n$$\n\nNow, output the attributes associated to the image data.\n\n```python\n>>> print(data.image_raw) # Original grayscale image\n>>> print(data.bkg) # Grayscale background\n>>> print(data.image) # Image of background subtracted\n>>> print(data.bkg_rms) # Background noise levels\n```\n\n### Show grayscale image\n\n```python\n>>> data.show('image_raw') # original image\n>>> # data.show('image_raw','figs/raw_image.png') # save to a figure\n>>> data.show('image') # background-subtracted\n>>> data.show('bkg') # background\n>>> data.show('bkg_rms') # background noise levels\n```\n\n<p align=\"middle\">\n  <img src=\"readme_figs/image_raw.png\" width=\"300\" />\n  <img src=\"readme_figs/image.png\" width=\"300\" />\n</p>\n\n<p align=\"middle\">\n  <img src=\"readme_figs/bkg.png\" width=\"300\" />\n  <img src=\"readme_figs/bkg_rms.png\" width=\"300\" />\n</p>\n\n### Extract centroid coordinates of star spots and do photometry\n\nUsing the DAOFIND algorithm to extract centroid coordinates and do photometry with Aperture Photometry method.\n\n```python\n>>> sources = data.find_source(phot='aperture',edgemask=True)\n>>> print(sources)\n>>> # <Source object: NUM = 25 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'APERTURE'>\n>>> # Output the centroid coordinates, brightness(sum of gray value within an aperture), and SNR of star spots.\n>>> print(sources.xy,sources.brightness,sources.snr)\n```\n\nUse the previously estimated centroid coordinates by DAOFIND algorithm as the prior value, fit the centroid coordinates and  do photometry with the PSF Photometry method.\n\n```python\n>>> sources = data.find_source(phot='psf',edgemask=True)\n>>> print(sources)\n>>> # <Source object: NUM = 25 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'PSF'>\n```\n\nUse the previously estimated centroid coordinates by DAOFIND algorithm as the prior value, fit the centroid coordinates and do photometry with the DAOPHOT Photometry method.\n\n```python\n>>> sources = data.find_source(phot='dao',edgemask=True)\n>>> print(sources)\n>>> # <Source object: NUM = 26 OFFSET = [511.5 511.5] EDGEMASK = True PHOT = 'DAO'>\n```\n\n### Show the extracted sources in image\n\n```python\n>>> sources.show()\n>>> #sources.show('figs/sources.png') # save image to a file\n```\n\n<p align=\"middle\">\n  <img src=\"readme_figs/centroids.png\" width=\"500\" />\n</p>\n\n## Change log\n\n- **0.2.0 \u2014 Nov 06, 2023**\n  \n  - Added implementation for automatically estimate the Full width at half maximum (FWHM) of the gaussian kernel for the image.\n  \n  - Added implementation for Point Spread Function(PSF)/Pixel Response Function(PRF) Photometry\n  \n  - Added implementation for DAOPHOT Photometry\n\n- **0.1.8 \u2014 Oct 22, 2023**\n  \n  - Added an information-rich string representation of the object and fixed some annotation typos.\n\n- **0.1.7 \u2014 Sep 23, 2023**\n  \n  - Fixed a warning caused by determining whether an array is empty in Python of version > 3.9.\n\n- **0.1.6 \u2014 Jun 29,  2023**\n  \n  - Added support for image file formats `.npy` and `numpy array` in function *AstroImage.read_image()*\n\n- **0.1.5 \u2014 May 14,  2023**\n  \n  - The class `Centriod` is *deprecated*, and the class `Source` is used instead\n  - Add method `.invariantfeatures()` to class `Source`, which calculates the triangle invariants and constructs a 2D Tree; and records the asterism indices for each triangle.\n\n- **0.1.0 \u2014 Apr 5,  2023**\n  \n  - The ***starextractor*** package was released.\n\n## Reference\n\n- [photutils](https://photutils.readthedocs.io/en/stable/index.html)\n- [Photometry Methods](http://srmastro.uvacreate.virginia.edu/astr313/lectures/photometry/photometry_methods.html)\n- [Astroalign](https://astroalign.quatrope.org/en/latest/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package for extracting stars and doing photometry from an astronomical image",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/lcx366/STAREXTRACTOR"
    },
    "split_keywords": [
        "source extraction",
        "photometry",
        "psf",
        "daofind",
        "fwhm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40d066fca7a8511d8d90348c177e36a14d9dcbefb2307490f5c64af3388d6925",
                "md5": "4289213aeb6691a01e127e046de4f015",
                "sha256": "86d1d5b5c1dc9ce32d9950245224c2098c37892991fc29471390a2df62afb9d4"
            },
            "downloads": -1,
            "filename": "starextractor-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4289213aeb6691a01e127e046de4f015",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 14721,
            "upload_time": "2023-11-06T01:38:05",
            "upload_time_iso_8601": "2023-11-06T01:38:05.580940Z",
            "url": "https://files.pythonhosted.org/packages/40/d0/66fca7a8511d8d90348c177e36a14d9dcbefb2307490f5c64af3388d6925/starextractor-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-06 01:38:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lcx366",
    "github_project": "STAREXTRACTOR",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "starextractor"
}
        
Elapsed time: 0.13838s