ecpi.process.imag.core.image_deconv module

Section author: ECLAIRs GP team

Deconvolution modules

This library provides functions to perform image reconstruction froms shadowgrams. Based on ‘CodedMaskImage’ python program of Cyril Lachaud and IDL program of Aleksandra Gros

Remarks: * shadowgrams correction : – For short time scales there are no corrections, the shadowgrams is directly used – For long time scales a quadratic fit ax**2+by**2+cx+dy+e should be performed

Summary

Classes:

Deconv

based on 'CodedMaskImage' python program of Cyril Lachaud and IDL program of Aleksandra Gros modular approach

Class diagram:

Functions:

correlate

compute the correlation between two 2d matrix

correlate_0

compute the correlation between two 2d matrix

remove_borders_from_sky_image

remove the borders of the sky image for appropriate plotting

Reference

class Deconv(detector_effect=None)[source]

Bases: object

based on ‘CodedMaskImage’ python program of Cyril Lachaud and IDL program of Aleksandra Gros modular approach

-> possibility to init the deconv (process G arrays) once for different _weight arrays or shadowgrams -> possibility to prepare the deconv (process A and B arrays) for different shadowgrams

build_array_with_padding(myarray)[source]

Builds an array containing the myarray in the center and a padding with zeroes outside

myarray should be smaller that the sky array. the build padded array has the dimension of the padded sky array (power of 2 above unpadded sky array size).

Parameters

myarray (2D array) – array to add the padding to

Returns

array with padding

Return type

2D array

decon(showarrays=False, savearrays=None)[source]

Actual deconvolution and construction of the sky image

  • Builds the sky array with the correct shape

where shape = Rebinned (120) + 2* shadowgrams (80) = 280x280 - Builds the shadowgrams arrays used for deconvolution (Decon suffix) by padding them correctly - Do the deconvolution to build the sky arrays

Note

Need the deconvolution to be initialized and prepared

Parameters
  • showarrays (bool) – plot sky_count, sky_variance and sky_snr. Default=False.

  • savearrays (string) – PATH of the directory to save the plots. Default=None

decon_init(mask_filename=None, mask_rebinned_filename=None, showarrays=False, debug=False)[source]

initialization of the deconvolution

initialization of the deconvolution (FIRST STEP)
  • Memorize the sky image array size according

the size of the shadowgrams and mask arrays - Prepare the mask array for deconvolution - Build the deconvolution arrays G

Note

Only needed at the beginning of the imaging process

Parameters
  • mask_filename (string) – PATH/name of the mask file. Default=None.

  • mask_rebinned_filename (string) – PATH/name of the rebinned mask Default=None.

  • showarrays (bool) – plot mask and rebinned mask. Default=False.

  • debug (bool) – whether or not to display debug quantities

decon_prep(efficiency_filename, nonuniformity_filename, showarrays=False, debug=False)[source]

preparation of the deconvolution

preparation of the deconvolution (SECOND STEP)
  • Prepare the _weight array and the auxiliary arrays A and B for deconvolution

(_weight to be applied to pixels to remove noisy pixels or mask sources in the fov)

Note

It should be executed each time the efficiency changes

Note

Need the deconvolution to be initialized

Parameters
  • efficiency_filename (string) – PATH/filename of the detector efficiency array

  • nonunif_filename (string) – PATH/filename of the detector non-uniformity array

  • showarrays (bool) – whether or not to show a plot

  • debug (bool) – whether or not to display debug quantities

get_shadowgrams()[source]

Return shadowgrams attribute

get_shadowgrams_bgcorrected()[source]

Return shadowgrams_bgcorrected attribute

get_shadowgrams_var()[source]

Return shadowgrams_var attribute

remove_padding_from_sky(myarray)[source]

Returns an array containing the data array in the center and no Padding border

the array with padding is the dimension of the sky array size (the power of 2 above the unpadded sky array size). the array without padding is the dimension of the unpadded sky array size.

Parameters

myarray (2D array) – padded array

Returns

array with no padding

Return type

2D array

set_mask(mask_filename=None, mask_rebinned_filename=None, showarrays=False)[source]

read mask array from file

default is common/data/maskECLAIRs.fits and maskECLAIRs_rebinned.fits G arrays are set to 0, because they have to be computed with the new mask.

Parameters
  • mask_filename (string) – PATH/name of the mask file. Default=None.

  • mask_rebinned_filename (string) – PATH/name of the rebinned mask Default=None.

  • showarrays (bool) – plot mask and rebinned mask. Default=False.

set_shadowgrams(shds)[source]

Set shadowgrams attribute to new value

set_shadowgrams_bgcorrected(shdsbgc)[source]

Set shadowgrams_var attribute to new value

set_shadowgrams_var(shdsv)[source]

Set shadowgrams_var attribute to new value

set_weight(efficiency_filename, nonunif_filename)[source]

Read the _weight array “W” from the fits file

Builds the Weigth arrays used for deconvolution (Decon suffix) by padding them correctly. A and B matrix are set to 0 because they have to be computed with the new W.

Parameters
  • efficiency_filename (string) – PATH/filename of the detector efficiency array

  • nonunif_filename (string) – PATH/filename of the detector non-uniformity array

correlate(a, b)[source]

compute the correlation between two 2d matrix

computing based on fft, conjugating a (for conjug_type=1)

Parameters
  • a (2D array) – left 2D data

  • b (2D array) – right 2D data

Returns

correlation matrix of a and b

Return type

2D array

correlate_0(a, b)[source]

compute the correlation between two 2d matrix

computing based on fft, conjugating b (for conjug_type=2)

Warning

in order to use this function instead of conjug_type=1:

rename it correlate and comment the last swap of DeconvV0.beuild_sky_image

Parameters
  • a (2D array) – left 2D data

  • b (2D array) – right 2D data

Returns

correlation matrix of a and b

Return type

2D array

remove_borders_from_sky_image(image)[source]

remove the borders of the sky image for appropriate plotting

Warning

deprecated ?

removes borders are 10 pixels width

Parameters

image (2D array) – sky image

Returns

smaller image

Return type

2D array