https://github.com/z-vig/reflspeckit
Spectral Data Cube Utility Functions
https://github.com/z-vig/reflspeckit
Last synced: 5 months ago
JSON representation
Spectral Data Cube Utility Functions
- Host: GitHub
- URL: https://github.com/z-vig/reflspeckit
- Owner: z-vig
- License: mit
- Created: 2025-09-01T14:38:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-11-17T22:20:13.000Z (7 months ago)
- Last Synced: 2025-12-26T01:51:30.422Z (6 months ago)
- Language: Python
- Size: 67.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π°οΈ **reflspeckit**
> βοΈ *A modern toolkit for working with any and all flavors of spectral data with a focus on applications for reflectance/emittance imaging spectroscopy*
---
[](https://pypi.org/project/reflspeckit/)
[](https://opensource.org/licenses/MIT)
[](https://pypi.org/project/reflspeckit/)
---
## π§ What is `reflspeckit`?
`reflspeckit` is a lightweight, modular Python package designed to make analysis of **spectral data cubes** simple, flexible, and fun. Whether you're exploring planetary hyperspectral data, performing band analysis, or building your own spectral pipelines β this toolkitβs got you covered.
---
## βοΈ Package Structure
`reflspeckit` provides two primary classes for the analysis of spectral data plus a third class specialized for large datasets:
>- π**Spec1D** - handles 1-dimensional, single spectrum data
>- π**Spec3D** - handles 3-dimensional spectral image cubes
>- ποΈ**StreamingSpec3D** - handles large image cubes using a streaming approach
Each class has equivalent methods, which are listed below:
---
## π§° Available Methods
| Method | Description |
|-------------|-------------|
| π©`outlier_removal`| Removes **anomalous data** in the spectral domain |
| π`noise_reduction` | Provides filtering methods to **smooth data** in the spectral domain |
|π«`continuum_removal`| Estimates and removes a **spectral contrinuum** from the data|
|πΌοΈ`make_m3_rgb (3D only)`| Creates a standard mafic mineral **RGB color-composite** image|
| π`fit_absorption` | Performs a **least squares polynomial** fit over a spectral region |
## π‘ Spectral Utilities
Various spectral utilities are available through the `reflspeckit.utils` subpackge.
| Module | Description |
|-------------|-------------|
| `get_nonzero`| If you have an empty 3D image array with the first two dimensions being pixels and the third dimension of size N, and each pixel is filled in to a certain depth, M <= N, this function returns a 2D image array that picks out all the pixel values at position M. |
|`rgb_composite`| Turns any three 2D arrays into a normalized rgb color composite image. The values of each band will be stretched from 0-255, with values above the 95th percentile being cut off to preserve the color stretch integrity.|
|`wvl_search`| Given an estimated wavelength values and a list of real wavelength vales, this module will return the real wavelength values that is closest to the estimate and the index at which this wavelength value is located within the actual wavelength array.|
*More utilities coming soon! As a work through my Ph.D., I will add all the various utility functions I write for spectral data processing here!*
---
## π **Quick Start**
```bash
pip install reflspeckit
```
```python
import reflspeckit as rsk
import matplotlib.pyplot as plt
# Loading in a single spectrum
my_spectrum = rsk.Spec1d(spectrum_array, wavelength_array, unit="nm")
my_spectrum.remove_outliers()
myspectrum.noise_reduction(method="box_filter", filter_width=5)
myspectrum.continuum_removal(method="double_line")
print(myspectrum.filtered) # Contains filtered spectrum
absorption_feature = myspectrum.fit_absorption(800, 1200, unit="nm")
print(absorption_feature.calculate_ibd()) # Returns integrated band depth.
# Loading in a spectral image cube
my_cube = rsk.Spec1d(cube_array, wavelength_array)
my_cube.remove_outliers()
my_cube.noise_reduction(method="box_filter", filter_width=5)
my_cube.continuum_removal(method="double_line")
print(myspectrum.cube) # Sequentially replaces myspectrum.cube to save memory.
rgb = my_cube.make_m3_rgb()
plt.imshow(rgb) # Shows RGB color-composite image.
```
## π Links
- **GitHub**: [https://github.com/z-vig/reflspeckit.git](https://github.com/z-vig/reflspeckit.git)
- **Docs**: (coming soon!)