Skip to content

Commit 6f72952

Browse files
committed
Tweaks to logging
1 parent b473d3c commit 6f72952

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

sunkit_image/coalignment/interface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import astropy
77
import astropy.units as u
88

9+
from sunpy import log
910
from sunpy.sun.models import differential_rotation
1011
from sunpy.util.exceptions import SunpyUserWarning
1112

@@ -85,6 +86,7 @@ def _update_fits_wcs_metadata(target_map, reference_map, affine_params):
8586
new_reference_pixel = affine_params.scale * affine_params.rotation_matrix @ old_reference_pixel + affine_params.translation
8687
new_reference_coordinate = reference_map.wcs.pixel_to_world(*new_reference_pixel)
8788
# Create a new map with the updated metadata
89+
log.debug(f"Shifting reference coordinate from {target_map.reference_coordinate} to {new_reference_coordinate} by {new_reference_coordinate.Tx - target_map.reference_coordinate.Tx}, {new_reference_coordinate.Ty - target_map.reference_coordinate.Ty}")
8890
return target_map.shift_reference_coord(
8991
new_reference_coordinate.Tx - target_map.reference_coordinate.Tx,
9092
new_reference_coordinate.Ty - target_map.reference_coordinate.Ty,

sunkit_image/coalignment/match_template.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
from skimage.feature import match_template
33

4+
from sunpy import log
5+
46
from sunkit_image.coalignment.interface import AffineParams, register_coalignment_method
57

68
__all__ = ["match_template_coalign"]
@@ -114,6 +116,7 @@ def match_template_coalign(target_array, reference_array, **kwargs):
114116
raise ValueError("The correlation output failed to work out a match.")
115117
# Find the best match location
116118
y_shift, x_shift = _find_best_match_location(corr)
119+
log.debug(f"Match template shift: x: {x_shift}, y: {y_shift}")
117120
# Particularly for this method, there is no change in the rotation or scaling,
118121
# hence the hardcoded values of scale to 1.0 & rotation to identity matrix
119122
scale = np.array([1.0, 1.0])

sunkit_image/coalignment/phase_cross_correlation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
from skimage.registration import phase_cross_correlation
33

4+
from sunpy import log
5+
46
from sunkit_image.coalignment.interface import AffineParams, register_coalignment_method
57

68
__all__ = ["phase_cross_correlation_coalign"]
@@ -36,8 +38,14 @@ def phase_cross_correlation_coalign(target_array, reference_array, **kwargs):
3638
"""
3739
if target_array.shape != reference_array.shape:
3840
raise ValueError("Input and target arrays must be the same shape.")
41+
if "upsample_factor" not in kwargs:
42+
kwargs["upsample_factor"] = 20
3943
shift, _, _ = phase_cross_correlation(reference_array, target_array, **kwargs)
40-
x_shift, y_shift = shift[1], shift[0]
44+
# Shift has axis ordering which is consistent with the axis order of the input arrays, so y, x
45+
# These are negative based on the example provided in the scikit-image documentation
46+
# https://scikit-image.org/docs/stable/auto_examples/registration/plot_register_translation.html
47+
x_shift, y_shift = -shift[1], -shift[0]
48+
log.debug(f"Phase cross correlation shift: x: {x_shift}, y: {y_shift}")
4149
# Particularly for this method, there is no change in the rotation or scaling,
4250
# hence the hardcoded values of scale to 1.0 & rotation to identity matrix
4351
scale = np.array([1.0, 1.0])

0 commit comments

Comments
 (0)