Skip to content

refactor channel on top of abstract channel class - #419

Draft
nabobalis wants to merge 11 commits into
mainfrom
channel_refactor
Draft

refactor channel on top of abstract channel class#419
nabobalis wants to merge 11 commits into
mainfrom
channel_refactor

Conversation

@nabobalis

@nabobalis nabobalis commented Aug 10, 2026

Copy link
Copy Markdown
Member

This is a first (second PR) attempt at refactoring the Channel class on top of the AbstractChannel class from sunkit-instruments. The latter is still in the form of a draft PR sunpy/sunkit-instruments#98 so this is an experimental PR at this stage.

The goal here is to easily enable calculating the temperature response functions.

As it stands, this represents a breaking change to the Channel API.

ToDos before this can be merged:

Summary by Sourcery

Refactor the AIA response Channel to build on sunkit_instruments.AbstractChannel, redefining effective area and degradation handling and introducing a time-bound channel API for response calculations.

Enhancements:

  • Rename and reorganize channel optical properties (mirror reflectance, filter transmittance, geometrical area, quantum efficiency) and recompute effective area as a pristine plus optional crosstalk component with time-dependent degradation.
  • Introduce configuration on Channel for EVE cross-calibration, crosstalk inclusion, correction tables, and calibration version, with internal caching and a new degradation API that combines instrument and EVE factors.
  • Add support for binding observation times via AbstractChannel.at so that effective area and wavelength response can be evaluated for specific epochs without mutating the underlying channel.
  • Adjust wavelength response calculations to use the refactored effective area, degradation handling, and pixel solid angle for consistency with SolarSoft/IDL results.
  • Update the AIA response gallery example to reflect the new property names, effective area interface, crosstalk control, and time-binding workflow.

Build:

  • Add a temporary sunkit-instruments Git dependency pointing at the AbstractChannel-based channel branch.

Documentation:

  • Add breaking-change changelog entries documenting the Channel refactor and new API.
  • Revise narrative documentation in the response function example to reflect the updated formulation, property names, and time-dependent correction usage.

Tests:

  • Refactor Channel tests to cover the new property names, pristine effective area computation, EVE correction helper, time-bound channels, and alignment of effective area and wavelength response with SSW/IDL to within tolerance.
  • Update FUV channel tests to assert the new contamination fallback behavior across the wavelength array.

Summary by Sourcery

Refactor the AIA response Channel to subclass sunkit_instruments.AbstractChannel, introducing a time-bindable channel API and reorganized optical properties while updating effective area, degradation, and wavelength response handling.

New Features:

  • Add configuration options on Channel for EVE cross-calibration, crosstalk inclusion, correction tables, and calibration version, with support for binding observation times via AbstractChannel.at.

Enhancements:

  • Rename and reorganize channel optical properties (mirror reflectance, filter transmittance, geometrical area, quantum efficiency) and recompute effective area as a combination of pristine optics, optional crosstalk, and time-dependent degradation.
  • Align wavelength response calculations with SolarSoft/IDL by incorporating pixel solid angle and using the refactored effective area and degradation model.
  • Handle missing preflight contamination data for FUV channels by falling back to unity across the wavelength grid.

Build:

  • Temporarily depend on a git-based sunkit-instruments version providing AbstractChannel.

Documentation:

  • Update the response function example to use the new Channel API, property names, crosstalk configuration, and time-binding workflow.
  • Add breaking-change changelog entries describing the Channel refactor and new API.

Tests:

  • Refactor Channel tests to cover the new optical properties, pristine effective area computation, EVE correction helper, time-bound channels, and agreement of effective area and wavelength response with SSW/IDL.
  • Adjust FUV channel tests to validate the new contamination fallback behavior.

@sourcery-ai

sourcery-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors aiapy.response.Channel to subclass sunkit_instruments.AbstractChannel, restructures channel optical/calibration properties and effective area/degradation computations into a time-bindable API, updates tests and examples to the new naming and behavior, and temporarily pins sunkit-instruments from a Git branch.

File-Level Changes

Change Details Files
Refactor Channel to subclass AbstractChannel and introduce a time-bound channel API for effective area and response calculations.
  • Change Channel to inherit from sunkit_instruments.response.abstractions.AbstractChannel and use Mapping instead of OrderedDict for instrument data inputs.
  • Extend Channel.init to accept include_eve_correction, include_crosstalk, correction_table, and calibration_version and store them as configuration attributes.
  • Implement correction_table property with lazy resolution and caching from path, table, or default SSW source, plus derived _correction_table and _calibration_version helpers.
  • Introduce degradation(obstime) that combines aiapy.calibrate.degradation with an optional EVE cross-calibration factor, returning unity when obstime is None.
  • Adopt AbstractChannel.at(obstime) to bind/unbind observation time via _obstime and make effective_area depend on bound time rather than explicit parameters.
aiapy/response/channel.py
Rename and reorganize optical property accessors and recompute effective area using pristine plus optional crosstalk components with preflight contamination handling.
  • Rename primary_reflectance/secondary_reflectance to primary_mirror_reflectance/secondary_mirror_reflectance and add mirror_reflectance as their product.
  • Rename focal_plane_filter_efficiency/entrance_filter_efficiency to focal_plane_filter_transmittance/entrance_filter_transmittance and add filter_transmittance as their product.
  • Rename geometrical_collecting_area to geometrical_area and quantum_efficiency to effective_quantum_efficiency for clarity and alignment with AbstractChannel.
  • Replace contamination with _preflight_contamination that falls back to ones over the wavelength array when contamination data is missing (e.g., FUV channels).
  • Add energy_per_electron, camera_gain, and pixel_solid_angle properties, and define _pristine_effective_area from geometry, mirrors, filters, QE, and preflight contamination.
  • Rework crosstalk into a private _crosstalk effective area term using pristine effective areas of the paired telescope channel, now constructed via type(self).
  • Redefine effective_area() as property method that returns the pristine effective area plus optional crosstalk, scaled by time-dependent degradation when the channel is time-bound.
aiapy/response/channel.py
Refactor EVE cross-calibration handling into a private helper and adjust wavelength_response to use the new effective area, degradation, and pixel solid angle.
  • Add private _get_eve_correction(obstime) that reproduces aia_bp_corrections.pro logic by selecting a correction epoch and interpolating to the pristine effective area.
  • Replace eve_correction public method with the new degradation API that optionally multiplies by _get_eve_correction when include_eve_correction is True.
  • Update wavelength_response to rely on the refactored effective_area, degradation, gain/camera model, and pixel_solid_angle so results align with SSW/IDL to within tolerances.
aiapy/response/channel.py
Update Channel tests to cover the new API, property names, time-binding behavior, and SSW/IDL alignment including FUV contamination fallback.
  • Adjust the channel_properties fixture to reflect new property names and drop removed ones like contamination, gain, and crosstalk.
  • Replace direct effective area recomputation test with test_nominal_effective_area that compares effective_area() to effarea stored in the instrument file when crosstalk is disabled.
  • Refactor EVE-related tests to use the new correction_table and calibration_version attributes and the get_eve_correction helper instead of eve_correction.
  • Add a parametrized test_effective_area that exercises combinations of obstime, correction_table sources, calibration_version, and include* flags using the at() API and checks the output shape.
  • Add test_at_returns_bound_copy to verify that at(obstime) returns a new time-bound channel, does not mutate the original, and that at(None) unbinds back to the pristine effective area.
  • Update wavelength_response_* tests to set correction_table/include flags on the Channel, use at(time) where appropriate, and compare to SSW results scaled by pixel_solid_angle using u.allclose.
  • Extend FUV channel tests to assert that _preflight_contamination falls back to ones across the wavelength array instead of a single 1 value.
aiapy/response/tests/test_channel.py
Revise the response function example to use the new Channel interface, property names, effective area API, and time-binding workflow.
  • Update the response function equation in the narrative to include pixel solid angle and reword description of transmittance and effective quantum efficiency.
  • Change plot usage from old property names to primary_mirror_reflectance/secondary_mirror_reflectance and entrance_filter_transmittance/focal_plane_filter_transmittance.
  • Swap the old contamination and quantum_efficiency plots for quantum efficiency and effective_area(), updating axes limits and labels accordingly.
  • Update wavelength response calculation to assign correction_table on the Channel and call wavelength_response() without passing it every time.
  • Adjust crosstalk example to construct a Channel with include_crosstalk=False instead of passing a flag to wavelength_response.
  • Switch time-dependent correction examples to use channel.at(obstime) and separate channels for EVE-corrected vs. non-EVE-corrected responses, removing explicit obstime/include_* parameters from wavelength_response calls.
  • Remove hard-coded y-axis limits that no longer match the revised response scaling and units.
examples/calculate_response_function.py
Align calibrate.prep documentation and sunkit-instruments dependency with the refactored Channel API.
  • Update the aiapy.calibrate.prep.degradation docstring See Also section to reference aiapy.response.Channel.degradation instead of the removed eve_correction.
  • Add a temporary Git-based sunkit-instruments dependency pointing to the AbstractChannel-based channel branch in pyproject.toml to ensure the new base class is available during development and CI.
  • Add breaking-change changelog entries documenting the Channel refactor, new property names, and API changes for users.
  • Include several breaking-change changelog fragment files for issue 344 to be merged into the release notes.
aiapy/calibrate/prep.py
pyproject.toml
changelog/344.breaking.1.rst
changelog/344.breaking.2.rst
changelog/344.breaking.3.rst
changelog/344.breaking.rst

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants