def initSpec(_strSpecVersion, _strSpecStatus, _strSpecAbort): """ Initialization of SpecVariable ... """ if EDUtilsBioSaxs.specVersion is None: EDUtilsBioSaxs.__strSpecVersion = _strSpecVersion EDUtilsBioSaxs.__strSpecStatus = _strSpecStatus EDUtilsBioSaxs.__strSpecAbort = _strSpecAbort if SpecVariable: EDUtilsBioSaxs.__specVarStatus = SpecVariable.SpecVariable( _strSpecStatus) EDUtilsBioSaxs.__specVarAbort = SpecVariable.SpecVariable( _strSpecAbort) else: EDVerbose.DEBUG( "EDUtilsBioSaxs initSpec called whereas it was already set-up") if EDUtilsBioSaxs.__strSpecVersion != _strSpecVersion: EDVerbose.WARNING( "EDUtilsBioSaxs initSpec specVersion %s whereas configured with %s" % (_strSpecVersion, EDUtilsBioSaxs.__strSpecVersion)) if EDUtilsBioSaxs.__strSpecStatus != _strSpecStatus: EDVerbose.WARNING( "EDUtilsBioSaxs initSpec specStatus %s whereas configured with %s" % (_strSpecVersion, EDUtilsBioSaxs.__strSpecVersion)) if EDUtilsBioSaxs.__strSpecAbort != _strSpecAbort: EDVerbose.WARNING( "EDUtilsBioSaxs initSpec specAbort %s whereas configured with %s" % (_strSpecVersion, EDUtilsBioSaxs.__strSpecVersion))
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:6780') 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:6780').getValue() DummyN = SpecVariable.SpecVariable( 'SCAN_N', 'corvette.cars.aps.anl.gov:6780').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 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+') dummy2 = f.read() f.close() os.remove(tempfile) dummy3 = cmdcon + dummy2 f = open(tempfile, 'a+') f.write(dummy3) f.close() widget1.setText(dummy3)
def findfolder(self): ProjPath = SpecVariable.SpecVariable( 'STARTUP_PROJECT_PATH', 'corvette.cars.aps.anl.gov:6780').getValue() temp = ProjPath[25::] temp1 = 'T:' + temp + 'images/' self.FolderN.setText(temp1) time.sleep(0.3)
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+') dummy2 = f.read() f.close() os.remove(tempfile) dummy3 = cmdcon + dummy2 f = open(tempfile, 'a+') f.write(dummy3) f.close() widget1.setText(dummy3)
def Reprocess(pDetector, pOperation, pDirectory, pPrefix, pRunNumber, pFrameFirst, pFrameLast, pConcentration, pComments, pCode, \ pMaskFile, pDetectorDistance, pWaveLength, pPixelSizeX, pPixelSizeY, pBeamCenterX, pBeamCenterY, pNormalisation, pBeamStopDiode, \ pMachineCurrent, pKeepOriginal, pTimeOut, pSPECVersion, pSPECVariableStatus, pSPECVariableAbort, pTerminal): if pSPECVersion is not None: if pSPECVariableStatus is not None: globals()["REPROCESS_STATUS"] = SpecVariable.SpecVariable( pSPECVariableStatus, pSPECVersion) if pSPECVariableAbort is not None: globals()["REPROCESS_ABORT"] = SpecVariable.SpecVariable( pSPECVariableAbort, pSPECVersion) if pDetector not in ("0", "1"): showMessage(4, "Invalid detector '%s'!" % pDetector) return if pOperation not in ("-2", "-1", "0", "1", "2", "3"): showMessage(4, "Invalid operation '%s'!" % pOperation) return if not os.path.exists(pDirectory): showMessage(4, "Directory '%s' not found!" % pDirectory) return if not os.path.exists(pDirectory + "/1d"): try: os.mkdir(pDirectory + "/1d") except Exception: showMessage( 4, "Could not create directory '1d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/2d"): try: os.mkdir(pDirectory + "/2d") except Exception: showMessage( 4, "Could not create directory '2d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/misc"): try: os.mkdir(pDirectory + "/misc") except Exception: showMessage( 4, "Could not create directory 'misc' in '%s'!" % pDirectory) return runNumberList = [] if pRunNumber == "": for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails( filename) if prefix == pPrefix and run != "" and frame != "" and ( pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm"): try: runNumberList.index(run) except Exception: runNumberList.append(run) else: list = pRunNumber.split(",") for runNumber in list: runNumber = "%03d" % int(runNumber) try: runNumberList.index(runNumber) except Exception: runNumberList.append(runNumber) if len(runNumberList) == 0: showMessage(4, "There are no runs for prefix '%s'!" % pPrefix) return else: runNumberList.sort() edf = EDF.EDF() spec = SPEC.SPEC() hdfDictionary = HDFDictionary.HDFDictionary() if pDetector == "0": dictionaryEDF = "EDF_PILATUS" else: dictionaryEDF = "EDF_VANTEC" status, dictionary = hdfDictionary.get( os.path.join(sys.path[0], "Reprocess.xml"), dictionaryEDF) if status != 0: showMessage(3, "Could not get '%s' dictionary!" % dictionaryEDF) #print dictionary if pKeepOriginal == "0": directory1D_REP = "" directory2D_REP = "" directoryMISC_REP = "" else: i = 0 while True: directory1D_REP = pDirectory + "/1d/reprocess" + str(i) if os.path.exists(directory1D_REP): i += 1 else: try: os.mkdir(directory1D_REP) except Exception: showMessage( 3, "Could not create reprocess directory '%s'!" % directory1D_REP) break i = 0 while True: directory2D_REP = pDirectory + "/2d/reprocess" + str(i) if os.path.exists(directory2D_REP): i += 1 else: try: os.mkdir(directory2D_REP) except Exception: showMessage( 3, "Could not create reprocess directory '%s'!" % directory2D_REP) break i = 0 while True: directoryMISC_REP = pDirectory + "/misc/reprocess" + str(i) if os.path.exists(directoryMISC_REP): i += 1 else: try: os.mkdir(directoryMISC_REP) except Exception: showMessage( 3, "Could not create reprocess directory '%s'!" % directoryMISC_REP) break print for runNumber in runNumberList: if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data frameList = [] for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails( filename) if prefix == pPrefix and run == runNumber and frame != "": if (pFrameFirst == "" or int(frame) >= int(pFrameFirst) ) and (pFrameLast == "" or int(frame) <= int(pFrameLast)): if pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm": try: frameList.index(frame) except Exception: frameList.append(frame) else: # reprocess was launched from BsxCuBE while collecting data frameList = ["%02d" % int(pFrameLast)] if len(frameList) == 0: showMessage(3, "There are no frames for run '%s'!" % runNumber) else: frameList.sort() for frame in frameList: if pDetector == "0": # Pilatus filenameRAW = "%s/raw/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) sizeRAW = 4090000 sizeNOR = 4100000 else: # Vantec filenameRAW = "%s/raw/%s_%s_%s.gfrm" % ( pDirectory, pPrefix, runNumber, frame) sizeRAW = 4200000 sizeNOR = 16780000 if pKeepOriginal == "0": filenameNOR = "%s/2d/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) filenameLOG = "%s/misc/%s_%s_%s.log" % ( pDirectory, pPrefix, runNumber, frame) filenameMSK = "%s/misc/%s_%s_%s.msk" % ( pDirectory, pPrefix, runNumber, frame) filenameANG = "%s/misc/%s_%s_%s.ang" % ( pDirectory, pPrefix, runNumber, frame) filenameDAT = "%s/1d/%s_%s_%s.dat" % (pDirectory, pPrefix, runNumber, frame) else: filenameNOR = "%s/%s_%s_%s.edf" % ( directory2D_REP, pPrefix, runNumber, frame) filenameLOG = "%s/%s_%s_%s.log" % ( directoryMISC_REP, pPrefix, runNumber, frame) filenameMSK = "%s/%s_%s_%s.msk" % ( directoryMISC_REP, pPrefix, runNumber, frame) filenameANG = "%s/%s_%s_%s.ang" % ( directoryMISC_REP, pPrefix, runNumber, frame) filenameDAT = "%s/%s_%s_%s.dat" % ( directory1D_REP, pPrefix, runNumber, frame) if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data if pConcentration == "" or pComments == "" or pCode == "" or pMaskFile == "" or pDetectorDistance == "" or pWaveLength == "" or pPixelSizeX == "" or pPixelSizeY == "" or pBeamCenterX == "" or pBeamCenterY == "" or pNormalisation == "" or pBeamStopDiode == "" or pMachineCurrent == "": filenameNOR_ORG = "%s/2d/%s_%s_%s.edf" % ( pDirectory, pPrefix, runNumber, frame) if os.path.exists(filenameNOR_ORG): edf.open(filenameNOR_ORG) header = edf.getHeader() history0 = "" history1 = "" i = 0 while i < len(header): if header[i].startswith("History-1 = "): history0 = header[i][12:] del header[i] i -= 1 elif header[i].startswith("History-1~1 = "): history1 = header[i][14:] del header[i] i -= 1 else: i += 1 header.append("history_combined = " + history0 + history1) #print header status, translate = hdfDictionary.translate( header, dictionary) edf.close() else: translate = [] showMessage( 3, "Trying to get values from file '%s' which doesn't exist" % filenameNOR_ORG) #print translate else: # reprocess was launched from BsxCuBE while collecting data translate = [] if pConcentration == "": concentration = makeTranslation(translate, "concentration", "0") else: concentration = pConcentration if pComments == "": comments = makeTranslation(translate, "comments", "") else: comments = pComments if pCode == "": code = makeTranslation(translate, "code", "") else: code = pCode if pMaskFile == "": maskFile = makeTranslation(translate, "mask_file", "") else: maskFile = pMaskFile if pDetectorDistance == "": detectorDistance = makeTranslation(translate, "detector_distance", "0") else: detectorDistance = pDetectorDistance if pWaveLength == "": waveLength = makeTranslation(translate, "wave_length", "0") else: waveLength = pWaveLength if pPixelSizeX == "": pixelSizeX = makeTranslation(translate, "pixel_size_X", "0") else: pixelSizeX = pPixelSizeX if pPixelSizeY == "": pixelSizeY = makeTranslation(translate, "pixel_size_Y", "0") else: pixelSizeY = pPixelSizeY if pBeamCenterX == "": beamCenterX = makeTranslation(translate, "beam_center_X", "0") else: beamCenterX = pBeamCenterX if pBeamCenterY == "": beamCenterY = makeTranslation(translate, "beam_center_Y", "0") else: beamCenterY = pBeamCenterY if pBeamStopDiode == "": beamStopDiode = makeTranslation(translate, "diode_current", "0") else: beamStopDiode = pBeamStopDiode if pMachineCurrent == "": machineCurrent = makeTranslation(translate, "machine_current", "0") else: machineCurrent = pMachineCurrent if pNormalisation == "": normalisation = makeTranslation(translate, "normalization_factor", "0") else: normalisation = pNormalisation if pOperation in ("-2", "-1", "0", "3"): print "Normalising EDF frame '%s'..." % filenameNOR if pKeepOriginal == "0": os.system("rm -f %s %s 2>/dev/null" % (filenameNOR, filenameLOG)) status = waitFile(filenameRAW, sizeRAW, pTimeOut) if status == 0: if float(beamStopDiode) == 0: showMessage( 3, "The value of the beam stop diode is zero!") else: if pDetector == "0": # Pilatus command = "saxs_mac +var +pass -omod n -i1err _i1val -i1dum -2 -i1ddum 1.1 -otit \"DiodeCurr=%s, MachCurr=%s mA, Concentration=%s, Comments: %s, Code: %s, Mask: %s, Normalisation: %s\" -i1dis \"%s\" -i1wvl \"%s_nm\" -i1pix %s_um %s_um -i1cen %s %s -ofac %s %s %s > %s 2>/dev/null" % \ (beamStopDiode, machineCurrent, concentration, comments, code, maskFile, normalisation, detectorDistance, waveLength, pixelSizeX, pixelSizeY, beamCenterX, beamCenterY, str(float(normalisation) / float(beamStopDiode)), filenameRAW, filenameNOR, filenameLOG) else: # Vantec command = "saxs_mac +var +pass -omod n -i1err _i1val -i1dum -2 -i1ddum 1.1 -otit \"DiodeCurr=%s, MachCurr=%s mA, Concentration=%s, Comments: %s, Code: %s, Mask: %s, Normalisation: %s\" -odis \"%s\" -i1wvl \"%s_nm\" -i1pix %s_um %s_um -i1cen %s %s -ofac %s %s %s > %s 2>/dev/null" % \ (beamStopDiode, machineCurrent, concentration, comments, code, maskFile, normalisation, detectorDistance, waveLength, pixelSizeX, pixelSizeY, beamCenterX, beamCenterY, str(float(normalisation) / float(beamStopDiode)), filenameRAW, filenameNOR, filenameLOG) #print command if subprocess.call(command, shell=True) == 0: showMessage( 2, "The frame '%s' was normalised..." % filenameNOR, filenameNOR) else: showMessage( 3, "Could not find 'saxs_mac' or it returned an error!" ) elif status == 1: print "Aborting data reprocess!" sys.exit(0) else: showMessage( 3, "File '%s' didn't appear on disk after '%s' seconds." % (filenameRAW, pTimeOut)) if pOperation in ("-2", "-1", "1", "3"): print "Generating 1D file '%s'..." % filenameDAT if pKeepOriginal == "0": os.system("rm -f %s %s %s 2>/dev/null" % (filenameDAT, filenameANG, filenameMSK)) status = waitFile(filenameNOR, sizeNOR, pTimeOut) if status == 0: command = "saxs_add -omod n %s %s %s > /dev/null 2>/dev/null" % ( filenameNOR, maskFile, filenameMSK) #print command if subprocess.call(command, shell=True) == 0: command = "saxs_angle -omod n -rsys normal -da 360_deg -odim = 1 %s %s > /dev/null 2>/dev/null" % ( filenameMSK, filenameANG) #print command if subprocess.call(command, shell=True) == 0: #command = "saxs_curves -i1err _i1val -scf 2_pi -ext .dat -spc \" \" -prm \"Sample c=%6.2f mg/ml,Concentration: %s,Code: %s\" %s %s" % (float(concentration), concentration, code, filenameANG, filenameDAT) command = "saxs_curves -scf 2_pi -ext .dat -spc \" \" %s %s > /dev/null 2>/dev/null" % ( filenameANG, filenameDAT) #print command if subprocess.call(command, shell=True) == 0: spec.open(filenameDAT) header = spec.getHeader() values = spec.getValues() spec.close() header[ 1] = " Sample c=%6.2f mg/ml" % float( concentration) header.append("Normalisation: %s" % normalisation) header.append("Concentration: %s" % concentration) header.append("Code: %s" % code) spec.open(filenameDAT, "w") spec.write(header, values) spec.close() showMessage( 2, "The 1D file '%s' was generated..." % filenameDAT, filenameDAT) else: showMessage( 3, "Could not find 'saxs_curves' or it returned an error!" ) else: showMessage( 3, "Could not find 'saxs_angle' or it returned an error!" ) else: showMessage( 3, "Could not find 'saxs_add' or it returned an error!" ) elif status == 1: print "Aborting data reprocess!" sys.exit(0) else: showMessage( 3, "File '%s' didn't appear on disk after '%s' seconds." % (filenameNOR, pTimeOut)) if pOperation in ("-2", "1", "2", "3"): if pKeepOriginal == "0": filenameDAT_AVE = "%s/1d/%s_%s_ave.dat" % ( pDirectory, pPrefix, runNumber) filenameANG_AVE = "%s/misc/%s_%s_ave.ang" % ( pDirectory, pPrefix, runNumber) filenameLOG_AVE = "%s/misc/%s_%s_ave.log" % ( pDirectory, pPrefix, runNumber) filenamePattern = "%s/misc/%s_%s_%s.ang" % ( pDirectory, pPrefix, runNumber, "%%") else: filenameDAT_AVE = "%s/%s_%s_ave.dat" % (directory1D_REP, pPrefix, runNumber) filenameANG_AVE = "%s/%s_%s_ave.ang" % (directoryMISC_REP, pPrefix, runNumber) filenameLOG_AVE = "%s/%s_%s_ave.log" % (directoryMISC_REP, pPrefix, runNumber) filenamePattern = "%s/%s_%s_%s.ang" % ( directoryMISC_REP, pPrefix, runNumber, "%%") print "Generating average '%s' from 1D files..." % filenameDAT_AVE if pKeepOriginal == "0": os.system( "rm -f %s %s %s 2>/dev/null" % (filenameDAT_AVE, filenameANG_AVE, filenameLOG_AVE)) if pFrameFirst == "": frameFirst = int(frameList[0]) else: frameFirst = int(pFrameFirst) if pFrameLast == "": frameLast = int(frameList[-1]) else: frameLast = int(pFrameLast) #command = "saxs_mac -omod n -i1err _i1val -var -add %d -ofac %f %s,%d,%d %s > %s" % (frameLast - frameFirst + 1, 1 / float(frameLast - frameFirst + 1), filenamePattern, frameFirst, frameLast, filenameANG_AVE, filenameLOG_AVE) command = "saxs_mac -omod n +var -add %d -ofac %s %s,%d,%d %s > %s 2>/dev/null" % ( frameLast - frameFirst + 1, str(1 / float(frameLast - frameFirst + 1)), filenamePattern, frameFirst, frameLast, filenameANG_AVE, filenameLOG_AVE) #print command if subprocess.call(command, shell=True) == 0: #command = "saxs_curves -i1err _i1val -scf 2_pi -ext .dat -spc \" \" -prm \"Sample c=%6.2f mg/ml,Concentration: %s,Code: %s\" %s %s" % (float(concentration), concentration, code, filenameANG_AVE, filenameDAT_AVE) command = "saxs_curves -scf 2_pi -ext .dat -spc \" \" %s %s > /dev/null 2>/dev/null" % ( filenameANG_AVE, filenameDAT_AVE) #print command if subprocess.call(command, shell=True) == 0: spec.open(filenameDAT_AVE) header = spec.getHeader() values = spec.getValues() spec.close() header[1] = " Sample c=%6.2f mg/ml" % float( concentration) header.append("Normalisation: %s" % normalisation) header.append("Concentration: %s" % concentration) header.append("Code: %s" % code) spec.open(filenameDAT_AVE, "w") spec.write(header, values) spec.close() showMessage( 2, "The average file '%s' was generated..." % filenameDAT_AVE, filenameDAT_AVE) else: showMessage( 3, "Could not find 'saxs_curves' or it returned an error!" ) else: showMessage( 3, "Could not find 'saxs_mac' or it returned an error!") if __terminal or pSPECVersion is not None: showMessage(0, "The data reprocessing is done!")
def __ltinitFinished(self, *args): table = self._widgetTree.child('__gridTable') stringVal = table.text(0, 0) nbColumn, valid = stringVal.toInt() if not valid: dialog = qt.QErrorMessage(self) dialog.message('Interval must be integer') return nbColumn += 1 self._logArgs['scan_type'] = 'lookup' posMot1 = [] posMot2 = [] pointMatchNb = 0 matchPointId = [] for i, (match, point) in enumerate( itertools.izip(self._matchPoints, self.__gridPoints)): if match: posMot1.append(point[0, 0]) posMot2.append(point[0, 1]) matchPointId.append((i / nbColumn, pointMatchNb)) pointMatchNb += 1 if posMot1: mot1Widget = self._widgetTree.child('__motor1') mot2Widget = self._widgetTree.child('__motor2') timeWidget = self._widgetTree.child('__time') ctime, valid = timeWidget.text().toFloat() mot1 = self.__getMotor(mot1Widget.currentText(), self._horizontalMotors) mot2 = self.__getMotor(mot2Widget.currentText(), self._verticalMotors) posMot1 = numpy.array(posMot1) posMot1 -= self._beamx posMot1 *= (self._XSize / mot1.getProperty('unit')) posMot1 += mot1.getPosition() posMot2 = numpy.array(posMot2) posMot2 -= self._beamy posMot2 *= (self._YSize / mot2.getProperty('unit')) posMot2 += mot2.getPosition() lineStartStop = [] lastLineId = -1 currentPointInLine = [] for lineId, pointId in matchPointId: if lineId != lastLineId: if currentPointInLine: lineStartStop.append(currentPointInLine) currentPointInLine = [pointId] lastLineId = lineId else: currentPointInLine.append(pointId) if currentPointInLine: lineStartStop.append(currentPointInLine) startIndex = [] stopIndex = [] for line in lineStartStop: startIndex.append(line[0]) stopIndex.append(line[-1]) startIndex = numpy.array(startIndex) stopIndex = numpy.array(stopIndex) specVersion = self._ltinit.specVersion for motor_name, pos_motor in zip( [str(mot1Widget.currentText()), str(mot2Widget.currentText())], [posMot1, posMot2]): ho = self.getHardwareObject(self["command"]) MOTOR_ARRAY = ho.addChannel( { "type": "spec", "version": specVersion, "name": "MOTOR_ARRAY", "dispatchMode": None }, "%s_ltscan_arr" % motor_name) MOTOR_ARRAY.setValue(SpecArray.SpecArray(pos_motor.ravel())) LT_START = SpecVariable.SpecVariable('LT_START', specVersion) LT_START.setValue(SpecArray.SpecArray(startIndex)) LT_STOP = SpecVariable.SpecVariable('LT_STOP', specVersion) LT_STOP.setValue(SpecArray.SpecArray(stopIndex)) LT_LINE = SpecVariable.SpecVariable('LT_LINE', specVersion) LT_LINE.setValue(len(stopIndex)) self._SpecCmd(str(mot1Widget.currentText()), str(mot2Widget.currentText()), ctime)
def Reprocess(pDetector, pOperation, pDirectory, pPrefix, pRunNumber, pFrameFirst, pFrameLast, pConcentration, pComments, pCode, \ pMaskFile, pDetectorDistance, pWaveLength, pPixelSizeX, pPixelSizeY, pBeamCenterX, pBeamCenterY, pNormalisation, pBeamStopDiode, \ pMachineCurrent, pKeepOriginal, pTimeOut, pSPECVersion, pSPECVariableStatus, pSPECVariableAbort, pTerminal): if pSPECVersion is not None: if pSPECVariableStatus is not None: globals()["REPROCESS_STATUS"] = SpecVariable.SpecVariable(pSPECVariableStatus, pSPECVersion) if pSPECVariableAbort is not None: globals()["REPROCESS_ABORT"] = SpecVariable.SpecVariable(pSPECVariableAbort, pSPECVersion) if pDetector not in ("0", "1"): showMessage(4, "Invalid detector '%s'!" % pDetector) return if pOperation not in ("-2", "-1", "0", "1", "2", "3"): showMessage(4, "Invalid operation '%s'!" % pOperation) return if not os.path.exists(pDirectory): showMessage(4, "Directory '%s' not found!" % pDirectory) return if not os.path.exists(pDirectory + "/1d"): try: os.mkdir(pDirectory + "/1d") except: showMessage(4, "Could not create directory '1d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/2d"): try: os.mkdir(pDirectory + "/2d") except: showMessage(4, "Could not create directory '2d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/misc"): try: os.mkdir(pDirectory + "/misc") except: showMessage(4, "Could not create directory 'misc' in '%s'!" % pDirectory) return runNumberList = [] if pRunNumber == "": for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails(filename) if prefix == pPrefix and run != "" and frame != "" and (pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm"): try: runNumberList.index(run) except: runNumberList.append(run) else: list = pRunNumber.split(",") for runNumber in list: runNumber = "%03d" % int(runNumber) try: runNumberList.index(runNumber) except: runNumberList.append(runNumber) if len(runNumberList) == 0: showMessage(4, "There are no runs for prefix '%s'!" % pPrefix) return else: runNumberList.sort() spec = SPEC() if pDetector == "0": dictionaryEDF = "EDF_PILATUS" else: dictionaryEDF = "EDF_VANTEC" if pKeepOriginal == "0": directory1D_REP = "" directory2D_REP = "" directoryMISC_REP = "" else: i = 0 while True: directory1D_REP = pDirectory + "/1d/reprocess" + str(i) if os.path.exists(directory1D_REP): i += 1 else: try: os.mkdir(directory1D_REP) except: showMessage(3, "Could not create reprocess directory '%s'!" % directory1D_REP) break i = 0 while True: directory2D_REP = pDirectory + "/2d/reprocess" + str(i) if os.path.exists(directory2D_REP): i += 1 else: try: os.mkdir(directory2D_REP) except: showMessage(3, "Could not create reprocess directory '%s'!" % directory2D_REP) break i = 0 while True: directoryMISC_REP = pDirectory + "/misc/reprocess" + str(i) if os.path.exists(directoryMISC_REP): i += 1 else: try: os.mkdir(directoryMISC_REP) except: showMessage(3, "Could not create reprocess directory '%s'!" % directoryMISC_REP) break print for runNumber in runNumberList: print """ ======================== <Starting RUN> run %s ======================== """ % runNumber if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data frameList = [] for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails(filename) if prefix == pPrefix and run == runNumber and frame != "": if (pFrameFirst == "" or int(frame) >= int(pFrameFirst)) and (pFrameLast == "" or int(frame) <= int(pFrameLast)): if pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm": try: frameList.index(frame) except: frameList.append(frame) else: # reprocess was launched from BsxCuBE while collecting data frameList = ["%05d" % int(pFrameLast)] if len(frameList) == 0: showMessage(3, "There are no frames for run '%s'!" % runNumber) else: frameList.sort() for frame in frameList: print "\n<Processing Frame> No. %s" % frame if pDetector == "0": # Pilatus filenameRAW = "%s/raw/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) sizeRAW = 4090000 sizeNOR = 4100000 else: # Vantec filenameRAW = "%s/raw/%s_%s_%s.gfrm" % (pDirectory, pPrefix, runNumber, frame) sizeRAW = 4200000 sizeNOR = 16780000 if pKeepOriginal == "0": filenameNOR = "%s/2d/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) filenameLOG = "%s/misc/%s_%s_%s.log" % (pDirectory, pPrefix, runNumber, frame) filenameMSK = "%s/misc/%s_%s_%s.msk" % (pDirectory, pPrefix, runNumber, frame) filenameANG = "%s/misc/%s_%s_%s.ang" % (pDirectory, pPrefix, runNumber, frame) filenameDAT = "%s/1d/%s_%s_%s.dat" % (pDirectory, pPrefix, runNumber, frame) else: filenameNOR = "%s/%s_%s_%s.edf" % (directory2D_REP, pPrefix, runNumber, frame) filenameLOG = "%s/%s_%s_%s.log" % (directoryMISC_REP, pPrefix, runNumber, frame) filenameMSK = "%s/%s_%s_%s.msk" % (directoryMISC_REP, pPrefix, runNumber, frame) filenameANG = "%s/%s_%s_%s.ang" % (directoryMISC_REP, pPrefix, runNumber, frame) filenameDAT = "%s/%s_%s_%s.dat" % (directory1D_REP, pPrefix, runNumber, frame) if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data if pConcentration == "" or \ pComments == "" or \ pCode == "" or \ pMaskFile == "" or \ pDetectorDistance == "" or \ pWaveLength == "" or \ pPixelSizeX == "" or \ pPixelSizeY == "" or \ pBeamCenterX == "" or \ pBeamCenterY == "" or \ pNormalisation == "" or \ pBeamStopDiode == "" or \ pMachineCurrent == "": filenameNOR_ORG = "%s/2d/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) if os.path.exists(filenameNOR_ORG): valdict = valuesFromHeader(filenameNOR_ORG) print "terminal ", __terminal print "pSPECVersion ", pSPECVersion print filenameNOR_ORG else: # reprocess was launched from BsxCuBE while collecting data valdict = [] # Concentration if pConcentration == "": if 'Concentration' in valdict: concentration = valdict['Concentration'] else: print "concentration not in header" else: concentration = pConcentration # Comments if pComments == "": if 'Comments' in valdict: comments = valdict['Comments'] else: print "comments not in header" comments = "" else: comments = pComments # Code if pCode == "": if 'Code' in valdict: code = valdict['Code'] else: print "code not in header" code = "" else: code = pCode # Mask if pMaskFile == "": if 'Mask' in valdict: maskFile = valdict['Mask'] else: print "maskFile not in header" else: maskFile = pMaskFile # Detectordistance if pDetectorDistance == "": if 'SampleDistance' in valdict: detectorDistance = valdict['SampleDistance'] else: print "DetectorDistance not in header" else: detectorDistance = pDetectorDistance # Wavelength if pWaveLength == "": if 'WaveLength' in valdict: # the program wants nanometers. the header contains meters waveLength = valdict['WaveLength'] waveLength = float(waveLength) * 1e9 else: print "Wavelength not in header" else: waveLength = pWaveLength # PSize X if pPixelSizeX == "": if 'PSize_1' in valdict: # the program wants micrometers the header contains meters pixelSizeX = valdict['PSize_1'] pixelSizeX = float(pixelSizeX) * 1e6 else: print "pixelSizeX not in header" else: pixelSizeX = pPixelSizeX # PSize Y if pPixelSizeY == "": if 'PSize_2' in valdict: # the program wants micrometers the header contains meters pixelSizeY = valdict['PSize_2'] pixelSizeY = float(pixelSizeY) * 1e6 else: print "pixelSizeY not in header" else: pixelSizeY = pPixelSizeY # Beamcenter X if pBeamCenterX == "": if 'Center_1' in valdict: beamCenterX = valdict['Center_1'] else: print "beamCenterX not in header" else: beamCenterX = pBeamCenterX # Beamcenter Y if pBeamCenterY == "": if 'Center_2' in valdict: beamCenterY = valdict['Center_2'] else: print "beamCenterY not in header" else: beamCenterY = pBeamCenterY # Beam stop diode if pBeamStopDiode == "": if 'DiodeCurr' in valdict: beamStopDiode = valdict['DiodeCurr'] else: print "beamStopDiode not in header" else: beamStopDiode = pBeamStopDiode # Machine current if pMachineCurrent == "": if 'MachCurr' in valdict: machineCurrent = valdict['MachCurr'] else: print "machineCurrent not in header" else: machineCurrent = pMachineCurrent # Normalisation if pNormalisation == "": if 'Normalisation' in valdict: normalisation = valdict['Normalisation'] else: print "normalisation not in header" else: normalisation = pNormalisation # print "Concentration is: %s " % concentration # print "Comments are: %s " % comments # print "Code is: %s " % code # print "Maskfile is: %s " % maskFile # print "Detector distance is: %s " % detectorDistance # print "Wavelength is: %s " % waveLength # print "pixelSizeX is: %s " % pixelSizeX # print "pixelSizeY is: %s " % pixelSizeY # print "beamCenterX is: %s " % beamCenterX # print "beamCenterY is: %s " % beamCenterY # print "beamDiodeCurrent is: %s " % beamStopDiode # print "machineCurrent is: %s " % machineCurrent # print "normalisation is: %s " % normalisation if pOperation in ("-2", "-1", "0", "3"): print " - Normalising EDF frame '%s'..." % filenameNOR if pKeepOriginal == "0": os.system("rm -f %s %s 2>/dev/null" % (filenameNOR, filenameLOG)) status = waitFile(filenameRAW, sizeRAW, pTimeOut) if status == 0: if float(beamStopDiode) == 0: showMessage(3, "The value of the beam stop diode is zero!") else: if pDetector == "0": # Pilatus command = "%s +var +pass -omod n -i1err _i1val -i1dum -2 -i1ddum 1.1 -otit \"DiodeCurr=%s, MachCurr=%s mA, Concentration=%s, Comments: %s, Code: %s, Mask: %s, Normalisation: %s\" -i1dis \"%s\" -i1wvl \"%s_nm\" -i1pix %s_um %s_um -i1cen %s %s -ofac %s %s %s > %s 2>/dev/null" % \ (saxs_mac, beamStopDiode, machineCurrent, concentration, comments, code, maskFile, normalisation, detectorDistance, waveLength, pixelSizeX, pixelSizeY, beamCenterX, beamCenterY, str(float(normalisation) / float(beamStopDiode)), filenameRAW, filenameNOR, filenameLOG) else: # Vantec command = "%s +var +pass -omod n -i1err _i1val -i1dum -2 -i1ddum 1.1 -otit \"DiodeCurr=%s, MachCurr=%s mA, Concentration=%s, Comments: %s, Code: %s, Mask: %s, Normalisation: %s\" -odis \"%s\" -i1wvl \"%s_nm\" -i1pix %s_um %s_um -i1cen %s %s -ofac %s %s %s > %s 2>/dev/null" % \ (saxs_mac, beamStopDiode, machineCurrent, concentration, comments, code, maskFile, normalisation, detectorDistance, waveLength, pixelSizeX, pixelSizeY, beamCenterX, beamCenterY, str(float(normalisation) / float(beamStopDiode)), filenameRAW, filenameNOR, filenameLOG) if subprocess.call(command, shell = True) == 0: showMessage(2, " - Done. frame '%s' was normalised." % filenameNOR, filenameNOR) else: showMessage(3, "Could not find 'saxs_mac' or it returned an error!") elif status == 1: print "Aborting data reprocess!" sys.exit(0) else: showMessage(3, "File '%s' didn't appear on disk after '%s' seconds." % (filenameRAW, pTimeOut)) if pOperation in ("-2", "-1", "1", "3"): print " - Generating 1D file '%s'..." % filenameDAT if pKeepOriginal == "0": os.system("rm -f %s %s %s 2>/dev/null" % (filenameDAT, filenameANG, filenameMSK)) status = waitFile(filenameNOR, sizeNOR, pTimeOut) if status == 0: command = "saxs_add -omod n %s %s %s > /dev/null 2>/dev/null" % (filenameNOR, maskFile, filenameMSK) #print command if subprocess.call(command, shell = True) == 0: command = "saxs_angle -omod n -rsys normal -da 360_deg -odim = 1 %s %s > /dev/null 2>/dev/null" % (filenameMSK, filenameANG) #print command if subprocess.call(command, shell = True) == 0: #command = "saxs_curves -i1err _i1val -scf 2_pi -ext .dat -spc \" \" -prm \"Sample c=%6.2f mg/ml,Concentration: %s,Code: %s\" %s %s" % (float(concentration), concentration, code, filenameANG, filenameDAT) command = "saxs_curves -scf 2_pi -ext .dat -spc \" \" %s %s > /dev/null 2>/dev/null" % (filenameANG, filenameDAT) #print command if subprocess.call(command, shell = True) == 0: spec.open(filenameDAT) header = spec.getHeader() values = spec.getValues() spec.close() header[1] = " Sample c=%6.2f mg/ml" % float(concentration) header.append("Normalisation: %s" % normalisation) header.append("Concentration: %s" % concentration) header.append("Code: %s" % code) spec.open(filenameDAT, "w") spec.write(header, values) spec.close() showMessage(2, " - Done. 1D file '%s' was generated." % filenameDAT, filenameDAT) else: showMessage(3, "Could not find 'saxs_curves' or it returned an error!") else: showMessage(3, "Could not find 'saxs_angle' or it returned an error!") else: showMessage(3, "Could not find 'saxs_add' or it returned an error!") elif status == 1: print "Aborting data reprocess!" sys.exit(0) else: showMessage(3, "File '%s' didn't appear on disk after '%s' seconds." % (filenameNOR, pTimeOut)) if pOperation in ("-2", "1", "2", "3"): if pKeepOriginal == "0": filenameDAT_AVE = "%s/1d/%s_%s_ave.dat" % (pDirectory, pPrefix, runNumber) filenameANG_AVE = "%s/misc/%s_%s_ave.ang" % (pDirectory, pPrefix, runNumber) filenameLOG_AVE = "%s/misc/%s_%s_ave.log" % (pDirectory, pPrefix, runNumber) filenamePattern = "%s/misc/%s_%s_%s.ang" % (pDirectory, pPrefix, runNumber, "%%") else: filenameDAT_AVE = "%s/%s_%s_ave.dat" % (directory1D_REP, pPrefix, runNumber) filenameANG_AVE = "%s/%s_%s_ave.ang" % (directoryMISC_REP, pPrefix, runNumber) filenameLOG_AVE = "%s/%s_%s_ave.log" % (directoryMISC_REP, pPrefix, runNumber) filenamePattern = "%s/%s_%s_%s.ang" % (directoryMISC_REP, pPrefix, runNumber, "%%") print "\n<Averaging>" print " - Generating average '%s' from 1D files..." % filenameDAT_AVE if pKeepOriginal == "0": os.system("rm -f %s %s %s 2>/dev/null" % (filenameDAT_AVE, filenameANG_AVE, filenameLOG_AVE)) if pFrameFirst == "": frameFirst = int(frameList[0]) else: frameFirst = int(pFrameFirst) if pFrameLast == "": frameLast = int(frameList[-1]) else: frameLast = int(pFrameLast) #command = "saxs_mac -omod n -i1err _i1val -var -add %d -ofac %f %s,%d,%d %s > %s" % (frameLast - frameFirst + 1, 1 / float(frameLast - frameFirst + 1), filenamePattern, frameFirst, frameLast, filenameANG_AVE, filenameLOG_AVE) command = "%s -omod n +var -add %d -ofac %s %s,%d,%d %s > %s 2>/dev/null" % (saxs_mac, frameLast - frameFirst + 1, str(1 / float(frameLast - frameFirst + 1)), filenamePattern, frameFirst, frameLast, filenameANG_AVE, filenameLOG_AVE) #print command if subprocess.call(command, shell = True) == 0: #command = "saxs_curves -i1err _i1val -scf 2_pi -ext .dat -spc \" \" -prm \"Sample c=%6.2f mg/ml,Concentration: %s,Code: %s\" %s %s" % (float(concentration), concentration, code, filenameANG_AVE, filenameDAT_AVE) command = "saxs_curves -scf 2_pi -ext .dat -spc \" \" %s %s > /dev/null 2>/dev/null" % (filenameANG_AVE, filenameDAT_AVE) #print command if subprocess.call(command, shell = True) == 0: spec.open(filenameDAT_AVE) header = spec.getHeader() values = spec.getValues() spec.close() header[1] = " Sample c=%6.2f mg/ml" % float(concentration) header.append("Normalisation: %s" % normalisation) header.append("Concentration: %s" % concentration) header.append("Code: %s" % code) spec.open(filenameDAT_AVE, "w") spec.write(header, values) spec.close() showMessage(2, " - average done.") else: showMessage(3, "Could not find 'saxs_curves' or it returned an error!") else: showMessage(3, "Could not find 'saxs_mac' or it returned an error!") if __terminal or pSPECVersion is not None: showMessage(0, "\n<Data reprocessing DONE>\n")
def Reprocess(pDetector, pOperation, pDirectory, pPrefix, pRunNumber, pFrameFirst, pFrameLast, pConcentration, pComments, pCode, \ pMaskFile, pDetectorDistance, pWaveLength, pPixelSizeX, pPixelSizeY, pBeamCenterX, pBeamCenterY, pNormalisation, pBeamStopDiode, \ pMachineCurrent, pKeepOriginal, pTimeOut, pSPECVersion, pSPECVariableStatus, pSPECVariableAbort, pTerminal): if pSPECVersion is not None: if pSPECVariableStatus is not None: globals()["REPROCESS_STATUS"] = SpecVariable.SpecVariable( pSPECVariableStatus, pSPECVersion) if pSPECVariableAbort is not None: globals()["REPROCESS_ABORT"] = SpecVariable.SpecVariable( pSPECVariableAbort, pSPECVersion) if pDetector not in ("0", "1"): showMessage(4, "Invalid detector '%s'!" % pDetector) return if pOperation not in ("-2", "-1", "0", "1", "2", "3"): showMessage(4, "Invalid operation '%s'!" % pOperation) return if not os.path.exists(pDirectory): showMessage(4, "Directory '%s' not found!" % pDirectory) return if not os.path.exists(pDirectory + "/1d"): try: os.mkdir(pDirectory + "/1d") except: showMessage( 4, "Could not create directory '1d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/2d"): try: os.mkdir(pDirectory + "/2d") except: showMessage( 4, "Could not create directory '2d' in '%s'!" % pDirectory) return if not os.path.exists(pDirectory + "/misc"): try: os.mkdir(pDirectory + "/misc") except: showMessage( 4, "Could not create directory 'misc' in '%s'!" % pDirectory) return runNumberList = [] if pRunNumber == "": for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails( filename) if prefix == pPrefix and run != "" and frame != "" and ( pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm"): try: runNumberList.index(run) except: runNumberList.append(run) else: list = pRunNumber.split(",") for runNumber in list: runNumber = "%03d" % int(runNumber) try: runNumberList.index(runNumber) except: runNumberList.append(runNumber) if len(runNumberList) == 0: showMessage(4, "There are no runs for prefix '%s'!" % pPrefix) return else: runNumberList.sort() spec = SPEC() if pDetector == "0": dictionaryEDF = "EDF_PILATUS" else: dictionaryEDF = "EDF_VANTEC" if pKeepOriginal == "0": directory1D_REP = "" directory2D_REP = "" directoryMISC_REP = "" else: i = 0 print for runNumber in runNumberList: if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data frameList = [] for filename in os.listdir(pDirectory + "/raw"): if os.path.isfile(pDirectory + "/raw/" + filename): prefix, run, frame, extra, extension = getFilenameDetails( filename) if prefix == pPrefix and run == runNumber and frame != "": if (pFrameFirst == "" or int(frame) >= int(pFrameFirst) ) and (pFrameLast == "" or int(frame) <= int(pFrameLast)): if pDetector == "0" and extension == "edf" or pDetector == "1" and extension == "gfrm": try: frameList.index(frame) except: frameList.append(frame) else: # reprocess was launched from BsxCuBE while collecting data frameList = ["%05d" % int(pFrameLast)] if len(frameList) == 0: showMessage(3, "There are no frames for run '%s'!" % runNumber) else: frameList.sort() for frame in frameList: if pDetector == "0": # Pilatus filenameRAW = "%s/raw/%s_%s_%s.edf" % (pDirectory, pPrefix, runNumber, frame) sizeRAW = 4090000 sizeNOR = 4100000 else: # Vantec filenameRAW = "%s/raw/%s_%s_%s.gfrm" % ( pDirectory, pPrefix, runNumber, frame) sizeRAW = 4200000 sizeNOR = 16780000 if __terminal or pSPECVersion is not None: # reprocess was launched from terminal or from BsxCuBE while reprocessing data if pConcentration == "" or \ pComments == "" or \ pCode == "" or \ pMaskFile == "" or \ pDetectorDistance == "" or \ pWaveLength == "" or \ pPixelSizeX == "" or \ pPixelSizeY == "" or \ pBeamCenterX == "" or \ pBeamCenterY == "" or \ pNormalisation == "" or \ pBeamStopDiode == "" or \ pMachineCurrent == "": filenameNOR_ORG = "%s/2d/%s_%s_%s.edf" % ( pDirectory, pPrefix, runNumber, frame) if os.path.exists(filenameNOR_ORG): valdict = valuesFromHeader(filenameNOR_ORG) else: # reprocess was launched from BsxCuBE while collecting data valdict = [] # Concentration if pConcentration == "": if 'Concentration' in valdict: concentration = valdict['Concentration'] else: print "concentration not in header" else: concentration = pConcentration # Comments if pComments == "": if 'Comments' in valdict: comments = valdict['Comments'] else: print "comments not in header" else: comments = pComments # Code if pCode == "": if 'Code' in valdict: code = valdict['Code'] else: print "code not in header" else: code = pCode # Mask if pMaskFile == "": if 'Mask' in valdict: maskFile = valdict['Mask'] else: print "maskFile not in header" else: maskFile = pMaskFile # Detectordistance if pDetectorDistance == "": if 'SampleDistance' in valdict: detectorDistance = valdict['SampleDistance'] else: print "DetectorDistance not in header" else: detectorDistance = pDetectorDistance # Wavelength if pWaveLength == "": if 'WaveLength' in valdict: waveLength = valdict['WaveLength'] else: print "Wavelength not in header" else: waveLength = pWaveLength # PSize X if pPixelSizeX == "": if 'PSize_1' in valdict: pixelSizeX = valdict['PSize_1'] else: print "pixelSizeX not in header" else: pixelSizeX = pPixelSizeX # PSize Y if pPixelSizeY == "": if 'PSize_2' in valdict: pixelSizeY = valdict['PSize_2'] else: print "pixelSizeY not in header" else: pixelSizeY = pPixelSizeY # Beamcenter X if pBeamCenterX == "": if 'Center_1' in valdict: beamCenterX = valdict['Center_1'] else: print "beamCenterX not in header" else: beamCenterX = pBeamCenterX # Beamcenter Y if pBeamCenterY == "": if 'Center_2' in valdict: beamCenterY = valdict['Center_2'] else: print "beamCenterY not in header" else: beamCenterY = pBeamCenterY # Beam stop diode if pBeamStopDiode == "": if 'DiodeCurr' in valdict: beamStopDiode = valdict['DiodeCurr'] else: print "beamStopDiode not in header" else: beamStopDiode = pBeamStopDiode # Machine current if pMachineCurrent == "": if 'MachCurr' in valdict: machineCurrent = valdict['MachCurr'] else: print "machineCurrent not in header" else: machineCurrent = pMachineCurrent # Normalisation if pNormalisation == "": if 'Normalisation' in valdict: normalisation = valdict['Normalisation'] else: print "normalisation not in header" else: normalisation = pNormalisation print "Concentration is: %s " % concentration print "Comments are: %s " % comments print "Code is: %s " % code print "Maskfile is: %s " % maskFile print "Detector distance is: %s " % detectorDistance print "Wavelength is: %s " % waveLength print "pixelSizeX is: %s " % pixelSizeX print "pixelSizeY is: %s " % pixelSizeY print "beamCenterX is: %s " % beamCenterX print "beamCenterY is: %s " % beamCenterY print "beamDiodeCurrent is: %s " % beamStopDiode print "machineCurrent is: %s " % machineCurrent print "normalisation is: %s " % normalisation if __terminal or pSPECVersion is not None: showMessage(0, "The data reprocessing is done!")