Skip to content

Askaniy/AstroColor

Repository files navigation

AstroColor

A Python library for converting between photometric systems, true color calculation, and space image processing.

It performs synthetic photometry on low-resolution (5-nm wavelength grid step) spectra as well as spectral reconstruction from measurements in filters based on Tikhonov regularization.

Pre-alpha version! Do not use!

Installation

Use AstroColor in a virtual environment:

python3 -m venv .venv
.venv/bin/pip install git+https://github.com/Askaniy/AstroColor.git

Or add AstroColor to your uv project:

uv add git+https://github.com/Askaniy/AstroColor.git

Key features

  • Calculate synthetic photometry
import astrocolor as ac

spectrum = ac.Spectrum(
    wavelength_nm=[400, 500, 600, 700],
    spectral_dist=[1, 2, 2, 1]
)
v_band = ac.Filter.get('Generic_Bessell.V')
flux_value, flux_error = ac.observe(spectrum, v_band)
  • Create a filter system
johnson_system = ac.FilterSet.get(
    'Generic_Bessell.B',
    'Generic_Bessell.V',
    'Generic_Bessell.R'
)
photospectrum_BVR = ac.observe(spectrum, johnson_system)
  • Reconstruct photometry measurements into a smooth spectrum
reconstructed = ac.spectral_reconstruction(photospectrum_BVR, requested_wavelengths=[400, 700])
  • Convert measurements directly between photometric systems
sloan_system = ac.FilterSet.get('SLOAN_SDSS.g', 'SLOAN_SDSS.r')
photospectrum_gr = ac.observe(photospectrum_BVR, sloan_system)
  • Work on your wavelengths
custom_filter_set = ac.Filter.monochromatic(656.279) | ac.Filter.monochromatic(486.135)
  • Calculate true colors
color_xyz = ac.ColorPoint.from_spectral_data(ac.sun_CALSPEC)
color_system = ac.ColorSystem('sRGB', 'Illuminant E') # recommended
color_rgb = color_xyz.to_color_system(color_system)
color_rgb.maximize_brightness = True
color_html = color_rgb.to_html()
  • Model spectra
bb_3000K = ac.BlackBodyModel(3000).determine_at_wavelengths([400, 700])
  • Process images via spectral cube reconstruction
# coming soon after debugging
  • Error propagation with covariance matrices
# coming soon after debugging

History

TrueColorTools were created in 2020 to resolve disputes regarding the color of celestial bodies. It features a graphical user interface and a user-expandable spectral database. Over time, the core of the program became self-contained enough to be spun off into a library. The refactoring took place in 2026; it opens up a general astronomical application.

For developers

Use uv sync --group dev to set the environment and build the library. Use uv run pytest for testing. Use \dev folder for local experiments.

Any changes suggested by AI must be thoroughly reviewed by the person who generated them. The responsibility always lies with the person.

About

A Python library for converting between photometric systems, color calculation, and space image processing

Resources

License

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages