Skip to main content

colorsynth

tests codecov Black Documentation Status PyPI version

A Python library for creating false-color images from spectral cubes: 3D Numpy arrays with two spatial axes and one spectral axis.

colorsynth collapses the spectral axis into red, green, and blue channels by mapping the spectrum into the human visible range and weighting it by the CIE 1931 color-matching functions. The shape of the spectrum controls the hue of each pixel, and the total intensity controls its brightness, so features like Doppler shifts are visible directly in the image.

Installation

colorsynth is available on the Python Package Index and can be installed using pip:

pip install colorsynth

Quickstart

Define a spectral cube containing a Gaussian emission line at every point, with a center wavelength that increases from left to right and a total intensity that increases from top to bottom, and collapse it into an RGB image using colorsynth.rgb():

import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
import colorsynth

# Define a wavelength grid for the spectral axis
wavelength = np.linspace(400, 700, num=61) * u.nm

# Define a spatial grid
x = np.linspace(0, 1, num=101)[:, np.newaxis, np.newaxis]
y = np.linspace(0, 1, num=101)[np.newaxis, :, np.newaxis]

# Define a spectral cube containing a Gaussian emission line at every point
center = 420 * u.nm + (680 - 420) * u.nm * y
width = 15 * u.nm
spd = x * np.exp(-np.square((wavelength - center) / width))

# Collapse the wavelength axis of the cube into RGB channels
rgb = colorsynth.rgb(spd, wavelength, axis=~0, spd_min=0, spd_max=1)

# Display the result as a false-color image
plt.imshow(rgb)
plt.show()

A synthetic spectral cube colorized with colorsynth.rgb()

The center wavelength of the emission line appears as hue, and its total intensity appears as brightness.

Gallery

An Si IV 1403 A spectroheliogram captured by the Interface Region Imaging Spectrograph and colorized using colorsynth.rgb(). The code to create this image can be found in the documentation.

IRIS spectroheliogram

Download files

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

Source Distribution

colorsynth-1.1.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

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

colorsynth-1.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file colorsynth-1.1.0.tar.gz.

File metadata

  • Download URL: colorsynth-1.1.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for colorsynth-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e93e6047689ef28e937abf50dcdf36b57cc091bc4717d2ca559053144b00b6a5
MD5 0296816126cfa2eb839b1f33e2d80f32
BLAKE2b-256 ee72f3108e022472aaf96f8dfbc607e713ed3e0222efdb2dca9af4ce5dcf44a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for colorsynth-1.1.0.tar.gz:

Publisher: publish.yml on sun-data/colorsynth

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

File details

Details for the file colorsynth-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: colorsynth-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for colorsynth-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4ea137683c62cf75f9133effc85e6d641a2608b93634c15b25d46bf59c28a15
MD5 9097eefc598a5135b773da458966c5d9
BLAKE2b-256 42cd4e23c0f42f86556e3cf72dd050cc774ad21ab24074716d2e7845f3817fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for colorsynth-1.1.0-py3-none-any.whl:

Publisher: publish.yml on sun-data/colorsynth

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

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.1

2 files

1.0.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

0.0.0

2 files

Supported by

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