Metadata-Version: 2.4
Name: prism-imageproc
Version: 0.1.0rc0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Rust
Requires-Dist: numpy>=1.26
Requires-Dist: xarray>=2024.1 ; extra == 'convert'
Requires-Dist: netcdf4>=1.6 ; extra == 'convert'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: xarray ; extra == 'test'
Requires-Dist: netcdf4 ; extra == 'test'
Requires-Dist: xarray>=2024.1 ; extra == 'xarray'
Provides-Extra: convert
Provides-Extra: test
Provides-Extra: xarray
Summary: Image processing for PrISM instruments
License: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# prism-imageproc

[![DOI](https://zenodo.org/badge/1254713531.svg)](https://zenodo.org/badge/latestdoi/1254713531)

`prism-imageproc` provides tools for processing images
from instruments modeled using [SpectroForge](https://github.com/prism-spectra/SpectroForge). The library includes functions
applying image transformations to map detector images onto the focal plane of the instrument, as well as
remove diffraction slit curvature from the images. This library is designed to be used stand-alone, using
the instrument configuration files generated by SpectroForge. This library is also used internally by
SpectroForge.

# Installation

You can install the library using pip:

```bash
pip install prism-imageproc
```

# Usage

The library is used in the following way:

```python
# Import the library
from prism_imageproc import ImageStraightener
import matplotlib.pyplot as plt # For plotting the straightened images

# Create a straightener object using the instrument configuration file
straightener = ImageStraightener.from_instrument_config('path/to/instrument.prcm')
# Get version of the library that produced this
lib_version = straightener.lib_version
# Get hash of the instrument model that produced this
instr_version = straightener.instr_version
# Load an image and map it onto the mosaic grid
image_array = ...  # Load your image as a 2D NumPy array
mapped_image = straightener.load_image(image_array)
# Straighten the image by removing slit curvature
straightened_images = mapped_image.straighten_image()
# The result is a dictionary of straightened images, one for each window. You can access them like this:
for window_name, straightened_image in straightened_images.items():
    print(f"Straightened image for window {window_name}:")
    straightened_image.plot()  # Render the straightened image
    plt.show() # Display the plot
```

