Skip to content

Initial base of GenericSpectrogram using NDCube#228

Open
Amityush-lgtm wants to merge 8 commits into
sunpy:ndcube-refactorfrom
Amityush-lgtm:ndcube-container
Open

Initial base of GenericSpectrogram using NDCube#228
Amityush-lgtm wants to merge 8 commits into
sunpy:ndcube-refactorfrom
Amityush-lgtm:ndcube-container

Conversation

@Amityush-lgtm

Copy link
Copy Markdown
Contributor

PR Description

This PR takes a step toward the ideas discussed in #218 and #209 by making GenericSpectrogram an ndcube.NDCube subclass.

Key Changes:

  • GenericSpectrogram now inherits from NDCube.
  • Added build_spectrogram_wcs using ndcube.extra_coords.table_coord to automatically generate WCS from time and frequency metadata.
  • Updated GenericSpectrogram to use WCS-aware .time and .frequency properties via axis_world_coords.
  • Safely updated legacy plotting mixins to use the new coordinate properties without breaking existing factory or plotting code.
  • Added ndcube to pyproject.toml.
    This keeps a stable foundation for using NDCube slicing and coordinate features while keeping the existing factory and mixins intact for now.

AI Assistance Disclosure

AI tools were used for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding
  • No AI tools were used

Regardless of AI use, the human contributor remains fully responsible for correctness, design choices, licensing compatibility, and long-term maintainability.

@Amityush-lgtm Amityush-lgtm changed the title Ndcube container Initial base of GenericSpectrogram using NDCube Jun 5, 2026
@hayesla hayesla added the NDCube Refactor This label is for issues/PR related to NDCube refactor for GSOC project 2026 label Jun 10, 2026

@samaloney samaloney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

Needs a change log I think you can use what in the PR description as a good start, also need to figure out the source of the test fail. If we know where it is can either add to list of ignored warning or fix

Comment thread pyproject.toml
Co-authored-by: Shane Maloney <maloneys@tcd.ie>
Comment thread pyproject.toml Outdated
@samaloney

Copy link
Copy Markdown
Member

I just applied a comment so you'll need to do a git pull or maybe git pull origin ndcube-container to get the changes locally

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

This looks great!

Needs a change log I think you can use what in the PR description as a good start, also need to figure out the source of the test fail. If we know where it is can either add to list of ignored warning or fix

Should the changelog be marked as a feature or something else?

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

I've added the changelog and marked it as a feature now will look at why the test is failing.

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

I found the problem, the oldestdeps test is failing due to AstropyDeprecationWarning for isiterable. looks like tox is installing the oldest sunpy but the newest astropy 7.2. Should i add a filter to ignore this warning for now???

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

The CI tests are passing now. Let me know if any other changes are required @samaloney and @hayesla

@samaloney samaloney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great first step, a few small suggestion mainly around documentation/docstrings.

Comment on lines -9 to -16
Base spectrogram class all spectrograms inherit.

Attributes
----------
meta : `dict-like`
Metadata for the spectrogram.
data : `numpy.ndarray`
The spectrogram data itself is a 2D array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep/add the atts/parameters section.

Comment on lines +17 to +20
This keeps the existing ``GenericSpectrogram(data, meta)`` construction
pattern while the factory and source-specific metadata design is still
being worked out. The time and frequency arrays are used to construct the
WCS and are also retained in ``meta`` for compatibility with existing code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this kind of narrative comment should be here it should be in the PR description or commit message etc

@Amityush-lgtm Amityush-lgtm Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Removing it

super().__init__(data=data, wcs=wcs, meta=meta, **kwargs)

@classmethod
def from_arrays(cls, time, frequency, data, meta=None, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so its used currently, i'll remove it for now.

Comment on lines +104 to +106
@property
def time(self):
return self.axis_world_coords("time")[0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a question but why are we adding a .time and the returning it from .times?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought .times and .frequencies were still widely used so I kept them while making .time and .frequency the primary WCS-based properties. Should i remove them??

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

Labels

NDCube Refactor This label is for issues/PR related to NDCube refactor for GSOC project 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants