Skip to content

Add coordinate lookup methods to GenericSpectrogram#183

Open
s7g4 wants to merge 1 commit intosunpy:mainfrom
s7g4:feature/coordinate-lookup-methods
Open

Add coordinate lookup methods to GenericSpectrogram#183
s7g4 wants to merge 1 commit intosunpy:mainfrom
s7g4:feature/coordinate-lookup-methods

Conversation

@s7g4
Copy link
Copy Markdown

@s7g4 s7g4 commented Mar 26, 2026

Description

This PR adds four coordinate lookup methods to the GenericSpectrogram base class to allow for easy conversion between array indices and physical units (frequency and time).

Specifically, it implements:

  • frequency_at_index(index) and time_at_index(index) for direct coordinate retrieval.
  • index_at_frequency(frequency) and index_at_time(time) using a nearest-neighbor approach with np.argmin on the absolute differences.

These methods are foundational for making radiospectra more coordinate-aware and align with the goals for my GSoC 2026 project proposal to modernize the package's data structures.

I've added unit tests for all four methods in radiospectra/spectrogram/tests/test_spectrogrambase.py and included a changelog fragment.

Issue(s) addressed

Checklist

  • I have followed the Coding Standards.
  • I have updated the documentation where necessary.
  • I have added tests for my changes.
  • I have added a changelog fragment.

Usage of Generative AI

  • I have used generative AI tools as an aid in developing this code.
  • I fully understand the proposed changes and can explain why they are the correct approach.

Explanation of AI usage: I used an AI assistant to help me learn and understand the codebase better. This was used as a learning and coding aid while I worked on the implementation. All of the code was written by me and checked throughly.

@samaloney
Copy link
Copy Markdown
Member

Thanks for the PR but as discussed on the issue #129 until the underling data structure is decided this work will most likely have to be redone so it not the best use of time and effort.

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