def DataColl(self, Delt, Nu, KphiS, KphiE, StpN, TimNE): flgon = 1 flgon = self.epicswarning(self.Delt, self.warn1, '13BMC:m37', flgon) flgon = self.epicswarning(self.Nu, self.warn2, '13BMC:m38', flgon) flgon = self.epicswarning(self.KphiStart, self.warn3, '13BMC:m33', flgon) flgon = self.epicswarning(self.KphiEnd, self.warn4, '13BMC:m33', flgon) flgon = self.stepwarning(self.StpN, self.warn5, flgon) flgon = self.speedwarning(self.TimperFrm, self.warn6, self.KphiStart, self.KphiEnd, self.StpN, flgon) if flgon: self.Detmov(Delt, Nu) xtalcmd = SpecCommand.SpecCommandA( '', 'corvette.cars.aps.anl.gov:6789') kphivelo = epics.caget('13BMC:m33.VELO') kphiini = epics.caget('13BMC:m33.VAL') cmdcon = "xtal kphi " + KphiS.text() + ' ' + KphiE.text( ) + ' ' + StpN.text() + ' ' + TimNE.text() eval("xtalcmd.executeCommand(\"%s\")" % cmdcon) Ttem = np.abs(kphiini - float(KphiS.text())) / kphivelo + float( TimNE.text()) * float(StpN.text()) + 3 time.sleep(Ttem) if (int(StpN.text()) > 1) and (self.SUMCK.isChecked() == True): time.sleep(2) DummyPath = SpecVariable.SpecVariable( 'SCANLOG_PATH', 'corvette.cars.aps.anl.gov:6789').getValue() DummyN = SpecVariable.SpecVariable( 'SCAN_N', 'corvette.cars.aps.anl.gov:6789').getValue() DumS = 'S' + (3 - len(str(DummyN))) * '0' + str(DummyN) + '/' L = re.split('/', DummyPath) # For Win7 system # FL = 'T:/'+ L[5]+'/'+ L[6]+'/'+ L[7]+'/'+ L[8]+'/'+ L[9]+'/'+ L[10]+'/'+ L[11]+'/images/'+ L[13]+'/'+DumS # For Win10 system FL = '//cars5/data/' + L[5] + '/' + L[6] + '/' + L[ 7] + '/' + L[8] + '/' + L[9] + '/' + L[10] + '/' + L[ 11] + '/images/' + L[13] + '/' + DumS files = [] # r=root, d=directories, f = files for r, d, f in os.walk(FL): for file in f: if '.cbf' in file: files.append(os.path.join(r, file)) elif '.tif' in file: files.append(os.path.join(r, file)) img = fabio.open(files[0]) for file in files[1:]: data = fabio.open(file).data img.data = img.data + data for xi in range(1043): for xj in range(981): if img.data[xi, xj] < 0: img.data[xi, xj] = -1 IML = FL + 'sum.cbf' img.write(IML) self.lastscan(self.LogL1, 'templog.txt')
def __init__(self, parent=None): super(calibUI, self).__init__(parent) self.setupUi(self) Dist0 = SpecVariable.SpecVariable('BMCPilatusDist', 'corvette.cars.aps.anl.gov:6780').getValue() self.T1.setText(str(Dist0)) beamX0 = SpecVariable.SpecVariable('BMCPilatusBeamX', 'corvette.cars.aps.anl.gov:6780').getValue() self.T2.setText(str(beamX0)) beamY0 = SpecVariable.SpecVariable('BMCPilatusBeamY', 'corvette.cars.aps.anl.gov:6780').getValue() self.T3.setText(str(beamY0)) self.R2.setChecked(True) ###################### Define actions ############# self.B1.clicked.connect(lambda: self.update_clicked())
def findfolder(self): ProjPath = SpecVariable.SpecVariable( 'STARTUP_PROJECT_PATH', 'corvette.cars.aps.anl.gov:6789').getValue() temp = ProjPath[25::] temp1 = 'T:' + temp + 'images/' self.FolderN.setText(temp1) time.sleep(0.3)
def nextscan(self, widget1, tempfile): # only use after press newsample LogPath = SpecVariable.SpecVariable('SCANLOG_PATH', 'corvette.cars.aps.anl.gov:6780').getValue() MajorPath = SpecVariable.SpecVariable('STARTUP_PROJECT_PATH', 'corvette.cars.aps.anl.gov:6780').getValue() len1 = len(MajorPath+"scandata/") dummy = LogPath[len1:-1] cmdcon = time.asctime()+'\n New data will be saved in folder: ' + dummy + '\n' f = open(tempfile, 'a+') f.seek(0) dummy2 = f.read() f.close() os.remove(tempfile) dummy3 = cmdcon + dummy2 f = open(tempfile, 'a+') f.write(dummy3) f.close() widget1.setText(dummy3)
def lastscan(self, widget1, tempfile): # only use after one scan is done. Newsample command creates a new logPath. LogPath = SpecVariable.SpecVariable('SCANLOG_PATH', 'corvette.cars.aps.anl.gov:6780').getValue() FilePath = SpecVariable.SpecVariable('SCANLOG_FILE', 'corvette.cars.aps.anl.gov:6780').getValue() len1 = len(LogPath) dummy = FilePath[len1:-4] dummy1 = re.split('_', dummy) cmdcon = time.asctime()+'\n '+ dummy1[2] +' done, saved in folder: '+ dummy1[0]+'_'+dummy1[1]+'\n' f = open(tempfile, 'a+') f.seek(0) dummy2 = f.read() f.close() os.remove(tempfile) dummy3 = cmdcon + dummy2 f = open(tempfile, 'a+') f.write(dummy3) f.close() widget1.setText(dummy3)