def save(self, data, fullname='../data/temp/temp.npy', log=True): fullname = FT.newname(fullname) np.save(fullname, data) self._temp_list.append(fullname) if log: with open(self._log, 'a') as f: f.write(time.strftime('%X') + " <> SAVED: " + fullname + '\n')
def start(chano, stc, name='test', path='../data/', exposures=[10, 100, 1000, 10000], mov={'shift': [0, 1, 2, 3, 4, 5]}): normalized_name = os.path.normpath(path + '/' + name) path, name, extension = FileTools.splitname(normalized_name) base_name = os.path.normpath(path + "/" + name) mask = 'Exposure: {:6d} Theta: {:6.2f} Shift: {:6.2f} Phi: {:6.2f}' time.sleep(5) print("\n\n") try: for motor, sweep in mov.items(): for x in sweep: setattr(chano, motor, x) for exposure in exposures: stc.exposure = exposure image = stc.capture() newname = FileTools.newname(base_name + '.npz') np.savez(newname, image=image, exposure=exposure, chanosat_pos=chano.pos) print( mask.format(exposure, chano.theta, chano.shift, chano.phi)) time_now = time.gmtime(time.time()) print("\n" + time.strftime("%X", time_now), end='') print(' - Saved as: {}'.format(os.path.relpath(newname))) time.sleep(1) except: print('\n\nUnexpected error.' ' Trying to reset chanosat to zero position\n\n') chano.pos = [0, 0, 0] time.sleep(1) raise
def save(self, data, fullname='temp.npy'): fullname = FT.newname(fullname, default=self._path_data) np.save(fullname, data) self._temp_list.append(fullname) return fullname