Skip to main content

Astronomical Data Science and Machine Learning Toolkit

Project description

spacekit

GitHub license CodeFactor Build Status Powered by STScI Badge Powered by Astropy DOI

Astronomical Data Science and Machine Learning Toolkit

ML Dashboard

Setup

Install with pip

# install extra deps for all non-pipeline tools (analysis, training, data viz)
$ pip install spacekit[x]

# for bare-minimum dependencies (STScI/SDP pipeline operations):
$ pip install spacekit

Install from source

$ git clone https://github.com/spacetelescope/spacekit
$ cd spacekit
$ pip install -e .[x]

Testing

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

# run all tests
$ pytest

# specify the `env` option to limit tests to a specific 'skope'
# env options: "svm", "hstcal", "jwstcal"
$ pytest --env svm -m svm
$ pytest --env hstcal -m cal
$ pytest --env jwstcal -m jwst

Pre-Trained Neural Nets

JWST Calibration Pipeline Resource Prediction (JWST)

JWST CAL Docs

  • Inference spacekit.skopes.jwst.cal.predict

From the command line:

$ python -m spacekit.skopes.jwst.cal.predict /path/to/inputs

# optionally specify a Program ID
$ python -m spacekit.skopes.jwst.cal.predict /path/to/inputs --pid 1076

From python:

> from spacekit.skopes.jwst.cal.predict import JwstCalPredict
> input_path = "/path/to/level1/exposures"
# optionally specify a Program ID `pid` (default is None)
> jcal = JwstCalPredict(input_path, pid=1076)
> jcal.run_inference()
# estimations for L3 product memory footprints (GB) are stored in a dict under the `predictions` attribute. Ground truth values (latest actual footprints recorded) are shown as inline comments.
> jcal.predictions
{
    'jw01076-o101-t1_nircam_clear-f212n': {'gbSize': 10.02}, # actual: 10.553384 
    'jw01076-o101-t1_nircam_clear-f210m': {'gbSize': 8.72},  # actual: 11.196752
    'jw01076-o101-t1_nircam_clear-f356w': {'gbSize': 7.38}, # actual: 6.905737
}
# NOTE: the target number "t1" is not intended to match actual target IDs used by the pipeline.

Single Visit Mosaic Alignment (HST)

SVM Docs

  • 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

HST Calibration Pipeline Resource Prediction (HST)

HST CAL Docs

  • Training spacekit.skopes.hst.cal.train
  • Inference spacekit.skopes.hst.cal.predict

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

K2 Docs

  • 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
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.

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

ROC

Eval

Preprocessing and Analysis Tools for Space Telescope Instrument Data

box

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

scatter

spacekit
└── spacekit
    └── analyzer
        └── compute.py
        └── explore.py
        └── scan.py
        └── track.py
    └── builder
        └── architect.py
        └── blueprints.py
        └── trained_networks
    └── dashboard
        └── cal
        └── svm
    └── datasets
        └── _base.py
        └── beam.py
        └── meta.py
    └── extractor
        └── load.py
        └── radio.py
        └── scrape.py
    └── generator
        └── augment.py
        └── draw.py
    └── logger
        └── log.py
    └── preprocessor
        └── encode.py
        └── ingest.py
        └── prep.py
        └── scrub.py
        └── transform.py
    └── skopes
        └── hst
            └── cal
                └── config.py
                └── predict.py
                └── train.py
                └── validate.py
            └── svm
                └── corrupt.py
                └── predict.py
                └── prep.py
                └── train.py
        └── jwst
            └── cal
                └── config.py
                └── predict.py
                └── train.py
        └── kepler
            └── light_curves.py
        
└── pyproject.toml
└── setup.cfg
└── tox.ini
└── tests
└── docker
└── docs
└── scripts
└── LICENSE
└── README.md
└── CONTRIBUTING.md
└── CODE_OF_CONDUCT.md
└── MANIFEST.in
└── bandit.yml
└── readthedocs.yaml
└── conftest.py
└── CHANGES.rst
                       
           /\    _       _                           _                      *  
/\_/\_____/  \__| |_____| |_________________________| |___________________*___
[===]    / /\ \ | |  _  |  _  | _  \/ __/ -__|  \| \_  _/ _  \ \_/ | * _/| | |
 \./    /_/  \_\|_|  ___|_| |_|__/\_\ \ \____|_|\__| \__/__/\_\___/|_|\_\|_|_|
                  | /             |___/        
                  |/   

Project details


Download files

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

Source Distribution

spacekit-1.1.4.tar.gz (7.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacekit-1.1.4-py3-none-any.whl (7.0 MB view details)

Uploaded Python 3

File details

Details for the file spacekit-1.1.4.tar.gz.

File metadata

  • Download URL: spacekit-1.1.4.tar.gz
  • Upload date:
  • Size: 7.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spacekit-1.1.4.tar.gz
Algorithm Hash digest
SHA256 d31b393734d6aea3e97fa1ff15dc4c3400941089a6bebc0fc76c8780f17ebd71
MD5 e041b213ed76075b1b30027a1d105187
BLAKE2b-256 149ec5d4acc96f1a7316a234abb280205282cde92a6dd0dfa3f4668a18f5a7ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacekit-1.1.4.tar.gz:

Publisher: publish_to_pypi.yml on spacetelescope/spacekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spacekit-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: spacekit-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spacekit-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 03bc33fc0b6808234e50905a05603e198d35f98fb0f67bea7ee1c7cdb0f30984
MD5 c7f3b1f9f1725e68b810cf314df9043b
BLAKE2b-256 42b7a1817a63ee701d70474207c6da08dfc5346d3b2e92da77f8568b8569ce78

See more details on using hashes here.

Provenance

The following attestation bundles were made for spacekit-1.1.4-py3-none-any.whl:

Publisher: publish_to_pypi.yml on spacetelescope/spacekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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