Ejemplo n.º 1
0
    def doSuccessExecSaxsMac(self, _edPlugin=None):
        self.DEBUG("EDPluginBioSaxsNormalizev1_0.doSuccessExecSaxsMac")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginBioSaxsNormalizev1_0.doSuccessExecSaxsMac")
        strEdnaLogFile = os.path.join(
            self.__edPluginExecSaxsMac.getWorkingDirectory(), self.__edPluginExecSaxsMac.getScriptLogFileName()
        )
        self.DEBUG("ExecPlugin log file is in: %s" % strEdnaLogFile)
        if os.path.isfile(self.strNormalizedImage) and self.isVerboseDebug():
            shutil.copy(self.strNormalizedImage, self.strNormalizedImage + ".bak")
        if os.path.isfile(strEdnaLogFile):
            shutil.copy(strEdnaLogFile, self.strLogFile)
            xsLogFile = XSDataFile()
            xsLogFile.setPath(XSDataString(self.strLogFile))
            self.xsdResult.setLogFile(xsLogFile)

        xsdiMetadata = XSDataInputBioSaxsMetadatav1_0()
        xsdiMetadata.setInputImage(self.xsdInput.normalizedImage)
        xsdiMetadata.setOutputImage(self.xsdInput.normalizedImage)
        xsdiMetadata.setBeamStopDiode(self.xsdInput.experimentSetup.beamStopDiode)
        xsdiMetadata.setNormalizationFactor(self.xsdInput.experimentSetup.normalizationFactor)
        xsdiMetadata.setDetector(self.xsdInput.experimentSetup.getDetector())
        xsdiMetadata.setMachineCurrent(self.xsdInput.experimentSetup.machineCurrent)
        xsdiMetadata.setMaskFile(self.xsdInput.experimentSetup.maskFile)
        xsdiMetadata.setDetectorDistance(self.xsdInput.experimentSetup.detectorDistance)
        xsdiMetadata.setWavelength(self.xsdInput.experimentSetup.wavelength)
        xsdiMetadata.setPixelSize_1(self.xsdInput.experimentSetup.pixelSize_1)
        xsdiMetadata.setPixelSize_2(self.xsdInput.experimentSetup.pixelSize_2)
        xsdiMetadata.setBeamCenter_1(self.xsdInput.experimentSetup.beamCenter_1)
        xsdiMetadata.setBeamCenter_2(self.xsdInput.experimentSetup.beamCenter_2)

        xsdiMetadata.setConcentration(self.xsdInput.sample.concentration)
        xsdiMetadata.setComments(self.xsdInput.sample.comments)
        xsdiMetadata.setCode(self.xsdInput.sample.code)

        self.__edPluginExecMetadata.setDataInput(xsdiMetadata)
def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if _strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf"):
        xsDataInputGridScreening = XSDataInputGridScreening()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
            XSDataTime(EDParallelExecuteGridScreening.fMaxExposureTime)
        )
        xsDataInputGridScreening.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputGridScreening.setImageFile(xsDataFile)
        if EDParallelExecuteGridScreening.bOnlyImageQualityIndicators:
            xsDataInputGridScreening.setDoOnlyImageQualityIndicators(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bStoreInISPyB:
            xsDataInputGridScreening.setStoreImageQualityIndicatorsInISPyB(XSDataBoolean(True))
        if EDParallelExecuteGridScreening.bDoOnlyIntegrationWithXMLOutput:
            xsDataInputGridScreening.setDoOnlyIntegrationWithXMLOutput(XSDataBoolean(True))
        strXML = xsDataInputGridScreening.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
Ejemplo n.º 3
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'outputFilePath':
			obj_ = XSDataFile()
			obj_.build(child_)
			self.setOutputFilePath(obj_)
		XSDataResult.buildChildren(self, child_, nodeName_)
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'image':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.image.append(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 5
0
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCorrectv10.py:
        - convert to HDF if needed (to be implemented)
        - move images (if needed)
        - set result XML   
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.postProcess")
        EDUtilsPath.createFolder(self.dictGeometry["OutputDir"])

        if self.getClassName() == "EDPluginSPDCorrectv10":

            strInputImagePathNoSfx = os.path.splitext(os.path.basename(self.pathToInputFile))[0]
            destFileBaseName = strInputImagePathNoSfx + self.dictGeometry["OutputFileType"]
            strOutputFilePath = os.path.join(self.dictGeometry["OutputDir"], destFileBaseName)
            if not self._bFireAndForget:
                if "corrected" in self.dictRes:
                    strTempFilePath = self.dictRes["corrected"]
                else:
                    strTempFilePath = os.path.join(self.getWorkingDirectory(), destFileBaseName)
                if self.dictGeometry["OutputFileType"].lower() in [".hdf5", ".nexus", ".h5", ".nx"]:
                    self.WARNING("HDF5/Nexus output is not yet implemented in the SPD plugin.")
                if os.path.exists(strOutputFilePath):
                    self.WARNING("Destination file exists, I will leave result file in %s." % strTempFilePath)
                    strOutputFilePath = strTempFilePath
                else:
                    shutil.move(strTempFilePath, strOutputFilePath)
            #        # Create the output data
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strOutputFilePath))

            xsDataResultSPD = XSDataResultSPD()
            xsDataResultSPD.setCorrectedFile(xsDataFile)
            self.setDataOutput(xsDataResultSPD)
Ejemplo n.º 6
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'inputMatrixFile':
			obj_ = XSDataFile()
			obj_.build(child_)
			self.setInputMatrixFile(obj_)
		XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 7
0
    def doSuccessExecSPDCake(self, _edPlugin=None):
        self.synchronizeOn()
        self.DEBUG("EDPluginControlID11v1_0.doSuccessExecSPDCake")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlID11v1_0.doSuccessExecSPDCake")

        xsdOut = _edPlugin.getDataOutput()

        xsdAzimFile = xsdOut.getCakedFile()
        xsdIn = XSDataInput1DPowderEDF()
        xsdIn.setEdfFile(xsdAzimFile)

        strInputFile = os.path.basename(_edPlugin.getDataInput().getInputFile().getPath().getValue())
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(
               os.path.join(self.__dictID11["output_dir"], os.path.splitext(strInputFile)[0] + "." + self.__dictID11["output_extn"])
                                     ))
        xsdIn.setOutputFile(xsdFile)

        xsdIn.setEdfFile(xsdOut.getCakedFile())

        xsdIn.setOutputFormat(XSDataString(self.__dictID11["output_extn"]))
        xsdIn.setNumberOfBins(XSDataInteger(int(self.__dictID11["RADIAL BINS"])))

        # EDF Launch
        edPluginEDF = self.loadPlugin(self.__strControlledPluginEDF)
        edPluginEDF.setDataInput(xsdIn)
        edPluginEDF.connectSUCCESS(self.doSuccessExec1DPowderEDF)
        edPluginEDF.connectFAILURE(self.doFailureExec1DPowderEDF)
        edPluginEDF.execute()
        self.synchronizeOff()
Ejemplo n.º 8
0
    def characteriseWithXmlInput(self, data_collection_id, sampleCharacteriseIndex, beamsize):
        if data_collection_id is not None:
          self.ednaInput.setDataCollectionId(XSDataInteger(data_collection_id))
        else:
          self.ednaInput.setDataCollectionId(None)
          logging.getLogger().warning("The data collection ID is not known for this characterisation. Therefore the EDNA results cannot be put into the database")

        # build data set
        imageSuffix = self.beamlinePars["BCM_PARS"].getProperty("FileSuffix")
        dataSetObj = XSDataMXCuBEDataSet()
        self.ednaInput.setDataSet([])
        methodDCNo = len(self.current_method[1])
        for methodIndex in range(methodDCNo):
          number_of_images = self.current_method[1][methodIndex]['number_of_images']
          imageNameIdx = self.current_method[0]
          listIndex = sampleCharacteriseIndex * methodDCNo + methodIndex
          for imageno in range(int(number_of_images)):
              imageFileObj = XSDataFile()
              pathStrObj = XSDataString()
              pathStrObj.setValue(('%s/%s_%d_%04d.%s' % (self.collectSeqList[listIndex]['fileinfo']['directory'],\
                                                         self.collectSeqList[listIndex]['fileinfo']['prefix'],\
                                                         int(self.collectSeqList[listIndex]['fileinfo']['run_number']),\
                                                         imageno+1,imageSuffix)))
              imageFileObj.setPath(pathStrObj)
              dataSetObj.addImageFile(imageFileObj)
        self.ednaInput.addDataSet(dataSetObj)

        if TEST:
          self.ednaInput.getDataSet()[0].getImageFile()[0].getPath().setValue("/opt/pxsoft/DNA/TestCase/ref-testscale_1_001.img")
          self.ednaInput.getDataSet()[0].getImageFile()[1].getPath().setValue("/opt/pxsoft/DNA/TestCase/ref-testscale_1_002.img")
        path = self.process_dir
        suffix = '_%s.xml' % (self.ednaInput.getDataCollectionId().getValue() or id(self.ednaInput))
        ednaResultsFile = os.path.join(path, 'EDNAOutput%s' % suffix)
        ednaInputXMLFile = os.path.join(path, 'EDNAInput%s' % suffix)
        if not os.path.isdir(path):
            os.makedirs(path)

        beamObj = self.ednaInput.getExperimentalCondition().getBeam()
        beamObj.setSize(XSDataSize(x=XSDataLength(float(beamsize[0])),y=XSDataLength(float(beamsize[1]))))
        """ create an edna input file using the ednainput model """
        ednaInputXML = self.ednaInput.exportToFile(ednaInputXMLFile)

        logging.getLogger().info("Starting Edna using xml file, %s" % ednaInputXMLFile)

        # use an intermediate script to run edna with its command line options
        edna_args = "%s  %s %s" % (ednaInputXMLFile,ednaResultsFile,path)
        edna_cmd=self.StartEdnaCommand+" "+edna_args
        if self.ednaPollTimer is None:
            self.ednaPollTimer = qt.QTimer()
            qt.QObject.connect(self.ednaPollTimer,qt.SIGNAL("timeout()"), self.pollEDNA)

        logging.getLogger().debug(edna_cmd)
        EDNA_PROCESSES.append(EnhancedPopen.Popen(edna_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True,universal_newlines=True))
        self.EDNAResultsFiles[id(EDNA_PROCESSES[-1])]=ednaResultsFile
        # save image prefix,etc. for next step
        # only take first image, since we just want to have image prefix, run number, etc. :
        # it is the same within the whole collectSeqList (hopefully)
        imagePrefix = self.collectSeqList[0]['fileinfo']['prefix'][4:] #remove ref-
        self.imagePathProperties[id(EDNA_PROCESSES[-1])]={"imagePrefix":imagePrefix, "imageDir": self.collectSeqList[0]['fileinfo']['directory'], "lRunN": int(self.collectSeqList[0]['fileinfo']['run_number'])}
        self.ednaPollTimer.start(100)
Ejemplo n.º 9
0
    def doSuccessSaxsMac(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginBioSaxsAveragev1_0.doSuccessSaxsMac")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginBioSaxsAveragev1_0.doSuccessSaxsMac")
        strEdnaLogFile = os.path.join(_edPlugin.getWorkingDirectory(), _edPlugin.getScriptLogFileName())
        EDVerbose.DEBUG("ExecPlugin log file is in: %s" % strEdnaLogFile)
        if os.path.isfile(strEdnaLogFile):
            shutil.copy(strEdnaLogFile, self.strLogFile)
            xsLogFile = XSDataFile()
            xsLogFile.setPath(XSDataString(self.strLogFile))
            self.xsdResult.setLogFile(xsLogFile)

        xsdiMetadata = XSDataInputBioSaxsMetadatav1_0()
        xsdiMetadata.setInputImage(self.dataInput.getAveragedImage())
        xsdiMetadata.setOutputImage(self.dataInput.getAveragedImage())
        xsdiMetadata.setConcentration(self.xsdMetadata.concentration)
        xsdiMetadata.setComments(self.xsdMetadata.comments)
        xsdiMetadata.setCode(self.xsdMetadata.code)
        xsdiMetadata.setDetector(self.xsdMetadata.getDetector())
        xsdiMetadata.setDetectorDistance(self.xsdMetadata.detectorDistance)
        xsdiMetadata.setPixelSize_1(self.xsdMetadata.pixelSize_1)
        xsdiMetadata.setPixelSize_2(self.xsdMetadata.pixelSize_2)
        xsdiMetadata.setBeamCenter_1(self.xsdMetadata.beamCenter_1)
        xsdiMetadata.setBeamCenter_2(self.xsdMetadata.beamCenter_2)
        xsdiMetadata.setWavelength(self.xsdMetadata.wavelength)
        xsdiMetadata.setMachineCurrent(self.xsdMetadata.machineCurrent)
        xsdiMetadata.setMaskFile(self.xsdMetadata.maskFile)
        xsdiMetadata.setNormalizationFactor(self.xsdMetadata.normalizationFactor)
        self.__edPluginSaxsSetMetadata.setDataInput(xsdiMetadata)
        self.__edPluginSaxsSetMetadata.connectSUCCESS(self.doSuccessSetMetadata)
        self.__edPluginSaxsSetMetadata.connectFAILURE(self.doFailureSetMetadata)
        self.__edPluginSaxsSetMetadata.executeSynchronous()
Ejemplo n.º 10
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'fileGraph':
			obj_ = XSDataFile()
			obj_.build(child_)
			self.fileGraph.append(obj_)
		XSDataResult.buildChildren(self, child_, nodeName_)
Ejemplo n.º 11
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'hklfile':
			obj_ = XSDataFile()
			obj_.build(child_)
			self.setHklfile(obj_)
		XSDataResult.buildChildren(self, child_, nodeName_)
 def createInputCharacterisationFromImageHeaders(self, _edPlugin):
     self.DEBUG("EDPluginControlInterfacev1_3.createInputCharacterisationFromImageHeaders")
     xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
     for xsDataStringImagePath in self.listImagePaths:
         xsDataFile = XSDataFile()
         xsDataFile.setPath(xsDataStringImagePath)
         xsDataInputSubWedgeAssemble.addFile(xsDataFile)
     _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
     _edPlugin.executeSynchronous()
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     self.DEBUG("EDPluginExecSiftDescriptorv1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultSiftDescriptor()
     if os.path.isfile(self.strKeys):
         xsdFile = XSDataFile()
         xsdFile.setPath(XSDataString(self.strKeys))
         xsDataResult.setDescriptorFile(xsdFile)
     self.setDataOutput(xsDataResult)
Ejemplo n.º 14
0
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     EDVerbose.DEBUG("*** EDPluginFIT2DCakev1_0.postProcess")
     # Create the output data
     xsDataResultFIT2DCake = XSDataResultFIT2DCake()
     if (self.m_strOutputFilePath is not None):
         xsDataFile = XSDataFile()
         xsDataFile.setPath(XSDataString(self.m_strOutputFilePath))
         xsDataResultFIT2DCake.setResultFile(xsDataFile)
     self.setDataOutput(xsDataResultFIT2DCake)
Ejemplo n.º 15
0
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     EDVerbose.DEBUG("EDPluginExecVideov10.postProcess")
     # Create some output data
     xsDataResult = XSDataResultExecVideo()
     xsDataFile = XSDataFile()
     xsDataFile.setPath(XSDataString(self.videoFile))
     xsDataResult.setVideoPath(xsDataFile)
     xsDataResult.setVideoPath(xsDataFile)
     xsDataResult.setVideoCodec(XSDataString(self.codec))
     self.setDataOutput(xsDataResult)
Ejemplo n.º 16
0
 def postProcess(self, _edObject=None):
     EDPlugin.postProcess(self)
     self.DEBUG("EDPluginWaitFile.postProcess: Waited for %.3f s" % self.getRunTime())
     xsDataResult = XSDataResultWaitFile()
     if os.path.exists(self.__filename):
         xsDataFile = XSDataFile()
         xsDataFile.setPath(XSDataString(self.__filename))
         xsDataResult.setActualFile(xsDataFile)
         xsDataResult.setActualSize(XSDataInteger(os.path.getsize(self.__filename)))
     xsDataResult.setTimedOut(XSDataBoolean(self.getRunTime() >= self.__timeout))
     # Create some output data
     self.setDataOutput(xsDataResult)
Ejemplo n.º 17
0
 def compressRaw(self):
     xsdin = XSDataInputExecCommandLine()
     xsdin.setFireAndForget(XSDataBoolean(1))
     xsdin.setInputFileName(self.getDataInput().getInputRaw())
     xsdin.setCommandLineOptions(XSDataString("-9"))
     xsdf = XSDataFile()
     xsdf.setPath(XSDataString("/bin/bzip2"))
     xsdin.setCommandLineProgram(xsdf)
     self.__edPluginExecBzip2.setDataInput(xsdin)
     self.__edPluginExecBzip2.connectSUCCESS(self.doSuccessExecBzip2)
     self.__edPluginExecBzip2.connectFAILURE(self.doFailureExecBzip2)
     self.__edPluginExecBzip2.executeSynchronous()
Ejemplo n.º 18
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecGnomv0_1.postProcess")
        # Create some output data
        xsDataResult = self.parseGnomOutputFile()

        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), "gnom.out")))

        xsDataResult.setOutput(xsDataFile)

        self.setDataOutput(xsDataResult)
Ejemplo n.º 19
0
    def doFailureExecSaxsMac(self, _edPlugin=None):
        self.DEBUG("EDPluginBioSaxsNormalizev1_0.doFailureExecSaxsMac")
        self.retrieveFailureMessages(_edPlugin, "EDPluginBioSaxsNormalizev1_0.doFailureExecSaxsMac")
        strEdnaLogFile = self.__edPluginExecSaxsMac.getScriptLogFileName()
        if os.path.isfile(strEdnaLogFile):
            shutil.copy(strEdnaLogFile, self.strLogFile)
            xsLogFile = XSDataFile()
            xsLogFile.setPath(XSDataString(self.strLogFile))
            self.xsdResult.setLogFile(xsLogFile)

        self.lstProcessLog.append("Normalization failure during execution of saxs_mac.")
        self.setFailure()
Ejemplo n.º 20
0
    def postProcess(self, _edObject=None):
        """
        """
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("*** EDPluginDCTWriteSinogramv1_0.postProcess")
        xsDataResultWriteSinogram = XSDataResultWriteSinogram()

        for pystrPathToOneSinogram in self.pydProcessSinograms:
            oneSinogram = XSDataFile()
            oneSinogram.setPath(XSDataString(pystrPathToOneSinogram + "Size%ix%i.edf" % (self.yMax, self.xMax)))
            xsDataResultWriteSinogram.addSinogramFile(oneSinogram)
            EDVerbose.DEBUG("Adding sinogram: %s" % pystrPathToOneSinogram)
        self.setDataOutput(xsDataResultWriteSinogram)
    def process(self, _edObject=None):
        """
        """
        for  i in range(2):
            execPlugin = self.loadPlugin(self.__strControlledPluginThumbnail)
            xsdin = XSDataInputExecThumbnail()
            xsdin.setInputArray(self.xsdImages[i])
            xsdFile = XSDataFile()
            xsdFile.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), "image%i.jpg" % self.xsdIdx[i].getValue())))
            xsdin.setOutputPath(xsdFile)
            xsdin.setLevelsColorize(XSDataBoolean(1))
            xsdin.setLevelsEqualize(XSDataBoolean(1))

            execPlugin.setDataInput(xsdin)
            execPlugin.connectSUCCESS(self.doSuccessThumb)
            execPlugin.connectFAILURE(self.doFailureThumb)
            self.ACThumbnail.addAction(execPlugin)
        self.ACThumbnail.execute()

        while len(self.xsdThumb) < 2:
            time.sleep(1)

        for  oneImage in self.xsdThumb:
            execPlugin = self.loadPlugin(self.__strControlledPluginSift)
            xsdin = XSDataInputSiftDescriptor()
            xsdin.setImage(oneImage)
            execPlugin.setDataInput(xsdin)
            execPlugin.connectSUCCESS(self.doSuccessSift)
            execPlugin.connectFAILURE(self.doFailureSift)
            self.ACSift.addAction(execPlugin)
        self.ACSift.execute()
#
#        else:
#            strError = "There are only %s images in self.xsdThumb" % len(self.xsdThumb)
#            EDVerbose.ERROR(strError)
#            self.setFailure()
#            raise RuntimeError(strError)

################################################################################
# This should be executed only after the Sift actions cluster finishes 
################################################################################
        while len(self.xsdKeys) < 2:
            time.sleep(1)

        execPlugin = self.loadPlugin(self.__strControlledPluginAutopano)
        xsdin = XSDataInputMeasureOffsetSift()
        xsdin.setDescriptorFile(self.xsdKeys)
        execPlugin.setDataInput(xsdin)
        execPlugin.connectSUCCESS(self.doSuccessAutopano)
        execPlugin.connectFAILURE(self.doFailureAutopano)
        execPlugin.executeSynchronous()
    def postProcess(self, _edObject=None):
        EDPluginExec.postProcess(self)
        self.DEBUG("EDPluginExecSaxsCurvesv1_1.postProcess")

        # Create some output data
        xsDataResult = XSDataResultSaxsCurvesv1_0()
        if self.outputDataFile is None:
            self.outputDataFile = "output.edf"
        if os.path.isfile(self.outputDataFile):
            xsdFile = XSDataFile()
            xsdFile.setPath(XSDataString(os.path.abspath(self.outputDataFile)))
            xsDataResult.setOutputDataFile(xsdFile)

        self.setDataOutput(xsDataResult)
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        strError = self.readProcessErrorLogFile()
        if((strError is not None) and (strError != "")):
            strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ('EDPluginMxv1ParamsToXMLv1_0.postProcess', 'EDPluginMxv1ParamsToXMLv1_0', strError)
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            raise RuntimeError, strErrorMessage

        # This should work as long as there is a single output, i.e. not a list: 
        strFilePath = os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName())
        xsDataFileResult = XSDataFile()
        xsDataFileResult.setPath(XSDataString(strFilePath))
        # Do not specify name of output here:
        self.setDataOutput(xsDataFileResult)
Ejemplo n.º 24
0
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     EDVerbose.DEBUG("EDPluginExecDcrawv1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultExecDcrawv1()
     xsdFile = XSDataFile()
     if self.__strOutputFile is not None:
         shutil.copyfile(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()), self.__strOutputFile)
         xsdFile.setPath(XSDataString(self.__strOutputFile))
     else:
         xsdFile.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName())))
     xsDataResult.setOutputPath(xsdFile)
     if self.__strOutputType is not None:
         xsDataResult.setOutputFileType(XSDataString(self.__strOutputType))
     self.setDataOutput(xsDataResult)
Ejemplo n.º 25
0
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("EDPluginExportAsciiPowderv1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResult1DPowderEDF()
     if self.outputFilename is None:
         xsDataResult.setTwoTheta(EDUtilsArray.arrayToXSData(self.npaTwoTheta))
         xsDataResult.setIntensity(EDUtilsArray.arrayToXSData(self.npaIntensities))
     else:
         xsdFile = XSDataFile()
         xsdFile.setPath(XSDataString(self.outputFilename))
         xsDataResult.setOutputFile(xsdFile)
     self.setDataOutput(xsDataResult)
     self.npaTwoTheta = None
     self.npaIntensities = None
     self.inputArray = None
Ejemplo n.º 26
0
 def postProcess(self, _edObject=None):
     """
     Postprocess of the plugin:
      
     * set output of the plugin
     * free some memory from large arrays
     """
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("EDPluginPyarchThumbnailv10.postProcess")
     # Create some output data
     if self.strOutputPath:
         xsDataResult = XSDataResultPyarchThumbnail()
         if os.path.isfile(self.strOutputPath):
             xsDataFile = XSDataFile()
             xsDataFile.setPath(XSDataString(self.strOutputPath))
             xsDataResult.setThumbnailPath(xsDataFile)
         self.setDataOutput(xsDataResult)
Ejemplo n.º 27
0
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     self.DEBUG("EDPluginExecSiftOffsetv1_0.postProcess")
     xsDataResult = XSDataResultMeasureOffsetSift()
     if os.path.isfile(self.outFile):
         xsdStr = XSDataString(self.outFile)
         xsdFile = XSDataFile()
         xsdFile.setPath(xsdStr)
         xsDataResult.setPanoFile(xsdFile)
         dx = []
         dy = []
         for oneLine in open(self.outFile).readlines():
             if oneLine.startswith("c"):
                 x = 0
                 X = 0
                 y = 0
                 Y = 0
                 for oneWord in oneLine.strip().split(" "):
                     if oneWord.startswith("x"):
                         x = float(oneWord[1:])
                     elif oneWord.startswith("X"):
                         X = float(oneWord[1:])
                     elif oneWord.startswith("y"):
                         y = float(oneWord[1:])
                     elif oneWord.startswith("Y"):
                         Y = float(oneWord[1:])
                 if x != 0 and y != 0 and X != 0 and Y != 0 and abs(X - x) < 100 and abs(Y - y) < 100:
                     dx.append(X - x)
                     dy.append(Y - y)
                 else:
                     self.DEBUG("%s %s %s %s %s %s %s" % (oneLine, x, y, X, Y, X - x, Y - y))
         dx.sort()
         dy.sort()
         subDx = dx[int(round(0.1 * len(dx))):int(round(0.9 * len(dx)))]
         subDy = dy[int(round(0.1 * len(dy))):int(round(0.9 * len(dy)))]
         sum1 = 0.0
         sum2 = 0.0
         for i in subDx:
             sum1 += i
         for i in subDy:
             sum2 += i
         xsDataResult.setOffset([XSDataDouble(-sum2 / max(1, len(subDy))), XSDataDouble(-sum1 / max(1, len(subDx))) ])
     # Create some output data
     self.setDataOutput(xsDataResult)
Ejemplo n.º 28
0
    def postProcess(self, _edObject=None):
        """
        Post-Process: set the output of the plugin
        """
        EDPluginExecProcessScript.postProcess(self)
        self.DEBUG("EDPluginExecCommandLinev10.postProcess")

        # Create some output data
        xsDataResult = XSDataResultExecCommandLine()
        if self.dataInput.getFireAndForget() is not None:
            if self.dataInput.getFireAndForget().value is True:
                self.setDataOutput(xsDataResult)
                return
        if self.dataInput.getOutfileFromStdout() is not None:
            #self.DEBUG("*** getOutfileFromStdout = %s" % self.dataInput.getOutfileFromStdout().value)
            if self.dataInput.getOutfileFromStdout().value : # this is not clean ... should be 1 or True ... or whatever
                if self.dataInput.getOutputPath() is not None:
                    outputPath = self.dataInput.getOutputPath().path.value
                    stdout = os.path.join(self.getWorkingDirectory() , self.getScriptLogFileName())

                    self.synchronizeOn()
                    if os.path.isdir(outputPath):
                        outfile = os.path.join(outputPath, os.path.split(self.dataInput.inputFileName.path.value)[1])
                    else:
                        outfile = outputPath
                    if os.path.isfile(outfile):
                            takenNames = []
                            [mydir, myname] = os.path.split(outfile)
                            for onefile in os.listdir(mydir):
                                if onefile.find(myname) == 0:
                                    takenNames.append(onefile)
                            for ext in string.digits + string.ascii_lowercase:
                                if not (outfile + ext) in takenNames:
                                    outfile += ext
                                    break
                    shutil.move(stdout , outfile)
                    self.synchronizeOff()

                    xsDataFile = XSDataFile()
                    xsDataFile.setPath(XSDataString(outfile))
                    xsDataResult.setOutputFilename(xsDataFile)
                else:
                    xsDataResult.setOutputFilename(self.getScriptLogFileName())
        self.setDataOutput(xsDataResult)
 def testCreateDataMOSFLMOutputIntegration(self):
     pluginIntegration = self.createPlugin()
     pluginIntegration.setScriptExecutable("cat")
     pluginIntegration.configure()
     strBaseName = pluginIntegration.getBaseName()
     shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileDat_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.dat"))
     shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfilePar_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.par"))
     shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileHKL_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.hkl"))
     shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_outputDnaTables_ok.xml"), os.path.join(pluginIntegration.getWorkingDirectory(), strBaseName + "_dnaTables.xml"))
     strMatrixFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt")
     pluginIntegration.setMatrixFileName(strMatrixFile)
     xsDataMOSFLMIntegrationOutput = pluginIntegration.createDataMOSFLMOutputIntegration()
     # Fix problem with absolute path by replacing it with a fixed one
     xsDataFile = XSDataFile()
     xsDataFile.setPath(XSDataString("/tmp/EDPluginMOSFLMIntegrationv10_process_1_1.mtz"))
     xsDataMOSFLMIntegrationOutput.setGeneratedMTZFile(xsDataFile)
     strReferenceXML = self.readAndParseFile(self.strReferenceDataOutputFile)
     xsDataMOSFLMIntegrationOutputReference = XSDataMOSFLMOutputIntegration.parseString(strReferenceXML)
     EDAssert.equal(xsDataMOSFLMIntegrationOutputReference.marshal(), xsDataMOSFLMIntegrationOutput.marshal())
Ejemplo n.º 30
0
    def postProcess(self, _edObject=None):
        EDPluginHDF5.postProcess(self)
        self.DEBUG("EDPluginHDF5MapOfSpectrav10.postProcess")
        xsDataResult = XSDataResultHDF5MapSpectra()
        if os.path.isfile(self.strHDF5Filename):
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(self.strHDF5Filename))
            xsDataResult.setHDF5File(xsDataFile)
            xsDataResult.setInternalHDF5Path(XSDataString(self.strHDF5Path))
        self.setDataOutput(xsDataResult)

        # Delete input images if requested
        if self.bDeleteSpectrum:
            for oneImage in self.listSpectrumFilenames:
                os.remove(oneImage)
#        De-Allocate memory
        self.listSpectrumFilenames = []
        self.listForcedPositions = []
        self.listSpectrumFileType = []
        self.listArray = []
Ejemplo n.º 31
0
 def readIdxrefLp(self, _pathToIdxrefLp, _xsDataResultXDSIndexing=None):
     self.DEBUG("EDPluginXDSIndexingv1_0.readIdxrefLp")
     if _xsDataResultXDSIndexing is None:
         xsDataResultXDSIndexing = XSDataResultXDSIndexing()
     else:
         xsDataResultXDSIndexing = _xsDataResultXDSIndexing
     if os.path.exists(_pathToIdxrefLp):
         xsDataResultXDSIndexing.pathToLogFile = XSDataFile(XSDataString(_pathToIdxrefLp))
         with open(_pathToIdxrefLp) as f:
             listLines = f.readlines()
         indexLine = 0
         doParseParameters = False
         doParseLattice = False
         while (indexLine < len(listLines)):
             if "DIFFRACTION PARAMETERS USED AT START OF INTEGRATION" in listLines[indexLine]:
                 doParseParameters = True
                 doParseLattice = False
             elif "DETERMINATION OF LATTICE CHARACTER AND BRAVAIS LATTICE" in listLines[indexLine]:
                 doParseParameters = False
                 doParseLattice = True
             if doParseParameters:
                 if "MOSAICITY" in listLines[indexLine]:
                     mosaicity = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.mosaicity = XSDataAngle(mosaicity)
                 elif "DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM" in listLines[indexLine]:
                     xBeam = float(listLines[indexLine].split()[-2])
                     yBeam = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.beamCentreX = XSDataFloat(xBeam)
                     xsDataResultXDSIndexing.beamCentreY = XSDataFloat(yBeam)
                 elif "CRYSTAL TO DETECTOR DISTANCE" in listLines[indexLine]:
                     distance = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.distance = XSDataLength(distance)
             elif doParseLattice:
                 if listLines[indexLine].startswith(" * ") and not listLines[indexLine + 1].startswith(" * "):
                     listLine = listLines[indexLine].split()
                     xsDataResultXDSIndexing.latticeCharacter = XSDataInteger(int(listLine[1]))
                     bravaisLattice = listLine[2]
                     xsDataResultXDSIndexing.bravaisLattice = XSDataString(bravaisLattice)
                     spaceGroup = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(bravaisLattice)
                     xsDataResultXDSIndexing.spaceGroup = XSDataString(spaceGroup)
                     spaceGroupNumber = EDUtilsSymmetry.getITNumberFromSpaceGroupName(spaceGroup)
                     xsDataResultXDSIndexing.spaceGroupNumber = XSDataInteger(spaceGroupNumber)
                     xsDataResultXDSIndexing.qualityOfFit = XSDataFloat(float(listLine[3]))
                     xsDataXDSCell = XSDataXDSCell()
                     xsDataXDSCell.length_a = XSDataLength(float(listLine[4]))
                     xsDataXDSCell.length_b = XSDataLength(float(listLine[5]))
                     xsDataXDSCell.length_c = XSDataLength(float(listLine[6]))
                     xsDataXDSCell.angle_alpha = XSDataAngle(float(listLine[7]))
                     xsDataXDSCell.angle_beta = XSDataAngle(float(listLine[8]))
                     xsDataXDSCell.angle_gamma = XSDataAngle(float(listLine[9]))
                     xsDataResultXDSIndexing.unitCell = xsDataXDSCell
             indexLine += 1
     return xsDataResultXDSIndexing
Ejemplo n.º 32
0
    def postProcess(self, _edObject=None):
        """
        Postprocess of the plugin:
         
        * set output of the plugin
        * free some memory from large arrays
        """
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecThumbnailv10.postProcess")
        # Create some output data

        xsDataResult = XSDataResultExecThumbnail()
        if os.path.isfile(self.output):
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(self.output))
            xsDataResult.setThumbnailPath(xsDataFile)
            xsDataString = XSDataString()
            xsDataString.setValue(self.format)
            xsDataResult.setThumbnailType(xsDataString)
        self.setDataOutput(xsDataResult)
        self.npaImage = None
Ejemplo n.º 33
0
 def testCheckParameters(self):
     xsDataInput = XSDataInputBioSaxsAzimutIntv1_0()
     xsDataInput.setNormalizedImage(XSDataImage())
     xsDataInput.setNormalizedImageSize(XSDataInteger())
     xsDataInput.setIntegratedImage(XSDataImage())
     xsDataInput.setIntegratedCurve(XSDataFile())
     xsDataInput.correctedImage = XSDataImage()
     xsDataInput.sample = XSDataBioSaxsSample()
     xsDataInput.experimentSetup = XSDataBioSaxsExperimentSetup()
     edPluginExec = self.createPlugin()
     edPluginExec.setDataInput(xsDataInput)
     edPluginExec.checkParameters()
Ejemplo n.º 34
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'characterisationResult':
         obj_ = XSDataResultCharacterisation()
         obj_.build(child_)
         self.setCharacterisationResult(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'fileGraph':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.fileGraph.append(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 35
0
 def processRun(self, run):
     run.dump_json()
     hdf5 = run.save_hdf5()
     self.json = os.path.splitext(hdf5)[0] + ".json"
     self.xsDataResult.hplcFile = XSDataFile(XSDataString(hdf5))
     self.xsDataResult.hplcImage = XSDataFile(XSDataString(run.make_plot()))
     for group in run.analyse():
         self.lstExecutiveSummary.append("Merging frames from %s to %s" % (group[0], group[-1]))
         xsdFrames = [XSDataFile(XSDataString(run.frames[i].subtracted)) for i in group]
         outname = os.path.splitext(run.frames[group[0]].subtracted)[0] + "_aver_%s.dat" % group[-1]
         edpugin = self.loadPlugin(self.strControlledPluginDatAver)
         edpugin.dataInput = XSDataInputDataver(outputCurve=XSDataFile(XSDataString(outname)), inputCurve=xsdFrames)
         edpugin.connectSUCCESS(self.doSuccessDatAver)
         edpugin.connectFAILURE(self.doFailureDatAver)
         edpugin.execute()
         run.merge_curves.append(outname)
         run.merge_analysis[outname] = None
         run.merge_Rg[outname] = None
         run.merge_framesDIC[outname] = [group[0], group[-1]]
     # Append to hdf5
     run.append_hdf5()
Ejemplo n.º 36
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'inputMatrix':
         obj_ = XSDataArray()
         obj_.build(child_)
         self.setInputMatrix(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'outputMatrixFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setOutputMatrixFile(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 37
0
 def postProcess(self, _edObject=None):
     EDPluginControl.postProcess(self)
     self.DEBUG("EDPluginBioSaxsSmartMergev1_7.postProcess")
     # Create some output data
     self.xsDataResult.mergedCurve = self.dataInput.mergedCurve
     if self.strSubFile is not None and os.path.isfile(self.strSubFile):
         self.xsDataResult.subtractedCurve = XSDataFile(
             XSDataString(self.strSubFile))
     self.xsDataResult.autoRg = self.autoRg
     self.xsDataResult.gnom = self.gnom
     self.xsDataResult.volume = self.volume
     self.xsDataResult.rti = self.rti
Ejemplo n.º 38
0
 def doSuccessAccumulator(self, _edPlugin=None):
     with self.locked():
         self.DEBUG("EDPluginWaitMultiFile.doSuccessAccumulator")
         self.retrieveSuccessMessages(
             _edPlugin, "EDPluginWaitMultiFile.doSuccessAccumulator")
         xsdQueries = _edPlugin.dataOutput.getQuery()
         if xsdQueries is not None and len(xsdQueries) == 1:
             xsdQuery = xsdQueries[0]
             if (xsdQuery is not None) and (len(xsdQuery.getItem()) == len(
                     self.listXsdFiles)):
                 self.xsdDataOut.setActualFile(
                     [XSDataFile(xsd) for xsd in xsdQuery.getItem()])
Ejemplo n.º 39
0
    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        self.DEBUG("EDPluginBioSaxsProcessOneFilev1_3.postProcess")
        # Create some output data
        xsDataResult = XSDataResultBioSaxsProcessOneFilev1_0()
        if os.path.exists(self.integratedCurve):
            xsDataResult.integratedCurve = XSDataFile(XSDataString(self.integratedCurve))
        xsDataResult.sample = self.sample
        xsDataResult.experimentSetup = self.experimentSetup

        xsDataResult.status = XSDataStatus(executiveSummary=XSDataString(os.linesep.join(self.lstExecutiveSummary)))
        self.setDataOutput(xsDataResult)
Ejemplo n.º 40
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecDamfiltv0_1.postProcess")

        xsDataResult = XSDataResultDamfilt()

        pathOutputFile = XSDataString(
            os.path.join(self.getWorkingDirectory(),
                         self.__strOutputPdbFileName))
        xsDataResult.setOutputPdbFile(XSDataFile(pathOutputFile))

        self.setDataOutput(xsDataResult)
Ejemplo n.º 41
0
 def average_buffers(self):
     """
     Average out all buffers
     """
     self.lstExecutiveSummary.append("Averaging out buffer files: " +
                                     ", ".join(self.hplc_run.for_buffer))
     xsdIn = XSDataInputDataver(inputCurve=[
         XSDataFile(XSDataString(i)) for i in self.hplc_run.for_buffer
     ])
     if self.dataInput.bufferCurve:
         xsdIn.outputCurve = self.dataInput.bufferCurve
     else:
         xsdIn.outputCurve = XSDataFile(
             XSDataString(
                 self.hplc_run.first_curve[::-1].split("_", 1)[1][::-1] +
                 "_buffer_aver%02i.dat" % len(self.hplc_run.for_buffer)))
     self.edPluginDatAver = self.loadPlugin(self.strControlledPluginDatAver)
     self.edPluginDatAver.dataInput = xsdIn
     self.edPluginDatAver.connectSUCCESS(self.doSuccessDatAver)
     self.edPluginDatAver.connectFAILURE(self.doFailureDatAver)
     self.edPluginDatAver.executeSynchronous()
Ejemplo n.º 42
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'plotSet':
			obj_ = XSDataPlotSet()
			obj_.build(child_)
			self.setPlotSet(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'filePlotMtv':
			obj_ = XSDataFile()
			obj_.build(child_)
			self.setFilePlotMtv(obj_)
		XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 43
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'elementName':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setElementName(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'inputFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setInputFile(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 44
0
    def postProcess(self, _oedObject=None):
        EDPluginExecProcessScript.postProcess(self, _oedObject)
        # Fill in file paths
        xsDataXDSFilePaths = XSDataXDSFilePaths()

        xparmXds = os.path.join(self.getWorkingDirectory(), "XPARM.XDS")
        if os.path.exists(xparmXds):
            xsDataXDSFilePaths.xparmXds = XSDataFile(XSDataString(xparmXds))

        xCorrectionsCbf = os.path.join(self.getWorkingDirectory(),
                                       "X-CORRECTIONS.cbf")
        if os.path.exists(xCorrectionsCbf):
            xsDataXDSFilePaths.xCorrectionsCbf = XSDataFile(
                XSDataString(xCorrectionsCbf))

        yCorrectionsCbf = os.path.join(self.getWorkingDirectory(),
                                       "Y-CORRECTIONS.cbf")
        if os.path.exists(yCorrectionsCbf):
            xsDataXDSFilePaths.yCorrectionsCbf = XSDataFile(
                XSDataString(yCorrectionsCbf))

        bkginitCbf = os.path.join(self.getWorkingDirectory(), "BKGINIT.cbf")
        if os.path.exists(bkginitCbf):
            xsDataXDSFilePaths.bkginitCbf = XSDataFile(
                XSDataString(bkginitCbf))

        gainCbf = os.path.join(self.getWorkingDirectory(), "GAIN.cbf")
        if os.path.exists(gainCbf):
            xsDataXDSFilePaths.gainCbf = XSDataFile(XSDataString(gainCbf))

        blankCbf = os.path.join(self.getWorkingDirectory(), "BLANK.cbf")
        if os.path.exists(blankCbf):
            xsDataXDSFilePaths.blankCbf = XSDataFile(XSDataString(blankCbf))

        self.dataOutput.filePaths = xsDataXDSFilePaths
Ejemplo n.º 45
0
 def parseOutputDirectory(self, _workingDirectory):
     xsDataResultXia2DIALS = XSDataResultXia2DIALS()
     # Log file
     xia2txtPath = os.path.join(_workingDirectory, "xia2.txt")
     if os.path.exists(xia2txtPath):
         xsDataResultXia2DIALS.logFile = XSDataFile(
             XSDataString(xia2txtPath))
     # Html file
     xia2htmlPath = os.path.join(_workingDirectory, "xia2.html")
     if os.path.exists(xia2htmlPath):
         xsDataResultXia2DIALS.htmlFile = XSDataFile(
             XSDataString(xia2htmlPath))
     # Summary file
     summaryPath = os.path.join(_workingDirectory, "xia2-summary.dat")
     if os.path.exists(summaryPath):
         xsDataResultXia2DIALS.summary = XSDataFile(
             XSDataString(summaryPath))
     # ISPyB XML file
     ispybXmlPath = os.path.join(_workingDirectory, "ispyb.xml")
     if os.path.exists(ispybXmlPath):
         xsDataResultXia2DIALS.ispybXML = XSDataFile(
             XSDataString(ispybXmlPath))
     # Datafiles
     dataFiles = glob.glob(os.path.join(_workingDirectory, "DataFiles",
                                        "*"))
     for dataFile in dataFiles:
         xsDataResultXia2DIALS.addDataFiles(
             XSDataFile(XSDataString(dataFile)))
     # Log files
     logFiles = glob.glob(os.path.join(_workingDirectory, "LogFiles", "*"))
     for logFile in logFiles:
         xsDataResultXia2DIALS.addLogFiles(XSDataFile(
             XSDataString(logFile)))
     return xsDataResultXia2DIALS
Ejemplo n.º 46
0
 def processRun(self, run):
     run.dump_json()
     hdf5 = run.save_hdf5()
     self.json = os.path.splitext(hdf5)[0] + ".json"
     self.xsDataResult.hplcFile = XSDataFile(XSDataString(hdf5))
     self.xsDataResult.hplcImage = XSDataFile(XSDataString(run.make_plot()))
     try:
         peaks = run.analyse()
         for group in peaks:
             self.lstExecutiveSummary.append(
                 "Merging frames from %s to %s" % (group[0], group[-1]))
             xsdFrames = [
                 XSDataFile(XSDataString(run.frames[i].subtracted))
                 for i in group
             ]
             outname = os.path.splitext(run.frames[
                 group[0]].subtracted)[0] + "_aver_%s.dat" % group[-1]
             edpugin = self.loadPlugin(self.strControlledPluginDatAver)
             edpugin.dataInput = XSDataInputDataver(outputCurve=XSDataFile(
                 XSDataString(outname)),
                                                    inputCurve=xsdFrames)
             edpugin.connectSUCCESS(self.doSuccessDatAver)
             edpugin.connectFAILURE(self.doFailureDatAver)
             edpugin.execute()
             run.merge_curves.append(outname)
             run.merge_analysis[outname] = None
             run.merge_Rg[outname] = None
             run.merge_framesDIC[outname] = [group[0], group[-1]]
     except ValueError:
         traceback.print_stack()
         self.ERROR(
             "EDPluginBioSaxsFlushHPLCv1_3: ValueError Error in analysing run"
         )
     except Exception as error:
         traceback.print_stack()
         self.ERROR(
             "EDPluginBioSaxsFlushHPLCv1_3:  Error in analysing run" %
             error)
     # Append to hdf5
     run.append_hdf5()
Ejemplo n.º 47
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginBioSaxsNormalizev1_1.process")
        xsdiWaitFile = XSDataInputWaitFile(
            expectedFile=XSDataFile(self.xsdInput.rawImage.path),
            expectedSize=self.xsdInput.rawImageSize,
            timeOut=XSDataTime(value=30))
        self.__edPluginExecWaitFile.setDataInput(xsdiWaitFile)
        self.__edPluginExecWaitFile.connectSUCCESS(self.doSuccessExecWaitFile)
        self.__edPluginExecWaitFile.connectFAILURE(self.doFailureExecWaitFile)
        self.__edPluginExecWaitFile.executeSynchronous()
        if self.isFailure():
            return
#        Small Numpy processing:
        fabIn = fabio.open(self.strRawImage)
        if "time_of_day" in fabIn.header:
            self.dictOutputHeader["time_of_day"] = fabIn.header["time_of_day"]
        if "Mask" in self.dictOutputHeader:
            mask = self.getMask(self.dictOutputHeader["Mask"])
            npaMaskedData = numpy.ma.masked_array(
                fabIn.data.astype("float32"),
                ((fabIn.data < 0) + (mask[:fabIn.dim2, :fabIn.dim1] < 0)))
        else:
            npaMaskedData = numpy.ma.masked_array(fabIn.data.astype("float32"),
                                                  (fabIn.data < 0))
        if self.dictOutputHeader["DiodeCurr"] == 0:
            warn = "DiodeCurr is Null --> I Guess we are testing and take it as one"
            self.lstProcessLog.append(warn)
            self.warning(warn)
            scale = self.dictOutputHeader["Normalization"]
        else:
            scale = self.dictOutputHeader[
                "Normalization"] / self.dictOutputHeader["DiodeCurr"]
        self.dictOutputHeader["Dummy"] = str(self.dummy)
        self.dictOutputHeader["DDummy"] = "0.1"
        self.dictOutputHeader["EDF_DataBlockID"] = "1.Image.Psd"
        header_keys = self.dictOutputHeader.keys()
        header_keys.sort()
        fabioOut = fabio.edfimage.edfimage(header=self.dictOutputHeader,
                                           header_keys=header_keys,
                                           data=numpy.ma.filled(
                                               npaMaskedData * scale,
                                               float(self.dummy)))
        fabioOut.appendFrame(header={
            "Dummy": str(self.dummy),
            "DDummy": "0.1",
            "EDF_DataBlockID": "1.Image.Error"
        },
                             data=(numpy.ma.filled(npaMaskedData * (scale**2),
                                                   float(self.dummy))))
        fabioOut.write(self.strNormalizedImage)
        self.lstProcessLog.append("Normalized image by factor %.3f " % (scale))
Ejemplo n.º 48
0
 def postProcess(self, _edObject=None):
     EDPluginControl.postProcess(self)
     self.DEBUG("EDPluginBioSaxsSmartMergev1_3.postProcess")
     # Create some output data
     xsDataResult = XSDataResultBioSaxsSmartMergev1_0()
     xsDataResult.mergedCurve = self.dataInput.mergedCurve
     executiveSummary = os.linesep.join(self.lstSummary)
     xsDataResult.status = XSDataStatus(executiveSummary=XSDataString(executiveSummary))
     if self.autoRg is not None:
         xsDataResult.autoRg = self.autoRg
     if self.strSubFile is not None and os.path.isfile(self.strSubFile):
         xsDataResult.subtractedCurve = XSDataFile(XSDataString(self.strSubFile))
     self.setDataOutput(xsDataResult)
Ejemplo n.º 49
0
 def postProcess(self, _edObject=None):
     """
     """
     if (self.edXMLFileSize > 0):
         EDVerbose.DEBUG(
             strftime("%Y-%m-%d %H:%M:%S") +
             " *** EDPluginExecSRBRegisterv10.postProcess...")
         # This is to make the tests pass, and it is during the postprocess step where the data is returned from the plugin.
         xsDataResultPluginExecSRBRegister = XSDataResultPluginExecSRBRegister(
         )
         edOutput = XSDataFile(XSDataString(self.edXMLFileName))
         xsDataResultPluginExecSRBRegister.setXmlIngestFileName(edOutput)
         self.setDataOutput(xsDataResultPluginExecSRBRegister)
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dataCollectionId':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setDataCollectionId(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'dozorProcessDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setDozorProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'xdsappProcessDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setXdsappProcessDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'doAnomAndNonanom':
         obj_ = XSDataBoolean()
         obj_.build(child_)
         self.setDoAnomAndNonanom(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 51
0
 def finallyProcess(self, _edPlugin=None):
     EDPluginExec.finallyProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_1.finallyProcess...")
     xsDataResultSimpleHTMLPage = XSDataResultSimpleHTMLPage()
     xsDataResultSimpleHTMLPage.setPathToHTMLFile(
         XSDataFile(
             XSDataString(
                 os.path.join(self.getWorkingDirectory(),
                              self.strHtmlFileName))))
     xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(
         XSDataFile(XSDataString(self.getWorkingDirectory())))
     # Write workflowStepReport HTML page
     pathToIndexFile = self.workflowStepReport.renderHtml(
         self.getWorkingDirectory(), nameOfIndexFile=self.strHtmlFileName)
     pathToJsonFile = self.workflowStepReport.renderJson(
         self.getWorkingDirectory())
     # Store in Pyarch
     if EDUtilsPath.isESRF() or EDUtilsPath.isEMBL() or EDUtilsPath.isALBA:
         strPyarchPath = None
         if self.xsDataResultCharacterisation is not None:
             strPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchHtmlDirectoryPath(
                 self.xsDataResultCharacterisation.getDataCollection())
         if strPyarchPath is None:
             # For debugging purposes
             strPyarchPath = EDUtilsPath.getEdnaUserTempFolder()
         EDHandlerESRFPyarchv1_0.copyHTMLDir(
             _strPathToHTMLDir=os.path.dirname(self.strPath),
             _strPathToPyarchDirectory=strPyarchPath)
         xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(
             XSDataFile(XSDataString(strPyarchPath)))
         if not os.path.exists(strPyarchPath):
             os.makedirs(strPyarchPath, 0o755)
         shutil.copy(pathToJsonFile, strPyarchPath)
         pathToJsonFile = os.path.join(strPyarchPath,
                                       os.path.basename(pathToJsonFile))
     # Write json file
     xsDataResultSimpleHTMLPage.pathToJsonFile = XSDataFile(
         XSDataString(pathToJsonFile))
     self.setDataOutput(xsDataResultSimpleHTMLPage)
Ejemplo n.º 52
0
 def process(self, _edObject=None):
     EDPluginControl.process(self)
     self.DEBUG("EDPluginControlGridScreeningv1_0.process")
     xsDataInputReadImageHeader = XSDataInputReadImageHeader()
     xsDataInputReadImageHeader.setImage(image=XSDataFile(
         path=XSDataString(self.strImageFile)))
     self.edPluginControlReadImageHeader.setDataInput(
         xsDataInputReadImageHeader)
     self.edPluginControlReadImageHeader.connectSUCCESS(
         self.doSuccessReadImageHeader)
     self.edPluginControlReadImageHeader.connectFAILURE(
         self.doFailureReadImageHeader)
     self.executePluginSynchronous(self.edPluginControlReadImageHeader)
Ejemplo n.º 53
0
 def createDataMOSFLMOutputGeneratePrediction(self):
     self.DEBUG("EDPluginMOSFLMGeneratePredictionv10.createDataMOSFLMOutputIntegration")
     xsDataMOSFLMInputGeneratePrediction = self.getDataInput()
     xsDataMOSFLMImage = xsDataMOSFLMInputGeneratePrediction.getImage()
     iImageNumber = xsDataMOSFLMImage.getNumber().getValue()
     xsDataMOSFLMOutputGeneratePrediction = XSDataMOSFLMOutputGeneratePrediction()
     xsDataImage = XSDataImage()
     xsDataImage.setNumber(XSDataInteger(iImageNumber))
     xsDataImage.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), self.getPredictionImageFileName())))
     xsDataMOSFLMOutputGeneratePrediction.setPredictionImage(xsDataImage)
      # Path to log file
     xsDataMOSFLMOutputGeneratePrediction.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))))
     return xsDataMOSFLMOutputGeneratePrediction
Ejemplo n.º 54
0
def populateXSDataInputSPDCake(dictID11):
    xsDataInputSPDCake = XSDataInputSPDCake()
    # Angle of tilt
    xsDataInputSPDCake.setAngleOfTilt(
        XSDataAngle(float(dictID11["ANGLE OF TILT"])))

    # Dark current
    if dictID11["DARK CURRENT"] == "YES":
        xsDataInputSPDCake.setDarkCurrentImageFile(
            XSDataFile(XSDataString(dictID11["DC FILE"])))
        #xsDataFile = XSDataFile()
        #xsDataFile.setPath(XSDataString(dictID11["DC FILE "]))
        #xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile)

    if dictID11["FLAT-FIELD"] == "YES":
        xsDataInputSPDCake.setFlatFieldImageFile(
            XSDataFile(XSDataString(dictID11["FF FILE"])))

    if dictID11["FF SCALE"] == "NO":
        xsDataInputSPDCake.setFlatFieldImageFile(
            XSDataFile(XSDataString(dictID11["FF MULTIPLIER"])))

    if dictID11["SPATIAL DIS."] == "YES":
        xsDataInputSPDCake.setSpatialDistortionFile(
            XSDataFile(XSDataString(dictID11["SD FILE"])))

    xsDataInputSPDCake.setStartAzimuth(
        XSDataAngle(float(dictID11["START AZIMUTH"])))
    xsDataInputSPDCake.setStopAzimuth(
        XSDataAngle(float(dictID11["END AZIMUTH"])))
    xsDataInputSPDCake.setInnerRadius(
        XSDataDouble(float(dictID11["INNER RADIUS"])))
    xsDataInputSPDCake.setOuterRadius(
        XSDataDouble(float(dictID11["OUTER RADIUS"])))

    xsDataInputSPDCake.setBufferSizeX(
        XSDataInteger(int(dictID11["X-PIXEL SIZE"])))
    xsDataInputSPDCake.setBufferSizeY(
        XSDataInteger(int(dictID11["Y-PIXEL SIZE"])))
    xsDataInputSPDCake.setSampleToDetectorDistance(
        XSDataLength(float(dictID11["DISTANCE"])))
    xsDataInputSPDCake.setWavelength(
        XSDataLength(float(dictID11["WAVELENGTH"])))

    xsDataInputSPDCake.setBeamCentreInPixelsX(
        XSDataDouble(float(dictID11["X-BEAM CENTRE"])))
    xsDataInputSPDCake.setBeamCentreInPixelsY(
        XSDataDouble(float(dictID11["Y-BEAM CENTRE"])))
    xsDataInputSPDCake.setTiltRotation(
        XSDataAngle(float(dictID11["TILT ROTATION"])))
    xsDataInputSPDCake.setOutputFileType(
        XSDataFile(XSDataString(dictID11["saving_format"])))
    xsDataInputSPDCake.setOutputFileType(
        XSDataFile(XSDataString(dictID11["output_dir"])))

    # TODO : some parameters remain not inserted in this file because not in the datamodel

    print xsDataInputSPDCake.marshal()
Ejemplo n.º 55
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'inputFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.inputFile.append(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'energyCalibration':
         obj_ = XSDataEnergyCalibration()
         obj_.build(child_)
         self.setEnergyCalibration(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 56
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'logFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setLogFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'solution':
         obj_ = XSDataXOalignSolution()
         obj_.build(child_)
         self.solution.append(obj_)
     XSDataResult.buildChildren(self, child_, nodeName_)
Ejemplo n.º 57
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'inputFile':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setInputFile(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'nSkipHeader':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setNSkipHeader(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
Ejemplo n.º 58
0
def functionXMLin(_strFilename):
    """Here we create the XML string to be passed to the EDNA plugin from the input strFilename
    This can / should be modified by the final user
    
    @param _strFilename: full path of the input file
    @type _strFilename: python string representing the path
    @return: string  
    """
    EDVerbose.screen("Starting processing of image %s" % (_strFilename))
    # First check if the filename end with .img or .mccd:
    strXML = None
    if (_strFilename.endswith(".img") or _strFilename.endswith(".mccd") or _strFilename.endswith(".cbf")):
        xsDataInputInterface = XSDataInputInterface()
        xsDataDiffractionPlan = XSDataDiffractionPlan()
        xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(EDParallelExecuteMXv1Characterisation.m_fMaxExposureTime))
        xsDataInputInterface.setDiffractionPlan(xsDataDiffractionPlan)
        xsDataFile = XSDataFile()
        xsDataFile.setPath(XSDataString(_strFilename))
        xsDataInputInterface.addImagePath(xsDataFile)
        strXML = xsDataInputInterface.marshal()
    else:
        EDVerbose.screen("File name not ending with .img or .mccd - ignored : %s" % _strFilename)
    return strXML
Ejemplo n.º 59
0
 def finallyProcess(self, _edPlugin=None):
     EDPluginExec.finallyProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_0.finallyProcess...")
     # Render the page
     strHTML = str(self.page)
     EDUtilsFile.writeFile(self.strPath, strHTML)
     xsDataResultSimpleHTMLPage = XSDataResultSimpleHTMLPage()
     xsDataResultSimpleHTMLPage.setPathToHTMLFile(
         XSDataFile(XSDataString(self.strPath)))
     xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(
         XSDataFile(XSDataString(os.path.dirname(self.strPath))))
     self.setDataOutput(xsDataResultSimpleHTMLPage)
     # Store in Pyarch
     strPyarchPath = None
     if self.xsDataResultCharacterisation is not None:
         strPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchHtmlDirectoryPath(
             self.xsDataResultCharacterisation.getDataCollection())
     if strPyarchPath is None:
         # For debugging purposes
         strPyarchPath = EDUtilsPath.getEdnaUserTempFolder()
     EDHandlerESRFPyarchv1_0.copyHTMLDir(
         _strPathToHTMLDir=os.path.dirname(self.strPath),
         _strPathToPyarchDirectory=strPyarchPath)
Ejemplo n.º 60
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'imageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5ImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setHdf5ImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'hdf5File':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setHdf5File(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputDirectory':
         obj_ = XSDataFile()
         obj_.build(child_)
         self.setForcedOutputDirectory(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'forcedOutputImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setForcedOutputImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'startImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setStartImageNumber(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'endImageNumber':
         obj_ = XSDataInteger()
         obj_.build(child_)
         self.setEndImageNumber(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)