-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
io.read_xml_config <- io.hexfile crashes for file names with mixed case (a la Sta001.hex,Sta001.XMLCOM)
- In the above case,
Sta001.hexis specified; function looks forSTA001.XMLCONalternativelysta001.XMLCON. - Mixed case prefix is common in datasets I have seen.
---> Should modify io.read_xml_config be case agnostic..
Example:
import ctdproc as ctd
hexfile = Path('./data/Sta0001.hex')
c = ctd.io.CTDHex(hexfile)
This works if I rename Sta0001.XMLCON to STA0001.XMLCON or sta0001.XMLCON. If not, I get the error below.
Resulting output
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File ~/work/code/python/ctdproc/ctdproc/io.py:436, in CTDHex.read_xml_config(self)
435 try:
--> 436 with open(self.xmlfile) as fd:
437 tmp = xmltodict.parse(fd.read())
FileNotFoundError: [Errno 2] No such file or directory: 'data/sta0001.XMLCON'
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
Cell In[10], line 3
1 import ctdproc as ctd
2 hexfile = Path('./data/Sta0001.hex')
----> 3 c = ctd.io.CTDHex(hexfile)
File ~/work/code/python/ctdproc/ctdproc/io.py:82, in CTDHex.__init__(self, filename)
73 self._mapunits_freq = dict(
74 t1="°C",
75 t2="°C",
(...)
78 p="dbar",
79 )
81 # extract all data and metadata and convert to physical units
---> 82 self._extract_physical_data()
File ~/work/code/python/ctdproc/ctdproc/io.py:85, in CTDHex._extract_physical_data(self)
84 def _extract_physical_data(self):
---> 85 self.read_xml_config()
86 self.parse_hex()
87 self.physicalunits()
File ~/work/code/python/ctdproc/ctdproc/io.py:439, in CTDHex.read_xml_config(self)
437 tmp = xmltodict.parse(fd.read())
438 except OSError as e:
--> 439 raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), e.filename)
440 sa = tmp["SBE_InstrumentConfiguration"]["Instrument"]["SensorArray"]["Sensor"]
441 # parse only valid sensors
FileNotFoundError: [Errno 2] No such file or directory: 'data/sta0001.XMLCON'
<\details>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels