Skip to content

Fixes time gap rendering in pcolormesh spectrogram plots#181

Open
MohamedAli1937 wants to merge 5 commits intosunpy:mainfrom
MohamedAli1937:fix-time-gaps
Open

Fixes time gap rendering in pcolormesh spectrogram plots#181
MohamedAli1937 wants to merge 5 commits intosunpy:mainfrom
MohamedAli1937:fix-time-gaps

Conversation

@MohamedAli1937
Copy link
Copy Markdown

@MohamedAli1937 MohamedAli1937 commented Mar 20, 2026

PR Description

Resolves the TODO in radiospectra/spectrogram/sources/eovsa.py that noted time gaps in spectrogram plots need to be rendered as actual gaps instead of being stretched across by pcolormesh.

fixes: #180

Solution:

  • Adds a _insert_time_gaps() helper to PcolormeshPlotMixin that detects gaps in the time axis and inserts NaN rows + midpoint timestamps so pcolormesh renders them as empty space.

Changes:

radiospectra/mixins.py:

  • Adds _insert_time_gaps(times, data, gap_threshold=None) static method.
  • Updates plot() with handle_gaps=True and gap_threshold=None parameters. The feature is enabled by default and backward compatible.

radiospectra/spectrogram/sources/eovsa.py:

  • Removes the outdated TODO comment.

radiospectra/tests/test_mixins.py (new):

  • Adds 5 unit tests covering no-gap, single-gap, multiple-gap, float-input, and manual-threshold cases.

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.

Screenshots:

time_gap_bug_demo

SunPyBot and others added 5 commits March 18, 2026 21:08
Copy link
Copy Markdown
Member

@samaloney samaloney left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I think the concept is good but needs some changes.

The image hence method in the PR isn't correct the size (in the x or time axis) of the data point before after the gap should be be same as the other?

As I mentioned in #180 since it very difficult to robustly detect gaps without detailed knowledge of the instrument and its operations this shouldn't be a default. Also I'm not sure it this kind of thing should be standalone function which returns a corrected spectrogram or method on the Spectrogram class. At the moment I'm leaning towards a standalone function.

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.

pcolormesh plots fill time gaps instead of showing them as empty

3 participants