Skip to content

Add CDAWeb CDF support for WIND and STEREO - #254

Open
Amityush-lgtm wants to merge 9 commits into
sunpy:mainfrom
Amityush-lgtm:add-cdaweb-support
Open

Add CDAWeb CDF support for WIND and STEREO #254
Amityush-lgtm wants to merge 9 commits into
sunpy:mainfrom
Amityush-lgtm:add-cdaweb-support

Conversation

@Amityush-lgtm

Copy link
Copy Markdown
Contributor

PR Description

Fixes #199
This PR adds support for reading CDAWeb CDF files

Changes:

  • Added parsing logic to _read_cdf to handle WIND WAVES (RAD1/RAD2) files sourced from CDAWeb.
  • Added parsing logic for STEREO S/WAVES (LFR/HFR).
  • Added mock tests for both WIND and STEREO CDAWeb parsing.

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 add CDAWeb cdf support for WIND and STEREO Add CDAWeb CDF support for WIND and STEREO Jul 7, 2026
raw_freqs = cdf.varget("FREQUENCY")
freq_fill = cdf.varattsget("FREQUENCY").get("FILLVAL", -1e31)
valid_freq_mask = raw_freqs > freq_fill
freqs = raw_freqs[valid_freq_mask] << u.Unit(cdf.varattsget("FREQUENCY").get("UNITS", "Hz"))

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.

Hum the fill value isn't used is it? Maybe do the assignment and filling the convert to a unit?

@Amityush-lgtm Amityush-lgtm Jul 7, 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, working on the assignment. One doubt, what should i use to replace the fill values?? np.nan or 0???

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

I've pushed an update using np.nan for the fill value for now, let me know what you think

@hayesla hayesla 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 looking good! there are two small bugs thought when I tested it with the real data files.

also could you add tests for teh two new data file paths? (using @pytest.mark.remote_data tests), an online test against a real CDAWeb file would cover the real parsing (and would have caught the two plotting issues I raised here)

Comment thread radiospectra/spectrogram/spectrogram_factory.py Outdated
Comment thread radiospectra/spectrogram/spectrogram_factory.py
Comment thread radiospectra/spectrogram/spectrogram_factory.py Outdated
Comment thread radiospectra/spectrogram/spectrogram_factory.py
@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

this is looking good! there are two small bugs thought when I tested it with the real data files.

also could you add tests for teh two new data file paths? (using @pytest.mark.remote_data tests), an online test against a real CDAWeb file would cover the real parsing (and would have caught the two plotting issues I raised here)

Thanks for testing this, i'll update the frequency handling accordingly and add online cdaweb tests for both the WIND and STEREO paths so we can cover the real parsing as well.

Comment thread radiospectra/spectrogram/spectrogram_factory.py
@Amityush-lgtm
Amityush-lgtm requested a review from hayesla July 17, 2026 18:24
@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

It seems the failure was due to a deprecation warning in cdflib with newer NumPy version and this one is due to server issue ig, i have added a warning filter to it


meta = {
"cdf_globals": cdf_globals,
"detector": "LFR+HFR",

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.

Im not too familiar with this data product or instruments but I think it makes sense to be able to read and plot the data from the different detectors separately. Unless it's only given by the instrument team as one file I can imagine a world where you would also like one without the other?

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.

Maybe the data can be separated using crop_freq() to get specific frequency range

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.

hmmm true, it looks like the freq ranges overlap though (10-160 kHz and 125kHz - 16MHz), I would vote to separate them but @samaloney or @hayesla might have better perspective

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 guess the question for @Amityush-lgtm is where did you get "LFR+HFR" from to hardcode in here? i think this reader works on one file (rather than seperate HFR+LFR files so i think its ok

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 wrote "LFR+HFR" because the CDAWeb files actually combines both the LFR and HFR into one single array so, i thought "LFR+HFR" would may be right name the detector

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.

Keeping this reader is the best! Maybe at one point we can add readers for the LFR and HFR data separately as they won't work by default with this one but, that can be for a different and future PR
from the CDF file it looks like it could be L3 data which was surprising @hayesla (Data_type : ['L3>Level 3'])
https://gist.github.com/Hermanlrx/0f149107efdb3c29e44759ae894c3294

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.

radiospectra shouldn't be changing the data only loading so if the file is combined leave it but this could make nice gallery example later showing how to split using crop_by_values.

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.

ok sounds good @Amityush-lgtm ! maybe open an issue to add support for the LFR/HFR seperate files @Hermanlrx and that can be in another PR

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.

Sounds good, I'll open the issue right away

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.

radiospectra shouldn't be changing the data only loading so if the file is combined leave it but this could make nice gallery example later showing how to split using crop_by_values.

Should i add this in the issue or make a seperate issue for this?


meta = {
"cdf_globals": cdf_globals,
"detector": "LFR+HFR",

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.

ok sounds good @Amityush-lgtm ! maybe open an issue to add support for the LFR/HFR seperate files @Hermanlrx and that can be in another PR

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.

Add support for radio data supplied by cdaweb

4 participants