def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     self.DEBUG("EDPluginExecMeasureOffsetv1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultMeasureOffset()
     xsDataResult.setOffset(self.tOffset)
     self.setDataOutput(xsDataResult)
 def configure(self):
     """
     Gets the web servise wdsl parameters from the config file and stores them in class member attributes.
     """
     EDPluginExec.configure(self)
     self.strUserName = str(self.config.get("userName"))
     if self.strUserName is None:
         self.ERROR("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.configure: No user name found in configuration!")
         self.setFailure()
     self.strPassWord = str(self.config.get("passWord"))
     if self.strPassWord is None:
         self.ERROR("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.configure: No pass word found in configuration!")
         self.setFailure()
     self.strToolsForAutoprocessingWebServiceWsdl = self.config.get("toolsForAutoprocessingWebServiceWsdl")
     if self.strToolsForAutoprocessingWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.configure: No toolsForAutoprocessingWebServiceWsdl found in configuration!")
         self.setFailure()
     self.strToolsForCollectionWebServiceWsdl = self.config.get("toolsForCollectionWebServiceWsdl")
     if self.strToolsForCollectionWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.configure: No toolsForCollectionWebServiceWsdl found in configuration!")
         self.setFailure()
     strAutoProcProgramId = self.config.get("autoProcProgramId")
     if strAutoProcProgramId is None:
         self.ERROR("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.configure: No autoProcProgramId found in configuration!")
         self.setFailure()
     else:
         self.iAutoProcProgramId = int(strAutoProcProgramId)
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.finallyProcess")
     xsDataResultStoreListOfImageQualityIndicators = XSDataResultStoreListOfImageQualityIndicators()
     for iImageQualityIndicatorsId in self.listImageQualityIndicatorsId:
         xsDataResultStoreListOfImageQualityIndicators.addImageQualityIndicatorsId(XSDataInteger(iImageQualityIndicatorsId))
     self.setDataOutput(xsDataResultStoreListOfImageQualityIndicators)
    def postProcess(self, _edObject=None):
        """
        Calls the parent preProcess method
        Checks that the installed 3rd party software is in the list of
        compatible versions
        """
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecProcessXIA2CORE.postProcess")

        # Tests the compatibles executable versions
        listCompatibleVersions = self.getListOfCompatibleVersions()

        if(len(listCompatibleVersions) != 0):

            bFound = False
            for compatibleVersion in listCompatibleVersions:
                bFound = self.findStringInLog(compatibleVersion)
                if(bFound == True):
                    break

            if(bFound == False):
                strErrorMessage = "Plugin not compatible with %s, compatible versions are: %s" % \
                                  (self.getStringVersion(),
                                   self.getCompatibleVersionsStringLine())
                EDVerbose.warning(strErrorMessage)
                self.addWarningMessage(strErrorMessage)
 def postProcess(self, _edObject=None):
     """
     """
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("*** EDPluginISPyBv1_1.postProcess")
     if self.m_xsDataResultISPyB is not None:
         self.setDataOutput(self.m_xsDataResultISPyB)
Example #6
0
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     EDVerbose.DEBUG("EDPluginExecPyHSTv10.process")
     xsDataInputPyHST = self.getDataInput()
     pyhst = PyHST_c.PyHST(xsDataInputPyHST.getOutputFileName(),
               Parameters.OVERSAMPLING_FACTOR,
               Parameters.START_VOXEL_1 - 1 + 1,
               Parameters.START_VOXEL_2 - 1 + 1,
               Parameters.END_VOXEL_1 - Parameters.START_VOXEL_1 + 1,
               Parameters.END_VOXEL_2 - Parameters.START_VOXEL_2 + 1,
               Parameters.ROTATION_AXIS_POSITION,
               Parameters.ANGLE_OFFSET * DEG2RAD,
               Parameters.ANGLE_BETWEEN_PROJECTIONS * DEG2RAD,
               Parameters.NO_SINOGRAM_FILTERING,
               dim_1,
               num_projections,
               BIG_SINOS ,
                   axis_corrections ,
                   Parameters.BICUBIC,
                   Parameters.SUMRULE ,
                   (angles),
                           Parameters.PENTEZONE,
                   Parameters.ZEROOFFMASK,
                          Parameters.CUMSUM_INTEGRAL
                   )
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     self.DEBUG("EDPluginExecPlotGlev1_1.process")
     for dictPlot in self.listPlot:
         if os.path.dirname(dictPlot["script"]) != self.getWorkingDirectory():
             shutil.copy(dictPlot["script"], self.getWorkingDirectory())
         listDataFiles = dictPlot["data"]
         for strDataFileFullPath in listDataFiles:
             strDataFile = os.path.basename(strDataFileFullPath)
             if not os.path.exists(os.path.join(self.getWorkingDirectory(), strDataFile)):
                 shutil.copy(strDataFileFullPath, self.getWorkingDirectory())
         if EDUtilsPath.isESRF():
             # Force PXSOFT version of gle
             strCommand = "/opt/pxsoft/bin/gle -verbosity 0 -r 150 -d jpg %s" % os.path.basename(dictPlot["script"])
         else:
             strCommand = "gle -verbosity 0 -r 150 -d jpg %s" % os.path.basename(dictPlot["script"])
         # Copied from EDPluginExecProcess
         self.DEBUG(self.getBaseName() + ": Processing")
         timer = threading.Timer(float(self.getTimeOut()), self.kill)
         timer.start()
         try:
             self.__subprocess = EDUtilsPlatform.Popen(shlex.split(str(EDUtilsPlatform.escape(strCommand))),
                                                cwd=self.getWorkingDirectory())
             self.__iPID = self.__subprocess.pid
             self.__strExecutionStatus = str(self.__subprocess.wait())
         except OSError as e:
             strErrorMessage = self.getPluginName() + " : required program gle not installed"
             self.error(strErrorMessage)
             self.setFailure()
         finally:
             timer.cancel()
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBGroupDataCollectionsv1_4.finallyProcess")
     xsDataResultISPyBGroupDataCollections = XSDataResultISPyBGroupDataCollections()
     for dataCollectionId in self.listDataCollectionIds:
         xsDataResultISPyBGroupDataCollections.addDataCollectionId(XSDataInteger(dataCollectionId))
     self.setDataOutput(xsDataResultISPyBGroupDataCollections)
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBStoreImageQualityIndicatorsv1_4.finallyProcess")
     xsDataResultStoreImageQualityIndicators = XSDataResultStoreImageQualityIndicators()
     if self.iImageQualityIndicatorsId is not None:
         xsDataResultStoreImageQualityIndicators.setImageQualityIndicatorsId(XSDataInteger(self.iImageQualityIndicatorsId))
     self.setDataOutput(xsDataResultStoreImageQualityIndicators)
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBStoreScreeningv1_4.finallyProcess")
     xsDataResultISPyBStoreScreening = XSDataResultISPyBStoreScreening()
     if self.iScreeningId is not None:
         xsDataResultISPyBStoreScreening.screeningId = XSDataInteger(self.iScreeningId)
     self.setDataOutput(xsDataResultISPyBStoreScreening)
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     self.DEBUG("EDPluginSubWedgeMergev1_1.postProcess")
     xsDataResultSubWedgeMerge = XSDataResultSubWedgeMerge()
     for xsDataSubWedgeMerge in self.__listResultSubWedgeMerge:
         xsDataResultSubWedgeMerge.addSubWedge(xsDataSubWedgeMerge)
     self.setDataOutput(xsDataResultSubWedgeMerge)
 def configure(self):
     """
     Gets the web servise wdsl parameters from the config file and stores them in class member attributes.
     """
     EDPluginExec.configure(self)
     self.strUserName = self.config.get("userName")
     if self.strUserName is None:
         self.ERROR("EDPluginISPyBStoreScreeningv1_4.configure: No user name found in configuration!")
         self.setFailure()
     self.strPassWord = self.config.get("passWord")
     if self.strPassWord is None:
         self.ERROR("EDPluginISPyBStoreScreeningv1_4.configure: No pass word found in configuration!")
         self.setFailure()
     self.strToolsForBLSampleWebServiceWsdl = self.config.get("toolsForBLSampleWebServiceWsdl")
     if self.strToolsForBLSampleWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreScreeningv1_4.configure: No toolsForBLSampleWebServiceWsdl found in configuration!")
         self.setFailure()
     self.strToolsForScreeningEDNAWebServiceWsdl = self.config.get("toolsForScreeningEDNAWebServiceWsdl")
     if self.strToolsForScreeningEDNAWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreScreeningv1_4.configure: No toolsForScreeningEDNAWebServiceWsdl found in configuration!")
         self.setFailure()
     self.strToolsForCollectionWebServiceWsdl = self.config.get("toolsForCollectionWebServiceWsdl")
     if self.strToolsForCollectionWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreScreeningv1_4.configure: No toolsForCollectionWebServiceWsdl found in configuration!")
         self.setFailure()
    def preProcess(self, _edObject=None):
        EDPluginExec.preProcess(self)
        self.DEBUG("EDPluginExecShiftImagev1_0.preProcess")
        sdi = self.dataInput
        if sdi.inputImage is not None:
            self.npaImage = numpy.array(EDUtilsArray.getArray(sdi.inputImage))
        elif  sdi.inputArray is not None:
            self.npaImage = EDUtilsArray.xsDataToArray(sdi.getInputArray())
        else:
            self.ERROR("EDPluginExecShiftImagev1_0.preProcess: You should either provide an images or an arrays, but I got: %s" % sdi.marshal())
            self.setFailure()
            raise RuntimeError

        offset = sdi.offset
        if len(offset) == 2:
            self.tOffset = (offset[0].value, offset[1].value)
        elif len(offset) == 1:
            self.tOffset = (offset[0].value, offset[0].value)

        if sdi.outputImage is not None:
            if sdi.outputImage.path is not None:
                self.strOutputType = "file"
                self.strOutputImage = sdi.outputImage.path.value
            if sdi.outputImage.shared is not None:
                self.strOutputType = "shared"
                self.strOutputImage = sdi.outputImage.shared.value
            if sdi.outputImage.array is not None:
                self.strOutputType = "array"
Example #14
0
    def configure(self):
        """
        Configures the plugin with executable from configuration file
        """
        EDPluginExec.configure(self)
        EDVerbose.DEBUG("EDPluginExecProcess.configure")
        strExecutable = self.config.get(self.CONF_EXEC_PROCESS_EXECUTABLE, None)
        if strExecutable is None:
            EDVerbose.DEBUG("EDPluginExecProcess.configure: No configuration parameter found for: %s , using default value: %s"\
                            % (self.CONF_EXEC_PROCESS_EXECUTABLE, self.getExecutable()))
        else:
            self.setExecutable(strExecutable)

        # test if we're to use oar and check for additional config
        if strExecutable == "oarsub":
            oar_options = self.config.get("oarOptions", None)
            if oar_options is None:
                EDVerbose.DEBUG('EDPluginExecProcess.configure: no additional options were specified for oarsub')
            self._oar_options = oar_options
            oar_poll = self.config.get("oarPollInterval", None)
            if oar_poll is None:
                EDVerbose.DEBUG('EDPluginExecProcess.configure: oar polling interval not configured')
                EDVerbose.DEBUG('EDPluginExecProcess.configure: using default version of {0}'.format(DEFAULT_OAR_POLL_INTERVAL))
                self._oar_poll_interval = DEFAULT_OAR_POLL_INTERVAL
            else:
                self._oar_poll_interval = oar_poll

        # The execProcessTimeOut is deprecated, see bug #563
        timeOut = self.config.get(self.CONF_EXEC_PROCESS_TIME_OUT, None)
        if timeOut is not None:
            EDVerbose.WARNING("Use of %s in plugin configuration is deprecated" % self.CONF_EXEC_PROCESS_TIME_OUT)
            EDVerbose.WARNING("Please use %s instead." % EDPlugin.CONF_TIME_OUT)
            self.setTimeOut(timeOut)
Example #15
0
    def process(self):
        EDPluginExec.process(self)
        l = len(self.lstInFiles)
        if l > 0:
            q0, I0, s0 = numpy.loadtxt(self.lstInFiles[0], unpack=True)
        if l > 1:
            q1, I1, s1 = numpy.loadtxt(self.lstInFiles[-1], unpack=True)
        if self.strOperation in ("ADD", "SUB") and (l == 2):
            q = q1
            assert abs(q1 - q0).max() < self.epsilon
            if self.strOperation == "SUB":
                I = I0 - I1
            else:
                I = I0 + I1
            s = numpy.sqrt(s0 * s0 + s1 * s1)
        if self.strOperation in ("MUL", "DIV") and (l >= 1) and self.dataInput.constant:
            q = q0
            if self.strOperation == "MUL":
                I = I0 * self.const
                s = s0 * self.const
            else:
                I = I0 / self.const
                s = s0 / self.const
            
        m = numpy.vstack((q, I, s))
#        numpy.savetxt(self.outputFile, m.T)
        with open(self.outputFile, "w") as outfile:
            numpy.savetxt(outfile, m.T)
 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)
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBGetPdbFilePathv1_4.finallyProcess")
     xsDataResultISPyBGetPdbFilePath = XSDataResultISPyBGetPdbFilePath()
     if self.strPathToPdbFile is not None:
         xsDataResultISPyBGetPdbFilePath.pdbFilePath = XSDataString(self.strPathToPdbFile)
     self.setDataOutput(xsDataResultISPyBGetPdbFilePath)
 def configure(self):
     """
     Gets the web servise wdsl parameters from the config file and stores them in class member attributes.
     """
     EDPluginExec.configure(self)
     self.strUserName = self.getStringConfigurationParameterValue("userName")
     if self.strUserName is None:
         self.ERROR("EDPluginISPyBStoreImageQualityIndicatorsv1_3.configure: No user name found in configuration!")
         self.setFailure()
     self.strPassWord = self.getStringConfigurationParameterValue("passWord")
     if self.strPassWord is None:
         self.ERROR("EDPluginISPyBStoreImageQualityIndicatorsv1_3.configure: No pass word found in configuration!")
         self.setFailure()
     self.strImageServiceWdsl = self.getStringConfigurationParameterValue("imageServiceWdsl")
     if self.strImageServiceWdsl is None:
         self.ERROR("EDPluginISPyBStoreImageQualityIndicatorsv1_3.configure: No imageServiceWdsl found in configuration!")
         self.setFailure()
     self.strToolsForMXCubeWebServiceWsdl = self.getStringConfigurationParameterValue("toolsForMXCubeWebServiceWsdl")
     if self.strToolsForMXCubeWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBStoreImageQualityIndicatorsv1_3.configure: No toolsForMXCubeWebServiceWsdl found in configuration!")
         self.setFailure()
     self.iAutoProcProgramId = self.getIntegerConfigurationParameterValue("autoProcProgramId")
     if self.iAutoProcProgramId is None:
         self.ERROR("EDPluginISPyBStoreImageQualityIndicatorsv1_3.configure: No autoProcProgramId found in configuration!")
         self.setFailure()
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecNormalizeImagev1_1.process")

        #numerator part: 
        fTotalDataTime = 0.0
        self.shape = self.listDataArray[0].shape
        npaSummedData = numpy.zeros(self.shape, dtype=self.dtype)

        for i in range(len(self.listDataArray)):
            fTotalDataTime += self.listDataExposure[i]
            npaSummedData += numpy.maximum(self.listDataArray[i] - self.getMeanDark(self.listDataExposure[i]), 0)
        npaNormalizedData = (npaSummedData / fTotalDataTime).astype(self.dtype)

        #denominator part
        fTotalFlatTime = 0.0
        npaSummedFlat = numpy.zeros(self.shape, dtype=self.dtype)

        for i in range(len(self.listFlatArray)):
            fTotalFlatTime += self.listFlatExposure[i]
            npaSummedFlat += numpy.maximum(self.listFlatArray[i] - self.getMeanDark(self.listFlatExposure[i]), 0)

        npaNormalizedFlat = (npaSummedFlat / fTotalFlatTime).astype(self.dtype)

        self.npaNormalized = npaNormalizedData / numpy.maximum(npaNormalizedFlat, numpy.ones_like(npaNormalizedFlat))
        if self.npaNormalized.dtype != numpy.dtype(self.dtype):
            self.npaNormalized = self.npaNormalized.astype(self.dtype)
    def process(self, _edObject=None):
        """
        First uses the ImageService to find the imageId.
        Then uses ToolsForCollectionWebService for storing the image quality indicators.
        """
        EDPluginExec.process(self)
        self.DEBUG("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.process")
        httpAuthenticatedToolsForAutoprocessingWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord)
        clientToolsForAutoprocessingWebService = Client(self.strToolsForAutoprocessingWebServiceWsdl, transport=httpAuthenticatedToolsForAutoprocessingWebService)
        # Loop over all input image quality indicators:
        listImageQualityIndicatorsForWS = []
        for xsDataImageQualityIndicators in self.dataInput.imageQualityIndicators:
            #print xsDataImageQualityIndicators.marshal()
            imageQualityIndicatorsWS3VO = clientToolsForAutoprocessingWebService.factory.create('imageQualityIndicatorsWS3VO')
            strPathToImage = xsDataImageQualityIndicators.getImage().getPath().getValue()
            imageQualityIndicatorsWS3VO.fileName                      = os.path.basename(strPathToImage)
            imageQualityIndicatorsWS3VO.fileLocation                  = os.path.dirname(strPathToImage)
#            imageQualityIndicatorsWS3VO.imageId                       = 0
            imageQualityIndicatorsWS3VO.autoProcProgramId             = self.iAutoProcProgramId
            imageQualityIndicatorsWS3VO.spotTotal                     = self.getXSValue(xsDataImageQualityIndicators.spotTotal)
            imageQualityIndicatorsWS3VO.inResTotal                    = self.getXSValue(xsDataImageQualityIndicators.inResTotal)
            imageQualityIndicatorsWS3VO.goodBraggCandidates           = self.getXSValue(xsDataImageQualityIndicators.goodBraggCandidates)
            imageQualityIndicatorsWS3VO.iceRings                      = self.getXSValue(xsDataImageQualityIndicators.iceRings)
            imageQualityIndicatorsWS3VO.method1Res                    = self.getXSValue(xsDataImageQualityIndicators.method1Res)
            imageQualityIndicatorsWS3VO.method2Res                    = self.getXSValue(xsDataImageQualityIndicators.method2Res)
            imageQualityIndicatorsWS3VO.maxUnitCell                   = self.getXSValue(xsDataImageQualityIndicators.maxUnitCell)
            imageQualityIndicatorsWS3VO.pctSaturationTop50Peaks       = self.getXSValue(xsDataImageQualityIndicators.pctSaturationTop50Peaks)
            imageQualityIndicatorsWS3VO.inResolutionOvrlSpots         = self.getXSValue(xsDataImageQualityIndicators.inResolutionOvrlSpots)
            imageQualityIndicatorsWS3VO.binPopCutOffMethod2Res        = self.getXSValue(xsDataImageQualityIndicators.binPopCutOffMethod2Res)
            imageQualityIndicatorsWS3VO.totalIntegratedSignal         = self.getXSValue(xsDataImageQualityIndicators.totalIntegratedSignal)
            imageQualityIndicatorsWS3VO.recordTimeStamp               = DateTime(datetime.datetime.now())
            listImageQualityIndicatorsForWS.append(imageQualityIndicatorsWS3VO)
        self.listImageQualityIndicatorsId = clientToolsForAutoprocessingWebService.service.storeOrUpdateImageQualityIndicatorsForFileNames(
            listImageQualityIndicatorsForWS = listImageQualityIndicatorsForWS)
        self.DEBUG("EDPluginISPyBStoreListOfImageQualityIndicatorsv1_4.process: listImageQualityIndicatorsId=%r" % self.listImageQualityIndicatorsId)
Example #21
0
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     EDVerbose.DEBUG("EDPluginExecProcess.process starting")
     if self.getExecutable() == "oarsub":
         self.process_on_oar(_edObject)
     else:
         self.process_locally(_edObject)
 def process(self, _edObject=None):
     """
     Uses ToolsForCollectionWebService 
     """
     EDPluginExec.process(self)
     self.DEBUG("EDPluginISPyBSetImagesPositionsv1_4.process")
     httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord
     )
     clientToolsForCollectionWebService = Client(
         self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService
     )
     # Loop over all positions
     listImagePosition = []
     for xsDataImagePosition in self.dataInput.imagePosition:
         imagePosition = clientToolsForCollectionWebService.factory.create("imagePosition")
         # Get the workflow ID and status
         imagePosition.fileName = os.path.basename(xsDataImagePosition.fileName.path.value)
         imagePosition.fileLocation = os.path.dirname(xsDataImagePosition.fileName.path.value)
         if xsDataImagePosition.jpegFileFullPath is not None:
             imagePosition.jpegFileFullPath = xsDataImagePosition.jpegFileFullPath.path.value
         if xsDataImagePosition.jpegThumbnailFileFullPath is not None:
             imagePosition.jpegThumbnailFileFullPath = xsDataImagePosition.jpegThumbnailFileFullPath.path.value
         listImagePosition.append(imagePosition)
     self.listImageCreation = clientToolsForCollectionWebService.service.setImagesPositions(
         listImagePosition=listImagePosition
     )
     self.DEBUG("EDPluginISPyBSetImagesPositionsv1_4.process: listImageCreation=%r" % self.listImageCreation)
 def process(self, _edPlugin=None):
     EDPluginExec.process(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_1.process...")
     if self.xsDataResultCharacterisation is not None:
         # WorkflowStepReport
         self.workflowStepReport = WorkflowStepReport("Characterisation")
         if self.xsDataResultCharacterisation is not None:
             self.workflowStepReport.setTitle("Characterisation Results")
         else:
             self.workflowStepReport.setTitle("No Characterisation Results!")
         # Link to the EDNA log file
         if self.dataInput.logFile is None:
             strPathToLogFile = self.getLogFileName()
         else:
             strPathToLogFile = self.dataInput.logFile.path.value
         if strPathToLogFile is not None:
             self.workflowStepReport.addLogFile("EDNA Log", "EDNA log file", strPathToLogFile)
         self.dataCollectionInfo()
         self.diffractionPlan()
         self.strategyResults()
         self.graphs()
         self.kappaResults()
         self.indexingResults()
         self.integrationResults()
         self.imageQualityIndicatorResults()
         self.createThumbnailRowOfImages()
    def __init__(self):
        """
        """
        EDPluginExec.__init__(self)

        self.setXSDataInputClass(XSDataInputBioSaxsMetadatav1_0)
        self.xsdInputData = None
        self.detector = None
        self.detectorDistance = None
        self.pixelSize_1 = None
        self.pixelSize_2 = None
        self.beamCenter_1 = None
        self.beamCenter_2 = None
        self.beamStopDiode = None
        self.wavelength = None
        self.maskFile = None
        self.normalizationFactor = None
        self.machineCurrent = None
        self.storageTemperature = None
        self.exposureTemperature = None
        self.exposureTime = None
        self.frameNumber = None
        self.frameMax = None
        self.timeOfFrame = None
        #
        self.code = None
        self.comments = None
        self.concentration = None
        self.strInputImage = None
        self.strOutputImage = None
        self.fabioedf = fabio.edfimage.edfimage()
    def process(self, _edObject=None):
        """
        Retrieves the contents of the DataCollectionContainer in ISPyB
        """
        EDPluginExec.process(self)
        self.DEBUG("EDPluginISPyBRetrieveDataCollectionv1_4.process")
        infile = self.getDataInput()
        inpath = infile.getImage().getPath().getValue()
        indir = os.path.dirname(inpath)
        infilename = os.path.basename(inpath)
        httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(username=self.strUserName, password=self.strPassWord)
        clientToolsForCollectionWebService = Client(self.strToolsForCollectionWebServiceWsdl, transport=httpAuthenticatedToolsForCollectionWebService)
        self.collectParameters = None

        # DataCollectionProgram
        collect_params = clientToolsForCollectionWebService.service.findDataCollectionFromFileLocationAndFileName(
                         indir,
                         infilename)
        if collect_params is None:
            self.ERROR("Couldn't find collect for file %s in ISPyB!" % inpath)
            self.setFailure()
        else:
            # the result is a suds.sudsobject.Object, we need to convert it
            res = XSDataISPyBDataCollection()
            try:
                for k, v in collect_params:
                    setattr(res, k, v)
            except:
                self.ERROR('something went wrong converting the result to a XSDataResultRetrieveDataCollection')
                self.setFailure()
            else:
                self.collectParameters = XSDataResultRetrieveDataCollection()
                self.collectParameters.dataCollection = res
    def configure(self):
        """
        Gets the dbserver parameters from the config file and stores them in class member attributes.
        """
        EDPluginExec.configure(self)
        pluginConfiguration = self.getConfiguration()

        if(pluginConfiguration == None):
            EDVerbose.DEBUG("*** EDPluginISPyBv1_2.configure: pluginConfiguration is None, using default settings")
        else:
            EDVerbose.DEBUG("*** EDPluginISPyBv1_2.configure: pluginConfiguration found, using settings from there")
            strDbserverHost = EDConfiguration.getStringParamValue(pluginConfiguration, "dbserverHost")
            if(strDbserverHost == None):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2.configure", self.getClassName(), \
                                                                     "Configuration parameter missing: dbserverHost")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage
            else:
                self.setDbserverHost(strDbserverHost)

            strDbserverPort = EDConfiguration.getStringParamValue(pluginConfiguration, "dbserverPort")
            if(strDbserverPort == None):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2.configure", self.getClassName(), \
                                                                     "Configuration parameter missing: dbserverPort")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage
            else:
                self.setDbserverPort(int (strDbserverPort))
 def configure(self):
     """
     Gets the configuration parameters (if any).
     """
     EDPluginExec.configure(self)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_1.configure")
     self.fMinTransmission = self.config.get("minTransmissionWarning", self.fMinTransmission)
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     self.DEBUG("EDPluginISPyBStoreAutoProcv1_4.postProcess")
     xsDataResultStoreAutoProc = XSDataResultStoreAutoProc()
     if self.iAutoProcId is not None:
         xsDataResultStoreAutoProc.setAutoProcId(XSDataInteger(self.iAutoProcId))
     self.setDataOutput(xsDataResultStoreAutoProc)
 def __init__(self):
     """
     Constructor of the plugin 
     """
     EDPluginExec.__init__(self)
     self.setXSDataInputClass(XSDataInputExecThumbnail)
     self.inputFilename = None
     self.thumbFormat = None
     self.colorize = None
     self.keepRatio = None
     self.gamma = None
     self.invert = None
     self.equalize = None
     self.autocontrast = None
     self.output = None
     self.format = None
     self.height = None
     self.width = None
     self.normalize = None
     self.npaImage = None
     self.cropBorders = None
     self.log = None
     self.minLevel = None
     self.maxLevel = None
     self.minLevelUnit = None
     self.maxLevelUnit = None
     self.gaussianBlur = None
     self.dilatation = None
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     # Read in input data (if any)
     if self.hasDataInput("indexingResult"):
         self.__xsDataIndexingResult = self.getDataInput("indexingResult")[0]
     if self.hasDataInput("imageQualityIndicators"):
         self.__listXSDataImageQualityIndicator = self.getDataInput("imageQualityIndicators")
Example #31
0
    def preProcess(self, _edObject=None):
        EDPluginExec.preProcess(self)
        self.DEBUG("EDPluginExecMeasureOffsetv2_0.preProcess")
        sdi = self.dataInput
        images = sdi.image
        arrays = sdi.array

        if len(images) == 2:
            self.npaIm1 = numpy.array(EDUtilsArray.getArray(images[0]))
            self.npaIm2 = numpy.array(EDUtilsArray.getArray(images[1]))
        elif len(arrays) == 2:
            self.npaIm1 = EDUtilsArray.xsDataToArray(arrays[0])
            self.npaIm2 = EDUtilsArray.xsDataToArray(arrays[1])
        else:
            strError = "EDPluginExecMeasureOffsetv2_0.preProcess: You should either provide two images or two arrays, but I got: %s" % sdi.marshal()[:1000]
            self.ERROR(strError)
            self.setFailure()
            raise RuntimeError(strError)

        crop = sdi.cropBorders
        if len(crop) > 1 :
            self.tCrop = tuple([ i.value for i in crop ])
        elif len(crop) == 1:
            self.tCrop = (crop[0].value, crop[0].value)

        center = sdi.center
        if len(center) > 1:
            self.tCenter = tuple([ i.value for i in center ])
        elif len(center) == 1:
            self.tCenter = (center[0].value, center[0].value)

        width = sdi.width
        if len(width) > 1 :
            self.tWidth = tuple([i.value for i in width])
        elif len(width) == 1:
            self.tWidth = (width[0].value, width[0].value)

        smooth = sdi.smoothBorders
        if len(smooth) == 2:
            self.tSmooth = (smooth[0].value, smooth[1].value)
        elif len(smooth) == 1:
            self.tSmooth = (smooth[0].value, smooth[0].value)

        if sdi.backgroundSubtraction is not None:
            self.bBackgroundsubtraction = (sdi.backgroundSubtraction.value in [1, True, "true"])

        if sdi.sobelFilter is not None:
            self.sobel = (sdi.sobelFilter in [1, True, "true"])
        EDAssert.equal(self.npaIm1.shape , self.npaIm2.shape, "Images have the same size")
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     imageFileName = os.path.basename(self.dataInput.image.path.value)
     # Default format
     strSuffix = "jpg"
     strPILFormat = "JPEG"
     # Check if format is provided
     if self.dataInput.format is not None:
         strFormat = self.dataInput.format.value
         if strFormat.lower() == "png":
             strSuffix = "png"
             strPILFormat = "PNG"
     # The following code has been adapted from EDPluginExecThumbnail written by J.Kieffer
     fabioImage = fabio.openimage.openimage(self.dataInput.image.path.value)
     numpyImage = fabioImage.data
     dtype = numpyImage.dtype
     sortedArray = numpyImage.flatten()
     sortedArray.sort()
     numpyImage = numpy.maximum(
         numpyImage,
         int(self.minLevel) * numpy.ones_like(numpyImage))
     maxLevel = sortedArray[int(
         round(float(self.maxLevel) * sortedArray.size / 100.0))]
     numpyImage = numpy.minimum(numpyImage,
                                maxLevel * numpy.ones_like(numpyImage))
     numpyImage = scipy.ndimage.morphology.grey_dilation(
         numpyImage, (self.dilatation, self.dilatation))
     mumpyImageFloat = (numpyImage.astype(numpy.float32)) / float(maxLevel)
     numpyImageInt = (mumpyImageFloat * 255.0).astype(numpy.uint8)
     pilOutputImage = ImageOps.invert(Image.fromarray(numpyImageInt, 'L'))
     if self.dataInput.height is not None and self.dataInput.width is not None:
         pilOutputImage = pilOutputImage.resize(
             (self.dataInput.width.value, self.dataInput.height.value),
             Image.ANTIALIAS)
     if self.dataInput.outputPath is None:
         outputPath = os.path.join(
             self.getWorkingDirectory(),
             os.path.splitext(imageFileName)[0] + "." + strSuffix)
     else:
         outputPath = self.dataInput.outputPath.path.value
     self.DEBUG("Output thumbnail path: %s" % outputPath)
     self.width, self.height = pilOutputImage.size
     if self.width * self.height > ImageFile.MAXBLOCK:
         ImageFile.MAXBLOCK = self.width * self.height
     pilOutputImage.save(outputPath,
                         strPILFormat,
                         quality=85,
                         optimize=True)
     self.dataOutput.thumbnail = XSDataFile(XSDataString(outputPath))
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     if self.__xsDataIndexingResult != None:
         self.setDataOutput(self.__xsDataIndexingResult, "indexingResult")
     else:
         self.__bIndexingSuccess = False
     self.setDataOutput(XSDataBoolean(self.__bIndexingSuccess),
                        "indexingSuccess")
     if self.__strStatusMessageIndexing != None:
         self.setDataOutput(XSDataString(self.__strStatusMessageIndexing),
                            "statusMessageIndexing")
     if self.__strStatusMessageImageQualityIndicators != None:
         self.setDataOutput(
             XSDataString(self.__strStatusMessageImageQualityIndicators),
             "statusMessageImageQualityIndicators")
Example #34
0
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("*** EDPluginEDFReadHeaderv1_0.postProcess")
     # Create some output data
     xsDataResultEDFReadHeader = XSDataResultEDFReadHeader()
     if (self.m_edDictionaryHeader is not None):
         xsDataDictionary = XSDataDictionary()
         for key in self.m_edDictionaryHeader.keys():
             xsDataKeyValuePair = XSDataKeyValuePair()
             xsDataKeyValuePair.setKey(XSDataString(key))
             xsDataKeyValuePair.setValue(
                 XSDataString(self.m_edDictionaryHeader[key]))
             xsDataDictionary.addKeyValuePair(xsDataKeyValuePair)
         xsDataResultEDFReadHeader.setDictionary(xsDataDictionary)
     self.setDataOutput(xsDataResultEDFReadHeader)
Example #35
0
 def __init__(self):
     EDPluginExec.__init__(self)
     self.setXSDataInputClass(XSDataInputSimpleHTMLPage)
     self.strPluginExecOutputHTMLName = "EDPluginExecOutputHTMLv1_0"
     self.edPluginExecOutputHTML = None
     self.strHTML = None
     self.xsDataResultCharacterisation = None
     self.xsDataKappa_alignment_response = None
     self.page = None
     self.strPath = None
     self.strTableColourTitle1 = "#F5F5FF"
     self.strTableColourTitle2 = "#F0F0FF"
     self.strTableColourRows = "#FFFFA0"
     self.strPageEDNALog = None
     self.xsDataSuggestedStrategy = None
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     self.DEBUG("EDPluginExecMatrixInvertv2_0.preProcess")
     self.xsdMatIn = self.dataInput.inputMatrix
     if self.xsdMatIn.path is not None:
         self.matIn = fabio.open(self.xsdMatIn.path.value).data
     elif self.xsdMatIn.shared is not None:
         self.matIn = EDShare[self.xsdMatIn.shared.value]
     elif self.xsdMatIn.array is not None:
         self.matIn = EDUtilsArray.xsDataToArray(self.xsdMatIn.array)
     else:
         self.ERROR("No valid input array provided")
     if self.matIn is None:
         self.ERROR("Input array is None")
         self.setFailure()
Example #37
0
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     self.DEBUG("EDPluginExecPlotGlev1_0.process")
     for strPath in self.listPlot:
         strCommand = "gle -verbosity 0 -r 150 -d jpg %s.gle" % strPath
         # Copied from EDPluginExecProcess
         self.DEBUG(self.getBaseName() + ": Processing")
         timer = threading.Timer(float(self.getTimeOut()), self.kill)
         timer.start()
         self.__subprocess = EDUtilsPlatform.Popen(
             shlex.split(str(EDUtilsPlatform.escape(strCommand))),
             cwd=self.getWorkingDirectory())
         self.__iPID = self.__subprocess.pid
         self.__strExecutionStatus = str(self.__subprocess.wait())
         timer.cancel()
Example #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 preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     self.DEBUG("EDPluginExecPlotGlev1_1.preProcess")
     FileGle = None
     # Check if we have a plotmtv input file
     xsDataInput = self.getDataInput()
     for xsDataGlePlot in xsDataInput.glePlot:
         dictPlot = {}
         dictPlot["script"] = xsDataGlePlot.script.path.value
         dictPlot["data"] = [xsDataGlePlot.data.path.value]
         self.listPlot.append(dictPlot)
     if xsDataInput.filePlotMtv is not None:
         strPlotMtvPath = xsDataInput.filePlotMtv.path.value
         if os.path.exists(strPlotMtvPath):
             strPlotMtv = EDUtilsFile.readFile(strPlotMtvPath)
             xsDataPlotSet = self.readPlotMtv(strPlotMtv)
         else:
             self.ERROR("Path to plt mtv file does not exist: %s" % strPlotMtvPath)
             self.setFailure()
             return
     else:
         xsDataPlotSet = xsDataInput.plotSet
     # Prepare input script
     iIndex = 1
     if xsDataPlotSet is not None:
         for xsDataPlot in xsDataPlotSet.plot:
             if xsDataPlot.xsize is None:
                 xsDataPlot.xsize = 10
             if xsDataPlot.ysize is None:
                 xsDataPlot.ysize = 10
             if iIndex in [1, 5, 8]:
                 xsDataPlot.keypos = "tl"
             elif iIndex in [2, 4, 6]:
                 xsDataPlot.keypos = "tr"
             elif iIndex in [3]:
                 xsDataPlot.keypos = "br"
             elif iIndex in [7]:
                 xsDataPlot.keypos = "bl"
             if iIndex == 4:
                 xsDataPlot.xmax = 500
             strPlotFile = os.path.join(self.getWorkingDirectory(), "plot%d" % iIndex)
             (strGle, listDataFiles) = self.prepareGleGraph(xsDataPlot)
             EDUtilsFile.writeFile(strPlotFile + ".gle", strGle)
             dictPlot = {}
             dictPlot["script"] = strPlotFile + ".gle"
             dictPlot["data"] = listDataFiles
             self.listPlot.append(dictPlot)
             iIndex += 1
Example #40
0
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     self.DEBUG("EDPluginExecSaxsCurvesv1_1.preProcess")
     xsdIn = self.getDataInput()
     if  xsdIn.getInputImage() is not None:
         self.inputImage = xsdIn.getInputImage().getPath().getValue()
         if not os.path.isfile(self.inputImage):
             self.ERROR("Input file %s does not exist ... try to go on anyway" % self.inputImage)
     if xsdIn.getOutputDataFile() is not None:
         self.outputDataFile = xsdIn.getOutputDataFile().getPath().getValue()
     if xsdIn.getOptions() is not None:
         self.options = xsdIn.getOptions().getValue()
     for oneHeader in  xsdIn.getExtraHeaders():
         self.extraHeader.append(oneHeader.getValue())
     if xsdIn.getHeaderMarker() is not None:
         self.headerMarker = xsdIn.getHeaderMarker().getValue()
Example #41
0
 def preProcess(self, _edPlugin=None):
     EDPluginExec.preProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev2_1.preProcess...")
     self.xsDataResultCharacterisation = self.getDataInput(
     ).getCharacterisationResult()
     if self.xsDataResultCharacterisation is None:
         if not self.getDataInput().getCharacterisationResultv2_0() is None:
             self.xsDataResultCharacterisation = self.getDataInput(
             ).getCharacterisationResultv2_0(
             ).getMxv1ResultCharacterisation()
             self.xsDataKappa_alignment_response = self.getDataInput(
             ).getCharacterisationResultv2_0().getPossibleOrientations()
             self.xsDataSuggestedOrientation = self.dataInput.characterisationResultv2_0.suggestedOrientation
     self.strHtmlFileName = "index.html"
     self.strPath = os.path.join(self.getWorkingDirectory(),
                                 self.strHtmlFileName)
 def __init__(self):
     """
     Constructor of the plugin
     """
     EDPluginExec.__init__(self)
     self.setXSDataInputClass(XSDataInputNormalize)
     self.listDataArray = []
     self.listDataExposure = []
     self.listDarkArray = []
     self.listDarkExposure = []
     self.listFlatArray = []
     self.listFlatExposure = []
     self.npaNormalized = None
     self.strOutputFilename = None
     self.strOutputShared = None
     self.shape = None
Example #43
0
 def __init__(self):
     EDPluginExec.__init__(self)
     self.setXSDataInputClass(XSDataInputSimpleHTMLPage)
     self.strPluginExecOutputHTMLName = "EDPluginExecOutputHTMLv1_0"
     self.edPluginExecOutputHTML = None
     self.strHTML = None
     self.xsDataResultCharacterisation = None
     self.strPath = None
     self.strTableColourTitle1 = "#F5F5FF"
     self.strTableColourTitle2 = "#F0F0FF"
     self.strTableColourRows = "#FFFFA0"
     self.strPageEDNALog = None
     self.fMinTransmission = 10  # %
     self.bIsHelical = False
     self.bIsMultiPositional = False
     self.workflowStepReport = None
Example #44
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
Example #45
0
 def configure(self,
               _bRequireToolsForCollectionWebServiceWsdl=False,
               _bRequireToolsForAutoprocessingWebServiceWsdl=False,
               _bRequireToolsForBLSampleWebServiceWsdl=False,
               _bRequireToolsForScreeningEDNAWebServiceWsdl=False):
     """
     Gets the web servise wdsl parameters from the config file and stores them in class member attributes.
     """
     EDPluginExec.configure(self)
     self.strUserName = str(self.config.get("userName"))
     if self.strUserName is None:
         self.ERROR(
             "{0}.configure: No user name found in configuration!".format(
                 self.getName()))
         self.setFailure()
     self.strPassWord = str(self.config.get("passWord"))
     if self.strPassWord is None:
         self.ERROR("{0}.configure: No pass word found in configuration!")
         self.setFailure()
     self.strToolsForCollectionWebServiceWsdl = self.config.get(
         "toolsForCollectionWebServiceWsdl")
     if _bRequireToolsForCollectionWebServiceWsdl and self.strToolsForCollectionWebServiceWsdl is None:
         self.ERROR(
             "{0}.configure: No toolsForCollectionWebServiceWsdl found in configuration!"
         )
         self.setFailure()
     self.strToolsForAutoprocessingWebServiceWsdl = self.config.get(
         "toolsForAutoprocessingWebServiceWsdl")
     if _bRequireToolsForAutoprocessingWebServiceWsdl and self.strToolsForAutoprocessingWebServiceWsdl is None:
         self.ERROR(
             "EDPluginISPyBStoreImageQualityIndicatorsv1_4.configure: No toolsForAutoprocessingWebServiceWsdl found in configuration!"
         )
         self.setFailure()
     self.strToolsForBLSampleWebServiceWsdl = self.config.get(
         "toolsForBLSampleWebServiceWsdl")
     if _bRequireToolsForBLSampleWebServiceWsdl and self.strToolsForBLSampleWebServiceWsdl is None:
         self.ERROR(
             "EDPluginISPyBGetSampleInformationv1_4.configure: No toolsForBLSampleWebServiceWsdl found in configuration!"
         )
         self.setFailure()
     self.strToolsForScreeningEDNAWebServiceWsdl = self.config.get(
         "toolsForScreeningEDNAWebServiceWsdl")
     if _bRequireToolsForScreeningEDNAWebServiceWsdl and self.strToolsForScreeningEDNAWebServiceWsdl is None:
         self.ERROR(
             "EDPluginISPyBStoreScreeningv1_4.configure: No toolsForScreeningEDNAWebServiceWsdl found in configuration!"
         )
         self.setFailure()
Example #46
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)
Example #47
0
 def __init__(self):
     """
     Initializes process related attributes described above
     """
     EDPluginExec.__init__(self)
     self.setRequiredToHaveConfiguration()
     self.__strConfigExecutable = "cat"
     self.__strConfigCommandline = ""
     self.__subprocess = None
     self.__iPID = None
     self.__strCWD = None
     self.__strExecutionStatus = ""
     self._start_time = None
     self._oar_job_id = None
     self._timer = None
     self._oar_options = None
     self._oar_poll_interval = None
Example #48
0
    def preProcess(self, _edObject=None):
        """
        Preprocess of the plugin: 
        check parameters and extract from EDNA format into something more simple & pythonic
        """
        EDPluginExec.preProcess(self)
        EDVerbose.DEBUG("EDPluginPyarchThumbnailv10.preProcess")
        sdi = self.getDataInput()
        if sdi.getInputImagePath() is not None:
            self.inputFilename = sdi.getInputImagePath().getPath().getValue()
            if not os.path.isfile(self.inputFilename):
                EDVerbose.ERROR(
                    "The input file provided is not a valid file: " +
                    self.inputFilename)
                raise "Not a valid file " + self.inputFilename

            # Output path
            strImageNameWithoutExt = os.path.basename(
                os.path.splitext(self.inputFilename)[0])
            strImageDirname = os.path.dirname(self.inputFilename)
            strOutputDirname = self.createPyarchFilePath(strImageDirname)
            # Check that output pyarch path exists and is writeable:
            bIsOk = False
            if strOutputDirname:
                if not os.path.exists(strOutputDirname):
                    # Try to create the directory
                    try:
                        os.makedirs(strOutputDirname)
                        bIsOk = True
                    except BaseException, e:
                        EDVerbose.WARNING("Couldn't create the directory %s" %
                                          strOutputDirname)
                elif os.access(strOutputDirname, os.W_OK):
                    bIsOk = True
            if not bIsOk:
                EDVerbose.warning("Cannot write to pyarch directory: %s" %
                                  strOutputDirname)
                strOutputDirname = tempfile.mkdtemp(
                    "", "EDPluginPyarchThumbnailv10_", "/tmp")
                EDVerbose.warning("Writing thumbnail images to: %s" %
                                  strOutputDirname)

            self.strOutputPath = os.path.join(strOutputDirname,
                                              strImageNameWithoutExt + ".jpeg")
            self.strOutputPathThumb = os.path.join(
                strOutputDirname, strImageNameWithoutExt + ".thumb.jpeg")
 def configure(self):
     """
     Gets the web servise wdsl parameters from the config file and stores them in class member attributes.
     """
     EDPluginExec.configure(self)
     self.strUserName = self.config.get("userName")
     if self.strUserName is None:
         self.ERROR("EDPluginISPyBGetSampleInformationv1_4.configure: No user name found in configuration!")
         self.setFailure()
     self.strPassWord = self.config.get("passWord")
     if self.strPassWord is None:
         self.ERROR("EDPluginISPyBGetSampleInformationv1_4.configure: No pass word found in configuration!")
         self.setFailure()
     self.strToolsForBLSampleWebServiceWsdl = self.config.get("toolsForBLSampleWebServiceWsdl")
     if self.strToolsForBLSampleWebServiceWsdl is None:
         self.ERROR("EDPluginISPyBGetSampleInformationv1_4.configure: No toolsForBLSampleWebServiceWsdl found in configuration!")
         self.setFailure()
Example #50
0
    def __init__(self):
        EDPluginExec.__init__(self)
        self.strWorkingDirectory = None
        self.strWorkingDir = None
        self.strEDNA2html = None
        self.strTitle = None
        self.strBasename = None
        self.strPath = None

        #        if not os.environ.has_key("EDNA2html"):
        #            self.setRequiredToHaveConfiguration(True)
        if os.environ.has_key("PATH"):
            self.strPath = os.environ["PATH"]
        self.setXSDataInputClass(XSDataString, "title")
        self.setXSDataInputClass(XSDataString, "basename")
        self.setXSDataInputClass(XSDataString, "workingDir")
        self.setXSDataInputClass(XSDataFile, "dnaFileDirectory")
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     self.DEBUG("EDPluginExecMatrixInvertv2_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultMatrixInvertv2()
     xsd = XSDataImageExt()
     if self.dataInput.outputMatrix is not None:
         if self.dataInput.outputMatrix.path is not None:
             fabio.edfimage.edfimage(data=self.matOut).write(self.dataInput.outputMatrix.path.value)
             xsd.path = self.dataInput.outputMatrix.path
         elif self.dataInput.outputMatrix.shared is not None:
             EDShare[self.dataInput.outputMatrix.shared.value] = self.matOut
             xsd.shared = self.dataInput.outputMatrix.shared
     else:
         xsd.array = EDUtilsArray.arrayToXSData(self.matOut, _bIncludeMd5sum=False)
     xsDataResult.setOutputMatrix(xsd)
     self.setDataOutput(xsDataResult)
Example #52
0
 def process(self, _edObject=None):
     EDPluginExec.process(self)
     EDVerbose.DEBUG("EDPluginExecMedianFilterv1_0.process")
     ndArray3D = None
     for strImgName in self.images:
         if not os.path.isfile(strImgName) :
             EDVerbose.ERROR("Unable to read file %s" % strImgName)
         else:
             if not strImgName in self.__dictImages:
                 data = fabio.open(strImgName).data
                 shape = data.shape
                 self.__dictImages[strImgName] = data.reshape(1, shape[0], shape[1])
             if ndArray3D is None:
                 ndArray3D = self.__dictImages[strImgName]
             else:
                 ndArray3D = numpy.concatenate((ndArray3D, self.__dictImages[strImgName]), axis=0)
     self.outputArray = scipy.median(ndArray3D, axis=0)
    def postProcess(self, _edObject=None):
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecMedianFilterv1_0.postProcess")
        # Create some output data
        xsDataResult = XSDataResultMedianFilter()
        if self.outputImage is None:
            xsDataResult.setOutputArray(
                EDUtilsArray.arrayToXSData(self.outputArray))
        else:
            edf = fabio.edfimage.edfimage(
                data=self.outputArray.astype("float32"))
            edf.write(self.outputImage)
            xsDataResult.setOutputImage(
                XSDataImage(XSDataString(self.outputImage)))

        self.setDataOutput(xsDataResult)
        self.outputArray = None
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     EDVerbose.DEBUG("EDPluginBioSaxsMetadatav1_1.preProcess")
     self.strInputImage = self.xsdInputData.getInputImage().getPath().value
     if self.xsdInputData.getDetector() is not None:
         self.detector = self.xsdInputData.getDetector().value
     if self.xsdInputData.detectorDistance is not None:
         self.detectorDistance = self.xsdInputData.detectorDistance.value
     if self.xsdInputData.beamCenter_1 is not None:
         self.beamCenter_1 = self.xsdInputData.beamCenter_1.value
     if self.xsdInputData.pixelSize_1 is not None:
         self.pixelSize_1 = self.xsdInputData.pixelSize_1.value
     if self.xsdInputData.beamCenter_2 is not None:
         self.beamCenter_2 = self.xsdInputData.beamCenter_2.value
     if self.xsdInputData.pixelSize_2 is not None:
         self.pixelSize_2 = self.xsdInputData.pixelSize_2.value
     if self.xsdInputData.beamStopDiode is not None:
         self.beamStopDiode = self.xsdInputData.beamStopDiode.value
     if self.xsdInputData.storageTemperature is not None:
         self.storageTemperature = self.xsdInputData.storageTemperature.value
     if self.xsdInputData.exposureTemperature is not None:
         self.exposureTemperature = self.xsdInputData.exposureTemperature.value
     if self.xsdInputData.exposureTime is not None:
         self.exposureTime = self.xsdInputData.exposureTemperature.value
     if self.xsdInputData.frameNumber is not None:
         self.frameNumber = self.xsdInputData.exposureTemperature.value
     if self.xsdInputData.frameMax is not None:
         self.frameMax = self.xsdInputData.exposureTemperature.value
     if self.xsdInputData.code is not None:
         self.code = self.xsdInputData.code.value
     if self.xsdInputData.comments is not None:
         self.comments = self.xsdInputData.comments.value
     if self.xsdInputData.concentration is not None:
         self.concentration = self.xsdInputData.concentration.value
     if self.xsdInputData.machineCurrent is not None:
         self.machineCurrent = self.xsdInputData.machineCurrent.value
     if self.xsdInputData.wavelength is not None:
         self.wavelength = self.xsdInputData.wavelength.value
     if self.xsdInputData.normalizationFactor is not None:
         self.normalizationFactor = self.xsdInputData.normalizationFactor.value
     if self.xsdInputData.maskFile is not None:
         self.maskFile = self.xsdInputData.maskFile.getPath().value
     if self.xsdInputData.getOutputImage() is not None:
         self.strOutputImage = self.xsdInputData.getOutputImage().getPath(
         ).value
Example #55
0
 def finallyProcess(self, _edObject=None):
     EDPluginExec.finallyProcess(self)
     self.DEBUG("EDPluginISPyBSetImagesPositionsv1_4.finallyProcess")
     xsDataResultISPyBSetImagesPositions = XSDataResultISPyBSetImagesPositions(
     )
     for imageCreation in self.listImageCreation:
         xsDataISPyBImageCreation = XSDataISPyBImageCreation()
         xsDataISPyBImageCreation.fileLocation = XSDataString(
             imageCreation.fileLocation)
         xsDataISPyBImageCreation.fileName = XSDataString(
             imageCreation.fileName)
         xsDataISPyBImageCreation.imageId = XSDataInteger(
             imageCreation.imageId)
         xsDataISPyBImageCreation.isCreated = XSDataBoolean(
             imageCreation.isCreated)
         xsDataResultISPyBSetImagesPositions.addImageCreation(
             xsDataISPyBImageCreation)
     self.setDataOutput(xsDataResultISPyBSetImagesPositions)
Example #56
0
 def __init__(self):
     """
     """
     EDPluginExec.__init__(self)
     self.setXSDataInputClass(XSDataInputStitchOffsetedImage)
     self._lImages = []  #list of ndarrays
     self._fDummy = 0
     self._lDummies = [
     ]  #list of 2-tuples of floats containing the dummy value and the delta-dummy
     self._lOffsets = [
     ]  #list of 2-tuples of floats containing the offset values
     self._strOutFile = None
     self._strBlending = "max"  #can be min or mean or naive
     self._bAutoscale = False
     self._ndaResult = None
     self.tCenter = None
     self.tWidth = None
     self._strMask = None
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     self.DEBUG("EDPluginExecNormalizeImagev1_1.postProcess")
     xsDataResult = XSDataResultNormalize()
     if self.strOutputFilename is not None:
         self.DEBUG("Writing file %s" % self.strOutputFilename)
         edf = fabio.edfimage.edfimage(data=self.npaNormalized, header={})
         edf.write(self.strOutputFilename)
         xsdo = XSDataImageExt(path=XSDataString(self.strOutputFilename))
     elif self.strOutputShared is not None:
         self.DEBUG("EDShare --> %s" % self.strOutputShared)
         EDShare[ self.strOutputShared] = self.npaNormalized
         xsdo = XSDataImageExt(shared=XSDataString(self.strOutputShared))
     else:
         xsdo = XSDataImageExt(array=EDUtilsArray.arrayToXSData(self.npaNormalized))
     xsDataResult.output = xsdo
     # Create some output data
     self.setDataOutput(xsDataResult)
Example #58
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)
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecReadDataID24v1_0.process")
        self.checkMandatoryParameters(self.dataInput, "Data Input is None")
        self.checkMandatoryParameters(self.dataInput.inputFile,
                                      "Data Input 'inputFile' is None")
        self.checkMandatoryParameters(
            self.dataInput.energyCalibration,
            "Data Input 'energyuCalibration' is None")
        self.checkMandatoryParameters(
            self.dataInput.energyCalibration.a,
            "Data Input 'energyCalibration a' is None")
        self.checkMandatoryParameters(
            self.dataInput.energyCalibration.b,
            "Data Input 'energyCalibration b' is None")
        # Load input data
        listNumpyArray = []
        iNumberOfSPectra = 0
        iNumberOfEnergies = 0
        for xsDataFile in self.dataInput.inputFile:
            numpyDataArray = self.loadInputData(xsDataFile.path.value)
            #            print numpyDataArray.shape
            listNumpyArray.append(numpyDataArray)
            iNumberOfEnergies = numpyDataArray.shape[0]
            iNumberOfSPectra += numpyDataArray.shape[1]
        numpyTotalDataArray = numpy.zeros(
            (iNumberOfEnergies, iNumberOfSPectra))
        #        print numpyTotalDataArray.shape
        iIndex = 0
        for numpyDataArray in listNumpyArray:
            iSpectra = numpyDataArray.shape[1]
            numpyTotalDataArray[:, iIndex:iIndex + iSpectra] = numpyDataArray
            iIndex += iSpectra

        # Create energy calibration array
        numpyEnergyCalibrationArray = self.createEnergyCalibrationArray(
            numpyTotalDataArray.shape[0], self.dataInput.energyCalibration)
        # Create some output data
        xsDataResultReadDataID24 = XSDataResultReadDataID24()
        xsDataResultReadDataID24.energy = EDUtilsArray.arrayToXSData(
            numpyEnergyCalibrationArray)
        xsDataResultReadDataID24.dataArray = EDUtilsArray.arrayToXSData(
            numpyTotalDataArray)
        self.setDataOutput(xsDataResultReadDataID24)
Example #60
0
 def process(self, _edObject=None):
     """
     Uses ToolsForCollectionWebService 
     """
     EDPluginExec.process(self)
     self.DEBUG("EDPluginISPyBStoreMotorPositionv1_4.process")
     httpAuthenticatedToolsForCollectionWebService = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord)
     clientToolsForCollectionWebService = Client(
         self.strToolsForCollectionWebServiceWsdl,
         transport=httpAuthenticatedToolsForCollectionWebService)
     # Loop over all positions
     motorPosition = self.createMotorPosition3VO(
         clientToolsForCollectionWebService, self.dataInput.motorPosition)
     self.motorPositionId = clientToolsForCollectionWebService.service.storeOrUpdateMotorPosition(
         motorPosition=motorPosition)
     self.DEBUG(
         "EDPluginISPyBStoreMotorPositionv1_4.process: motorPositionId=%r" %
         self.motorPositionId)