Skip to content

Fix #110: Ensure spectrogram plotting correctly handles non-UTC time scales#144

Merged
samaloney merged 6 commits intosunpy:mainfrom
Amityush-lgtm:fix-cdf-time-scale
Feb 20, 2026
Merged

Fix #110: Ensure spectrogram plotting correctly handles non-UTC time scales#144
samaloney merged 6 commits intosunpy:mainfrom
Amityush-lgtm:fix-cdf-time-scale

Conversation

@Amityush-lgtm
Copy link
Copy Markdown
Contributor

PR Description

Fixes an issue where plotting data with different time scales i.e. 'tt' and 'utc' would result in time offsets because GenericSpectrogram plotting was using the raw time scale components directly via .datetime. Corrects the plotting logic to always convert to UTC first.
Closes #110

What changed

  • Modified radiospectra/mixins.py to ensure self.times is converted to UTC before generating datetime objects for plotting.
  • Added internal helper _times_utc_datetime to handle the conversion if supported by the time object.
  • Validated that plotting correctly aligns with UTC time regardless of input time scale.

@samaloney, Let me know your thoughts on this!!

@samaloney
Copy link
Copy Markdown
Member

This is not specific to this PR. I'm posting this to all open PRs. Please be aware of the update to our AI usage policy, specifically on the disclosure of and acceptable uses of AI.

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 RP but I'm not sure defaulting to UTC is the best option. What if someone wants to plot in tt scale, it would be better to convert to the existing scale if one exists.

Should be able to use or follow similar approach to astroy's time_support

@Amityush-lgtm
Copy link
Copy Markdown
Contributor Author

Thanks a lot for your response. @samaloney I am currently working on a way to solve the issue by not defaulting to UTC but i am stuck and having a doubt regarding the scales. For mixed time scales on the same axes, should the first plotted scale define the axis scale for the plots?

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.

Great I think this is almost ready just a small tidy up of the imports and should be good to go.

@samaloney samaloney merged commit f497cd4 into sunpy:main Feb 20, 2026
18 of 19 checks passed
Amityush-lgtm pushed a commit to Amityush-lgtm/radiospectra that referenced this pull request Feb 20, 2026
samaloney pushed a commit that referenced this pull request Feb 23, 2026
* Resolve conflicts with merged PR #144 and simplify axis converter
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.

Time with different scale may be plotted unintentionally.

2 participants