astroPImage 0.1.3
Makes it easy to process and locate astrophotography images.
Requires Python: >=3.6

# AstroPImage

### A python package that makes processing astrophotography data a piece of PI.
## Installation
```
pip3 install astroPImage
```
## Example usage
```python
from astroPImage import image
from PIL import Image
import skimage

image = image.Image('/Volumes/HDD/in/light/180420_Li_00000041.fits') \
        .createBias('/Volumes/HDD/in/bias/') \
        .createDark('/Volumes/HDD/in/dark/') \
        .createFlat('/Volumes/HDD/in/flat/') \
        .process() \
        .filter() \
        .locate('YOUR_KEY_HERE')

Image.fromarray(skimage.img_as_ubyte(image.binary*255), mode='L').save('binary.png')
Image.fromarray(skimage.img_as_ubyte(image.histogramEqualize()*image.binary), mode='L').save('hist.png')
```
## Documentation

```python
image = Image(path, exposure='EXPOSURE')
```
Creates a new instance of `Image`

`path`: the path of the fits file to create this image with.\
`exposure`: the name of the header to use for the exposure value, defaults to `EXPOSURE`.
- - -
```python
Image.createBias(path)
```
Creates a master bias file from all fits files in the given directory

`path`: the path of the directory to use fits files from.
- - -
```python
Image.createDark(path, exposure='EXPOSURE')
```
Creates a master dark file from all fits files in the given directory. If  `createBias()` was called on before this method, the bias file will be applied to the dark files.

`path`: the path of the directory to use fits files from.\
`exposure`: the name of the header to use for the exposure value, defaults to `EXPOSURE`.
- - -
```python
Image.createFlat(path, exposure='EXPOSURE')
```
Creates a master dark file from all fits files in the given directory. If a `createBias()` or `createDark()` were called before this method, the bias and dark files will be applied to the flat files

`path`: the path of the directory to use fits files from.
`exposure`: the name of the header to use for the exposure value, defaults to `EXPOSURE`.</p>
- - -
```python
Image.process()
```
Applies `Image.bias`, `Image.dark` and `Image.flat` to `Image.image` if they exist.
- - -
```python
Image.filter()
```
Filters almost all noise out of both `Image.binary` and `Image.processed`. Calls `Image.process()` if `Image.processed` does not exist yet.
- - -
```python
Image.histogramEqualize(image=Image.filtered | image.processed | Image.image, kernel_size=16, clip_limit=0.05, bins=256)
```
Calls scikit-image's `exposure.equalize_adapthist()` function with default values better suited for astrophotography.

`image`: the image you want to equalize, defaults to `Image.filtered`, then `image.processed`, then `Image.image`.
(copied from scikit-image docs):
`kernel_size`: Defines the shape of contextual regions used in the algorithm. If iterable is passed, it must have the same number of elements as image.ndim (without color channel). If integer, it is broadcasted to each image dimension. Defaults to `16` for each dimension.
`clip_limit`: Clipping limit, normalized between 0 and 1 (higher values give more contrast). Defaults to `0.05`.
`bins`: Number of gray bins for histogram (“data range”). Defaults to `256`.
- - -
```python
Image.locate(key, callback=None)
```
Tries to find out what part of the sky the image contains, using nova.astrometry.net.

`key`: your API key for nova.astrometry.net\
`callback`: a function to call after the locating process has finished.