Skip to content

Commit badb4d7

Browse files
committed
Random tweaks
1 parent 12d5e45 commit badb4d7

10 files changed

Lines changed: 198 additions & 186 deletions

File tree

aiapy/calibrate/tests/test_prep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_correct_degradation(aia_171_map, source) -> None:
124124
uncorrected_over_corrected = aia_171_map.data / original_corrected.data
125125
# If intensity is zero, ratio will be NaN/infinite
126126
i_valid = aia_171_map.data > 0.0
127-
assert np.allclose(uncorrected_over_corrected[i_valid], d)
127+
np.testing.assert_allclose(uncorrected_over_corrected[i_valid], d)
128128

129129

130130
@pytest.mark.parametrize(
@@ -254,4 +254,4 @@ def test_register_cupy(aia_171_map) -> None:
254254
pytest.importorskip("cupy")
255255
cupy_map = register(aia_171_map, method="cupy")
256256
scipy_map = register(aia_171_map, method="scipy")
257-
assert np.allclose(cupy_map.data, scipy_map.data)
257+
np.testing.assert_allclose(cupy_map.data, scipy_map.data)

aiapy/calibrate/tests/test_spikes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_respike_meta(respiked_map) -> None:
3939
@pytest.mark.remote_data
4040
def test_fetch_with_prefetched_spikes(aia_193_level1_map, respiked_map, spikes) -> None:
4141
respiked_map_prefetched = respike(aia_193_level1_map, spikes=spikes)
42-
assert np.allclose(respiked_map.data, respiked_map_prefetched.data)
42+
np.testing.assert_allclose(respiked_map.data, respiked_map_prefetched.data)
4343

4444

4545
@pytest.mark.remote_data
@@ -56,7 +56,7 @@ def test_cutout(respiked_map, aia_193_level1_map) -> None:
5656
top_right=SkyCoord(*trc, frame=aia_193_level1_map.coordinate_frame),
5757
),
5858
)
59-
assert np.allclose(respiked_map_cutout.data, cutout_map_respiked.data)
59+
np.testing.assert_allclose(respiked_map_cutout.data, cutout_map_respiked.data)
6060

6161

6262
@pytest.mark.remote_data

aiapy/psf/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55

66
from .deconvolve import *
77
from .psf import *
8+
from .utils import *

aiapy/psf/psf.py

Lines changed: 3 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from sunpy import log
1010
from sunpy.util.decorators import deprecated
1111

12+
from aiapy.psf.utils import filter_mesh_parameters
1213
from aiapy.utils.decorators import validate_channel
1314

1415
try:
@@ -18,159 +19,7 @@
1819
except ImportError:
1920
HAS_CUPY = False
2021

21-
__all__ = ["_psf", "calculate_psf", "filter_mesh_parameters", "psf"]
22-
23-
24-
def filter_mesh_parameters(*, use_preflightcore=False):
25-
"""
26-
Geometric parameters for meshes in AIA filters used to calculate the point
27-
spread function.
28-
29-
Parameters
30-
----------
31-
use_preflightcore : `bool`, optional
32-
If True, use the pre-flight values for the filter mesh parameters
33-
34-
Returns
35-
-------
36-
meshinfo : `dict`
37-
Dictionary with filter mesh information for each channel. Each channel
38-
entry then contains another dictionary with the following keys
39-
describing filter mesh properties of that channel
40-
(see Table 2 of [1]_):
41-
42-
* ``angle_arm``: Angles of the four entrance filter arms
43-
* ``error_angle_arm``: Error in angle of the four entrance filter arms
44-
* ``spacing_e``: Distance between diffraction spikes from entrance filter
45-
* ``spacing_fp``: Distance between diffraction spikes from focal plane filter
46-
* ``mesh_pitch``: Pitch of the mesh
47-
* ``mesh_width``: Width of the mesh
48-
* ``width``: Width applied to the Gaussian such that *after*
49-
convolution we have the proper width
50-
(:math:`4/3` at :math:`1/e` of max)
51-
52-
References
53-
----------
54-
.. [1] `Grigis, P., Su, Y., Weber M., et al., 2012,
55-
AIA PSF Characterization and Deconvolution
56-
<https://sohoftp.nascom.nasa.gov/solarsoft/sdo/aia/idl/psf/DOC/psfreport.pdf>`_
57-
58-
See Also
59-
--------
60-
`calculate_psf` : Calculate the composite point spread function
61-
62-
Notes
63-
-----
64-
These parameters were calculated from the following images and
65-
reference background images.
66-
67-
94:
68-
69-
* image: 'AIA20101016_191039_0094.fits'
70-
* reference: 'AIA20101016_190903_0094.fits'
71-
72-
131:
73-
74-
* image: 'AIA20101016_191035_0131.fits'
75-
* reference: 'AIA20101016_190911_0131.fits'
76-
77-
171:
78-
79-
* image: 'AIA20101016_191037_0171.fits'
80-
* reference: 'AIA20101016_190901_0171.fits'
81-
82-
193:
83-
84-
* image: 'AIA20101016_191056_0193.fits'
85-
* reference: 'AIA20101016_190844_0193.fits'
86-
87-
211:
88-
89-
* image: 'AIA20101016_191038_0211.fits'
90-
* reference: 'AIA20101016_190902_0211.fits'
91-
92-
304:
93-
94-
* image: 'AIA20101016_191021_0304.fits'
95-
* reference: 'AIA20101016_190845_0304.fits'
96-
97-
335:
98-
99-
* image: 'AIA20101016_191041_0335.fits'
100-
* reference: 'AIA20101016_190905_0335.fits'
101-
"""
102-
return {
103-
94 * u.angstrom: {
104-
"angle_arm": [49.81, 40.16, -40.28, -49.92] * u.deg,
105-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
106-
"spacing_e": 8.99 * u.pixel,
107-
"mesh_pitch": 363.0 * u.um,
108-
"mesh_width": 34.0 * u.um,
109-
"spacing_fp": 0.207 * u.pixel,
110-
"width": (0.951 if use_preflightcore else 4.5) * u.pixel,
111-
"CDELT": [0.600109, 0.600109] * u.arcsec,
112-
},
113-
131 * u.angstrom: {
114-
"angle_arm": [50.27, 40.17, -39.70, -49.95] * u.deg,
115-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
116-
"spacing_e": 12.37 * u.pixel,
117-
"mesh_pitch": 363.0 * u.um,
118-
"mesh_width": 34.0 * u.um,
119-
"spacing_fp": 0.289 * u.pixel,
120-
"width": (1.033 if use_preflightcore else 4.5) * u.pixel,
121-
"CDELT": [0.600698, 0.600698] * u.arcsec,
122-
},
123-
171 * u.angstrom: {
124-
"angle_arm": [49.81, 39.57, -40.13, -50.38] * u.deg,
125-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
126-
"spacing_e": 16.26 * u.pixel,
127-
"mesh_pitch": 363.0 * u.um,
128-
"mesh_width": 34.0 * u.um,
129-
"spacing_fp": 0.377 * u.pixel,
130-
"width": (0.962 if use_preflightcore else 4.5) * u.pixel,
131-
"CDELT": [0.599489, 0.599489] * u.arcsec,
132-
},
133-
193 * u.angstrom: {
134-
"angle_arm": [49.82, 39.57, -40.12, -50.37] * u.deg,
135-
"error_angle_arm": [0.02, 0.02, 0.03, 0.04] * u.deg,
136-
"spacing_e": 18.39 * u.pixel,
137-
"mesh_pitch": 363.0 * u.um,
138-
"mesh_width": 34.0 * u.um,
139-
"spacing_fp": 0.425 * u.pixel,
140-
"width": (1.512 if use_preflightcore else 4.5) * u.pixel,
141-
"CDELT": [0.600758, 0.600758] * u.arcsec,
142-
},
143-
211 * u.angstrom: {
144-
"angle_arm": [49.78, 40.08, -40.34, -49.95] * u.deg,
145-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
146-
"spacing_e": 19.97 * u.pixel,
147-
"mesh_pitch": 363.0 * u.um,
148-
"mesh_width": 34.0 * u.um,
149-
"spacing_fp": 0.465 * u.pixel,
150-
"width": (1.199 if use_preflightcore else 4.5) * u.pixel,
151-
"CDELT": [0.600758, 0.600758] * u.arcsec,
152-
},
153-
304 * u.angstrom: {
154-
"angle_arm": [49.76, 40.18, -40.14, -49.90] * u.degree,
155-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
156-
"spacing_e": 28.87 * u.pixel,
157-
"mesh_pitch": 363.0 * u.um,
158-
"mesh_width": 34.0 * u.um,
159-
"spacing_fp": 0.670 * u.pixel,
160-
"width": (1.247 if use_preflightcore else 4.5) * u.pixel,
161-
"CDELT": [0.600165, 0.600165] * u.arcsec,
162-
},
163-
335 * u.angstrom: {
164-
"angle_arm": [50.40, 39.80, -39.64, -50.25] * u.degree,
165-
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
166-
"spacing_e": 31.83 * u.pixel,
167-
"mesh_pitch": 363.0 * u.um,
168-
"mesh_width": 34.0 * u.um,
169-
"spacing_fp": 0.738 * u.pixel,
170-
"width": (0.962 if use_preflightcore else 4.5) * u.pixel,
171-
"CDELT": [0.600737, 0.600737] * u.arcsec,
172-
},
173-
}
22+
__all__ = ["calculate_psf", "psf"]
17423

17524

17625
@u.quantity_input
@@ -335,7 +184,7 @@ def _psf(meshinfo, angles, diffraction_orders, *, focal_plane=False, use_gpu=Tru
335184
return (1 - area_not_mesh) * psf / psf.sum() + area_not_mesh * psf_core / psf_core.sum()
336185

337186

338-
@deprecated("1.0", alternative="calculate_psf")
187+
@deprecated("0.11.0", alternative="calculate_psf")
339188
@u.quantity_input
340189
def psf(channel: u.angstrom, *, use_preflightcore=False, diffraction_orders=None, use_gpu=True):
341190
"""

aiapy/psf/tests/test_psf.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
11
import numpy as np
2-
import pytest
3-
4-
import aiapy.psf
5-
from aiapy.conftest import CHANNELS
6-
7-
MESH_PROPERTIES = [
8-
"angle_arm",
9-
"error_angle_arm",
10-
"spacing_e",
11-
"spacing_fp",
12-
"mesh_pitch",
13-
"mesh_width",
14-
"width",
15-
]
16-
17-
18-
@pytest.mark.parametrize("use_preflightcore", [True, False])
19-
def test_filter_mesh_parameters(use_preflightcore) -> None:
20-
params = aiapy.psf.filter_mesh_parameters(use_preflightcore=use_preflightcore)
21-
assert isinstance(params, dict)
22-
assert all(c in params for c in CHANNELS)
23-
assert all(all(p in params[c] for p in MESH_PROPERTIES) for c in CHANNELS)
242

253

264
def test_psf(psf) -> None:

aiapy/psf/tests/test_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
3+
import aiapy.psf
4+
from aiapy.conftest import CHANNELS
5+
6+
MESH_PROPERTIES = [
7+
"angle_arm",
8+
"error_angle_arm",
9+
"spacing_e",
10+
"spacing_fp",
11+
"mesh_pitch",
12+
"mesh_width",
13+
"width",
14+
]
15+
16+
17+
@pytest.mark.parametrize("use_preflightcore", [True, False])
18+
def test_filter_mesh_parameters(use_preflightcore) -> None:
19+
params = aiapy.psf.filter_mesh_parameters(use_preflightcore=use_preflightcore)
20+
assert isinstance(params, dict)
21+
assert all(c in params for c in CHANNELS)
22+
assert all(all(p in params[c] for p in MESH_PROPERTIES) for c in CHANNELS)

0 commit comments

Comments
 (0)