MAVENSDC / cdflib

A python module for reading NASA's Common Data Format (cdf) files
MIT License
82 stars 45 forks source link

globalattsget() can't handle line breaks in an attribute field (since version 1.0.0) #226

Closed jgieseler closed 1 year ago

jgieseler commented 1 year ago

The new cdflib version 1.0+ can't handle any more line breaks in a (global) attribute field. With version 0.4.9 it worked.

Working example:

>>> import cdflib
>>> from sunpy.net import Fido
>>> from sunpy.net import attrs as a
>>> starttime="2022-1-26 10:30"
>>> endtime="2022-1-26 15:40"
>>> trange = a.Time(starttime, endtime)
>>> dataset = a.cdaweb.Dataset('PSP_ISOIS-EPIHI_L2-HET-RATES60')
>>> results = Fido.search(trange & dataset)
>>> files = Fido.fetch(results)
>>> cdf = cdflib.CDF(files[0])
>>> cdf.globalattsget()

Output with cdflib 1.0.5 (note e.g. HTTP_LINK or LINK_TITLE):

{'Acknowledgement': ['Cite McComas et al (2016), doi:10.1007/s11214-014-0059-1'],
 'Data_type': ['L2-HET-rates60>Level 2 HET 1-minute rates'],
 'Data_version': ['16'],
 'Descriptor': ['ISOIS-EPIHI>Integrated Science Investigation of the Sun, Energetic Particle Instrument Hi'],
 'Discipline': ['Solar Physics>Heliospheric Physics',
  'Solar Physics>Heliospheric Physics'],
 'File_naming_convention': ['source_descriptor_datatype_yyyyMMdd'],
 'Generated_by': ['ISOIS SOC, University of New Hampshire'],
 'Generation_date': ['20230513'],
 'HTTP_LINK': ['https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html',
  'https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html',
  'https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html',
  'https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html',
  'https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html'],
 'Input_files': ['psp_isois-epihi_l2-het-rates60_20220126_v4.4.0.cdf'],
 'Instrument_type': ['Particles (space)', 'Particles (space)'],
 'LINK_TEXT': ['Data ', 'Data ', 'Data ', 'Data ', 'Data '],
 'LINK_TITLE': ['Rules of Use',
  'Rules of Use',
  'Rules of Use',
  'Rules of Use',
  'Rules of Use'],
 'Logical_file_id': ['psp_isois-epihi_l2-het-rates60_20220126_v16'],
 'Logical_source': ['psp_isois-epihi_l2-het-rates60'],
 'Logical_source_description': ['Parker Solar Probe ISOIS EPI-Hi Level 2 HET 1-minute Rates'],
 'Mission_group': ['PSP'],
 'PI_affiliation': ['Princeton University'],
 'PI_name': ['David McComas'],
 'Project': ['LWS>Living With a Star'],
 'Skeleton_version': ['4.1.0'],
 'Software_version': ['4.1.0'],
 'Source_name': ['PSP>Parker Solar Probe'],
 'spase_DatasetResourceID': ['spase://VSPO/NumericalData/ParkerSolarProbe/ISOIS/EPI-Hi/HET/Fluxes/Level2/PT1M'],
 'Time_resolution': ['1 minute to 1 hour'],
 'TITLE': ['Parker Solar Probe ISOIS EPI-Hi Level 1 HET 1-minute Rates'],
 'Rules_of_use': ['See https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html.',
  'See https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html.'],
 'TEXT': ['EPI-Hi HET 60 second rates cdf. Time tags indicate midpoint of integration.',
  'EPI-Hi HET 60 second rates cdf. Time tags indicate midpoint of integration.']}

Output with cdflib 0.4.9:

{'Acknowledgement': 'Cite McComas et al (2016), doi:10.1007/s11214-014-0059-1',
 'Data_type': 'L2-HET-rates60>Level 2 HET 1-minute rates',
 'Data_version': '16',
 'Descriptor': 'ISOIS-EPIHI>Integrated Science Investigation of the Sun, Energetic Particle Instrument Hi',
 'Discipline': ['Solar Physics>Heliospheric Physics',
  'Space Physics>Interplanetary Studies'],
 'File_naming_convention': 'source_descriptor_datatype_yyyyMMdd',
 'Generated_by': 'ISOIS SOC, University of New Hampshire',
 'Generation_date': '20230513',
 'HTTP_LINK': ['https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html',
  'https://link.springer.com/article/10.1007%2Fs11214-014-0059-1',
  'http://fields.ssl.berkeley.edu/',
  'https://www2.mps.mpg.de/homes/fraenz/systems/',
  'https://spp-isois.sr.unh.edu/data_public/ISOIS_Data_Glossary.pdf'],
 'Input_files': 'psp_isois-epihi_l2-het-rates60_20220126_v4.4.0.cdf',
 'Instrument_type': ['Particles (space)', 'Plasma and Solar Wind'],
 'LINK_TEXT': ['Data ',
  'Instrument paper at ',
  'Magnetic field data for pitch angle calculation courtesy of ',
  'Coordinate systems according to definitions of ',
  'Detailed information in '],
 'LINK_TITLE': ['Rules of Use',
  'Space Science Reviews',
  'the FIELDS team',
  'Fraenz and Harper, PSS, 2002.',
  'ISOIS Data Glossary'],
 'Logical_file_id': 'psp_isois-epihi_l2-het-rates60_20220126_v16',
 'Logical_source': 'psp_isois-epihi_l2-het-rates60',
 'Logical_source_description': 'Parker Solar Probe ISOIS EPI-Hi Level 2 HET 1-minute Rates',
 'Mission_group': 'PSP',
 'PI_affiliation': 'Princeton University',
 'PI_name': 'David McComas',
 'Project': 'LWS>Living With a Star',
 'Skeleton_version': '4.1.0',
 'Software_version': '4.1.0',
 'Source_name': 'PSP>Parker Solar Probe',
 'spase_DatasetResourceID': 'spase://VSPO/NumericalData/ParkerSolarProbe/ISOIS/EPI-Hi/HET/Fluxes/Level2/PT1M',
 'Time_resolution': '1 minute to 1 hour',
 'TITLE': 'Parker Solar Probe ISOIS EPI-Hi Level 1 HET 1-minute Rates',
 'Rules_of_use': ['See https://spp-isois.sr.unh.edu/ISOIS_Terms_of_Use.html.',
  'Cite as, "McComas et al. (2016)" and contact the ISOIS instrument team before publication. Please do not distribute this file.'],
 'TEXT': ['EPI-Hi HET 60 second rates cdf. Time tags indicate midpoint of integration.',
  'Instrument paper: Integrated Science Investigation of the Sun (ISIS): Design of the Energetic Particle Investigation. McComas, D. J. et al (2016). Space Sci. Rev., doi:10.1007/s11214-014-0059-1']}
jgieseler commented 1 year ago

Thanks!