Skip to content

lanemeier7/crispy

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

420 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌟 CRISPY

The Coronagraph Rapid Imaging Spectrograph in Python

Python License Tests

CRISPY simulates the WFIRST (now Roman Space Telescope) Integral Field Spectrograph with high-fidelity modeling of optical effects, detector characteristics, and data reduction pipelines.


🎯 Features

  • πŸ”­ High-Fidelity IFS Simulation: Complete modeling of WFIRST/Roman Space Telescope IFS
  • 🌈 Polychromatic Processing: Full spectral cube generation and analysis
  • πŸŽ›οΈ Multiple Configurations: Support for WFIRST and PISCES instruments
  • πŸ§ͺ Comprehensive Testing: Modern pytest framework with emoji output
  • πŸ“Š Data Reduction Tools: Optimal extraction, wavelength calibration, and more
  • 🐍 Python 3.8+: Modernized for current Python standards

πŸš€ Quick Start

Prerequisites

Installation

🐍 Option 1: Using Conda/Mamba Environment (Recommended)

# Clone the repository
git clone https://github.com/mjrfringes/crispy.git
cd crispy

# Create and activate the conda environment (use 'mamba' instead of 'conda' if preferred)
conda env create -f environment.yml
conda activate crispy

# Install in development mode
pip install -e .

# Test the installation πŸ§ͺ
python test_environment.py

⚑ Option 2: Direct Installation

# Clone and install directly
git clone https://github.com/mjrfringes/crispy.git
cd crispy
python setup.py install

πŸ§ͺ Running Tests

CRISPY includes a modern pytest framework with beautiful emoji output:

Quick Test Commands

# Always activate environment first
conda activate crispy

# Run all working tests βœ…
python run_tests.py --working

# Run unit tests only πŸ§ͺ  
python run_tests.py --unit

# Run integration tests πŸš€
python run_tests.py --integration

# Run fast tests (skip slow ones) ⚑
python run_tests.py --fast

# Run with coverage report πŸ“Š
python run_tests.py --coverage

# Get help with all options
python run_tests.py --help

Example Output

πŸš€ Starting CRISPY Test Suite
==================================================
tests/unit/test_core_functionality.py βœ….βœ…βœ…βœ….βœ…βœ… 
tests/unit/test_working_functions.py βœ….βœ…βœ…βœ….βœ…βœ…
==================================================
πŸ“Š Test Session Complete!
πŸŽ‰ All tests passed!

πŸ“– Usage Examples

Basic IFS Simulation

import numpy as np
from crispy.configs.WFIRST import params
from crispy.IFS import polychromeIFS

# Load WFIRST parameters
par = params.Params()

# Create input cube (wavelength, x, y)
wavelengths = np.linspace(600, 900, 10)  # nm
input_cube = np.ones((10, 64, 64))

# Run IFS simulation
detector_image = polychromeIFS(par, wavelengths, input_cube)

Working with Different Instruments

# WFIRST configuration
from crispy.configs.WFIRST import params as wfirst_params
wfirst_par = wfirst_params.Params()

# PISCES configuration  
from crispy.configs.PISCES import params as pisces_params
pisces_par = pisces_params.Params()

print(f"WFIRST R = {wfirst_par.R}")  # R = 50
print(f"PISCES R = {pisces_par.R}")  # R = 70

Optimal Extraction

from crispy.tools.image import Image
from crispy.unitTests import testOptExt

# Load your detector image
detector_data = np.random.rand(128, 128) * 1000
image = Image(data=detector_data)

# Perform optimal extraction
spectrum, variance = testOptExt(par, image, lensX=0, lensY=0)

Wavelength Solution Files

The detector mapping stored in lamsol.dat is documented in the Sphinx docs as Wavelength Solution Files. That page explains the column layout, coefficient ordering, lenslet index convention, and the recommended APIs for converting a given lenslet index and wavelength into detector (x, y) coordinates.


πŸ“ Project Structure

crispy/
β”œβ”€β”€ crispy/                 # Main package
β”‚   β”œβ”€β”€ WFIRST/            # WFIRST instrument parameters
β”‚   β”œβ”€β”€ PISCES/            # PISCES instrument parameters  
β”‚   β”œβ”€β”€ tools/             # Analysis and processing tools
β”‚   └── *.py               # Core modules
β”œβ”€β”€ tests/                 # Modern pytest test suite
β”‚   β”œβ”€β”€ unit/              # Unit tests
β”‚   β”œβ”€β”€ integration/       # Integration tests
β”‚   └── conftest.py        # Test fixtures
β”œβ”€β”€ docs/                  # Documentation and notebooks
β”œβ”€β”€ environment.yml        # Conda environment
β”œβ”€β”€ setup.py              # Package setup
β”œβ”€β”€ pytest.ini           # pytest configuration  
└── run_tests.py         # Test runner with emoji support

πŸ› οΈ Development

Running Notebooks

# Start Jupyter in the crispy environment
conda activate crispy
jupyter notebook

# Navigate to docs/source/notebooks/ for examples

Building Documentation

cd docs
make html

Adding Tests

Tests are organized by category with descriptive markers:

@pytest.mark.working      # βœ… Known working tests
@pytest.mark.experimental # ⚠️  Experimental features  
@pytest.mark.slow         # 🐌 Long-running tests
@pytest.mark.requires_data # πŸ“ Needs reference data

🌐 Documentation

  • πŸ“š Full Documentation: https://mjrfringes.github.io/crispy/index.html
  • 🌈 Wavelength Solution Format: build the docs locally and open the Wavelength Solution Files page for lamsol.dat details
  • πŸ”§ Developer Guide: See CLAUDE.md for development workflow
  • πŸ““ Example Notebooks: Located in docs/source/notebooks/

πŸ‘₯ Contributors

Original Development Team:

  • Maxime Rizzo
  • Tim Brandt
  • Neil Zimmerman
  • Tyler Groff
  • Prabal Saxena
  • Mike McElwain
  • Avi Mandell

Institution: NASA Goddard Space Flight Center


πŸ“œ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.


πŸ› Issues & Support


πŸŽ‰ Getting Started

Ready to simulate some spectra?

  1. ⬇️ Install: Follow the installation instructions above
  2. πŸ§ͺ Test: Run python run_tests.py --working to verify everything works
  3. πŸ“š Learn: Check out the notebooks in docs/source/notebooks/
  4. πŸš€ Simulate: Start with the basic examples above

Happy Simulating! βœ¨πŸ”­

About

Simulates the WFIRST IFS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 93.9%
  • Jupyter Notebook 6.0%
  • Shell 0.1%