- sunkit_image.coalignment.mapsequence_coalign_by_match_template(mc, template=None, layer_index=0, func=<function _default_fmap_function>, clip=True, shift=None, **kwargs)#
Co-register the layers in a
MapSequenceaccording to a template taken from that
When using this functionality, it is a good idea to check that the shifts that were applied were reasonable and expected. One way of checking this is to animate the original
MapSequence, animate the coaligned
MapSequence, and compare the differences you see to the calculated shifts.
Currently this module provides image co-alignment by template matching. and is partially inspired by the SSWIDL routine tr_get_disp.pro. In this implementation, the template matching is handled via
sunpy.map.MapSequence) – A
(ny, nx, nt), where
ntis the number of layers in the
int, optional) – The template is assumed to refer to the map in the
MapSequenceindexed by the value of
layer_index. Displacements of all maps in the
MapSequenceare assumed to be relative to this layer. The displacements of the template relative to this layer are therefore
func (function, optional) – A function which is applied to the data values before the coalignment method is applied. This can be useful in coalignment, because it is sometimes better to co-align on a function of the data rather than the data itself. The calculated shifts are applied to the original data. Examples of useful functions to consider for EUV images are the logarithm or the square root. The function is of the form
func = F(data). The default function ensures that the data are floats.
clip (bool, optional) – If True, then clip off x, y edges of the maps in the sequence that are potentially affected by edges effects.
shift (dict, optional) – A dictionary with two keys, ‘x’ and ‘y’. Key ‘x’ is an astropy quantities array of corresponding to the amount of shift in the x-direction (in arcseconds, assuming the helio-projective Cartesian coordinate system) that is applied to the input
MapSequence. Key ‘y’ is an
Quantityarray corresponding to the amount of shift in the y-direction (in arcseconds, assuming the helio-projective Cartesian coordinate system) that is applied to the input
MapSequence. The number of elements in each array must be the same as the number of maps in the
MapSequence. If a shift is passed in to the function, that shift is applied to the input
MapSequenceand the template matching algorithm is not used.
The remaining keyword arguments are sent to
MapSequencethat has co-aligned by matching the template.
>>> from sunkit_image.coalignment import mapsequence_coalign_by_match_template as mc_coalign >>> coaligned_mc = mc_coalign(mc) >>> coaligned_mc = mc_coalign(mc, layer_index=-1) >>> coaligned_mc = mc_coalign(mc, clip=False) >>> coaligned_mc = mc_coalign(mc, template=sunpy_map) >>> coaligned_mc = mc_coalign(mc, template=two_dimensional_ndarray) >>> coaligned_mc = mc_coalign(mc, func=np.log)
J.P. Lewis, Fast Template Matching, Vision Interface 95, Canadian Image Processing and Pattern Recognition Society, Quebec City, Canada, May 15-19, 1995, p. 120-123 http://www.scribblethink.org/Work/nvisionInterface/vi95_lewis.pdf.