Skip to content

RFSSpectrogram level and version properties raise KeyError on real CDF files #184

@MohamedAli1937

Description

@MohamedAli1937

Describe the bug

The SpectrogramFactory parses the global attributes from CDF files and stores them in the metadata dictionary under the key "cdf_globals".

However, the RFSSpectrogram class properties (level and version) attempt to read from the key "cdf_meta".

This key mismatch causes a KeyError when attempting to access spec.level or spec.version on any spectrogram instantiated from a real PSP RFS CDF file. The existing unit tests pass because they skip the factory and mock the metadata with "cdf_meta" directly.

To Reproduce

import sunpy
from radiospectra.spectrogram import Spectrogram

# Assuming `file.cdf` is a valid Parker Solar Probe RFS file
spec = Spectrogram("file.cdf")

# This will raise a KeyError: 'cdf_meta'
print(spec.level)
print(spec.version)

Screenshots

No response

System Details

sunpy: 7.1.0
astropy: 7.2.0
matplotlib: 3.10.8
radiospectra: 0.1.dev519+ge9d493ba5
Python: 3.14.2
OS: Windows 11

Installation method

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProbably a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions