Using deconvolve to deconvolve images

deconvolve can sharpen images using the point spread function derived for Hinode XRT

Deconvolution is ordinarily used when wanting to remove the blurring around sharp objects or features caused by the telescope’s point spread function. Here we show an example of its use for an XRT image taken during the transit of Venus in 2012. We download this data from the VSO using methods in SunPy.

[1]:
from sunpy.map import Map
from sunpy.net import Fido
from sunpy.net import attrs as a

from xrtpy.image_correction.deconvolve import deconvolve

result = Fido.search(
    a.Time("2012-06-05 21:58:39", "2012-06-05 21:59:00"), a.Instrument("xrt")
)

data_file = Fido.fetch(result[0], progress=False)
/home/docs/checkouts/readthedocs.org/user_builds/xrtpy/envs/latest/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

deconvolve takes a SunPy map as input and returns the deconvolved image and metadata as a SunPy map.

[2]:
in_map = Map(data_file)
out_map = deconvolve(in_map)
Files Downloaded:   0%|          | 0/1 [00:00<?, ?file/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:   0%|          | 0.00/33.6M [00:00<?, ?B/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:   1%|          | 293k/33.6M [00:00<00:11, 2.93MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  10%|█         | 3.47M/33.6M [00:00<00:01, 19.6MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  20%|██        | 6.73M/33.6M [00:00<00:01, 24.9MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  30%|███       | 10.2M/33.6M [00:00<00:00, 28.7MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  40%|████      | 13.6M/33.6M [00:00<00:00, 30.5MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  50%|████▉     | 16.6M/33.6M [00:00<00:00, 30.4MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  59%|█████▊    | 19.7M/33.6M [00:00<00:00, 30.3MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  68%|██████▊   | 23.0M/33.6M [00:00<00:00, 31.0MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  78%|███████▊  | 26.2M/33.6M [00:00<00:00, 31.3MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  87%|████████▋ | 29.3M/33.6M [00:01<00:00, 31.1MB/s]
xrtpy.XRT20170324_151721.0.PSF560.fits:  97%|█████████▋| 32.5M/33.6M [00:01<00:00, 31.3MB/s]
Files Downloaded: 100%|██████████| 1/1 [00:01<00:00,  1.22s/file]
Files Downloaded:   0%|          | 0/1 [00:00<?, ?file/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:   0%|          | 0.00/33.6M [00:00<?, ?B/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:   3%|▎         | 912k/33.6M [00:00<00:03, 9.10MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  14%|█▍        | 4.67M/33.6M [00:00<00:01, 25.9MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  24%|██▍       | 8.02M/33.6M [00:00<00:00, 29.3MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  34%|███▎      | 11.3M/33.6M [00:00<00:00, 30.7MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  43%|████▎     | 14.4M/33.6M [00:00<00:00, 30.9MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  53%|█████▎    | 17.8M/33.6M [00:00<00:00, 31.7MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  63%|██████▎   | 21.3M/33.6M [00:00<00:00, 32.8MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  73%|███████▎  | 24.6M/33.6M [00:00<00:00, 32.3MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  83%|████████▎ | 27.9M/33.6M [00:00<00:00, 32.6MB/s]
xrtpy.XRT20170324_161721.0.PSF1000.fits:  93%|█████████▎| 31.2M/33.6M [00:01<00:00, 30.8MB/s]
Files Downloaded: 100%|██████████| 1/1 [00:01<00:00,  1.18s/file]

deconvolve uses the Richardson-Lucy deconvolution algorithm and takes a few optional input parameters including niter (no. of iterations to perform, 5 by default), pdf1keV (to use the point spread function defined at 1.0 keV rather than the default one defined at 560 eV) and verbose (False by default). Above we just used the default settings.

To see the effects of the deconvolution we plot both the input and output images:

[3]:
import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1, projection=in_map)
in_map.plot(axes=ax1, title="Original Image")
ax2 = fig.add_subplot(1, 2, 2, projection=out_map)
out_map.plot(axes=ax2, title="Deconvolved Image")
fig.subplots_adjust(wspace=0.5)
plt.show()
../../_images/notebooks_data_analysis_Deconvolving_XRT_images_7_0.png