def process(self, text, scan, *args, **kws): # Some folks use more than two spaces! Use regular expression(re) module scan.L = re.split(" +", strip_first_word(text)) if len(scan.L) == 1 and hasattr(scan, 'N') and scan.N[0] > 1: # BUT: some folks only use a single-space as a separator! # perhaps #L was written with single-space separators.? # Unusual for scan to have only 1 column, but possible labels = strip_first_word(text).split() if len(labels) == scan.N[0]: scan.L = labels scan.column_first = scan.L[0] scan.column_last = scan.L[-1]
def process(self, text, scan, *args, **kws): scan.comments.append(strip_first_word(text)) pos = text.find('Scan aborted after ') if pos > 0: scan._aborted_ = text[pos:] if isinstance(scan, SpecDataFileScan): scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): scan.comments.append( strip_first_word(text) ) pos = text.find('Scan aborted after ') if pos > 0: scan._aborted_ = text[pos:] if isinstance(scan, SpecDataFileScan): scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): text = strip_first_word(text) pos = text.find(" ") scan.T = text[:pos] scan.time_name = text[pos:].strip().lstrip('(').rstrip(')') scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): if not hasattr(scan, 'UXML'): scan.UXML = [] line = strip_first_word(text) scan.UXML.append(line) scan.addPostProcessor('UXML_metadata', self.postprocess)
def process(self, text, scan, *args, **kws): if not hasattr(scan, "UXML"): scan.UXML = [] line = strip_first_word(text) scan.UXML.append(line) scan.addPostProcessor("UXML_metadata", self.postprocess)
def process(self, text, spec_obj, *args, **kws): args = strip_first_word(text).split() mne = args[0] pv = args[1] if not hasattr(spec_obj, "EPICS_PV"): # use OrderedDict since it remembers the order we found these spec_obj.EPICS_PV = OrderedDict() spec_obj.EPICS_PV[mne] = pv
def process(self, text, scan, *args, **kws): s = strip_first_word(text).split() preset_time, elapsed_live_time, elapsed_real_time = map(float, s) if not hasattr(scan, 'MCA'): scan.MCA = {} scan.MCA['preset_time'] = preset_time scan.MCA['elapsed_live_time'] = elapsed_live_time scan.MCA['elapsed_real_time'] = elapsed_real_time scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): s = strip_first_word(text).split() ROI_name = s[0] first_chan, last_chan = map(int, s[1:]) if not hasattr(scan, 'MCA'): scan.MCA = {} if 'ROI' not in scan.MCA: scan.MCA['ROI'] = {} scan.MCA['ROI'][ROI_name] = {} scan.MCA['ROI'][ROI_name]['first_chan'] = first_chan scan.MCA['ROI'][ROI_name]['last_chan'] = last_chan
def process(self, text, scan, *args, **kws): # #@CHANN 1201 1110 1200 1 s = strip_first_word(text).split() number_saved, first_saved, last_saved = map(int, s[0:3]) reduction_coef = float(s[-1]) if not hasattr(scan, 'MCA'): scan.MCA = {} scan.MCA['number_saved'] = number_saved scan.MCA['first_saved'] = first_saved scan.MCA['last_saved'] = last_saved scan.MCA['reduction_coef'] = reduction_coef scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): # #@CALIB a b c s = strip_first_word(text).split() a, b, c = map(float, s) if not hasattr(scan, 'MCA'): scan.MCA = {} if 'CALIB' not in scan.MCA: scan.MCA['CALIB'] = {} scan.MCA['CALIB']['a'] = a scan.MCA['CALIB']['b'] = b scan.MCA['CALIB']['c'] = c scan.addH5writer(self.key, self.writer)
def process(self, part, spec_obj, *args, **kws): scan = SpecDataFileScan(spec_obj.headers[-1], part, parent=spec_obj) text = part.splitlines()[0].strip() scan.S = strip_first_word(text) scan.scanNum = scan.S.split()[0] scan.scanCmd = strip_first_word(scan.S) if scan.scanNum in spec_obj.scans: # Before raising an exception, # Check for duplicate and create alternate name # write as "%d.%d" % (scan.scanNum, index) # where index is the lowest integer in # range(1,really big) that is not already in use. # really_big < len(total number of scans in data file) # Will a non-integer scanNum break anything? for i in range(1, len(scan.parent.scans)): new_scanNum = "%s.%d" % (scan.scanNum, i) if new_scanNum not in spec_obj.scans: scan.scanNum = new_scanNum break scan.scanNum = str(scan.scanNum) if scan.scanNum in spec_obj.scans: msg = str(scan.scanNum) + ' in ' + spec_obj.fileName raise DuplicateSpecScanNumber(msg) spec_obj.scans[scan.scanNum] = scan
def process(self, text, scan, *args, **kws): text = strip_first_word(text) pos = text.rfind(" ") last_chan = int(text[pos:]) text = text[:pos] pos = text.rfind(" ") first_chan = int(text[pos:]) ROI_name = text[:pos].strip() if not hasattr(scan, 'MCA'): scan.MCA = {} if 'ROI' not in scan.MCA: scan.MCA['ROI'] = {} scan.MCA['ROI'][ROI_name] = {} scan.MCA['ROI'][ROI_name]['first_chan'] = first_chan scan.MCA['ROI'][ROI_name]['last_chan'] = last_chan
def process(self, text, header, *args, **kws): if not hasattr(header, 'o'): header.o = [] header.o.append( strip_first_word(text).split() ) header.addPostProcessor('positioner cross-referencing', self.postprocess)
def process(self, text, header, *args, **kws): header.O.append( strip_first_word(text).split() )
def process(self, text, scan, *args, **kws): scan.T = strip_first_word(text).split()[0] scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): scan.M, dname = strip_first_word(text).split() scan.monitor_name = dname.lstrip('(').rstrip(')') scan.addH5writer(self.key, self.writer)
def process(self, text, scan, *args, **kws): s = strip_first_word(text) if len(s) > 0: scan.Q = map(float, s.split()) scan.addH5writer(self.key, self.writer)
def process(self, buf, scan, *args, **kws): header = SpecDataFileHeader(buf, parent=scan) line = buf.splitlines()[0].strip() header.epoch = int(strip_first_word(line)) header.interpret() # parse the full header scan.headers.append(header)
def process(self, text, spec_obj, *args, **kws): spec_obj.H.append( strip_first_word(text).split() )
def process(self, text, scan, *args, **kws): scan.date = strip_first_word(text) if isinstance(scan, SpecDataFileScan): scan.addH5writer(self.key, self.writer)
def process(self, text, spec_obj, *args, **kws): s = strip_first_word(text) if not hasattr(spec_obj, "MyTest"): # a list allows for more than one #TEST in a scan spec_obj.MyTest = [] spec_obj.MyTest.append(s)
def process(self, text, spec_file_obj, *args, **kws): spec_file_obj.specFile = strip_first_word(text)
def process(self, text, scan, *args, **kws): scan.P.append(strip_first_word(text)) scan.addPostProcessor('motor_positions', self.postprocess)
def process(self, text, scan, *args, **kws): scan.P.append( strip_first_word(text) ) scan.addPostProcessor('motor_positions', self.postprocess)
def process(self, text, scan, *args, **kws): scan.I = float(strip_first_word(text))
def process(self, text, header, *args, **kws): header.O.append(strip_first_word(text).split())
def process(self, text, scan, *args, **kws): scan.N = map(int, strip_first_word(text).split())
def process(self, text, header, *args, **kws): if not hasattr(header, 'o'): header.o = [] header.o.append(strip_first_word(text).split()) header.addPostProcessor('positioner cross-referencing', self.postprocess)
def process(self, text, scan, *args, **kws): scan.V.append( strip_first_word(text) ) scan.addPostProcessor('unicat_metadata', self.postprocess)
def process(self, text, scan, *args, **kws): subkey = text.split()[0].lstrip('#') scan.G[subkey] = strip_first_word(text) if len(scan.G) > 0: scan.addH5writer(self.key, self.writer)
def test_strip_first_word(self): self.assertEqual(utils.strip_first_word('one two three'), 'two three')