Skip to content

Commit 1f04351

Browse files
committed
Tweaks from Nabil
1 parent b910153 commit 1f04351

File tree

9 files changed

+45
-64
lines changed

9 files changed

+45
-64
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: "v0.13.3"
3+
rev: "v0.14.0"
44
hooks:
55
- id: ruff
66
args: ["--fix", "--unsafe-fixes"]
@@ -30,8 +30,8 @@ repos:
3030
hooks:
3131
- id: codespell
3232
args: [ "--write-changes" ]
33-
- repo: https://github.com/crate-ci/typos
34-
rev: v1
33+
- repo: https://github.com/adhtruong/mirrors-typos
34+
rev: v1.38.0
3535
hooks:
3636
- id: typos
3737
- repo: https://github.com/pre-commit/mirrors-mypy

changelog/290.breaking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Increased the minimum required versions:
55
- sunpy 7.0.0 (from 6.0.0)
66
- NumPy 1.26.0 (from 1.23.5)
77
- Astropy 6.1.0 (from 5.3.0)
8-
- SciPy 1.11.0 (from 1.10.1)
8+
- SciPy 1.12.0 (from 1.10.1)

examples/aligning_aia_with_eis_maps.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@
66
This example shows how to coalign EIS rasters to AIA images in order correct for the pointing
77
uncertainty in EIS.
88
"""
9-
# sphinx_gallery_thumbnail_number = 2
10-
11-
129
import matplotlib.pyplot as plt
1310

1411
import astropy.units as u
1512
from astropy.visualization import AsinhStretch, ImageNormalize
1613

1714
import sunpy.map
18-
from sunpy.net import Fido
19-
from sunpy.net import attrs as a
2015

2116
from sunkit_image.coalignment import coalign
2217

2318
###################################################################################
2419
# For this example, we will use a preprocessed EIS raster image of the Fe XII
25-
# 195.119 Å line. This raster image was prepared using the `eispac <https://eispac.readthedocs.io/en/latest/>`_ package.
26-
20+
# 195.119 Å line.
21+
# This raster image was prepared using the `eispac <https://eispac.readthedocs.io/en/latest/>`__ package.
2722

2823
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")
2924

@@ -33,13 +28,17 @@
3328
# 193 Å channel of AIA as it sees plasma at approximately the same temperature as
3429
# the 195.119 Å line in our EIS raster.
3530

36-
query = Fido.search(
37-
a.Time(start=eis_map.date-1*u.minute, near=eis_map.date, end=eis_map.date+1*u.minute),
38-
a.Instrument.aia,
39-
a.Wavelength(193*u.angstrom)
40-
)
41-
aia_file = Fido.fetch(query, site='NSO')
42-
aia_map = sunpy.map.Map(aia_file)
31+
# Below is the Fido query to search and download the AIA data.
32+
# from sunpy.net import Fido
33+
# from sunpy.net import attrs as a
34+
# query = Fido.search(
35+
# a.Time(start=eis_map.date-1*u.minute, near=eis_map.date, end=eis_map.date+1*u.minute),
36+
# a.Instrument.aia,
37+
# a.Wavelength(193*u.angstrom)
38+
# )
39+
# aia_file = Fido.fetch(query, site='NSO')
40+
# For now though we have stored this file on Github so we can download it directly.
41+
aia_map = sunpy.map.Map("https://github.com/sunpy/data/raw/refs/heads/main/sunkit-image/aia.lev1.193A_2014_01_08T09_57_30.84Z.image_lev1.fits")
4342

4443
####################################################################################
4544
# Before coaligning the images, we first resample the AIA image to the same plate

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies = [
3434
"astropy>=6.1.0",
3535
"numpy>=1.26.0",
3636
"matplotlib>=3.8.0",
37-
"scipy>=1.11.0",
37+
"scipy>=1.12.0",
3838
"scikit-image>=0.20.0",
3939
"sunpy[map]>=7.0.0",
4040
]

sunkit_image/coalignment/interface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ def _update_fits_wcs_metadata(target_map, reference_map, affine_params):
9191
new_reference_coordinate.Tx - target_map.reference_coordinate.Tx,
9292
new_reference_coordinate.Ty - target_map.reference_coordinate.Ty,
9393
)
94-
# TODO: Support metadata updates to PCij/CDij and CDELT for non-unity scaling and
95-
# rotation in the affine transform
9694

9795

9896
def _warn_user_of_separation(target_map, reference_map):

sunkit_image/coalignment/phase_cross_correlation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ def phase_cross_correlation_coalign(target_array, reference_array, **kwargs):
3838
"""
3939
if target_array.shape != reference_array.shape:
4040
raise ValueError("Input and target arrays must be the same shape.")
41-
if "upsample_factor" not in kwargs:
42-
kwargs["upsample_factor"] = 20
4341
shift, _, _ = phase_cross_correlation(reference_array, target_array, **kwargs)
4442
# 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
43+
# See the example here:
4644
# https://scikit-image.org/docs/stable/auto_examples/registration/plot_register_translation.html
47-
x_shift, y_shift = -shift[1], -shift[0]
45+
x_shift, y_shift = shift[1], shift[0]
4846
log.debug(f"Phase cross correlation shift: x: {x_shift}, y: {y_shift}")
4947
# Particularly for this method, there is no change in the rotation or scaling,
5048
# hence the hardcoded values of scale to 1.0 & rotation to identity matrix

sunkit_image/coalignment/tests/test_coalignment.py

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@
77
from astropy.io import fits
88

99
import sunpy.map
10-
from sunpy.net import Fido
11-
from sunpy.net import attrs as a
1210

1311
from sunkit_image.coalignment import coalign
14-
from sunkit_image.coalignment.interface import (
15-
REGISTERED_METHODS,
16-
AffineParams,
17-
_update_fits_wcs_metadata,
18-
register_coalignment_method,
19-
)
12+
from sunkit_image.coalignment.interface import AffineParams, _update_fits_wcs_metadata
2013
from sunkit_image.tests.helpers import figure_test
2114

2215

@@ -28,16 +21,12 @@ def eis_test_map():
2821

2922

3023
@pytest.fixture()
31-
def aia193_test_map(eis_test_map):
32-
query = Fido.search(
33-
a.Time(start=eis_test_map.date-1*u.minute,
34-
end=eis_test_map.date+1*u.minute,
35-
near=eis_test_map.date),
36-
a.Instrument.aia,
37-
a.Wavelength(193*u.angstrom),
38-
)
39-
file = Fido.fetch(query, site='NSO')
40-
return sunpy.map.Map(file)
24+
def aia193_test_map():
25+
# This is matched to the EIS observation time
26+
url = "https://github.com/sunpy/data/raw/refs/heads/main/sunkit-image/aia.lev1.193A_2014_01_08T09_57_30.84Z.image_lev1.fits"
27+
with fits.open(url) as hdul:
28+
hdul.verify('silentfix')
29+
return sunpy.map.Map(hdul[1].data, hdul[1].header)
4130

4231

4332
@pytest.mark.remote_data()
@@ -116,32 +105,18 @@ def test_coalignment_figure(incorrect_pointing_cutout_map, cutout_map, aia171_te
116105
return fig
117106

118107

119-
def test_register_coalignment_method():
120-
@register_coalignment_method("test_method")
121-
def test_func():
122-
return "Test function"
123-
124-
assert "test_method" in REGISTERED_METHODS
125-
assert REGISTERED_METHODS["test_method"] == test_func
126-
assert test_func() == "Test function"
127-
128-
129108
def test_unsupported_affine_parameters(incorrect_pointing_cutout_map, aia171_test_map):
130109
affine_rot = AffineParams(
131110
scale=[1,1],
132111
rotation_matrix=2*np.eye(2),
133112
translation=[0,0],
134113
)
135114
with pytest.raises(NotImplementedError, match=r"Changes to the rotation metadata are currently not supported."):
136-
_ = _update_fits_wcs_metadata(incorrect_pointing_cutout_map,
137-
aia171_test_map,
138-
affine_rot)
115+
_update_fits_wcs_metadata(incorrect_pointing_cutout_map, aia171_test_map, affine_rot)
139116
affine_scale = AffineParams(
140117
scale=[2,3],
141118
rotation_matrix=np.eye(2),
142119
translation=[0,0],
143120
)
144121
with pytest.raises(NotImplementedError, match=r"Changes to the pixel scale metadata are currently not supported."):
145-
_ = _update_fits_wcs_metadata(incorrect_pointing_cutout_map,
146-
aia171_test_map,
147-
affine_scale)
122+
_update_fits_wcs_metadata(incorrect_pointing_cutout_map, aia171_test_map, affine_scale)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from sunkit_image.coalignment.interface import REGISTERED_METHODS, register_coalignment_method
2+
3+
4+
def test_register_coalignment_method():
5+
@register_coalignment_method("test_method")
6+
def test_func():
7+
return "Test function"
8+
9+
assert "test_method" in REGISTERED_METHODS
10+
assert REGISTERED_METHODS["test_method"] == test_func
11+
assert test_func() == "Test function"

sunkit_image/tests/figure_hashes_mpl_3100_ft_261_sunpy_700_astropy_710.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"sunkit_image.coalignment.tests.test_coalignment.test_coalignment_figure": "8d25cd83565991eff3ab88a789a33ac9b1c0b9edc0f63cc0414fe4ba6c1d50f3",
3-
"sunkit_image.tests.test_enhance.test_mgn[array]": "f7a8e5a7377422c652a47217981d1c3bd1a66b5c211eae6ef18e4cef2660e438",
3+
"sunkit_image.tests.test_enhance.test_mgn[array]": "d3ed034e34d03288aad08c06447fde42a8eb5c7ce4c0543a2090bb04c75fad1a",
44
"sunkit_image.tests.test_enhance.test_mgn[map]": "50bb490a6cc2408befe13c7f2a54f7433df80c2473dd21b619ace35de7e8f250",
55
"sunkit_image.tests.test_enhance.test_mgn_submap": "cf3948d3ffa8ed4eacc500bee170db68bb1a96d2cec1c92e48f74c01827dc397",
66
"sunkit_image.tests.test_enhance.test_mgn_cutout": "5b54d80ba0040a6eec181b8a83b5d294a4fbc60a5818651d67fc6dbf2690940f",
77
"sunkit_image.tests.test_enhance.test_wow[array]": "fe6ee53b57b2fc6d8ce8a96e4273c3ddbe17057aeded32611b8e7294648d28e5",
8-
"sunkit_image.tests.test_enhance.test_wow[map]": "f5535fad0fe2d6ff2bfdfb10a984bb6a21ece95d971070482136fe6e6f874f1a",
8+
"sunkit_image.tests.test_enhance.test_wow[map]": "4b7cbf0d529cb7680d0e4d738279ab54867c7160b251b3336f9c27e0f498ed9d",
99
"sunkit_image.tests.test_enhance.test_wow_submap": "73b8f7749ded1fd6898a7a83da4f755d4b6391c0215ca459be07982aeff9dae8",
10-
"sunkit_image.tests.test_enhance.test_wow_cutout": "880e8f961e6943cd2ee4ff32379ea0444e4b5cf1494b6b42b0dc027ee7adf532",
10+
"sunkit_image.tests.test_enhance.test_wow_cutout": "a4f8d8941378c952c62da0113b154f1b7eba1b8399cf8ac49215ba8269749fb5",
1111
"sunkit_image.tests.test_radial.test_fig_nrgf": "57b79f69ba537ff2ee37a879048f7d1232173567cc8c7b2e46988cb8b11a5575",
1212
"sunkit_image.tests.test_radial.test_fig_fnrgf": "42044b0b483cd9623c59530c93f4e71b817df335050a71bb9c026cbf429cd7bd",
1313
"sunkit_image.tests.test_radial.test_fig_rhef": "1c97e4b501d6f614b8777ef36c97a1d17645287020d2979c206f84d51cce6db6",
14-
"sunkit_image.tests.test_radial.test_multifig_rhef": "d8963086739e0f011394a9ceb007d851bf12f9b542decd9b3dcaeeb993e6cda0",
15-
"sunkit_image.tests.test_stara.test_stara_plot": "88a1fafc42b22264a68a9b633bfa3bbe22ce3e89cbf8db15920a9d28b62e49f6",
14+
"sunkit_image.tests.test_radial.test_multifig_rhef": "090d0416549db66274e1cfd8cd8a12cbaa2ed7062b641894977d5a75fd89c784",
15+
"sunkit_image.tests.test_stara.test_stara_plot": "5aac9b08827c4e7ae77919d8cf123f4c0852e6da17c9e436408aff64cc6132e5",
1616
"sunkit_image.tests.test_trace.test_occult2_fig[array]": "e59f4c476b6b27788ab8dc397cb0d2f34f8d6032eced289fd2eabeb324b39558",
1717
"sunkit_image.tests.test_trace.test_occult2_fig[map]": "e59f4c476b6b27788ab8dc397cb0d2f34f8d6032eced289fd2eabeb324b39558",
1818
"sunkit_image.tests.test_trace.test_occult2_cutout": "1b18459111342c3bab4a2c8fb08b012eef4a69767e08753d8918fe4987fa165d"

0 commit comments

Comments
 (0)