colorsynth
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()
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e93e6047689ef28e937abf50dcdf36b57cc091bc4717d2ca559053144b00b6a5
|
|
| MD5 |
0296816126cfa2eb839b1f33e2d80f32
|
|
| BLAKE2b-256 |
ee72f3108e022472aaf96f8dfbc607e713ed3e0222efdb2dca9af4ce5dcf44a8
|
Provenance
The following attestation bundles were made for colorsynth-1.1.0.tar.gz:
Publisher:
publish.yml on sun-data/colorsynth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colorsynth-1.1.0.tar.gz -
Subject digest:
e93e6047689ef28e937abf50dcdf36b57cc091bc4717d2ca559053144b00b6a5 - Sigstore transparency entry: 2523562380
- Sigstore integration time:
-
Permalink:
sun-data/colorsynth@c94355b22b6b99dd05538997b9168a6a615ec724 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/sun-data
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c94355b22b6b99dd05538997b9168a6a615ec724 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4ea137683c62cf75f9133effc85e6d641a2608b93634c15b25d46bf59c28a15
|
|
| MD5 |
9097eefc598a5135b773da458966c5d9
|
|
| BLAKE2b-256 |
42cd4e23c0f42f86556e3cf72dd050cc774ad21ab24074716d2e7845f3817fae
|
Provenance
The following attestation bundles were made for colorsynth-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on sun-data/colorsynth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colorsynth-1.1.0-py3-none-any.whl -
Subject digest:
c4ea137683c62cf75f9133effc85e6d641a2608b93634c15b25d46bf59c28a15 - Sigstore transparency entry: 2523562473
- Sigstore integration time:
-
Permalink:
sun-data/colorsynth@c94355b22b6b99dd05538997b9168a6a615ec724 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/sun-data
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c94355b22b6b99dd05538997b9168a6a615ec724 -
Trigger Event:
release
-
Statement type: