make softcal more tolerant reading .340 files
accept tab instead of space in 'Data Format' header keyword Change-Id: I77e5500da5eaed6fd1097723533bc86207fa73d8
This commit is contained in:
parent
bec3359069
commit
9b71d3621d
@ -74,13 +74,18 @@ class Parser340(StdParser):
|
|||||||
def parse(self, line):
|
def parse(self, line):
|
||||||
"""scan header for data format"""
|
"""scan header for data format"""
|
||||||
if self.header:
|
if self.header:
|
||||||
if line.startswith("Data Format"):
|
key, _, value = line.partition(':')
|
||||||
dataformat = line.split(":")[1].strip()[0]
|
if value: # this is a header line, as it contains ':'
|
||||||
if dataformat == '4':
|
value = value.split()[0]
|
||||||
self.logx, self.logy = True, False # logOhm
|
key = ''.join(key.split()).lower()
|
||||||
elif dataformat == '5':
|
if key == 'dataformat':
|
||||||
self.logx, self.logy = True, True # logOhm, logK
|
if value == '4':
|
||||||
elif line.startswith("No."):
|
self.logx, self.logy = True, False # logOhm
|
||||||
|
elif value == '5':
|
||||||
|
self.logx, self.logy = True, True # logOhm, logK
|
||||||
|
elif value not in ('1', '2', '3'):
|
||||||
|
raise ValueError('invalid Data Format')
|
||||||
|
elif line.contains('No.'):
|
||||||
self.header = False
|
self.header = False
|
||||||
return
|
return
|
||||||
super().parse(line)
|
super().parse(line)
|
||||||
@ -140,7 +145,10 @@ class CalCurve:
|
|||||||
parser.parse(line)
|
parser.parse(line)
|
||||||
self.convert_x = nplog if parser.logx else linear
|
self.convert_x = nplog if parser.logx else linear
|
||||||
self.convert_y = npexp if parser.logy else linear
|
self.convert_y = npexp if parser.logy else linear
|
||||||
self.spline = splrep(np.asarray(parser.xdata), np.asarray(parser.ydata), s=0)
|
try:
|
||||||
|
self.spline = splrep(np.asarray(parser.xdata), np.asarray(parser.ydata), s=0)
|
||||||
|
except:
|
||||||
|
raise ValueError('invalid curve, may be not monotonic?')
|
||||||
|
|
||||||
def __call__(self, value):
|
def __call__(self, value):
|
||||||
"""convert value
|
"""convert value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user