Skip to content

Commit

Permalink
Merge pull request #817 from vasole/axas_locale
Browse files Browse the repository at this point in the history
[IO] AXAS - Calculate live time instead of reading it.
  • Loading branch information
vasole authored Nov 15, 2021
2 parents 40a489d + bff1d54 commit 5e455fe
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions PyMca5/PyMcaIO/specfilewrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,13 @@ def __init__(self, filename, amptek=None, qxas=None, dta=None):
ketek_keys = ["File Version = ",
"Livetime = ",
"Realtime = ",
"Input Count Rate = ",
"Output Count Rate = ",
"= KETEK"]
ketek_counter = 0
icr = None
ocr = None
live_time = None
live_time = None
real_time = None
for line in self.header:
Expand All @@ -367,18 +372,41 @@ def __init__(self, filename, amptek=None, qxas=None, dta=None):
if keylower.startswith("livetime ="):
tokens = line.split()
if tokens[-1] == "s":
live_time = float(tokens[2] + "." + tokens[3])
if "." in tokens[2]:
live_time = float(tokens[2])
else:
live_time = float(tokens[2] + "." + tokens[3])
elif keylower.startswith("realtime ="):
tokens = line.split()
if tokens[-1] == "s":
real_time = float(tokens[2] + "." + tokens[3])
if "." in tokens[2]:
real_time = float(tokens[2])
else:
real_time = float(tokens[2] + "." + tokens[3])
elif keylower.startswith("input count rate = "):
tokens = line.split(" = ")[-1].split()
if "." in tokens[0]:
icr = float(tokens[0])
else:
icr = float(tokens[0] + "." + tokens[1])
elif keylower.startswith("output count rate = "):
tokens = line.split(" = ")[-1].split()
if "." in tokens[0]:
ocr = float(tokens[0])
else:
ocr = float(tokens[0] + "." + tokens[1])
ketek_counter += 1
break
if ketek_counter == len(ketek_keys):
if ketek_counter >= 4:
self.ketek = 1
if real_time and live_time:
self._ketekHeader = {}
self._ketekHeader['S'] = '#S1 '+ " Unlabelled Spectrum"
if ocr and icr:
live_time = real_time * ocr / icr
_logger.info("Taking live time = real_time * ocr / icr")
else:
_logger.warning("Taking live time from file")
self._ketekHeader['@CTIME'] = ['#@CTIME %f %f %f' % (real_time,
live_time,
real_time)]
Expand Down

0 comments on commit 5e455fe

Please sign in to comment.