Skip to main content

A Library For Generating Morphological Semantic Segmentation Maps of Astronomical Images

Project description

https://cdn.jsdelivr.net/gh/morpheus-project/morpheus/morpheus.svg
https://travis-ci.com/morpheus-project/morpheus.svg?branch=master https://codecov.io/gh/morpheus-project/morpheus/branch/master/graph/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg https://img.shields.io/badge/python-3.6-blue.svg https://readthedocs.org/projects/morpheus-astro/badge/?version=latest

Morpheus is a neural network model used to generate pixel level morphological classifications for astronomical sources. This model can be used to generate segmentation maps or to inform other photometric measurements with granular morphological information.

Installation

Morpheus is implemented using Tensorflow. It listed in the dependecies for the package. If you want to use an accelerated version of Tensorflow, for example, to take advantage of GPU acceleration, then be sure to install it before you install Morpheus.

pip install morpheus-astro

Usage

The main way to interact with Morpheus is by using the morpheus.classifier.Classifier class. Using this class you can classify astronomical images in 2 ways:

  1. Using classify_arrays to classify numpy arrays.

from morpheus.classifier import Classifier
from morpheus.data import example

h, j, v, z = example.get_sample()
morphs = Classifier.classify_arrays(h=h, j=j, v=v, z=z)

The output that is returned is a dictionary where the keys are the morphological classes: spheroid, disk, irregular, point source, and background and the values are the corresponding numpy arrays.

  1. Using classify_files to classify FITS files:

from morpheus.classifier import Classifier
from morpheus.data import example

# this saves the sample numpy arrays as FITS files in 'out_dir'
example.get_sample(out_dir='.')
h, j, v, z = [f'{band}.fits' for band in 'hjvz']

morphs = Classifier.classify_files(h=h, j=j, v=v, z=z)

Using FITS files can be useful for classifying files that are too large to fit into memory. If an image is too large to fit into memory, then specify the out_dir argument and the outputs will be saved there rather than returned.

from morpheus.classifier import Classifier
from morpheus.data import example

# this saves the sample numpy arrays as fits files in 'out_dir'
example.get_sample(out_dir='.')
h, j, v, z = [f'{band}.fits' for band in 'hjvz']

Classifier.classify_files(h=h, j=j, v=v, z=z, out_dir='.')

If you’re classifying a large image and have multiple NVIDIA GPUs on the same machine available the image can be classified in parallel using the gpus argument. The image split evenly along the first dimension and then handed off to subprocess to classify the subset of the image, after which, the image is stitched back together.

from morpheus.classifier import Classifier

# h, j, v, and, z are strings that point to a large image

# gpus should be an integer list containing the GPU ids for the GPUs that
# you want to use to classify the images. You can get these values by
# calling 'nvidia-smi'
gpus = [0, 1]

Classifier.classify_files(h=h, j=j, v=v, z=z, out_dir='.', gpus=gpus)

Documentation

https://morpheus-astro.readthedocs.io/

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

morpheus-astro-0.1.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

morpheus_astro-0.1.0-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file morpheus-astro-0.1.0.tar.gz.

File metadata

  • Download URL: morpheus-astro-0.1.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.7

File hashes

Hashes for morpheus-astro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cea1bbb78e3aaccbcab7ebfe1d5952bfc891b465c5cf80713bc85ee3dfba01d
MD5 3c899b2975f96e6dbf843fae5fcf17e7
BLAKE2b-256 784e5142329064d23a75bb50f8f42881d5c9c356dd52dffbacb8459da7da452b

See more details on using hashes here.

File details

Details for the file morpheus_astro-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: morpheus_astro-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.7

File hashes

Hashes for morpheus_astro-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16000d7479d0b6f55815fb2b0c65a3f0c92034cb9aac3d13576a5c9045b0ff3e
MD5 5f0ac8a2590925b52749f85cb03a1d1e
BLAKE2b-256 cfec498e536bbbf79f66693a07f0aea7c4ab19970a123ba950300c7e6b451f30

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