Skip to main content

Reproducing SAOImageDS9 Colormap in Python

SAOImageDS9 is an image display and visualization tool for astronomical data, which can be used for fast image processing and inspection. In DS9, we can drag the mouse on the image viewer to manipulate the colormap and then visualize data effectively and quickly. Unlike the DS9, color normalization and stretch in Python should be set manually.

Here we take notes about how to reproduce the colormap of DS9 in Python, supposing that you have already tuned the colormap parameters in DS9.

Installation

pip install ds9_norm

Usage

from astromy_ds9 import ds9norm


import astropy
import matplotlib.pyplot as plt
data = astropy.io.fits.getdata('https://github.com/glue-viz/ds9norm/raw/master/m51.fits')

norm = ds9_norm(vmin=3053.38, vmax=13513.9, bias=0.581921, contrast=0.890152, stretch='sqrt')
plt.imshow(data, norm=norm, cmap='gray', origin='lower', interpolation='None')

There are 5 input parameters for ds9_norm function.

  • vmin and vmax: you can find the values in Scale -> Scale Parameters -> Below the histogram, Low is vmin and High is vmax.
  • bias and contrast: you can find the values in Color -> Color Parameters
  • stretch: you can find it in Scale -> see which one is marked with a check mark. Allowed values are 'linear' | 'log' | 'sqrt' | 'power' | 'squared' | 'asinh' | 'sinh'.
help

Check example code in test and example.

Methodology

Please check the methodology in doc. Also see ds9norm for reference.

Citation

If you find this useful, please acknowledge.

Metadata

Release files for astromy-ds9 0.0.1

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

Source distribution (sdist)

Source distribution for astromy-ds9 0.0.1
File Size Uploaded Provenance Actions
astromy_ds9-0.0.1.tar.gz 5.5 kB Without provenance Details for astromy_ds9-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for astromy-ds9 0.0.1
File Interpreter ABI Platform Actions
astromy_ds9-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for astromy_ds9-0.0.1-py2.py3-none-any.whl

Total release size: 10.4 kB

Release files / astromy_ds9-0.0.1.tar.gz

Download URL astromy_ds9-0.0.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c4b5411f4162aa60fcee5b9a26f6a82c1a7e6e8d49c46dc5995fcfe6b6071643
BLAKE2b-256 checksum
How to use checksums
c947b1ccd9c4c53940d9875a8192425d3fdad73b7fec64ec9fdab7bc999c332b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / astromy_ds9-0.0.1-py2.py3-none-any.whl

Download URL astromy_ds9-0.0.1-py2.py3-none-any.whl
Size 4.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8343732702427adfab4e076045a8b41a146a4203f0431736cf75c12c773fbcbf
BLAKE2b-256 checksum
How to use checksums
8ed6b94613c3291340d0a9e51b18bb515a7ebf0b1373748b2d955bf9a8f68b97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for astromy-ds9 0.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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