Skip to content

Conversation

@jeipollack
Copy link
Contributor

@jeipollack jeipollack commented May 13, 2025

This PR adds inference capabilities to the WaveDiff / WF-PSF framework, allowing the user to generate broadband (polychromatic) PSFs from a trained model, given a list of positions and SEDs.

It had a refactor PR merged into it in order to carry on with the development which is why it contains >100 commits (unfortunately and not a practice that will be repeated).

Closes #159 (Validation runs described there)

Key Changes

  • Introduced psf_inference.py and associated test_inference packages for PSF inference workflows
  • Refactored TFPhysicalPolychromatic and related modules to separate training vs. inference behaviour
  • Added PSFInferenceEngine class to centralise training, simulation, metrics, and inference logic
  • Moved model weights loading to psf_model_loader.py
  • Centralised PSF data extraction in data_handler
  • Updated configuration handling for inference (inference_config.yaml)
  • Updated documentation (small) to include inference package
  • Core Refactoring from PR 165 refactor tfphysicalpolychromatic to cleanly separate training vs inference behaviour #166:
    • New run_type attribute: Added to data_handler supporting training, simulation, metrics, and inference modes
    • ZernikeInputsFactory class: New factory class that builds ZernikeInputs instances based on the specified run type
    • Enhanced ZernikeInputs data class: Now intelligently assembles Zernike contribution lists based on run_type and available data (including priors and source positions for CCD misalignment corrections)
    • Hybrid loading pattern: Refactored to use eager loading in constructors combined with lazy-loading via property decorators, reducing constructor overhead and improving modularity
    • Code organization: Improved module structure including new tf_utils.py module in the psf_models sub-package
    • Bug fix: Fixed incorrect argument name in DataHandler class that prevented training dataset images from being converted to TensorFlow data type as expected
    • Helper Methods: Added several helper methods to assist with preparing datasets and ensure data type conversion is performed as expected
    • Deprecations: Removed get_obs_positions as it was no longer needed
  • Bug fix: Fix logger formatting for relative RMSE metrics in metrics.py (values were not being displayed)
  • Changelog Fragment added describing updates

Testing

  • CI tests pass successfully
  • Unit tests cover:
    • Loading trained models and other aspects of inference setup
    • Generating PSFs for multiple positions/SEDs and error handling
    • Consistency of outputs and tensor handling
    • Clearing cached values
  • Verified backward compatibility with existing develop code
  • Confirmed inferred PSFs from test datasets match expected results with high accuracy

@jeipollack jeipollack self-assigned this May 13, 2025
@jeipollack jeipollack added the enhancement New feature or request label May 13, 2025
@jeipollack jeipollack changed the title Feature/159 psf output from trained model Draft:Feature/159 psf output from trained model May 13, 2025
@jeipollack jeipollack changed the base branch from develop to case_study_psf_decontamination July 3, 2025 07:21
Base automatically changed from case_study_psf_decontamination to develop August 5, 2025 10:32
@jeipollack jeipollack force-pushed the feature/159-psf-output-from-trained-model branch from f15c0f2 to 89da2e0 Compare August 5, 2025 13:39
@jeipollack jeipollack changed the title Draft:Feature/159 psf output from trained model Feature/159 psf output from trained model Nov 12, 2025
@jeipollack jeipollack requested a review from sfarrens November 12, 2025 10:39
@jeipollack jeipollack added the documentation Improvements or additions to documentation label Nov 20, 2025
@jeipollack jeipollack changed the title Feature/159 psf output from trained model Draft: Feature/159 psf output from trained model Nov 20, 2025
@jeipollack jeipollack force-pushed the feature/159-psf-output-from-trained-model branch 2 times, most recently from c199e05 to 9f64df3 Compare December 8, 2025 12:21
Jennifer Pollack added 13 commits January 22, 2026 16:13
…ean up submodule docs, update conf.py, and update pyproject.toml version
- Removed old auto-generated wf_psf.rst from _autosummary
- Updated toc.rst (fixed tab issues, reference api.rst)
- Added api.rst with :recursive: directive and wf_psf.run entrypoint
- Refined __init__.py docstrings for all subpackages for clarity and consistency
- Updated module-level docstrings (purpose, authors, TensorFlow notes, etc.)
- Shorten sections to make developer-friendly
- Added new structure for each section: Purppose, Key Fields, Notes, General Notes, etc, where applicable
- Partial completion - new PR is required to verify optional versus required settings
- Added cross-references between config sections
- Clarified required fields for ground_truth_model.model_params
- Updated General Notes and reorganized section numbering
- Improved examples and directory structures
- Fixed build warnings due to missing anchors and code block lexing
…odels and tf_modules, add/rm modules, update import statements and tests
@jeipollack jeipollack force-pushed the feature/159-psf-output-from-trained-model branch from e995e7c to 6b2a1fe Compare January 22, 2026 15:30
Jennifer Pollack added 2 commits January 23, 2026 13:58
Rebase dropped commits that removed weights_path from the metrics interface.
Cleaning up remaining references in docstrings and tests.
Use f-strings instead of %-formatting to properly display percent symbols
in metric output.
@jeipollack jeipollack changed the title Draft: Feature/159 psf output from trained model Feature/159 psf output from trained model Jan 26, 2026
@jeipollack
Copy link
Contributor Author

it would be very ideal to squash and merge this commit in order to simplify rebasing the other branches.

@jeipollack jeipollack removed the request for review from sfarrens January 26, 2026 12:12
@jeipollack jeipollack changed the title Feature/159 psf output from trained model DRAFT: Feature/159 psf output from trained model Jan 26, 2026
@jeipollack jeipollack changed the title DRAFT: Feature/159 psf output from trained model Feature/159 psf output from trained model Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

Add function to output PSF for shape measurement given a trained model

3 participants