spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
143 stars 58 forks source link

cdflib bug: global attributes always returned as lists, even if the CDF has them as scalars #811

Closed jameswilburlewis closed 3 months ago

jameswilburlewis commented 3 months ago

cdflib versions 1.2.0 through 1.2.6 seem to always return lists for global attribute values. This breaks some PySPEDAS code which tries to do string comparisons or extract substrings, and gets lists instead. I've added workarounds for this handful of specific cases, but we'll want to switch them back when a cdflib patch is released.

I've opened an issue in the cdflib repository: https://github.com/MAVENSDC/cdflib/issues/240

jameswilburlewis commented 3 months ago

We have a workaround now (check the datatype before attempting to manipulate the attribute, take the first element if necessary).