Skip to content

Commit

Permalink
Merge pull request #83 from CosmoStat/dummy_main
Browse files Browse the repository at this point in the history
Pre-release v2.0.0
  • Loading branch information
sfarrens authored Nov 16, 2023
2 parents 899a6e3 + 0dbb7f9 commit 146725f
Show file tree
Hide file tree
Showing 419 changed files with 24,590 additions and 27,122 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CD

on:
push:
branches:
- main


jobs:
docs:
name: Deploy API documentation
runs-on: [ubuntu-latest]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.10.5
uses: actions/setup-python@v3
with:
python-version: "3.10.5"

- name: Check Python Version
run: python --version

- name: Install dependencies
run: |
python -m pip install ".[docs]"
- name: Build API documentation
run: |
sphinx-apidoc -Mfeo docs/source src/wf_psf
sphinx-build docs/source docs/build
- name: Deploy API documentation
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI

on:
pull_request:
branches:
- main


jobs:
test-full:
runs-on: [ubuntu-latest]

steps:
- name:
uses: actions/checkout@v3

- name: Set up Python 3.10.5
uses: actions/setup-python@v3
with:
python-version: "3.10.5"

- name: Install dependencies
run: python -m pip install ".[test]"

- name: Test with pytest
run: python -m pytest
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/

# Remove method comparison data
method-comparison/compatible-datasets/*
tf_notebooks

# Log files from slurm
*.err
Expand Down Expand Up @@ -61,11 +62,13 @@ htmlcov/
.coverage.*
.cache
nosetests.xml
pytest.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
src/wf_psf/pytest.xml

# Translations
*.mo
Expand All @@ -86,6 +89,11 @@ instance/

# Sphinx documentation
docs/_build/
docs/source/wf_psf*.rst
docs/source/_static/file.png
docs/source/_static/images/logo_colab.png
docs/source/_static/minus.png
docs/source/_static/plus.png

# PyBuilder
target/
Expand Down Expand Up @@ -143,3 +151,7 @@ dmypy.json

# Pyre type checker
.pyre/


# WF-PSF Debug
/debug/
102 changes: 5 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,103 +3,11 @@
<h1 align='center'>WaveDiff</h1>
<h2 align='center'>A differentiable data-driven wavefront-based PSF modelling framework.</h2>

WaveDiff is a differentiable PSF modelling pipeline constructed with [Tensorflow](https://github.com/tensorflow/tensorflow). It was developed at the [CosmoStat lab](https://www.cosmostat.org) at CEA Paris-Saclay.

See the [documentation](https://cosmostat.github.io/wf-psf/) for details on how to install and run WaveDiff.

This repository includes:
- A differentiable PSF model entirely built in [Tensorflow](https://github.com/tensorflow/tensorflow).
- A numpy-based PSF simulator [here](https://github.com/tobias-liaudat/wf-psf/blob/main/wf_psf/SimPSFToolkit.py).
- A [numpy-based PSF simulator](https://github.com/CosmoStat/wf-psf/tree/dummy_main/src/wf_psf/sims).
- All the scripts, jobs and notebooks required to reproduce the results in [arXiv:2203.04908](http://arxiv.org/abs/2203.04908) and [arXiv:2111.12541](https://arxiv.org/abs/2111.12541).

For more information on how to use the WaveDiff model through configurable scripts see the `long-runs` directory's [README](https://github.com/tobias-liaudat/wf-psf/blob/main/long-runs/README.md).

## Proposed framework

A schematic of the proposed framework can be seen below. The PSF model is estimated (trained) using star observations in the field-of-view.

<img height=300 src="assets/PSF_model_diagram_v6.png" >

<!-- Visual reconstruction example of the WaveDiff-original PSF model trained on a simplified Euclid-like setting.
<img height=800 src="assets/PSF_reconstruction_example.png" > -->


## Install

`wf-psf` is pure python and can be easily installed with `pip`. After cloning the repository, run the following commands:

```bash
$ cd wf-psf
$ pip install .
```

The package can then be imported in Python as `import wf_psf as wf`. We recommend using the release `1.2.0` for stability as the current main branch is under development.

## Requirements
- [numpy](https://github.com/numpy/numpy) [>=1.19.2]
- [scipy](https://github.com/scipy/scipy) [>=1.5.2]
- [TensorFlow](https://www.tensorflow.org/) [==2.4.1]
- [TensorFlow Addons](https://github.com/tensorflow/addons) [==0.12.1]
- [Astropy](https://github.com/astropy/astropy) [==4.2]
- [zernike](https://github.com/jacopoantonello/zernike) [==0.0.31]
- [opencv-python](https://github.com/opencv/opencv-python) [>=4.5.1.48]
- [pillow](https://github.com/python-pillow/Pillow) [>=8.1.0]
- [galsim](https://github.com/GalSim-developers/GalSim) [>=2.3.1]

Optional packages:
- [matplotlib](https://github.com/matplotlib/matplotlib) [=3.3.2]
- [seaborn](https://github.com/mwaskom/seaborn) [>=0.11]


## Reproducible research

#### [arXiv:2203.04908](http://arxiv.org/abs/2203.04908) Rethinking data-driven point spread function modeling with a differentiable optical model (2022)
_Submitted._

- Use the release 1.2.0.
- All the scripts, jobs and notebooks to reproduce the figures from the article can be found [here](https://github.com/tobias-liaudat/wf-psf/tree/main/papers/article_IOP).
- The trained PSF models are found [here](https://github.com/tobias-liaudat/wf-psf/tree/main/papers/article_IOP/data/models).
- The input PSF field can be found [here](https://github.com/tobias-liaudat/wf-psf/tree/main/data).
- The script used to generate the input PSF field is [this one](https://github.com/tobias-liaudat/wf-psf/blob/main/long-runs/LR-PSF-field-gen-coherentFields.py).
- The code required to run the comparison against pixel-based PSF models is in [this directory](https://github.com/tobias-liaudat/wf-psf/tree/main/method-comparison).
- The training of the models was done using [this script](https://github.com/tobias-liaudat/wf-psf/blob/main/long-runs/train_eval_plot_script_click.py). In order to match the script's option for the different models with the article you should follow:
- `poly->WaveDiff-original`
- `graph->WaveDiff-graph`
- `mccd->WaveDiff-Polygraph`

_Note: To run the comparison to other PSF models you need to install them first. See [RCA](https://github.com/CosmoStat/rca), [PSFEx](https://github.com/astromatic/psfex) and [MCCD](https://github.com/CosmoStat/mccd)._


#### [arXiv:2111.12541](https://arxiv.org/abs/2111.12541) Rethinking the modeling of the instrumental response of telescopes with a differentiable optical model (2021)
_NeurIPS 2021 Workshop on Machine Learning and the Physical Sciences._

- Use the release 1.2.0.
- All the scripts, jobs and notebooks to reproduce the figures from the article can be found [here](https://github.com/tobias-liaudat/wf-psf/tree/main/papers/Neurips2021_ML4Physics_workshop).



## Citation

If you use `wf-psf` in a scientific publication, we would appreciate citations to the following paper:

*Rethinking data-driven point spread function modeling with a differentiable optical model*, T. Liaudat, J.-L. Starck, M. Kilbinger, P.-A. Frugier, [arXiv:2203.04908](http://arxiv.org/abs/2203.04908), 2022.


The BibTeX citation is the following:
```
@misc{https://doi.org/10.48550/arxiv.2203.04908,
doi = {10.48550/ARXIV.2203.04908},
url = {https://arxiv.org/abs/2203.04908},
author = {Liaudat, Tobias and Starck, Jean-Luc and Kilbinger, Martin and Frugier, Pierre-Antoine},
keywords = {Instrumentation and Methods for Astrophysics (astro-ph.IM), Computer Vision and Pattern Recognition (cs.CV), FOS: Physical sciences, FOS: Physical sciences, FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Rethinking data-driven point spread function modeling with a differentiable optical model},
publisher = {arXiv},
year = {2022},
copyright = {arXiv.org perpetual, non-exclusive license}
}
```

2 changes: 2 additions & 0 deletions config/configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
training_conf: training_config.yaml
44 changes: 44 additions & 0 deletions config/data_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Training and test data sets for training and/or metrics evaluation
data:
training:
# Specify directory path to data; Default setting is /path/to/repo/data
data_dir: data/coherent_euclid_dataset/
file: train_Euclid_res_200_TrainStars_id_001.npy
# if training data set file does not exist, generate a new one by setting values below
stars: null
positions: null
SEDS: null
zernike_coef: null
C_poly: null
params: #
d_max: 2
max_order: 45
x_lims: [0, 1000.0]
y_lims: [0, 1000.0]
grid_points: [4, 4]
n_bins: 20
max_wfe_rms: 0.1
oversampling_rate: 3.0
output_Q: 3.0
output_dim: 32
LP_filter_length: 2
pupil_diameter: 256
euclid_obsc: true
n_stars: 200
test:
data_dir: data/coherent_euclid_dataset/
file: test_Euclid_res_id_001.npy
# If test data set file not provided produce a new one
stars: null
noisy_stars: null
positions: null
SEDS: null
zernike_coef: null
C_poly: null
parameters:
d_max: 2
max_order: 45
x_lims: [0, 1000.0]
y_lims: [0, 1000.0]
grid_points: [4,4]
max_wfe_rms: 0.1
33 changes: 33 additions & 0 deletions config/logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[loggers]
keys=root, simpleLogger

[handlers]
keys=consoleHandler, fileHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler, fileHandler

[logger_simpleLogger]
level=DEBUG
handlers=consoleHandler, fileHandler
qualname=simpleLogger
propagate=0

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=simpleFormatter
args=('%(filename)s', 'w')

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
Loading

0 comments on commit 146725f

Please sign in to comment.