def prepare_edna_input(self, edna_input):

        # used for strategy calculation (characterization) using data analysis cluster
        # ALBA specific

        firstImage = None

        for dataSet in edna_input.getDataSet():
            for imageFile in dataSet.imageFile:
                if imageFile.getPath() is None:
                    continue
                firstImage = imageFile.path.value
                break

        listImageName = os.path.basename(firstImage).split("_")
        prefix = "_".join(listImageName[:-2])
        run_number = listImageName[-2]
        i = 1

        if hasattr(edna_input, "process_directory"):
            edna_directory = os.path.join(edna_input.process_directory, "characterisation_%s_run%s_%d" % (prefix, run_number, i))
            while os.path.exists(edna_directory):
                i += 1
                edna_directory = os.path.join(edna_input.process_directory, "characterisation_%s_run%s_%d" % (prefix, run_number, i))
            os.makedirs(edna_directory)
        else:
            raise RuntimeError("No process directory specified in edna_input")

        edna_input.process_directory = edna_directory

        output_dir = XSDataFile()
        path = XSDataString()
        path.setValue(edna_directory)
        output_dir.setPath(path)
        edna_input.setOutputFileDirectory( output_dir )
Ejemplo n.º 2
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()
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.º 4
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.º 5
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
               os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
Ejemplo n.º 6
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)
Ejemplo n.º 7
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.º 8
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        xsd.setLevelsColorize(XSDataBoolean(True))
        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsGamma(XSDataFloat(gamma))
        xml = xsd.marshal()
    return xml
Ejemplo n.º 9
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)
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.postProcess")
     if self.__strWorkingDir != None:
         xsDataFileHTMLFile = XSDataFile()
         xsDataFileHTMLDir = XSDataFile()
         
         if self.strBasename is None:
             strHTMLFilePath = os.path.join(self.__strWorkingDir, "edna.html")
             strHTMLDirPath = os.path.join(self.__strWorkingDir, "edna_html")
         else:
             strHTMLFilePath = os.path.join(self.strBasename, "edna.html")
             strHTMLDirPath = os.path.join(self.strBasename, "edna_html")
         
         if os.path.exists(strHTMLFilePath):
             strFileContent = EDUtilsFile.readFile(strHTMLFilePath)
             strFileContent = strFileContent.replace("table,td,th { border-style: none;", "div.edna table,td,th { border-style: none;")
             strFileContent = strFileContent.replace("td,th { border-style: solid;", "div.edna td,th { border-style: solid;")
             strFileContent = strFileContent.replace("th { background-color: gray;", "div.edna th { background-color: gray;")
             strFileContent = strFileContent.replace("<body onload=\"initTable('strategyData',false,false);\">", "<body onload=\"initTable('strategyData',false,false);\"><div class = 'edna'> ")
             strFileContent = strFileContent.replace("</body>", "</div></body>")
             EDUtilsFile.writeFile(strHTMLFilePath, strFileContent)
             xsDataFileHTMLFile.setPath(XSDataString(strHTMLFilePath))
             xsDataFileHTMLDir.setPath(XSDataString(strHTMLDirPath))
             self.setDataOutput(xsDataFileHTMLFile, "htmlFile")
             self.setDataOutput(xsDataFileHTMLDir, "htmlDir")
         else:
             EDVerbose.ERROR("EDPluginExecOutputHTMLv1_0.postProcess: file doesn't exist: " + strHTMLFilePath)
Ejemplo n.º 11
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 create_autoproc_input(self, event, params):
        """
        Descript. :
        """
        WAIT_XDS_TIMEOUT = 20
        WAIT_XDS_RESOLUTION = 1

        file_name_timestamp = time.strftime("%Y%m%d_%H%M%S")
        
        autoproc_path = params.get("xds_dir")
        autoproc_xds_filename = os.path.join(autoproc_path, "XDS.INP")
        autoproc_input_filename = os.path.join(autoproc_path, 
                                                "edna-autoproc-input-%s" % \
                                                file_name_timestamp)
        autoproc_output_file_name = os.path.join(autoproc_path, 
                                                 "edna-autoproc-results-%s" % \
                                                 file_name_timestamp)

        autoproc_input = XSDataAutoprocInput() 
        autoproc_xds_file = XSDataFile()
        autoproc_xds_file.setPath(XSDataString(autoproc_xds_filename))
        autoproc_input.setInput_file(autoproc_xds_file)

        autoproc_output_file = XSDataFile()
        autoproc_output_file.setPath(XSDataString(autoproc_output_file_name))
        autoproc_input.setOutput_file(autoproc_output_file)

        autoproc_input.setData_collection_id(XSDataInteger(params.get("collection_id")))
        residues_num = float(params.get("residues", 0))
        if residues_num != 0:
            autoproc_input.setNres(XSDataDouble(residues_num)) 
        space_group = params.get("sample_reference").get("spacegroup", "")
        if len(space_group) > 0:
            autoproc_input.setSpacegroup(XSDataString(space_group)) 
        unit_cell = params.get("sample_reference").get("cell", "")
        if len(unit_cell) > 0:
            autoproc_input.setUnit_cell(XSDataString(unit_cell))

        autoproc_input.setCc_half_cutoff(XSDataDouble(18.0))
       
        #Maybe we have to check if directory is there. Maybe create dir with mxcube
        xds_appeared = False
        wait_xds_start = time.time()
        logging.debug('EMBLAutoprocessing: Waiting for XDS.INP file: %s' % autoproc_xds_filename)
        while not xds_appeared and time.time() - wait_xds_start < WAIT_XDS_TIMEOUT:
            if os.path.exists(autoproc_xds_filename) and os.stat(autoproc_xds_filename).st_size > 0:
                xds_appeared = True
                logging.debug('EMBLAutoprocessing: XDS.INP file is there, size={0}'.\
                        format(os.stat(autoproc_xds_filename).st_size))
            else:
                os.system("ls %s> /dev/null"%(os.path.dirname(autoproc_path)))
                gevent.sleep(WAIT_XDS_RESOLUTION)
        if not xds_appeared:
            logging.error('EMBLAutoprocessing: XDS.INP file ({0}) failed to appear after {1} seconds'.\
                    format(autoproc_xds_filename, WAIT_XDS_TIMEOUT))
            return None, False
 
        autoproc_input.exportToFile(autoproc_input_filename)

        return autoproc_input_filename, True
Ejemplo n.º 13
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")):
        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
 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()
Ejemplo n.º 15
0
 def createInputCharacterisationFromImageHeaders(self, _edPlugin):
     self.DEBUG("EDPluginControlInterfacev1_2.createInputCharacterisationFromImageHeaders")
     xsDataInputSubWedgeAssemble = XSDataInputSubWedgeAssemble()
     for xsDataStringImagePath in self.listImagePaths:
         xsDataFile = XSDataFile()
         xsDataFile.setPath(xsDataStringImagePath)
         xsDataInputSubWedgeAssemble.addFile(xsDataFile)
     _edPlugin.setDataInput(xsDataInputSubWedgeAssemble)
     _edPlugin.executeSynchronous()
Ejemplo n.º 16
0
 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.º 17
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.º 18
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)
 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.º 20
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.º 21
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.º 22
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.º 23
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.º 24
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.º 25
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.º 26
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.º 27
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.º 28
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()
Ejemplo n.º 30
0
    def createInput(self):
        ccp4DataInputControlPipelineCalcDiffMap = CCP4DataInputControlPipelineCalcDiffMap(
        )

        xsDataStringPDBIn = XSDataString(self.strPDBIn)
        xsDataStringPDBOut = XSDataString(self.strPDBOut)
        xsDataStringMTZIn = XSDataString(self.strMTZIn)
        xsDataStringMTZOut = XSDataString(self.strMTZOut)

        xsDataFilePDBIn = XSDataFile()
        xsDataFilePDBIn.setPath(xsDataStringPDBIn)
        xsDataFilePDBOut = XSDataFile()
        xsDataFilePDBOut.setPath(xsDataStringPDBOut)
        xsDataFileMTZIn = XSDataFile()
        xsDataFileMTZIn.setPath(xsDataStringMTZIn)
        xsDataFileMTZOut = XSDataFile()
        xsDataFileMTZOut.setPath(xsDataStringMTZOut)

        ccp4DataInputControlPipelineCalcDiffMap.setXYZIN(xsDataFilePDBIn)
        ccp4DataInputControlPipelineCalcDiffMap.setXYZOUT(xsDataFilePDBOut)
        ccp4DataInputControlPipelineCalcDiffMap.setHKLIN(xsDataFileMTZIn)
        ccp4DataInputControlPipelineCalcDiffMap.setHKLOUT(xsDataFileMTZOut)

        ccp4MTZColLabels = CCP4MTZColLabels()
        ccp4MTZColLabels.setIMEAN(XSDataString(self.colLabelI))
        ccp4MTZColLabels.setSIGIMEAN(XSDataString(self.colLabelSIGI))

        ccp4DataInputControlPipelineCalcDiffMap.setColLabels(ccp4MTZColLabels)

        return ccp4DataInputControlPipelineCalcDiffMap
Ejemplo n.º 31
0
    def createInput(self):
        ccp4DataInputControlPipelineCalcDiffMap = CCP4DataInputControlPipelineCalcDiffMap()
        
        xsDataStringPDBIn = XSDataString(self.strPDBIn)
        xsDataStringPDBOut = XSDataString(self.strPDBOut)
        xsDataStringMTZIn = XSDataString(self.strMTZIn)
        xsDataStringMTZOut = XSDataString(self.strMTZOut)

        xsDataFilePDBIn = XSDataFile()
        xsDataFilePDBIn.setPath(xsDataStringPDBIn)
        xsDataFilePDBOut = XSDataFile()
        xsDataFilePDBOut.setPath(xsDataStringPDBOut)
        xsDataFileMTZIn = XSDataFile()
        xsDataFileMTZIn.setPath(xsDataStringMTZIn)
        xsDataFileMTZOut = XSDataFile()
        xsDataFileMTZOut.setPath(xsDataStringMTZOut)
        
        ccp4DataInputControlPipelineCalcDiffMap.setXYZIN(xsDataFilePDBIn)
        ccp4DataInputControlPipelineCalcDiffMap.setXYZOUT(xsDataFilePDBOut)
        ccp4DataInputControlPipelineCalcDiffMap.setHKLIN(xsDataFileMTZIn)
        ccp4DataInputControlPipelineCalcDiffMap.setHKLOUT(xsDataFileMTZOut)
        
        ccp4MTZColLabels = CCP4MTZColLabels()
        ccp4MTZColLabels.setIMEAN(XSDataString(self.colLabelI))
        ccp4MTZColLabels.setSIGIMEAN(XSDataString(self.colLabelSIGI))
        
        ccp4DataInputControlPipelineCalcDiffMap.setColLabels(ccp4MTZColLabels)

        return ccp4DataInputControlPipelineCalcDiffMap
Ejemplo n.º 32
0
    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):
        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)
Ejemplo n.º 34
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.º 35
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)
Ejemplo n.º 36
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.º 37
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.º 38
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 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.º 40
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.º 41
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.º 42
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.º 43
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.º 44
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.º 45
0
 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)
     # Replace path to log file since it cannot be determined by the unit test
     xsDataMOSFLMIntegrationOutput.setPathToLogFile(
         XSDataFile(XSDataString("MOSFLMIntegrationv10.log")))
     EDAssert.equal(xsDataMOSFLMIntegrationOutputReference.marshal(),
                    xsDataMOSFLMIntegrationOutput.marshal())
Ejemplo n.º 46
0
    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)
            self.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.º 47
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)
Ejemplo n.º 48
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)
 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.º 50
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        #        xsd.setLevelsColorize(XSDataBoolean(True))
        #        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsEqualize(XSDataBoolean(True))

        #        xsd.setLevelsGamma(XSDataDouble(gamma))
        xsd.setLevelsMin(XSDataDouble(0.0))
        xsdMax = XSDataDoubleWithUnit()
        xsdMax.setValue(99.9)
        xsdMax.setUnit(XSDataString("""%"""))
        xsd.setLevelsMax(xsdMax)
        #        xsd.setLevelsAutoContrast(XSDataDouble(1.0))
        xsd.setFilterBlur([XSDataInteger(5)])
        xsd.setFilterDilatation([XSDataInteger(10)])
        # xsd.setCropBorders(XSDataInteger(), XSDataInteger())
        xsd.setLevelsInvert(XSDataBoolean(True))
        xsd.setThumbHeight(XSDataInteger(256))
        xsd.setThumbWidth(XSDataInteger(256))
        xml = xsd.marshal()
    return xml
Ejemplo n.º 51
0
def fileName2xml(filename):
    """Here we create the XML string to be passed to the EDNA plugin from the input filename
    This can / should be modified by the final user
    
    @param filename: full path of the input file
    @type filename: python string representing the path
    @rtype: XML string
    @return: python string  
    """
    if filename.endswith(".jpg"):
        xm = None
    else:
        upperDir = os.path.dirname(os.path.dirname(filename))
        if not os.path.isdir(os.path.join(upperDir, "Thumbnail")):
            os.makedirs(os.path.join(upperDir, "Thumbnail"), int("775", 8))
        destinationPath = os.path.join(upperDir, "Thumbnail")
        xsd = XSDataInputExecThumbnail()
        xsdFile = XSDataFile()
        xsdFile.setPath(XSDataString(filename))
        xsd.setInputImagePath(xsdFile)
        xsdPath = XSDataFile()
        xsdPath.setPath(XSDataString(destinationPath))
        xsd.setOutputPath(xsdPath)
        #        xsd.setLevelsColorize(XSDataBoolean(True))
        #        xsd.setLevelsNormalize(XSDataBoolean(True))
        xsd.setLevelsEqualize(XSDataBoolean(True))

        #        xsd.setLevelsGamma(XSDataDouble(gamma))
        xsd.setLevelsMin(XSDataDouble(0.0))
        xsdMax = XSDataDoubleWithUnit()
        xsdMax.setValue(99.9)
        xsdMax.setUnit(XSDataString("""%"""))
        xsd.setLevelsMax(xsdMax)
        #        xsd.setLevelsAutoContrast(XSDataDouble(1.0))
        xsd.setFilterBlur([XSDataInteger(5)])
        xsd.setFilterDilatation([XSDataInteger(10)])
        #xsd.setCropBorders(XSDataInteger(), XSDataInteger())
        xsd.setLevelsInvert(XSDataBoolean(True))
        xsd.setThumbHeight(XSDataInteger(256))
        xsd.setThumbWidth(XSDataInteger(256))
        xml = xsd.marshal()
    return xml
Ejemplo n.º 52
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.º 53
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.º 54
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        EDVerbose.DEBUG("*** EDPluginFIT2DCakev1_1.postProcess")
        #Remove the temporary data file
        os.remove(os.path.join(self.getWorkingDirectory(), "CleanedImage.edf"))
        os.remove(os.path.join(self.getWorkingDirectory(), "spline"))
        # Create the output data
        xsDataResultFIT2DCake = XSDataResultFIT2DCake()
        if (self.m_strOutputFilePath is not None):
            if os.path.splitext(self.m_strOutputFilePath)[1].lower() == ".cif" :
############read CHI plot file and convert it in cif cile if needed
                cif = CIFfile.CIF()
                cif.loadCHIPLOT(os.path.splitext(self.m_strOutputFilePath)[0] + ".chi")
                cif["_diffrn_radiation_wavelength"] = str(self.getDataInput().getWavelength().getValue())
                cif["_pd_instr_dist_spec/detc"] = str(self.getDataInput().getSampleToDetectorDistance().getValue())
                cif.saveCIF(self.m_strOutputFilePath)
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(self.m_strOutputFilePath))
            xsDataResultFIT2DCake.setResultFile(xsDataFile)
        self.setDataOutput(xsDataResultFIT2DCake)
Ejemplo n.º 55
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.º 56
0
    def postProcess(self, _edObject=None):
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.postProcess")
        if self.strWorkingDir != None:
            xsDataFileHTMLFile = XSDataFile()
            xsDataFileHTMLDir = XSDataFile()

            if self.strBasename is None:
                strHTMLFilePath = os.path.join(self.strWorkingDir, "edna.html")
                strHTMLDirPath = os.path.join(self.strWorkingDir, "edna_html")
            else:
                strHTMLFilePath = os.path.join(self.strBasename, "edna.html")
                strHTMLDirPath = os.path.join(self.strBasename, "edna_html")

            if os.path.exists(strHTMLFilePath):
                strFileContent = EDUtilsFile.readFile(strHTMLFilePath)
                strFileContent = strFileContent.replace(
                    "table,td,th { border-style: none;",
                    "div.edna table,td,th { border-style: none;")
                strFileContent = strFileContent.replace(
                    "td,th { border-style: solid;",
                    "div.edna td,th { border-style: solid;")
                strFileContent = strFileContent.replace(
                    "th { background-color: gray;",
                    "div.edna th { background-color: gray;")
                strFileContent = strFileContent.replace(
                    "<body onload=\"initTable('strategyData',false,false);\">",
                    "<body onload=\"initTable('strategyData',false,false);\"><div class = 'edna'> "
                )
                strFileContent = strFileContent.replace(
                    "</body>", "</div></body>")
                EDUtilsFile.writeFile(strHTMLFilePath, strFileContent)
                xsDataFileHTMLFile.setPath(XSDataString(strHTMLFilePath))
                xsDataFileHTMLDir.setPath(XSDataString(strHTMLDirPath))
                self.setDataOutput(xsDataFileHTMLFile, "htmlFile")
                self.setDataOutput(xsDataFileHTMLDir, "htmlDir")
            else:
                EDVerbose.ERROR(
                    "EDPluginExecOutputHTMLv1_0.postProcess: file doesn't exist: "
                    + strHTMLFilePath)
Ejemplo n.º 57
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.º 58
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()