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.

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

Citation

If you use colorsynth in your research, please cite it. The citation metadata is kept in CITATION.cff, which the "Cite this repository" button on GitHub can export as BibTeX or APA. Please include the version of colorsynth that you used, which is given by importlib.metadata.version("colorsynth").

@software{colorsynth,
  author = {Smart, Roy T.},
  title = {colorsynth},
  version = {X.Y.Z},
  url = {https://github.com/sun-data/colorsynth},
}

Metadata

Release files for colorsynth 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorsynth 1.1.2
File Size Uploaded
colorsynth-1.1.2.tar.gz 35.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for colorsynth 1.1.2
File Interpreter ABI Platform
colorsynth-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 60.7 kB

Release files / colorsynth-1.1.2.tar.gz

Download URL colorsynth-1.1.2.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a4ec347b0c0422c1e850f10f0c85d9befef1c6b4313ff177f0f2d88cbb0b303c
BLAKE2b-256 checksum
How to use checksums
b2d07e83b8b72cce4438b85229441a1783fc6cc6f886e414c3694d14ba0cc376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / colorsynth-1.1.2-py3-none-any.whl

Download URL colorsynth-1.1.2-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7070dff49be5563ea74d61509a26ea2c8d2bd7069ee8daf4da813db97f1a85cb
BLAKE2b-256 checksum
How to use checksums
8df1d07b1797b56cc05c0f10d9b08f26ba7c8f67fd75e6a1278590a4af1558f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page