From 5884fc68327c839732a3da696ba2a70927ad9d7a Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Tue, 10 Sep 2024 14:18:37 -0700 Subject: [PATCH] Nabil review --- _typos.toml | 3 + changelog/207.breaking.rst | 6 +- .../adding_a_coalignment_method.rst | 6 +- examples/aligning_aia_with_eis_maps.py | 65 +++++++++++-------- sunkit_image/coalignment/__init__.py | 2 +- sunkit_image/coalignment/decorators.py | 6 +- sunkit_image/coalignment/interface.py | 60 ++++++++--------- sunkit_image/coalignment/match_template.py | 18 ++--- .../coalignment/tests/test_coalignment.py | 31 ++++----- .../coalignment/tests/test_decorators.py | 6 +- .../coalignment/tests/test_match_template.py | 10 ++- sunkit_image/conftest.py | 31 +++------ ..._mpl_390_ft_261_sunpy_600_astropy_610.json | 4 +- 13 files changed, 126 insertions(+), 122 deletions(-) diff --git a/_typos.toml b/_typos.toml index b4283011..dc94d4ef 100644 --- a/_typos.toml +++ b/_typos.toml @@ -7,3 +7,6 @@ default.extend-ignore-identifiers-re = [ "iy", "BA", ] + +[default.extend-words] +eis = "eis" diff --git a/changelog/207.breaking.rst b/changelog/207.breaking.rst index 29cde56d..cd82ee2a 100644 --- a/changelog/207.breaking.rst +++ b/changelog/207.breaking.rst @@ -6,13 +6,16 @@ As solar imaging data continues to grow in complexity, the existing coalignment **New Features:** - **Coalignment Interface** (`sunkit_image.coalignment.interface`): + - ``coalign`` function: A high-level function for image coalignment with a specified method. Default method: :func:`~sunkit_image.coalignment.match_template.match_template_coalign`. - ``AffineParams`` NamedTuple: Stores and passes affine transformation parameters. - **Template Matching Coalignment** (`sunkit_image.coalignment.match_template`): + - ``match_template_coalign`` function: A coalignment method that uses template matching. - **Decorator Utility** (`sunkit_image.coalignment.decorators`): + - ``register_coalignment_method`` decorator: Enables easy registration of coalignment methods. - Global Registry: Maintains a dictionary of registered coalignment methods. @@ -27,5 +30,4 @@ As solar imaging data continues to grow in complexity, the existing coalignment **Examples** -- Please find the examples related to the :ref:`adding of coalignment method ` and using a -coalignment method here :ref:`sphx_glr_generated_gallery_aligning_aia_with_eis_maps.py` +- Please find the examples related to the :ref:`adding of coalignment method ` and using a coalignment method here :ref:`sphx_glr_generated_gallery_aligning_aia_with_eis_maps.py` diff --git a/docs/how_to_guide/adding_a_coalignment_method.rst b/docs/how_to_guide/adding_a_coalignment_method.rst index e943b788..13fa9cb7 100644 --- a/docs/how_to_guide/adding_a_coalignment_method.rst +++ b/docs/how_to_guide/adding_a_coalignment_method.rst @@ -51,9 +51,9 @@ The :func:`~sunkit_image.coalignment.coalign` function does not change any probl Checking if the Method is Registered ==================================== -To check if your method is registered, you can check if it is present in the registered methods dictionary ``registered_methods`` using the following code: +To check if your method is registered, you can check if it is present in the registered methods dictionary ``REGISTERED_METHODS`` using the following code: .. code-block:: python - from sunkit_image.coalignment.decorators import registered_methods - print(registered_methods) + from sunkit_image.coalignment.decorators import REGISTERED_METHODS + print(REGISTERED_METHODS) diff --git a/examples/aligning_aia_with_eis_maps.py b/examples/aligning_aia_with_eis_maps.py index a661409b..d63b0042 100644 --- a/examples/aligning_aia_with_eis_maps.py +++ b/examples/aligning_aia_with_eis_maps.py @@ -3,39 +3,47 @@ Coaligning EIS to AIA ===================== -This example shows how to EISA data to AIA using cross-correlation which is implemented as the "match_template" method. +This example shows how to EIS data to AIA using cross-correlation which is implemented as the "match_template" method. """ # sphinx_gallery_thumbnail_number = 2 # NOQA: ERA001 import matplotlib.pyplot as plt import astropy.units as u -from astropy.io import fits -from astropy.visualization import ImageNormalize, AsinhStretch -from sunpy.net import Fido ,attrs as a +from astropy.visualization import AsinhStretch, ImageNormalize + import sunpy.map +from sunpy.net import Fido +from sunpy.net import attrs as a + from sunkit_image.coalignment import coalign -from sunkit_image.data.test import get_test_filepath ################################################################################### -# Firstly, let us acquire the EIS and AIA data we need for this example. +# Firstly, let us acquire the IS and AIA data we need for this example. +# +# For this example, we will use the IS data from the sunpy data repository. +# This is a preprocessed IS raster data. + + +eis_map = sunpy.map.Map("https://github.com/sunpy/data/raw/main/sunkit-image/eis_20140108_095727.fe_12_195_119.2c-0.int.fits") -with fits.open ("https://github.com/sunpy/data/raw/main/sunkit-image/eis_20140108_095727.fe_12_195_119.2c-0.int.fits") as hdul: - eis_map = sunpy.map.Map(hdul[0].data, hdul[0].header) -eis_map.plot() +fig = plt.figure() + +ax = fig.add_subplot(111, projection=eis_map) +eis_map.plot(axes=ax, aspect=eis_map.meta['cdelt2'] / eis_map.meta['cdelt1'], + cmap='Blues_r', norm=ImageNormalize(stretch=AsinhStretch())) ################################################################################### # Lets find the AIA image that we want to use as a reference. -# We would be using the image near the date_average of this raster. +# We want to be using an image near the "date_average" of the IS raster. -# The following way is necessary because this eis doesn't have direct date_start, date_avg and date_end attributes. query = Fido.search(a.Time(start=eis_map.meta["date_beg"], near=eis_map.meta["date_avg"], end=eis_map.meta["date_end"]), a.Instrument('aia'), a.Wavelength(193*u.angstrom)) aia_file = Fido.fetch(query) aia_map = sunpy.map.Map(aia_file) #################################################################################### -# Before coaligning the images, we first downsample the AIA image to the same plate -# scale as the EIS image. This is not done automatically. +# Before coaligning the images, we first downsample the AIA image to the same plate +# scale as the IS image. This is not done automatically. nx = (aia_map.scale.axis1 * aia_map.dimensions.x) / eis_map.scale.axis1 ny = (aia_map.scale.axis2 * aia_map.dimensions.y) / eis_map.scale.axis2 @@ -43,33 +51,34 @@ aia_downsampled = aia_map.resample(u.Quantity([nx, ny])) #################################################################################### -# Now we can coalign EIS to AIA using a cross-correlation. -# For this we would be using the "match_template" method. -# For details of the implementation refer to the +# Now we can coalign IS to AIA using cross-correlation. For this we would be using the +# "match_template" method. For details of the implementation refer to the # documentation of `~sunkit_image.coalignment.match_template.match_template_coalign`. coaligned_eis_map = coalign(aia_downsampled, eis_map) #################################################################################### -# To check now effective this has been, we will plot the EIS data and -# overlap the bright regions from AIA before and after coalignment. -# Plot the EIS data and overlap the bright regions from AIA before and after coalignment. +# To check now effective this has been, we will plot the IS data and +# overlap the bright regions from AIA before and after the coalignment. -levels = [200, 400, 500, 700, 800] * aia_map.unit +levels = [800] * aia_map.unit fig = plt.figure(figsize=(15, 7.5)) -# Plot before coalignment +# Before coalignment ax = fig.add_subplot(121, projection=eis_map) -eis_map.plot(axes=ax, title='Before', aspect=eis_map.meta['cdelt2'] / eis_map.meta['cdelt1'], +eis_map.plot(axes=ax, title='Before coalignment', + aspect=coaligned_eis_map.meta['cdelt2'] / coaligned_eis_map.meta['cdelt1'], cmap='Blues_r', norm=ImageNormalize(stretch=AsinhStretch())) -aia_map.draw_contours(levels, axes=ax, alpha=0.3) +aia_map.draw_contours(levels, axes=ax) -# Plot after coalignment +# After coalignment ax = fig.add_subplot(122, projection=coaligned_eis_map) -coaligned_eis_map.plot(axes=ax, title='After', aspect=coaligned_eis_map.meta['cdelt2'] / coaligned_eis_map.meta['cdelt1'], - cmap='Blues_r', norm=ImageNormalize(stretch=AsinhStretch())) -aia_map.draw_contours(levels, axes=ax, alpha=0.3) +coaligned_eis_map.plot(axes=ax, title='After coalignment', + aspect=coaligned_eis_map.meta['cdelt2'] / coaligned_eis_map.meta['cdelt1'], + cmap='Blues_r', norm=ImageNormalize(stretch=AsinhStretch())) +aia_map.draw_contours(levels, axes=ax) fig.tight_layout() -plt.show() \ No newline at end of file + +plt.show() diff --git a/sunkit_image/coalignment/__init__.py b/sunkit_image/coalignment/__init__.py index c0a9c922..f26572ac 100644 --- a/sunkit_image/coalignment/__init__.py +++ b/sunkit_image/coalignment/__init__.py @@ -1,4 +1,4 @@ from sunkit_image.coalignment.interface import coalign -from sunkit_image.coalignment.match_template import match_template_coalign as _ +from sunkit_image.coalignment.match_template import match_template_coalign as _ # NOQA: F401 __all__ = ["coalign"] diff --git a/sunkit_image/coalignment/decorators.py b/sunkit_image/coalignment/decorators.py index 8d4cff0f..7a44b640 100644 --- a/sunkit_image/coalignment/decorators.py +++ b/sunkit_image/coalignment/decorators.py @@ -1,7 +1,7 @@ -__all__ = ["register_coalignment_method", "registered_methods"] +__all__ = ["register_coalignment_method", "REGISTERED_METHODS"] # Global Dictionary to store the registered methods and their names -registered_methods = {} +REGISTERED_METHODS = {} def register_coalignment_method(name): @@ -15,7 +15,7 @@ def register_coalignment_method(name): """ def decorator(func): - registered_methods[name] = func + REGISTERED_METHODS[name] = func return func return decorator diff --git a/sunkit_image/coalignment/interface.py b/sunkit_image/coalignment/interface.py index aa616131..de0d1cd5 100644 --- a/sunkit_image/coalignment/interface.py +++ b/sunkit_image/coalignment/interface.py @@ -10,7 +10,7 @@ from sunpy.sun.models import differential_rotation from sunpy.util.exceptions import SunpyUserWarning -from sunkit_image.coalignment.decorators import registered_methods +from sunkit_image.coalignment.decorators import REGISTERED_METHODS __all__ = ["AffineParams"] @@ -34,7 +34,7 @@ class AffineParams(NamedTuple): def _update_fits_wcs_metadata(reference_map, target_map, affine_params): """ - Update the metadata of a sunpy Map object based on affine transformation + Update the metadata of a sunpy.map.Map` based on affine transformation parameters. Parameters @@ -43,46 +43,39 @@ def _update_fits_wcs_metadata(reference_map, target_map, affine_params): The reference map object to which the target map is to be coaligned. target_map : `sunpy.map.Map` The original map object whose metadata is to be updated. - affine_params : object - An object containing the affine transformation parameters. This object must - have attributes for translation (dx, dy), scale, and rotation. + affine_params : `NamedTuple` + A `NamedTuple` containing the affine transformation parameters. + If you want to use a custom object, it must have attributes for "translation" (dx, dy), "scale", and "rotation_matrix". Returns ------- `sunpy.map.Map` A new sunpy map object with updated metadata reflecting the affine transformation. """ - # Extacting the affine parameters - pc_matrix = target_map.rotation_matrix - translation = affine_params.translation - scale = affine_params.scale - rotation_matrix = affine_params.rotation_matrix - # Updating the PC matrix - new_pc_matrix = pc_matrix @ rotation_matrix + # Updating the PC_ij matrix + new_pc_matrix = target_map.rotation_matrix @ affine_params.rotation_matrix # Calculate the new reference pixel. - old_reference_pixel = np.array([target_map.reference_pixel.x.value, target_map.reference_pixel.y.value]) - new_reference_pixel = scale*rotation_matrix @ old_reference_pixel + translation + old_reference_pixel = np.asarray([target_map.reference_pixel.x.value, target_map.reference_pixel.y.value]) + new_reference_pixel = affine_params.scale * affine_params.rotation_matrix @ old_reference_pixel + affine_params.translation reference_coord = reference_map.wcs.pixel_to_world(new_reference_pixel[0],new_reference_pixel[1]) Txshift = reference_coord.Tx - target_map.reference_coordinate.Tx Tyshift = reference_coord.Ty - target_map.reference_coordinate.Ty + # Create a new map with the updated metadata fixed_map = target_map.shift_reference_coord(Txshift, Tyshift) - fixed_map.meta["PC1_1"] = new_pc_matrix[0, 0] fixed_map.meta["PC1_2"] = new_pc_matrix[0, 1] fixed_map.meta["PC2_1"] = new_pc_matrix[1, 0] fixed_map.meta["PC2_2"] = new_pc_matrix[1, 1] - - fixed_map.meta['cdelt1'] = (target_map.scale[0] / scale[0]).value - fixed_map.meta['cdelt2'] = (target_map.scale[1] / scale[1]).value - + fixed_map.meta['cdelt1'] = (target_map.scale[0] / affine_params.scale[0]).value + fixed_map.meta['cdelt2'] = (target_map.scale[1] / affine_params.scale[1]).value return fixed_map -def _warn_user_of_separation(reference_map,target_map): +def _warn_user_of_separation(reference_map, target_map): """ - Issues a warning if the separation between the reference and target maps is - large. + Issues a warning if the separation between the ``reference_map`` and + ``target_map`` is large. Parameters ---------- @@ -124,15 +117,16 @@ def _warn_user_of_separation(reference_map,target_map): def coalign(reference_map, target_map, method='match_template'): """ - Performs image coalignment using a specified method (defaults to - `~sunkit_image.coalignment.match_template.match_template_coalign`). This - function updates the metadata of the target map to align it with the - reference map. + Performs image coalignment using the specified method. + + This function updates the metadata of the target map to align it with the reference map. .. note:: - * This function is intended to correct maps with known incorrect metadata. It is not designed to address issues like differential rotation or changes in observer location, which are encoded in the coordinate metadata. - * The function modifies the metadata of the map, not the underlying array data. For adjustments that involve coordinate transformations, consider using `~sunpy.map.GenericMap.reproject_to` instead. + * This function is intended to correct maps with known incorrect metadata. + It is not designed to address issues like differential rotation or changes in observer location, which are encoded in the coordinate metadata. + * The function modifies the metadata of the map, not the underlying array data. + For adjustments that involve coordinate transformations, consider using `~sunpy.map.GenericMap.reproject_to` instead. Parameters ---------- @@ -153,14 +147,12 @@ def coalign(reference_map, target_map, method='match_template'): ValueError If the specified method is not registered. """ - if method not in registered_methods: - msg = (f"Method {method} is not a registered method: {list(registered_methods.keys())}." + if method not in REGISTERED_METHODS: + msg = (f"Method {method} is not a registered method: {list(REGISTERED_METHODS.keys())}." "The method needs to be registered, with the correct import.") raise ValueError(msg) target_array = target_map.data reference_array = reference_map.data - _warn_user_of_separation(reference_map, target_map) - - AffineParams = registered_methods[method](reference_array, target_array) - return _update_fits_wcs_metadata(reference_map, target_map, AffineParams) + affine_params = REGISTERED_METHODS[method](reference_array, target_array) + return _update_fits_wcs_metadata(reference_map, target_map, affine_params) diff --git a/sunkit_image/coalignment/match_template.py b/sunkit_image/coalignment/match_template.py index 5ac72b43..dd531d88 100644 --- a/sunkit_image/coalignment/match_template.py +++ b/sunkit_image/coalignment/match_template.py @@ -94,28 +94,28 @@ def match_template_coalign(reference_array, target_array): Parameters ---------- - input_array : numpy.ndarray + input_array : `numpy.ndarray` The input 2D array to be coaligned. - template_array : numpy.ndarray + template_array : `numpy.ndarray` The template 2D array to align to. Returns ------- - AffineParams - A named tuple containing the following affine transformation parameters: + `sunkit_image.coalignment.interface.AffineParams` + A `NamedTuple` containing the following affine transformation parameters: - - scale : list + - scale : `list` A list of tuples representing the scale transformation as an identity matrix. - - rotation : float + - rotation : `float` The rotation angle in radians, which is fixed at 0.0 in this function. - - translation : tuple + - translation : `tuple` A tuple containing the x and y translation values. - """ corr = match_template(np.float64(reference_array), np.float64(target_array)) # Find the best match location y_shift, x_shift = _find_best_match_location(corr) - # Particularly for this method, there is no change in the rotation or scaling, hence the hardcoded values of scale to 1.0 & rotation to identity matrix + # Particularly for this method, there is no change in the rotation or scaling, + # hence the hardcoded values of scale to 1.0 & rotation to identity matrix scale = np.array([1.0, 1.0]) rotation_matrix = np.eye(2) return AffineParams(scale=scale, rotation_matrix=rotation_matrix, translation=(x_shift , y_shift )) diff --git a/sunkit_image/coalignment/tests/test_coalignment.py b/sunkit_image/coalignment/tests/test_coalignment.py index d98f2b0f..fa62abaf 100644 --- a/sunkit_image/coalignment/tests/test_coalignment.py +++ b/sunkit_image/coalignment/tests/test_coalignment.py @@ -1,24 +1,22 @@ -import warnings -import numpy as np -from numpy.testing import assert_allclose import matplotlib.pyplot as plt +import numpy as np import pytest -from scipy.ndimage import shift as sp_shift +from numpy.testing import assert_allclose import astropy.units as u -from astropy.io import fits from astropy.coordinates import SkyCoord +from astropy.io import fits import sunpy.map -from sunpy.net import Fido, attrs as a -from sunpy.util.exceptions import SunpyUserWarning +from sunpy.net import Fido +from sunpy.net import attrs as a from sunkit_image.coalignment import coalign -from sunkit_image.coalignment.decorators import register_coalignment_method, registered_methods +from sunkit_image.coalignment.decorators import register_coalignment_method from sunkit_image.coalignment.interface import AffineParams -from sunkit_image.data.test import get_test_filepath from sunkit_image.tests.helpers import figure_test + @pytest.fixture() def eis_test_map(): url = "https://github.com/sunpy/data/raw/main/sunkit-image/eis_20140108_095727.fe_12_195_119.2c-0.int.fits" @@ -32,10 +30,10 @@ def test_coalignment(eis_test_map): nx = (aia193_test_map.scale.axis1 * aia193_test_map.dimensions.x) / eis_test_map.scale[0] ny = (aia193_test_map.scale.axis2 * aia193_test_map.dimensions.y) / eis_test_map.scale[1] aia193_test_downsampled_map = aia193_test_map.resample(u.Quantity([nx, ny])) - coaligned_is_map = coalign(aia193_test_downsampled_map, eis_test_map, "match_template") - assert coaligned_is_map.data.shape == eis_test_map.data.shape - assert_allclose(coaligned_is_map.wcs.wcs.crval[0], aia193_test_downsampled_map.wcs.wcs.crval[0],rtol = 1e-2, atol = 0.13) - assert_allclose(coaligned_is_map.wcs.wcs.crval[1], aia193_test_downsampled_map.wcs.wcs.crval[1],rtol = 1e-2, atol = 0.13) + coaligned_eis_map = coalign(aia193_test_downsampled_map, eis_test_map, "match_template") + assert coaligned_eis_map.data.shape == eis_test_map.data.shape + assert_allclose(coaligned_eis_map.wcs.wcs.crval[0], aia193_test_downsampled_map.wcs.wcs.crval[0],rtol = 1e-2, atol = 0.13) + assert_allclose(coaligned_eis_map.wcs.wcs.crval[1], aia193_test_downsampled_map.wcs.wcs.crval[1],rtol = 1e-2, atol = 0.13) @pytest.fixture() @@ -48,7 +46,10 @@ def cutout_map(aia171_test_map): def test_coalignment_reflects_pixel_shifts(cutout_map, aia171_test_map): - """Check if coalignment adjusts world coordinates as expected based on reference coordinate shifts.""" + """ + Check if coalignment adjusts world coordinates as expected based on + reference coordinate shifts. + """ messed_map = cutout_map.shift_reference_coord(25 * u.arcsec, 50 * u.arcsec) original_world_coords = cutout_map.reference_coordinate fixed_cutout_map = coalign(aia171_test_map, messed_map) @@ -71,7 +72,7 @@ def test_coalignment_figure(cutout_map, aia171_test_map): # Messed up map ax2 = fig.add_subplot(132, projection=messed_map) messed_map.plot(axes=ax2, title='Messed Cutout') - cutout_map.draw_contours(levels, axes=ax2, alpha=0.3) + cutout_map.draw_contours(levels, axes=ax2, alpha=0.3) # After coalignment ax3 = fig.add_subplot(133, projection=fixed_cutout_map) fixed_cutout_map.plot(axes=ax3, title='Fixed Cutout') diff --git a/sunkit_image/coalignment/tests/test_decorators.py b/sunkit_image/coalignment/tests/test_decorators.py index 8a3761c0..57df3bde 100644 --- a/sunkit_image/coalignment/tests/test_decorators.py +++ b/sunkit_image/coalignment/tests/test_decorators.py @@ -1,4 +1,4 @@ -from sunkit_image.coalignment.decorators import register_coalignment_method, registered_methods +from sunkit_image.coalignment.decorators import REGISTERED_METHODS, register_coalignment_method def test_register_coalignment_method(): @@ -6,6 +6,6 @@ def test_register_coalignment_method(): def test_func(): return "Test function" - assert "test_method" in registered_methods - assert registered_methods["test_method"] == test_func + assert "test_method" in REGISTERED_METHODS + assert REGISTERED_METHODS["test_method"] == test_func assert test_func() == "Test function" diff --git a/sunkit_image/coalignment/tests/test_match_template.py b/sunkit_image/coalignment/tests/test_match_template.py index 287be166..ca46e515 100644 --- a/sunkit_image/coalignment/tests/test_match_template.py +++ b/sunkit_image/coalignment/tests/test_match_template.py @@ -5,6 +5,7 @@ import astropy.units as u +from sunkit_image.coalignment.decorators import REGISTERED_METHODS from sunkit_image.coalignment.match_template import ( _find_best_match_location, _get_correlation_shifts, @@ -46,7 +47,12 @@ def test_get_correlation_shifts(): _get_correlation_shifts(test_array) -def test_find_best_match_location(aia171_test_map_layer, aia171_test_template, aia171_test_shift): - result = match_template(aia171_test_map_layer, aia171_test_template) +def test_find_best_match_location(aia171_test_map, aia171_test_template, aia171_test_shift): + with np.errstate(all='ignore'): + result = match_template(aia171_test_map.data, aia171_test_template) match_location = u.Quantity(_find_best_match_location(result)) assert_allclose(match_location.value, np.array(result.shape) / 2.0 - 0.5 + aia171_test_shift, rtol=1e-3, atol=0) + + +def test_registered_method(): + assert REGISTERED_METHODS["match_template"] is not None diff --git a/sunkit_image/conftest.py b/sunkit_image/conftest.py index 1d9fe4ec..26fa2498 100644 --- a/sunkit_image/conftest.py +++ b/sunkit_image/conftest.py @@ -183,8 +183,7 @@ def aia_171(request): @pytest.fixture() def hmi_map(): - hmi_file = get_test_filepath("hmi_continuum_test_lowres_data.fits") - return sunpy.map.Map(hmi_file) + return sunpy.map.Map(get_test_filepath("hmi_continuum_test_lowres_data.fits")) @pytest.fixture() @@ -198,31 +197,21 @@ def aia171_test_map(): return sunpy.map.Map(Path(testpath) / "aia_171_level1.fits") -@pytest.fixture() -def aia171_test_shift(): - return np.array([3, 5]) - - -@pytest.fixture() -def aia171_test_map_layer(aia171_test_map): - return aia171_test_map.data.astype("float32") # SciPy 1.4 requires at least 16-bit floats - - @pytest.fixture() def aia171_test_map_layer_shape(aia171_test_map_layer): return aia171_test_map_layer.shape @pytest.fixture() -def aia171_test_template(aia171_test_shift, aia171_test_map_layer, aia171_test_map_layer_shape): - # Test template - a1 = aia171_test_shift[0] + aia171_test_map_layer_shape[0] // 4 - a2 = aia171_test_shift[0] + 3 * aia171_test_map_layer_shape[0] // 4 - b1 = aia171_test_shift[1] + aia171_test_map_layer_shape[1] // 4 - b2 = aia171_test_shift[1] + 3 * aia171_test_map_layer_shape[1] // 4 - return aia171_test_map_layer[a1:a2, b1:b2] +def aia171_test_shift(): + return np.array([3, 5]) @pytest.fixture() -def aia171_test_template_shape(aia171_test_template): - return aia171_test_template.shape +def aia171_test_template(aia171_test_shift, aia171_test_map): + a1 = aia171_test_shift[0] + aia171_test_map.data.shape[0] // 4 + a2 = aia171_test_shift[0] + 3 * aia171_test_map.data.shape[0] // 4 + b1 = aia171_test_shift[1] + aia171_test_map.data.shape[1] // 4 + b2 = aia171_test_shift[1] + 3 * aia171_test_map.data.shape[1] // 4 + # Requires at least 32-bit floats to pass. + return aia171_test_map.data[a1:a2, b1:b2].astype("float32") diff --git a/sunkit_image/tests/figure_hashes_mpl_390_ft_261_sunpy_600_astropy_610.json b/sunkit_image/tests/figure_hashes_mpl_390_ft_261_sunpy_600_astropy_610.json index 3698041d..4afd8a2b 100644 --- a/sunkit_image/tests/figure_hashes_mpl_390_ft_261_sunpy_600_astropy_610.json +++ b/sunkit_image/tests/figure_hashes_mpl_390_ft_261_sunpy_600_astropy_610.json @@ -2,6 +2,8 @@ "sunkit_image.coalignment.tests.test_coalignment.test_coalignment_figure": "2339ce38ff576888472a5f527b80c24ff34f0f7e9d7631af0eeefc96accb7ac7", "sunkit_image.tests.test_enhance.test_mgn[array]": "f7a8e5a7377422c652a47217981d1c3bd1a66b5c211eae6ef18e4cef2660e438", "sunkit_image.tests.test_enhance.test_mgn[map]": "50bb490a6cc2408befe13c7f2a54f7433df80c2473dd21b619ace35de7e8f250", + "sunkit_image.tests.test_enhance.test_wow[array]": "fe6ee53b57b2fc6d8ce8a96e4273c3ddbe17057aeded32611b8e7294648d28e5", + "sunkit_image.tests.test_enhance.test_wow[map]": "f5535fad0fe2d6ff2bfdfb10a984bb6a21ece95d971070482136fe6e6f874f1a", "sunkit_image.tests.test_radial.test_fig_nrgf": "3193fd00cf0d48c8f7aee21ed4b3a71a65e30ef80edecf0fd55330528b475a4a", "sunkit_image.tests.test_radial.test_fig_fnrgf": "404b6b49279eb2ff76c7ec63b632ed397bcf71e2db4ac6cfaf20c00b9d885cf5", "sunkit_image.tests.test_radial.test_fig_rhef": "c38e2522793b222438bc076576ef640a2c1b43b019b3e0558adecd6d25f61405", @@ -9,4 +11,4 @@ "sunkit_image.tests.test_stara.test_stara_plot": "88a1fafc42b22264a68a9b633bfa3bbe22ce3e89cbf8db15920a9d28b62e49f6", "sunkit_image.tests.test_trace.test_occult2_fig[array]": "e59f4c476b6b27788ab8dc397cb0d2f34f8d6032eced289fd2eabeb324b39558", "sunkit_image.tests.test_trace.test_occult2_fig[map]": "e59f4c476b6b27788ab8dc397cb0d2f34f8d6032eced289fd2eabeb324b39558" -} \ No newline at end of file +}