This repo contains a Python package that I have written for applying Phase Diversity Reconstruction on Solar Orbiter data (or any other telescope with a circular aperture). It could be applied on any astronomical data as well.
It is based on the algorithm described in Löfdahl and Scharmer. 1994
An important note here is to use a unified unit for all parameters (nm or m)
The parameters needed for this class are:
lam
: the wavelength of studydiameter
: the diameter of the telescope's aperturefocal_length
: the effective focal length of the telescopename
: the name of your telescopeplatescale
: the pixel size in arcsecondssize
: the size of the detector in pixels
This class allows the user to compute:
calc_ps
: platescale in arcsec/pixel with an additional input ofpix_size
in units the same as the focal lengthspatial_resolution
: the spatial resolution (Rayleigh limit)pupil_size
: the size of the exit pupil of the system
This class allows the user to:
- Minimize the "Error Metric" and get the Zernike Polynomials describing the wavefront error of the telescope
- Plot the wavefront error, the point spread function (PSF), the modulation transfer function (MTF), the 1D azimuthal MTF of the telescope
- Construct the PSF and MTF from a set of Zernike Polynomials (from wavefront to PSF to OTF to MTF)
- Restore blurred images and correct for the PSF choosing between the Wiener filter and the Richardson-Lucy filter
The parameters of this class:
- the pair of focused and defocused images, the input image should have a format of
2xsize_xxsize_y
. - the parameters of the
Telescope
class cutoff
frequency for the noise filteringreg
: regularization parameter for the Wiener filterap
: the amount of the apodization rim in pixelsx1, x2, y1, y2
: the delimeters of the region of interestco_num
: number of Zernike polynomials to fit the wavefrontdel_z
: the amount of defocus in lambda
The modules of this class:
fit
: takes in the method of fitting and returns the best-fit Zernike coefficientsplot_results
: takes in the returned Zernike coefficients and plots the wavefront error, the 2D MTF, the 1D MTFrestored_scene
: perform the deconvolution of a blurred image with an input of Zernike Coefficients. The user can use between two filterWiener
andrichardsonLucy
For fitting the wavefront error is sub-regions of the full FOV of the PD dataset. The user can enter the size of the subregion (it has to be quadratic) plus the number of Zernike polynomials to be fit and the names of the output files (one for the wavefront error and one for the 2D MTF).
The class offers the option to run parallel computation by setting the parser -p to True (see below).
The minimization
class returns the best-fit zernike polynomials, a visualisation of the results (wavefront error+MTF), and the restored scene (in this case the focused image of the PD dataset). To get these specific results, type in the shell terminal:
python3 minimization.py -i 'path/input.fits' -w 617.3e-6 -a 140 -f 4125.3 -p 0.5 -c 0.5 -r 1e-10 -ap 10 -x1 500 -x2 650 -y1 500 -y2 650 -z 10 -del 0.5 -o path/reduced.fits -fl 'Wiener'
The specific description of the parsers and input to the class can be found inside the main code. The values given above are for an example PD dataset taken by the PHI/HRT telescope. You can change the values according to your telescope.
To use the patch_pd
class:
python3 patch_pd.py -i 'path/input.fits' -z 10 -d 265 -ow 'path/output_wf.fits' -om 'path/output_wf.fits -p True
The parsers description can be found in the main code