Metadata-Version: 2.1
Name: spacekit
Version: 0.3.1
Summary: Astronomical Data Science and Machine Learning Toolkit
Home-page: https://github.com/alphasentaurii/spacekit
Author: Ru Keïn
Author-email: rkein@stsci.edu
License: MIT
Project-URL: Source, https://github.com/alphasentaurii/spacekit
Project-URL: Documentation, https://spacekit.readthedocs.io
Project-URL: Tracker, https://github.com/alphasentaurii/spacekit/issues
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tensorflow (>=2.6.2)
Requires-Dist: astropy
Requires-Dist: astroquery
Requires-Dist: boto3
Requires-Dist: matplotlib (<4)
Requires-Dist: numpy (>=1.19)
Requires-Dist: pandas
Requires-Dist: plotly
Requires-Dist: progressbar
Requires-Dist: stsci.tools
Requires-Dist: sklearn
Requires-Dist: tables
Requires-Dist: tqdm
Requires-Dist: pydot
Requires-Dist: graphviz
Provides-Extra: dev
Requires-Dist: black ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest-profiling ; extra == 'dev'
Requires-Dist: tox ; extra == 'dev'
Requires-Dist: bandit ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx-astropy ; extra == 'docs'
Provides-Extra: test
Requires-Dist: pytest-astropy ; extra == 'test'

# spacekit

[![Powered by Astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org)
![GitHub repo size](https://img.shields.io/github/repo-size/alphasentaurii/spacekit)
![GitHub license](https://img.shields.io/github/license/alphasentaurii/spacekit?color=black)


Astronomical Data Science and Machine Learning Toolkit


![ML Dashboard](./previews/neural-network-graph.png)

## Setup

**Install with pip**

```bash
$ pip install spacekit
```

**Install from source**

```bash
$ git clone https://github.com/alphasentaurii/spacekit
$ cd spacekit
$ pip install -e .
```

*Testing*

See `tox.ini` for a list of test suite markers.

```bash
# run all tests
$ pytest

# some tests, like the `scan` module rely on the test `env` option 
$ pytest --env svm -m scan
$ pytest --env cal -m scan
```


### Pre-Trained Neural Nets

**Single Visit Mosaic Alignment (HST)**

[SVM Docs](https://spacekit.readthedocs.io/en/latest/skopes/hst/svm.html)

* Preprocessing: ``spacekit.skopes.hst.svm.prep``
* Predict Image Alignments: ``spacekit.skopes.hst.svm.predict``
* Train Ensemble Classifier: ``spacekit.skopes.hst.svm.train``
* Generate synthetic misalignments†: ``spacekit.skopes.hst.svm.corrupt``
        
*† requires Drizzlepac*
    
**Calibration Data Pipeline (HST)**

[CAL Docs](https://spacekit.readthedocs.io/en/latest/skopes/hst/cal.html)

* ``spacekit.skopes.hst.cal.train``


**Exoplanet Detection with time-series photometry (K2, TESS)**

[K2 Docs](https://spacekit.readthedocs.io/en/latest/skopes/kepler/light-curves.html)

* ``spacekit.skopes.kepler.light_curves``


### Customizable Model Building Classes

Build, train and experiment with multiple model iterations using the ``builder.architect.Builder`` classes

Example: Build and train an MLP and 3D CNN ensemble network

- continuous/encoded data for the multi-layer perceptron
- 3 RGB image "frames" per image input for the CNN
- Stack mixed inputs and use the outputs of MLP and CNN as inputs for the final ensemble model

```python
ens = BuilderEnsemble(XTR, YTR, XTS, YTS, name="svm_ensemble")
ens.build()
ens.batch_fit()

# Save Training Metrics
outputs = f"data/{date_timestamp}"
com = ComputeBinary(builder=ens, res_path=f"{outputs}/results/test")
com.calculate_results()
```
# Load and plot metrics to evaluate and compare model performance

Analyze and compare results across iterations from metrics saved using ``analyze.compute.Computer`` class objects. Almost all plots are made using plotly and are dynamic/interactive.

```python
# Load data and metrics
from spacekit.analyzer.scan import MegaScanner
res = MegaScanner(perimeter="data/2022-*-*-*")
res._scan_results()
```

![ROC](./previews/roc-auc.png)

![Eval](./previews/model-performance.png)


### Preprocessing and Analysis Tools for Space Telescope Instrument Data

![box](./previews/eda-box-plots.png)

```python
from spacekit.analyzer.explore import HstCalPlots
res.load_dataframe()
hst = HstCalPlots(res.df, group="instr")
hst.scatter
```

![scatter](./previews/eda-scatterplots.png)


```python
spacekit
└── spacekit
    └── analyzer
        └── compute.py
        └── explore.py
        └── scan.py
        └── track.py
    └── builder
        └── architect.py
        └── blueprints.py
    └── dashboard
    └── datasets
    └── extractor
        └── load.py
        └── radio.py
        └── scrape.py
    └── generator
        └── augment.py
        └── draw.py
    └── preprocessor
        └── encode.py
        └── scrub.py
        └── transform.py
    └── skopes
        └── hst
            └── cal
            └── svm
                └── corrupt.py
                └── predict.py
                └── prep.py
                └── train.py
        └── kepler
        └── trained_networks
└── setup.py
└── tests
└── docker
└── LICENSE
└── README.md
```


```bash
                       
           /\    _       _                           _                      *  
/\_/\_____/  \__| |_____| |_________________________| |___________________*___
[===]    / /\ \ | |  _  |  _  | _  \/ __/ -__|  \| \_  _/ _  \ \_/ | * _/| | |
 \./    /_/  \_\|_|  ___|_| |_|__/\_\ \ \____|_|\__| \__/__/\_\___/|_|\_\|_|_|
                  | /             |___/        
                  |/   

```

