read_cdf/TimeSeries crashes if CDF variable doesn't have a 'FILLVAL' attribute #7565
Labels
Affects Dev
An issue/bug that affects master
Affects Release
An issue/bug that affects a released version (use a version label too)
Bug
Probably a bug
Effort Low
Requires a small time investment
Good First Issue
The best issues for new people to tackle!
io/CDF
Issue with CDF files
io
Affects the io submodule
Package Novice
Requires little knowledge of the internal structure of SunPy
Priority High
Rapid action required
timeseries
Affects the timeseries submodule
Describe the bug
Similar to #5907, I stumbled upon CDF files that aren't fully complying to the CDF ISTP Metadata Guidelines by having a variable that doesn't provide a corresponding FILLVAL attribute.
read_cdf()
is expecting this attribute to exist, and otherwise crashes (and with it alsoTimeSeries
):sunpy/sunpy/io/_cdf.py
Lines 83 to 87 in 9f0a37d
But as has been mentioned in #5907 (comment), it's not uncommon that a CDF file is not fully following the ISTP standard (these are by the way recent PSP data files, so I'll anyhow contact the instrument team). If the
FILLVAL
information isn't provided by the instrument team, one could just skip the replacement call. So I propose to changeif np.issubdtype(data.dtype, np.floating):
to something likeif np.issubdtype(data.dtype, np.floating) and 'FILLVAL' in attrs:
To Reproduce
Because the error message occurs in
read_cdf
when usingTimeSeries
, this is what I'm calling here directly:Screenshots
No response
System Details
Installation method
pip
The text was updated successfully, but these errors were encountered: