def collect_data(self, filter=None): ''' collect data for some or all of the samples based on type ''' # create directory if not os.path.isdir(self.dir): os.mkdir(self.dir) # create recipe, run it # TODO: filename based on type filenames = [sn + '_PerpHys.dat' for sn in self.snames] for i,fn in enumerate(filenames): dpath = os.path.join(self.dir, fn) seq.hys(5000, -5000, fn=dpath, rate=100, pts=1000) # TODO: run # TODO: detect when done, motor friction scan c = raw_input('(n)ext / (q)uit?') # link data to sname try: self.data[i] = pyppms.ppms(dpath) except: # could not find data pass if c == 'q': break print('Done')
def fromfile(self, filter): ''' import ppms data from files. Could make it a classmethod''' # could be intelligent about which files are used, so they don't have # to be specified one by one file = pyppms.latest(filter) # name sample relative to others in its directory path, fn = os.path.split(file) files = fnmatch.filter(os.listdir(path), '*.dat') sname = fn.replace(_long_substr(files),'') self.snames.append(sname) data = pyppms.ppms(file) self.data.append(data)
def fromdir(self, dirfilter='', ffilter=''): dir = pyppms.latestdir(dirfilter) print('importing data from ' + dir) files = fnmatch.filter(os.listdir(dir), '*'+ffilter+'*.dat') # find something different about the file names and call that the # sample name # There's an issue here if you want case insensitivity snames = [s.replace(_long_substr(files),'') for s in files] #os.mkdir(dirpath) self.snames.extend(snames) data = [pyppms.ppms(fn) for fn in files] self.data.extend(data)