Metadata-Version: 2.4
Name: astrocolor
Version: 0.1.0
Summary: Library to perform spectral reconstruction, calculate synthetic photometry and colors.
Author: Askaniy Anpilogov
Author-email: Askaniy Anpilogov <aaskaniy@gmail.com>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: numpy>=2.4.4
Requires-Dist: scipy>=1.17.1
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/Askaniy/AstroColor
Project-URL: Repository, https://github.com/Askaniy/AstroColor
Project-URL: Issues, https://github.com/Askaniy/AstroColor/issues
Project-URL: Changelog, https://github.com/Askaniy/AstroColor/releases
Description-Content-Type: text/markdown

# 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:
```sh
python3 -m venv .venv
.venv/bin/pip install git+https://github.com/Askaniy/AstroColor.git
```

Or add AstroColor to your [uv](https://github.com/astral-sh/uv) project:
```sh
uv add git+https://github.com/Askaniy/AstroColor.git
```


## Key features

- Calculate synthetic photometry
```py
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
```py
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
```py
reconstructed = ac.spectral_reconstruction(photospectrum_BVR, requested_wavelengths=[400, 700])
```

- Convert measurements directly between photometric systems
```py
sloan_system = ac.FilterSet.get('SLOAN_SDSS.g', 'SLOAN_SDSS.r')
photospectrum_gr = ac.observe(photospectrum_BVR, sloan_system)
```

- Work on your wavelengths
```py
custom_filter_set = ac.Filter.monochromatic(656.279) | ac.Filter.monochromatic(486.135)
```

- Calculate true colors
```py
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
```py
bb_3000K = ac.BlackBodyModel(3000).determine_at_wavelengths([400, 700])
```

- Process images via spectral cube reconstruction
```py
# coming soon after debugging
```

- Error propagation with covariance matrices
```py
# coming soon after debugging
```



## History

[TrueColorTools](https://github.com/Askaniy/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.
