Coder Social home page Coder Social logo

pypher's Introduction

PyPHER - Python-based PSF Homogenization kERnels

Latest Version Documentation Status License type DOI number GitHub CI

Compute an homogenization kernel between two PSFs.

This code is well suited for PSF matching applications in both an astronomical or microscopy context.

It has been developed as part of the ESA Euclid mission and is currently being used for multi-band photometric studies of HST (visible) and Herschel (IR) data.

Paper:http://arxiv.org/abs/1609.02006
Documentation:https://pypher.readthedocs.io

Features

  1. Warp (rotation + resampling) the PSF images (if necessary),
  2. Filter images in Fourier space using a regularized Wiener filter,
  3. Produce a homogenization kernel.

Note: pypher needs the pixel scale information to be present in the FITS files. If not, use the provided addpixscl method to add this missing info.

Warning: This code does not

  • interpolate NaN values (replaced by 0 instead),
  • center PSF images,
  • minimize the kernel size.

Installation

PyPHER works both with Python 2.7 and 3.4 or above and relies on numpy, scipy and astropy libraries.

Option 1: Pip

pip install pypher

Option 2: from source

git clone https://github.com/aboucaud/pypher
cd pypher
python setup.py install

Option 3: from conda-forge

conda install -c conda-forge pypher

Basic example

$ pypher psf_a.fits psf_b.fits kernel_a_to_b.fits -r 1.e-5

This will create the desired kernel kernel_a_to_b.fits and a short log kernel_a_to_b.log with information about the processing.

Acknowledging

If you make use of any product of this code in a scientific publication, please consider acknowledging the work by citing the paper using the BibTeX information in the Cite this repository section at the top right of the page.

pypher's People

Contributors

aboucaud avatar forieux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pypher's Issues

For the encircled energy curve, after psf-matching with pypher

Hi!
I am using pypher for psf-matching in multi-wavelength analysis.
But I want to check the robustness of my psf-matching in order to use the matching kernels in my SED fitting.
Recently, I read a paper of JWST spatially resolved analysis which talks about the psf matching. (Abdurro'uf et al. 2023)
In the Appendix C of the paper mentioned above, they calculate the encircled energy of the convolved PSF image. (they first generate the convolution kernels to F444W, and convolve the PSF images of other bands to get convolved psf; Well, they calculate the encircled energy of the convolved psf and the psf of f444w)
They find that, after convolution, the convolved psfs of all other bands fit well with the target band f444w.
Consequently, they claim that the psf matching in their work is robust.
image
I also want to check the encircled engery distribution after & before the psf matching.
I first download the empirical psf generated by Abdurro'uf (GitHub website here).
And generate the matching kernel to z band on u, g, r, i bands with pypher.
Convolve the psf images with the kernels, and I get these figures.
original_ee
(This is the original psf encircled energy curve of the 5 bands, without being convolved with matching kernels)
matched_ee
(This is for the convolved psfs)
Note: by the way, I convolve images with functions in PHOTUTILS. (convolve_fft)
We can see that the shape of the EE curve really have changed after psf-matching.
But there still exist manifest differences between the matched images.
When it comes to the PSF-matching of the JWST filters, the results are given below:
original_ee
(This figure is about the input psfs)
matched_ee
(Well, this is for the psfs after psf-matching)
The generation of the matching kernels are all with PyPHER.
Could you please tell me whether this method can check the the robustness of a PSF matching?
Whether my results indicate a bad PSF-matching?
I really want to do well in the processing of PSF.
Anything from you will be appreciated!
Last, thanks for your making this wonderful code available!

Best.

Mingfeng Liu
Postgraduate Student, 1st year
Nanjing Normal University

pypher psf2otf problem

Your psf2otf function uses numpy.fft.fft2 instead of fftn, resulting in the incorrect otf.

import successfully but unable to reuse psf2otf

Hi there, I am a green hand, my goal is to reuse your psf2otf to reproduce matlab function

I successfully python setup.py install in my current env, and can import pypher with no errors, but when I call pypher.psf2otf the console reports

AttributeError: module 'pypher' has no attribute 'psf2otf'

and I have no idea, thanks for reviewing

Use astropy.io.fits, don't install pyfits

When I try to pip install pypher, it tries to install pyfits:

$ pip install pypher --user
Collecting pypher
  Downloading pypher-0.6.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.9 in /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pypher)
Collecting pyfits>=3.2 (from pypher)
  Downloading pyfits-3.4.tar.gz (1.7MB)
    100% |████████████████████████████████| 1.7MB 491kB/s 
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.2 in /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pypher)
Installing collected packages: pyfits, pypher

pyfits has been deprecated for years, astropy.io.fits should be used.
I have the latest astropy (1.2).

Can you please change setup.py to accept Astropy and not install pyfits if someone has Astropy?

If you agree with the change, but don't know how to declare it in setup.py, let me know and I'll make a pull request with a suggestion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.