mapsequence_coalign_by_match_template¶
- sunpy.image.coalignment.mapsequence_coalign_by_match_template(mc, template=None, layer_index=0, func=<function _default_fmap_function>, clip=True, shift=None, **kwargs)[source]¶
Co-register the layers in a
MapSequence
according to a template taken from thatMapSequence
. This method REQUIRES that scikit-image be installed. When using this functionality, it is a good idea to check that the shifts that were applied to were reasonable and expected. One way of checking this is to animate the originalMapSequence
, animate the coalignedMapSequence
, and compare the differences you see to the calculated shifts.- Parameters
mc (
sunpy.map.MapSequence
) – AMapSequence
of shape(ny, nx, nt)
, wherent
is the number of layers in theMapSequence
.template ({None | sunpy.map.Map |
numpy.ndarray
}, optional) – The template used in the matching. If annumpy.ndarray
is passed, thenumpy.ndarray
has to have two dimensions.layer_index (
int
, optional) – The template is assumed to refer to the map in theMapSequence
indexed by the value oflayer_index
. Displacements of all maps in theMapSequence
are assumed to be relative to this layer. The displacements of the template relative to this layer are therefore(0, 0)
.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 co-ordinate system) that is applied to the input
MapSequence
. Key ‘y’ is anQuantity
array corresponding to the amount of shift in the y-direction (in arcseconds, assuming the helio-projective Cartesian co-ordinate system) that is applied to the inputMapSequence
. The number of elements in each array must be the same as the number of maps in theMapSequence
. If a shift is passed in to the function, that shift is applied to the inputMapSequence
and the template matching algorithm is not used.
Notes
The remaining keyword arguments are sent to
sunpy.image.coalignment.apply_shifts
.- Returns
sunpy.map.MapSequence
– AMapSequence
that has co-aligned by matching the template.
Examples
>>> from sunpy.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)