Skip to content

Commit

Permalink
Merge pull request #11 from CEA-COSMIC/develop
Browse files Browse the repository at this point in the history
Version 0.0.2 patch release
  • Loading branch information
sfarrens authored Jun 23, 2022
2 parents 41c6395 + 5f75837 commit cbf4178
Show file tree
Hide file tree
Showing 16 changed files with 488 additions and 118 deletions.
151 changes: 137 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,142 @@
# Compiled source #
###################
*.o
*.so
*.pyc
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Logs and temporaries #
########################
*.log
*~
.coverage
# C extensions
*.so

# Folders #
###########
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
pysap_astro.egg-info/
__pycache__/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
pytest.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/source/fortuna.*
docs/source/scripts.*
docs/source/*.nblink

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
PySAP-Astro
===============

|travis| |codecov| |pypi|
|CI| |codecov| |pypi|

.. |travis| image:: https://travis-ci.org/CEA-COSMIC/pysap-astro.svg?branch=master
:target: https://travis-ci.org/CEA-COSMIC/pysap-astro
.. |CI| image:: https://github.com/CEA-COSMIC/pysap-astro/workflows/CI/badge.svg
:target: https://github.com/CEA-COSMIC/pysap-astro/actions?query=workflow%3ACI

.. |codecov| image:: https://codecov.io/gh/CEA-COSMIC/pysap-astro/branch/master/graph/badge.svg?token=XHJIQXV7AX
:target: https://codecov.io/gh/CEA-COSMIC/pysap-astro
Expand All @@ -18,7 +18,7 @@ Python Sparse data Analysis Package external ASTRO plugin.
This package is part of the PySAP plug-in framework and is not intended to
work as a stand-alone package.

This work is made available by a community of people, amoung which the
This work is made available by a community of people, among which the
CEA Neurospin UNATI and CEA CosmoStat laboratories, in particular A. Grigis,
J.-L. Starck, P. Ciuciu, and S. Farrens.

Expand All @@ -27,4 +27,4 @@ Important links
===============

- Official PySAP source code repo: https://github.com/CEA-COSMIC/pysap
- PySAP HTML documentation (last stable release): https://python-pysap.readthedocs.io/en/latest/
- PySAP HTML documentation (last stable release): https://cea-cosmic.github.io/pysap
12 changes: 6 additions & 6 deletions astro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# for details.
##########################################################################

"""Module defines all the Astro related plugins."""
"""PYSAP-ASTRO.
__all__ = ['deconvolution', 'denoising']
This plug-in provides tools for astrophysical data processing.
"""

from . import *
from .deconvolution import *
from .denoising import *
__all__ = ['deconvolution', 'denoising']

version_info = (0, 0, 0)
version_info = (0, 0, 2)
__version__ = '.'.join(str(c) for c in version_info)
8 changes: 5 additions & 3 deletions astro/deconvolution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
# for details.
##########################################################################

"""Module defines all the Astro deconvolution plugins."""
"""DECONVOLUTION.
__all__ = ['deconvolve', 'linear', 'wavelet_filters']
This module provides tools for astrophysical image deconvolution.
"""

from . import *
__all__ = ['deconvolve', 'linear', 'wavelet_filters']
54 changes: 35 additions & 19 deletions astro/deconvolution/deconvolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
# for details.
##########################################################################

"""CONDA-VU Galaxy Image Deconvolution."""
"""DECONVOLVE.
This module defines functions to perform galaxy image deconvolution using the
Condat-Vu algorithm.
"""

# System import
import pysap
Expand All @@ -31,18 +36,21 @@
def psf_convolve(data, psf, psf_rot=False):
"""PSF Convolution.
Convolve the input data with the PSF provided.
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data, 2D image
psf : np.ndarray
psf : numpy.ndarray
Input PSF, 2D image
psf_rot : bool, optional
Option to rotate the input PSF (default is False)
Option to rotate the input PSF, default is ``False``
Returns
-------
np.ndarray convolved image
numpy.ndarray
Convolved image
"""
if psf_rot:
Expand All @@ -54,21 +62,25 @@ def psf_convolve(data, psf, psf_rot=False):
def get_weights(data, psf, filters, wave_thresh_factor=np.array([3, 3, 4])):
"""Get Sparsity Weights.
Get the weights needed for the sparse regularisation term in the
deconvolution problem.
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data, 2D image
psf : np.ndarray
psf : numpy.ndarray
Input PSF, 2D image
filters : np.ndarray
filters : numpy.ndarray
Wavelet filters
wave_thresh_factor : np.ndarray, optional
Threshold factors for each wavelet scale (default is
np.array([3, 3, 4]))
wave_thresh_factor : numpy.ndarray, optional
Threshold factors for each wavelet scale, default is
``np.array([3, 3, 4])``
Returns
-------
np.ndarray weights
numpy.ndarray
Weights
"""
noise_est = sigma_mad(data)
Expand All @@ -93,24 +105,28 @@ def sparse_deconv_condatvu(
):
"""Sparse Deconvolution with Condat-Vu.
Perform deconvolution using sparse regularisation with the Condat-Vu
algorithm.
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data, 2D image
psf : np.ndarray
psf : numpy.ndarray
Input PSF, 2D image
n_iter : int, optional
Maximum number of iterations, default is 300
Maximum number of iterations, default is ``300``
n_reweights : int, optional
Number of reweightings, default is 1
Number of reweightings, default is ``1``
verbose : bool, optional
Verbosity option, default is True
Verbosity option, default is ``True``
progress : bool, optional
Option to show progress bar, default is True
Option to show progress bar, default is ``True``
Returns
-------
np.ndarray deconvolved image
numpy.ndarray
Deconvolved image
"""
# Print the algorithm set-up
Expand Down
10 changes: 7 additions & 3 deletions astro/deconvolution/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
# for details.
##########################################################################

"""Module contains linears operators classes."""
"""LINEAR.
This module defines a linears operator class for wavelet convolution.
"""

from modopt.opt.linear import LinearParent
from modopt.signal.wavelet import filter_convolve
Expand All @@ -21,10 +25,10 @@ class WaveletConvolve2(LinearParent):
Parameters
----------
filters: np.ndarray
filters: numpy.ndarray
Array of wavelet filter coefficients
method : str {'astropy', 'scipy'}, optional
Convolution method (default is 'astropy')
Convolution method, default is ``astropy``
"""

Expand Down
15 changes: 10 additions & 5 deletions astro/deconvolution/wavelet_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
# for details.
##########################################################################

"""Module contains methods for getting wavelet transform filters."""
"""WAVELET FILTER.
This module defines a function for getting wavelet transform filters.
"""

import numpy as np
from pysap import load_transform
Expand All @@ -16,7 +20,7 @@
def get_cospy_filters(data_shape, transform_name, n_scales=4, coarse=False):
"""Get PySAP transform filters.
This method obtains wavelet filters by calling cospy
This method obtains wavelet filters using the transform name provided.
Parameters
----------
Expand All @@ -25,13 +29,14 @@ def get_cospy_filters(data_shape, transform_name, n_scales=4, coarse=False):
transform_name : str
Name of wavelet transform
n_scales : int, optional
Number of transform scales (default is 4)
Number of transform scales, default is ``4``
coarse : bool, optional
Option to keep coarse scale (default is 'False')
Option to keep coarse scale, default is ``False``
Returns
-------
np.ndarray 3D array of wavelet filters
numpy.ndarray
3D array of wavelet filters
"""
# Adjust the shape of the input data.
Expand Down
Loading

0 comments on commit cbf4178

Please sign in to comment.