Dobyโ€™s ESA Pyxel Logs

๐Ÿš€ Pyxel Contribution: Load General Image Function

Summary: Introduces the load_general_image function to the Pyxel framework, extending photon collection models.

URL: https://gitlab.com/esa/pyxel/-/merge_requests/1105

Date: 2025-10-22

โœจ Overview

This contribution adds the load_general_image function to the Pyxel framework. It expands photon collection by allowing Pyxel to load image files such as PNG, JPG, and FITS as detector input. This makes the simulation process more flexible and accessible for various data sources.

Merge Request: MR #1105


๐Ÿ”ง Technical Details

File location: pyxel/models/photon_collection/load_image.py
New function: load_general_image

  • Supports multiple image formats (FITS, PNG, JPG, etc.)
  • Handles cropping, alignment, and positioning
  • Converts data to photons using bit resolution and detector gain scaling
  • Returns either numpy arrays or xarray objects
  • Integrates detector header metadata when FITS headers are available

๐Ÿงช Testing

A new test file was added at tests/models/photon_collection/test_load_general_image.py

Covers:

  • โœ… PNG and FITS image loading
  • โœ… Photon conversion with bit resolution
  • โœ… Detector integration behavior

To run:

pytest -k test_load_general_image -v

๐Ÿ“Š YAML Usage Example

pipeline:
  photon_collection:
    - name: load_general_image
      func: pyxel.models.photon_collection.load_general_image
      enabled: true
      arguments:
        image_file: "tests/data/andromeda.png"
        convert_to_photons: true
        bit_resolution: 16
        return_as: "xarray"

Run with:

pyxel run test_general_image.yaml

๐Ÿ“ Integration Notes

  • Updated the module initializer to export load_general_image
  • Kept load_image for backward compatibility
  • Contribution uploaded to branch: feature/load-general-image

๐Ÿš€ Future Work

  • Add TIFF and BMP support
  • Validate large image sizes
  • Improve memory handling for high-resolution detectors

๐Ÿฆ• Authored by: Doby Baxter
๐ŸŒŒ Contribution for: ESA Pyxel Project

โš™๏ธ Config Lab