Skip to content

feature: add frequency_at_index method to GenericSpectrogram (#129).#172

Open
dhanushsaimudari wants to merge 4 commits intosunpy:mainfrom
dhanushsaimudari:feature-index
Open

feature: add frequency_at_index method to GenericSpectrogram (#129).#172
dhanushsaimudari wants to merge 4 commits intosunpy:mainfrom
dhanushsaimudari:feature-index

Conversation

@dhanushsaimudari
Copy link

@dhanushsaimudari dhanushsaimudari commented Mar 9, 2026

Added the frequency_at_index method to the GenericSpectrogram class. This method allows users to retrieve the physical frequency value associated with a specific array index along the frequency axis.

The implementation includes:

-Validation logic to ensure the provided index is within the bounds of the frequency axis.
-Raising a descriptive IndexError if the index is out of range, helping users debug data mapping issues.

AI Assistance Disclosure

AI tools were used for :

[x] Code generation (Initial drafting of the method structure)
[x] Research and understanding (Clarifying rST syntax for the changelog)

Note: I have manually verified the logic using a local test suite with dummy spectrogram data to ensure the mapping is accurate.

Related Issues
Closes #129

@samaloney
Copy link
Member

Thanks for the PR just a few housekeeping issues please retain and use the PR template which is created when the PR is opened. (You can see it here: https://github.com/sunpy/.github/blob/main/.github/PULL_REQUEST_TEMPLATE.md)

Also, please note, as discussed on the #129, this isn’t really ready for work until after the decision on the underlying data structure for the Spectrogram object.

@dhanushsaimudari
Copy link
Author

dhanushsaimudari commented Mar 11, 2026

Thank you for the feedback! @samaloney I have updated the PR description to follow the official template. I understand that the data structure decision for the Spectrogram object is still pending; I'm happy to keep this PR as a draft or wait for the decision before making further adjustments.

Also I'm looking at the background subtraction task. Are we prioritizing a specific algorithm like constant-median subtraction for the initial implementation, or are we more focused on the pluggable API structure first?

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.

Method that returns the frequency at a specific index on a Spectrogram

2 participants