Conversation
Contributor
Reviewer's GuideThis PR refactors the AIA PSF filter mesh parameter function into a new utility module, updates the PSF deconvolution example visuals with figure sizing and layout improvements, and standardizes test assertions across the codebase to use numpy.testing.assert_allclose. Class diagram for the new filter_mesh_parameters utilityclassDiagram
class filter_mesh_parameters {
+dict filter_mesh_parameters(use_preflightcore: bool = False)
"Returns mesh parameters for each AIA channel as a dictionary."
"Keys: angle_arm, error_angle_arm, spacing_e, spacing_fp, mesh_pitch, mesh_width, width, CDELT"
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
0cac46f to
badb4d7
Compare
Contributor
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `aiapy/psf/utils.py:90-97` </location>
<code_context>
- """
- return {
- 94 * u.angstrom: {
- "angle_arm": [49.81, 40.16, -40.28, -49.92] * u.deg,
- "error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
- "spacing_e": 8.99 * u.pixel,
- "mesh_pitch": 363.0 * u.um,
- "mesh_width": 34.0 * u.um,
- "spacing_fp": 0.207 * u.pixel,
- "width": (0.951 if use_preflightcore else 4.5) * u.pixel,
- "CDELT": [0.600109, 0.600109] * u.arcsec,
- },
- 131 * u.angstrom: {
</code_context>
<issue_to_address>
**nitpick:** Mixing 'u.deg' and 'u.degree' for units may cause confusion.
Standardize the angle unit to either 'u.deg' or 'u.degree' across all dictionary entries to ensure consistency and prevent potential bugs.
</issue_to_address>
### Comment 2
<location> `aiapy/psf/utils.py:10` </location>
<code_context>
-__all__ = ["_psf", "calculate_psf", "filter_mesh_parameters", "psf"]
-
-
-def filter_mesh_parameters(*, use_preflightcore=False):
- """
- Geometric parameters for meshes in AIA filters used to calculate the point
</code_context>
<issue_to_address>
**issue (complexity):** Consider refactoring the function to use shared constants and a per-channel table to reduce code repetition.
Here’s one way to collapse most of the repetition by moving per‐channel values into a small table and then iterating over it. All of the shared constants (`mesh_pitch`, `mesh_width`, default `width`, default `error_angle_arm`) live in one dict, and only the truly varying bits live in your table:
```python
import astropy.units as u
# module‐level constants
_COMMON = {
"mesh_pitch": 363.0 * u.um,
"mesh_width": 34.0 * u.um,
"error_angle_arm": [0.02, 0.02, 0.02, 0.02] * u.deg,
"default_width": 4.5 * u.pixel,
}
# per‐channel parameters
_CHANNELS = [
{
"wave": 94,
"angle": [49.81, 40.16, -40.28, -49.92],
"spacing_e": 8.99,
"spacing_fp": 0.207,
"preflight_width": 0.951,
"cdelt": 0.600109,
},
{
"wave": 131,
"angle": [50.27, 40.17, -39.70, -49.95],
"spacing_e": 12.37,
"spacing_fp": 0.289,
"preflight_width": 1.033,
"cdelt": 0.600698,
},
# … repeat for 171, 193, 211, 304, 335 …
{
"wave": 193,
"angle": [49.82, 39.57, -40.12, -50.37],
"spacing_e": 18.39,
"spacing_fp": 0.425,
"preflight_width": 1.512,
"cdelt": 0.600758,
"error_angle_arm": [0.02, 0.02, 0.03, 0.04],
},
]
def filter_mesh_parameters(*, use_preflightcore=False):
meshinfo = {}
for ch in _CHANNELS:
w = ch["wave"] * u.angstrom
# start with common parameters
params = {
**{k: _COMMON[k] for k in ("mesh_pitch", "mesh_width")},
"angle_arm": ch["angle"] * u.deg,
"spacing_e": ch["spacing_e"] * u.pixel,
"spacing_fp": ch["spacing_fp"] * u.pixel,
"CDELT": [ch["cdelt"], ch["cdelt"]] * u.arcsec,
# pick preflight or default width
"width": ((ch["preflight_width"] if use_preflightcore
else _COMMON["default_width"].value)
* u.pixel),
}
# override error_angle_arm if present, otherwise use common
err = ch.get("error_angle_arm", _COMMON["error_angle_arm"])
params["error_angle_arm"] = err * u.deg
meshinfo[w] = params
return meshinfo
```
– Extracts all the nearly‐identical fields into `_COMMON`
– Moves only the changing numbers into `_CHANNELS`
– Builds the final dict in a simple loop, preserving exactly the same units and values.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
25490c9 to
33c9af4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Refactor the PSF submodule by moving mesh parameter utilities into a separate file, clean up public API and deprecation metadata, enhance the PSF example plotting script, and standardize test assertion methods across the codebase with updated tolerances.
Enhancements:
Documentation:
Tests: