Example #1
0
File: stitch.py Project: kif/edna
def process(_listInputFile,
            _output,
            dummy=0,
            autoscale=False,
            center=None,
            width=None,
            blending=None,
            mask=None):
    """
    call EDNA with this options:
    @param _listInputFile: list of input files as strings
    @param _output: output file name
    @param dummy: value for dummy pixels
    @param autoscale: shall image intensity be scaled (boolean)
    @param center: 2-list of int representing the center of the ROI
    @param width:  2-list of int representing the width of the ROI
    @param blending: blending method: max, mean or min 
    @param mask: name of the file containing the mask
    """
    xsd = XSDataInputStitchImage()
    xsd.dummyValue = XSDataDouble(dummy)
    xsd.autoscale = XSDataBoolean(autoscale)
    if blending:
        xsd.blending = XSDataString(blending)
    if mask:
        xsd.mask = XSDataImage(XSDataString(mask))
    xsd.outputImage = XSDataImage(XSDataString(_output))
    xsd.inputImages = [XSDataImage(XSDataString(i)) for i in _listInputFile]
    if isinstance(width, list):
        xsd.widthROI = [XSDataInteger(i) for i in width]
    if isinstance(center, list):
        xsd.centerROI = [XSDataInteger(i) for i in center]
    job = EDJob(EDNAPluginName)
    job.setDataInput(xsd)
    job.execute()
Example #2
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginBioSaxsReduceFileSeriev1_0.preProcess")
        self.sample = self.dataInput.sample
        self.experimentSetup = self.dataInput.experimentSetup
        self.lstRawImg = [XSDataImage(i.path) for i in self.dataInput.fileSerie.files]
        self.directory1D = self.dataInput.directory1D.path.value
        self.directory2D = self.dataInput.directory2D.path.value
        self.directoryMisc = self.dataInput.directoryMisc.path.value
        if self.dataInput.forceReprocess is not None:
            self.forceReprocess = bool(self.dataInput.forceReprocess.value)
        if self.dataInput.rawImageSize is not None:
            self.rawImageSize = self.dataInput.rawImageSize

        bForceNewDirectories = False
        listBasname = [os.path.basename(i.path.value) for i in self.lstRawImg]
        common = os.path.commonprefix(listBasname)
        self.strMergedCurve = os.path.join(self.directory1D, common + "ave.dat")
        list2D = [os.path.join(self.directory2D, i) for i in listBasname]
        list1D = [os.path.join(self.directory1D, os.path.splitext(i)[0] + ".dat") for i in listBasname]
        listMisc = [os.path.join(self.directoryMisc, os.path.splitext(i)[0] + ".ang") for i in listBasname]
        found = [os.path.exists(i) for i in list1D + list2D + [self.strMergedCurve]]
        found.sort()
        if found[0]: #all files exists
            self.WARNING("All destination files already exists")
            self.lstSummary.append("All destination files already exists")
            if not self.forceReprocess: #then everything is already done
                self.bSkipProcess = True
            else:
                bForceNewDirectories = True
        elif found[-1]:
            self.WARNING("At lease few destination files already exists, but not all ... I will reprocess in another directory")
            self.lstSummary.append("At lease few destination files already exists, but not all ... I will reprocess in another directory")
            bForceNewDirectories = True

        if bForceNewDirectories:
            suffix = time.strftime("-%Y%m%d%H%M%S", time.localtime())
            self.lstSummary.append("Adding suffix %s to directories" % suffix)
            self.directory1D += suffix
            self.directory2D += suffix
            self.directoryMisc += suffix
            self.strMergedCurve = os.path.join(self.directory1D, common + "ave.dat")

        if not os.path.isdir(self.directory1D):
            os.makedirs(self.directory1D)
        if not os.path.isdir(self.directory2D):
            os.makedirs(self.directory2D)
        if not os.path.isdir(self.directoryMisc):
            os.makedirs(self.directoryMisc)

        self.lstCorImg = [ XSDataImage(XSDataString(i)) for i in list2D]
        self.lstIntImg = [ XSDataImage(XSDataString(i)) for i in listMisc]
        self.lstIntCrv = [ XSDataFile(XSDataString(i)) for i in list1D]
        self.lstLogFil = [XSDataFile(XSDataString(os.path.join(self.directoryMisc, os.path.splitext(i)[0] + ".log")))\
                           for i in listBasname]
Example #3
0
 def testCheckParameters(self):
     xsDataInput = XSDataInputBioSaxsHPLCv1_0()
     xsDataInput.rawImage = XSDataImage()
     xsDataInput.sample = XSDataBioSaxsSample()
     xsDataInput.experimentSetup = XSDataBioSaxsExperimentSetup()
     xsDataInput.logFile = XSDataFile()
     xsDataInput.normalizedImage = XSDataImage()
     xsDataInput.rawImageSize = XSDataInteger()
     edPluginExecBioSaxsNormalize = self.createPlugin()
     edPluginExecBioSaxsNormalize.setDataInput(xsDataInput)
     edPluginExecBioSaxsNormalize.checkParameters()
Example #4
0
 def testCheckParameters(self):
     xsDataInput = XSDataInputBioSaxsAzimutIntv1_0()
     xsDataInput.setNormalizedImage(XSDataImage())
     xsDataInput.setNormalizedImageSize(XSDataInteger())
     xsDataInput.setIntegratedImage(XSDataImage())
     xsDataInput.setIntegratedCurve(XSDataFile())
     xsDataInput.correctedImage = XSDataImage()
     xsDataInput.sample = XSDataBioSaxsSample()
     xsDataInput.experimentSetup = XSDataBioSaxsExperimentSetup()
     edPluginExec = self.createPlugin()
     edPluginExec.setDataInput(xsDataInput)
     edPluginExec.checkParameters()
Example #5
0
 def postProcess(self, _edObject=None):
     EDPluginControl.postProcess(self)
     EDVerbose.DEBUG("EDPluginBioSaxsMetadatav1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultBioSaxsMetadatav1_0()
     if self.strOutputImage is not None:
         xsdImage = XSDataImage()
         xsdImage.setPath(XSDataString(self.strOutputImage))
         xsDataResult.setOutputImage(xsdImage)
     if self.detector is not None:
         #            EDVerbose.DEBUG("Detector=%s" % self.detector)
         xsDataResult.setDetector(XSDataString(self.detector))
     if self.detectorDistance is not None:
         #            EDVerbose.DEBUG("DetectorDistance %s(%s)" % (self.detectorDistance, self.detectorDistance.__class__))
         xsDataResult.setDetectorDistance(
             XSDataLength(self.detectorDistance))
     if self.pixelSize_1 is not None:
         #            EDVerbose.DEBUG("pixelSize_1  %s(%s)" % (self.pixelSize_1, self.pixelSize_1.__class__))
         xsDataResult.setPixelSize_1(XSDataLength(self.pixelSize_1))
     if self.pixelSize_2 is not None:
         #            EDVerbose.DEBUG("pixelSize_2  %s(%s)" % (self.pixelSize_2, self.pixelSize_2.__class__))
         xsDataResult.setPixelSize_2(XSDataLength(self.pixelSize_2))
     if self.beamCenter_1 is not None:
         #            EDVerbose.DEBUG("beamCenter_1  %s(%s)" % (self.beamCenter_1, self.beamCenter_1.__class__))
         xsDataResult.setBeamCenter_1(XSDataDouble(self.beamCenter_1))
     if self.beamCenter_2 is not None:
         #            EDVerbose.DEBUG("beamCenter_2  %s(%s)" % (self.beamCenter_2, self.beamCenter_2.__class__))
         xsDataResult.setBeamCenter_2(XSDataDouble(self.beamCenter_2))
     if self.beamStopDiode is not None:
         #            EDVerbose.DEBUG("beamStopDiode  %s(%s)" % (self.beamStopDiode, self.beamStopDiode.__class__))
         xsDataResult.setBeamStopDiode(XSDataDouble(self.beamStopDiode))
     if self.wavelength is not None:
         xsDataResult.setWavelength(XSDataWavelength(self.wavelength))
     if self.maskFile is not None:
         xsdFile = XSDataImage()
         xsdFile.setPath(XSDataString(self.maskFile))
         xsDataResult.setMaskFile(xsdFile)
     if self.normalizationFactor is not None:
         xsDataResult.setNormalizationFactor(
             XSDataDouble(self.normalizationFactor))
     if self.machineCurrent is not None:
         xsDataResult.setMachineCurrent(XSDataDouble(self.machineCurrent))
     if self.code is not None:
         xsDataResult.setCode(XSDataString(self.code))
     if self.comments is not None:
         xsDataResult.setComments(XSDataString(self.comments))
     if self.concentration is not None:
         xsDataResult.setConcentration(XSDataDouble(self.concentration))
     EDVerbose.DEBUG("xsDataResult=%s" % xsDataResult.marshal())
     self.setDataOutput(xsDataResult)
    def testCheckParameters(self):
        xsDataInput = XSDataInputBioSaxsAveragev1_0()
        xsDataInput.setIntegratedImageSize(XSDataInteger())
        xsDataInput.setIntegratedImage([XSDataImage(), XSDataImage()])
        xsDataInput.setAveragedCurve(XSDataFile())
        xsDataInput.setNormalizationFactor(XSDataDouble())
        xsDataInput.setAveragedImage(XSDataImage())
        xsDataInput.setConcentration(XSDataDouble())
        xsDataInput.setComments(XSDataString())
        xsDataInput.setCode(XSDataString())
        xsDataInput.setLogFile(XSDataFile())

        edPluginExec = self.createPlugin()
        edPluginExec.setDataInput(xsDataInput)
        edPluginExec.checkParameters()
Example #7
0
 def doSuccessExecAccumulator(self, _edPlugin=None):
     self.DEBUG(
         "EDPluginControlMedianFilterImagev1_0.doSuccessExecAccumulator")
     self.retrieveSuccessMessages(
         _edPlugin,
         "EDPluginControlMedianFilterImagev1_0.doSuccessExecAccumulator")
     xdOut = _edPlugin.getDataOutput()
     if (xdOut is not None) and (xdOut.getQuery() != []):
         query = xdOut.getQuery()[0]
         self.xsdMedian = XSDataInputMedianFilter()
         self.xsdMedian.setInputImages(
             [XSDataImage(i) for i in query.getItem()])
         if self.outputImage is not None:
             self.xsdMedian.setOutputImage(
                 XSDataImage(XSDataString(self.outputImage)))
Example #8
0
 def testCheckParameters(self):
     xsDataInput = XSDataInputMedianFilterImage()
     xsDataInput.setInputImage(XSDataImage())
     xsDataInput.setFilterWidth(XSDataInteger(5))
     edPluginExecMedianFilterImage = self.createPlugin()
     edPluginExecMedianFilterImage.setDataInput(xsDataInput)
     edPluginExecMedianFilterImage.checkParameters()
 def doSuccessExecMetadata(self, _edPlugin=None):
     self.DEBUG("EDPluginBioSaxsNormalizev1_0.doSuccessExecMetadata")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginBioSaxsNormalizev1_0.doSuccessExecMetadata")
     if os.path.isfile(self.strNormalizedImage):
         xsNormFile = XSDataImage()
         xsNormFile.setPath(XSDataString(self.strNormalizedImage))
         self.xsdResult.setNormalizedImage(xsNormFile)
Example #10
0
 def doSuccessReadImageHeader(self, _edPlugin=None):
     self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessReadImageHeader")
     xsDataResultReadImageHeader = self.edPluginControlReadImageHeader.getDataOutput()
     if xsDataResultReadImageHeader is not None:
         xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
         self.xsDataCollection = XSDataCollection()
         self.xsDataCollection.addSubWedge(xsDataSubWedge)
         self.xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
         if not self.bDoOnlyIntegrationWithXMLOutput:
             xsDataInputControlImageQualityIndicators = XSDataInputControlImageQualityIndicators()
             if self.bStoreImageQualityIndicatorsInISPyB:
                 xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(True)
             else:
                 xsDataInputControlImageQualityIndicators.doUploadToIspyb = XSDataBoolean(False)
             xsDataInputControlImageQualityIndicators.addImage(XSDataImage(path=XSDataString(self.strImageFile)))
             self.edPluginControlIndicators.setDataInput(xsDataInputControlImageQualityIndicators)
             self.edPluginControlIndicators.connectSUCCESS(self.doSuccessIndicators)
             self.edPluginControlIndicators.connectFAILURE(self.doFailureIndicators)
             self.executePluginSynchronous(self.edPluginControlIndicators)
         else:
             xsDataIndexingInput = XSDataIndexingInput()
             xsDataIndexingInput.setDataCollection(self.xsDataCollection)
             from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
             xsDataMOSFLMIndexingInput = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing(xsDataIndexingInput)
             self.edPluginMOSFLMIndexing.connectSUCCESS(self.doSuccessIndexingMOSFLM)
             self.edPluginMOSFLMIndexing.connectFAILURE(self.doFailureIndexingMOSFLM)
             self.edPluginMOSFLMIndexing.setDataInput(xsDataMOSFLMIndexingInput)
             self.edPluginMOSFLMIndexing.executeSynchronous()
Example #11
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'image':
			obj_ = XSDataImage()
			obj_.build(child_)
			self.image.append(obj_)
		XSDataInput.buildChildren(self, child_, nodeName_)
 def testCheckParameters(self):
     xsDataInput = XSDataInputHDF5StackImages(
         HDF5File=XSDataFile(),
         internalHDF5Path=XSDataString(),
         inputImageFile=[XSDataImage()])
     edPluginExecHDF5StackImages = self.createPlugin()
     edPluginExecHDF5StackImages.setDataInput(xsDataInput)
     edPluginExecHDF5StackImages.checkParameters()
 def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage,
                                 _xsDataExperimentalCondition):
     """
     This method retrieves the flux and beamsize from ISPyB
     """
     xsDataExperimentalCondition = None
     if (_xsDataExperimentalCondition is not None):
         bFoundValidFlux = False
         xsDataExperimentalCondition = _xsDataExperimentalCondition.copy()
         xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection(
         )
         xsDataInputRetrieveDataCollection.setImage(
             XSDataImage(_xsDataFirstImage.getPath()))
         self.edPluginISPyBRetrieveDataCollection.setDataInput(
             xsDataInputRetrieveDataCollection)
         self.edPluginISPyBRetrieveDataCollection.executeSynchronous()
         xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput(
         )
         if xsDataResultRetrieveDataCollection is not None:
             xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection(
             )
             if xsDataISPyBDataCollection is not None:
                 fFlux = xsDataISPyBDataCollection.getFlux()
                 if fFlux is not None:
                     self.screen(
                         "ISPyB reports flux to be: %g photons/sec" % fFlux)
                     if fFlux > self.fFluxThreshold:
                         xsDataExperimentalCondition.getBeam().setFlux(
                             XSDataFlux(fFlux))
                         bFoundValidFlux = True
                 fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX
                 fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY
                 if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None:
                     self.screen("ISPyB reports beamsize X to be: %.3f mm" %
                                 fBeamSizeAtSampleX)
                     self.screen("ISPyB reports beamsize Y to be: %.3f mm" %
                                 fBeamSizeAtSampleY)
                     xsDataSize = XSDataSize()
                     xsDataSize.x = XSDataLength(fBeamSizeAtSampleX)
                     xsDataSize.y = XSDataLength(fBeamSizeAtSampleY)
                     xsDataExperimentalCondition.getBeam().setSize(
                         xsDataSize)
         if not bFoundValidFlux:
             self.screen(
                 "No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data."
             )
             xsDataBeam = xsDataExperimentalCondition.getBeam()
             xsDataBeamFlux = xsDataBeam.getFlux()
             if xsDataBeamFlux is not None:
                 fFluxMXCuBE = xsDataBeamFlux.getValue()
                 self.screen("MXCuBE reports flux to be: %g photons/sec" %
                             fFluxMXCuBE)
                 if fFluxMXCuBE < self.fFluxThreshold:
                     self.screen("MXCuBE flux invalid!")
     return xsDataExperimentalCondition
Example #14
0
    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        self.DEBUG("EDPluginBioSaxsNormalizev1_1.postProcess")

        if os.path.isfile(self.strNormalizedImage):
            xsNormFile = XSDataImage()
            xsNormFile.setPath(XSDataString(self.strNormalizedImage))
            self.xsdResult.setNormalizedImage(xsNormFile)
        self.xsdResult.status = XSDataStatus(executiveSummary=XSDataString(os.linesep.join(self.lstProcessLog)))
        # Create some output data
        self.setDataOutput(self.xsdResult)
Example #15
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 not filename.endswith(".edf"):
        return
    basename = os.path.basename(filename)
    upperDir = os.path.dirname(os.path.dirname(filename))
    if not os.path.isdir(os.path.join(upperDir, "MedianFiltered")):
        os.makedirs(os.path.join(upperDir, "MedianFiltered"), int("775", 8))
    destinationPath = os.path.join(upperDir, "MedianFiltered", basename)
    xsd = XSDataInputMedianFilterImage()
    xsd.setFilterWidth(XSDataInteger(FilterWidth))
    xsd.setInputImage(XSDataImage(XSDataString(filename)))
    xsd.setMedianFilteredImage(XSDataImage(XSDataString(destinationPath)))
    return xsd.marshal()
    def doSucessGetMetadata(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginBioSaxsAveragev1_0.doSuccessGetMetadata")
        #        self.strProcessLog += "Averaging EDF images to '%s'\n" % (self.averagedImage)
        self.xsdMetadata = _edPlugin.getDataOutput()

        xsdSaxsMac = XSDataInputSaxsMacv1_0()
        prefix = os.path.commonprefix(self.integratedImages)
        listFilesReversed = []
        for oneFile in self.integratedImages:
            revLst = list(oneFile)
            revLst.reverse()
            listFilesReversed.append("".join(revLst))
        revLst = list(os.path.commonprefix(listFilesReversed))
        revLst.reverse()
        suffix = "".join(revLst)
        lenSuffix = len(suffix)
        lenPrefix = len(prefix)
        maxdif = 0
        maxInt = 0
        miniInt = sys.maxint
        for oneFile in self.integratedImages:
            lenOneFile = len(oneFile)
            if lenOneFile - lenSuffix - lenPrefix > maxdif:
                maxdif = lenOneFile - lenSuffix - lenPrefix
            try:
                val = int(oneFile[lenPrefix:-lenSuffix])
            except Exception:
                val = None
                pass
            if val is not None:
                if val < miniInt:
                    miniInt = val
                if val > maxInt:
                    maxInt = val
        strImages = prefix + """%""" * maxdif + suffix + ",%i,%i" % (miniInt,
                                                                     maxInt)
        self.strProcessLog += "Averaging images '%s' to %s\n" % (
            strImages, self.averagedImage)
        EDVerbose.DEBUG("Averaging '%s'\n" % (strImages))
        xsdImage = XSDataImage()
        xsdImage.setPath(XSDataString(strImages))
        xsdiSaxsMac = XSDataInputSaxsMacv1_0()
        xsdiSaxsMac.setInputImage(xsdImage)
        xsdiSaxsMac.setOutputImage(self.dataInput.getAveragedImage())
        xsdiSaxsMac.setOptions(
            XSDataString("+pass -omod n +var -add %d" %
                         len(self.integratedImages)))
        xsdiSaxsMac.setMultConst(XSDataDouble(1.0 /
                                              len(self.integratedImages)))
        self.__edPluginSaxsMac.setDataInput(xsdiSaxsMac)
        self.__edPluginSaxsMac.connectSUCCESS(self.doSuccessSaxsMac)
        self.__edPluginSaxsMac.connectFAILURE(self.doFailureSaxsMac)
        self.__edPluginSaxsMac.executeSynchronous()
Example #17
0
    def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage, _xsDataExperimentalCondition):
        """
        This method retrieves the flux and beamsize from ISPyB
        """
        xsDataExperimentalCondition = None
        if (_xsDataExperimentalCondition is not None):
            bFoundValidFlux = False
            xsDataExperimentalCondition = _xsDataExperimentalCondition.copy()
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
            xsDataInputRetrieveDataCollection.setImage(XSDataImage(_xsDataFirstImage.getPath()))
            self.edPluginISPyBRetrieveDataCollection.setDataInput(xsDataInputRetrieveDataCollection)
            self.edPluginISPyBRetrieveDataCollection.executeSynchronous()
            xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput()
            if xsDataResultRetrieveDataCollection is not None:
                xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection()
                if xsDataISPyBDataCollection is not None:
                    fFlux = xsDataISPyBDataCollection.getFlux_end()
                    if fFlux is not None:
                        self.screen("ISPyB reports flux to be: %g photons/sec" % fFlux)
                        if fFlux > self.fFluxThreshold:
                            xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(fFlux))
                            bFoundValidFlux = True
                    fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX
                    fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY
                    if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None:
                        self.screen("ISPyB reports beamsize X to be: %.3f mm" % fBeamSizeAtSampleX)
                        self.screen("ISPyB reports beamsize Y to be: %.3f mm" % fBeamSizeAtSampleY)
                        xsDataSize = XSDataSize()
                        xsDataSize.x = XSDataLength(fBeamSizeAtSampleX)
                        xsDataSize.y = XSDataLength(fBeamSizeAtSampleY)
                        xsDataExperimentalCondition.getBeam().setSize(xsDataSize)
                    # Get transmission if it's not already there
                    if xsDataExperimentalCondition.beam.transmission is None:
                        fTransmission = xsDataISPyBDataCollection.transmission
                        xsDataExperimentalCondition.beam.transmission = XSDataDouble(fTransmission)
            if not bFoundValidFlux:
                self.screen("No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data.")
                xsDataBeam = xsDataExperimentalCondition.getBeam()
                xsDataBeamFlux = xsDataBeam.getFlux()
                if xsDataBeamFlux is not None:
                    fFluxMXCuBE = xsDataBeamFlux.getValue()
                    self.screen("MXCuBE reports flux to be: %g photons/sec" % fFluxMXCuBE)
                    if fFluxMXCuBE < self.fFluxThreshold:
                        self.screen("MXCuBE flux lower than threshold flux %g photons/s!" % self.fFluxThreshold)
                        self.screen("Forcing flux to 0.0 photons/s")
                        xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0))
                else:
                    # Force missing flux to 0.0
                    self.screen("No flux neither in ISPyB nor in mxCuBE, forcing flux to 0.0 photon/s")
                    xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0))

        return xsDataExperimentalCondition
Example #18
0
    def makeXML(self, 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  
        """
        bProcessFile = False
        basename = os.path.basename(filename)
        for oneExt in self.listExtensions:
            if basename.endswith(oneExt):
                bProcessFile = True
                break
        if bProcessFile:
            for onePref in self.listExcludedPrefix:
                if basename.startswith(onePref):
                    bProcessFile = False
        if not bProcessFile:
            EDVerbose.screen("Not processing file: %s" % filename)
            return
        xsdimage = XSDataImage()
        xsdimage.setPath(XSDataString(filename))
        xsd = XSDataInputDiffractionCT()
        xsd.setImage(xsdimage)
        xsd.setDestinationDirectory(self.destinationDirectory)
        xsd.setSinogramFileNamePrefix(self.sinogramFileNamePrefix)
        xsd.setPowderDiffractionSubdirectory(
            self.powderDiffractionSubdirectory)
        xsd.setPowderDiffractionFormat(self.powderDiffractionFormat)
        if self.indexOffset is not None and self.fastMotorSteps is not None:
            idx = 0
            basename = list(os.path.splitext(os.path.basename(filename))[0])
            basename.reverse()
            number = ""
            for i in basename:
                if i.isdigit():
                    number = i + number
                else:
                    break
            idx = int(number) - self.indexOffset
            if idx < 0: return

            self.forceInstrument.set_tomo_spec_displ_x(
                XSDataLength(idx % (self.fastMotorSteps + 1)))
            self.forceInstrument.set_tomo_spec_displ_rotation(
                XSDataLength(idx // (self.fastMotorSteps + 1)))
        xsd.setOverrideScanParam(self.forceInstrument)
        xsd.setOverrideImageParam(self.forceImage)

        return xsd.marshal()
Example #19
0
    def testCheckParameters(self):
        xsDataInput = XSDataInputBioSaxsNormalizev1_0()
        xsDataInput.setRawImage(XSDataImage())
        #        xsDataInput.setLogFile(XSDataFile())
        xsDataInput.setNormalizedImage(XSDataImage())
        xsDataInput.setRawImageSize(XSDataInteger())
        xsDataInput.setExperimentSetup(XSDataBioSaxsExperimentSetup())
        xsDataInput.setSample(XSDataBioSaxsSample())
        #        xsDataInput.setBeamStopDiode(XSDataDouble())
        #        xsDataInput.setNormalizationFactor(XSDataDouble())
        #        xsDataInput.setMachineCurrent(XSDataDouble())
        #        xsDataInput.setMaskFile(XSDataImage())
        #        xsDataInput.setDetectorDistance(XSDataLength())
        #        xsDataInput.setWavelength(XSDataWavelength())
        #        xsDataInput.setPixelSize_1(XSDataLength())
        #        xsDataInput.setPixelSize_2(XSDataLength())
        #        xsDataInput.setBeamCenter_1(XSDataDouble())
        #        xsDataInput.setBeamCenter_2(XSDataDouble())

        edPluginExecBioSaxsNormalize = self.createPlugin()
        edPluginExecBioSaxsNormalize.setDataInput(xsDataInput)
        edPluginExecBioSaxsNormalize.checkParameters()
    def testCheckParameters(self):
        xsDataInput = XSDataInputBioSaxsProcessOneFilev1_0()
        xsDataInput.rawImage = XSDataImage()
        xsDataInput.sample = XSDataBioSaxsSample()
        xsDataInput.experimentSetup = XSDataBioSaxsExperimentSetup()
        xsDataInput.logFile = XSDataFile()
        xsDataInput.normalizedImage = XSDataImage()
        xsDataInput.rawImageSize = XSDataInteger()
        #        xsDataInput.beamStopDiode = XSDataDouble()
        #        xsDataInput.normalizationFactor = XSDataDouble()
        #        xsDataInput.machineCurrent = XSDataDouble()
        #        xsDataInput.maskFile = XSDataImage()
        #        xsDataInput.detectorDistance = XSDataLength()
        #        xsDataInput.wavelength = XSDataWavelength()
        #        xsDataInput.pixelSize_1 = XSDataLength()
        #        xsDataInput.pixelSize_2 = XSDataLength()
        #        xsDataInput.beamCenter_1 = XSDataDouble()
        #        xsDataInput.beamCenter_2 = XSDataDouble()

        edPluginExecBioSaxsNormalize = self.createPlugin()
        edPluginExecBioSaxsNormalize.setDataInput(xsDataInput)
        edPluginExecBioSaxsNormalize.checkParameters()
Example #21
0
    def postProcess(self, _edObject=None):
        EDPluginExecProcessScript.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecSaxsMacv1_0.postProcess")
        # Create some output data
        xsDataResult = XSDataResultSaxsMacv1_0()
        if self.outputImage is None:
            self.outputImage = "output.edf"
        if os.path.isfile(self.outputImage):
            xsdFile = XSDataImage()
            xsdFile.setPath(XSDataString(os.path.abspath(self.outputImage)))
            xsDataResult.setOutputImage(xsdFile)

        self.setDataOutput(xsDataResult)
Example #22
0
 def createDataMOSFLMOutputGeneratePrediction(self):
     self.DEBUG("EDPluginMOSFLMGeneratePredictionv10.createDataMOSFLMOutputIntegration")
     xsDataMOSFLMInputGeneratePrediction = self.getDataInput()
     xsDataMOSFLMImage = xsDataMOSFLMInputGeneratePrediction.getImage()
     iImageNumber = xsDataMOSFLMImage.getNumber().getValue()
     xsDataMOSFLMOutputGeneratePrediction = XSDataMOSFLMOutputGeneratePrediction()
     xsDataImage = XSDataImage()
     xsDataImage.setNumber(XSDataInteger(iImageNumber))
     xsDataImage.setPath(XSDataString(os.path.join(self.getWorkingDirectory(), self.getPredictionImageFileName())))
     xsDataMOSFLMOutputGeneratePrediction.setPredictionImage(xsDataImage)
      # Path to log file
     xsDataMOSFLMOutputGeneratePrediction.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))))
     return xsDataMOSFLMOutputGeneratePrediction
Example #23
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
Example #24
0
    def testCheckParameters(self):
        xsDataInput = XSDataInputBioSaxsAsciiExportv1_0()
        #        xsDataInput.setNormalizedImage(XSDataImage())
        #        xsDataInput.setNormalizedImageSize(XSDataInteger())
        xsDataInput.setIntegratedImage(XSDataImage())
        xsDataInput.setIntegratedCurve(XSDataFile())
        #        xsDataInput.setNormalizationFactor(XSDataDouble())
        #        xsDataInput.setMaskFile(XSDataImage())
        #        xsDataInput.setCorrectedImage(XSDataImage())
        #        xsDataInput.setConcentration(XSDataDouble())
        #        xsDataInput.setComments(XSDataString())
        #        xsDataInput.setCode(XSDataString())

        edPluginExec = self.createPlugin()
        edPluginExec.setDataInput(xsDataInput)
        edPluginExec.checkParameters()
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlH5ToCBFv1_0.process")
        imageNumber = self.dataInput.imageNumber.value
        if self.dataInput.hdf5ImageNumber is None:
            hdf5ImageNumber = imageNumber
        else:
            hdf5ImageNumber = self.dataInput.hdf5ImageNumber.value

        if self.dataInput.ispybDataCollection is None:
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection(
            )
            xsDataImage = XSDataImage(self.dataInput.hdf5File.path)
            xsDataInputRetrieveDataCollection.image = xsDataImage
            self.edPluginISPyBRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
            self.edPluginISPyBRetrieveDataCollection.executeSynchronous()
            xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.dataOutput
            dataCollection = xsDataResultRetrieveDataCollection.dataCollection
        else:
            dataCollection = self.dataInput.ispybDataCollection
        if dataCollection is not None:
            if dataCollection.overlap is None:
                overlap = 0.0
            else:
                overlap = dataCollection.overlap
            axisStart = dataCollection.axisStart
            oscillationRange = dataCollection.axisRange
            axisStartNew = axisStart - (overlap +
                                        oscillationRange) * (imageNumber - 1)
            dataCollection.axisStart = axisStartNew
            xsDataISPyBDataCollection = XSDataISPyBDataCollection.parseString(
                dataCollection.marshal())
        else:
            xsDataISPyBDataCollection = None
        xsDataInputH5ToCBF = XSDataInputH5ToCBF()
        xsDataInputH5ToCBF.hdf5File = self.dataInput.hdf5File
        xsDataInputH5ToCBF.imageNumber = self.dataInput.imageNumber
        xsDataInputH5ToCBF.hdf5ImageNumber = XSDataInteger(hdf5ImageNumber)
        xsDataInputH5ToCBF.dataCollection = xsDataISPyBDataCollection
        xsDataInputH5ToCBF.forcedOutputDirectory = self.dataInput.forcedOutputDirectory
        self.edPluginEDPluginH5ToCBF.dataInput = xsDataInputH5ToCBF
        self.edPluginEDPluginH5ToCBF.executeSynchronous()
        if self.edPluginEDPluginH5ToCBF.dataOutput is not None:
            self.dataOutput.outputCBFFile = self.edPluginEDPluginH5ToCBF.dataOutput.outputCBFFile
            if dataCollection is not None:
                self.dataOutput.ispybDataCollection = XSDataISPyBDataCollection.parseString(
                    dataCollection.marshal())
    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        self.DEBUG("EDPluginControlDozorv1_0.postProcess")
        # Write a file to be used with ISPyB or GNUPLOT only if data collection id in input
        dataCollectionId = None
        if self.dataInput.dataCollectionId is None and len(self.dataInput.image) > 0:
            # Only try to obtain data collection id if at the ESRF and path starts with "/data"
            if EDUtilsPath.isESRF() and self.dataInput.image[0].path.value.startswith("/data"):
                xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
                xsDataInputRetrieveDataCollection.image = XSDataImage(self.dataInput.image[0].path)
                edPluginISPyBRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
                edPluginISPyBRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
                edPluginISPyBRetrieveDataCollection.executeSynchronous()
                xsDataResultRetrieveDataCollection = edPluginISPyBRetrieveDataCollection.dataOutput
                if xsDataResultRetrieveDataCollection is not None:
                    dataCollection = xsDataResultRetrieveDataCollection.dataCollection
                    if dataCollection is not None:
                        dataCollectionId = dataCollection.dataCollectionId
        elif self.dataInput.dataCollectionId is not None:
            dataCollectionId = self.dataInput.dataCollectionId.value

        if dataCollectionId is not None:
            minImageNumber = None
            maxImageNumber = None
            minAngle = None
            maxAngle = None
            minDozorValue = None
            maxDozorValue = None
            minResolution = None
            maxResolution = None
            dozorPlotFileName = "dozor_{0}.png".format(dataCollectionId)
            dozorCsvFileName = "dozor_{0}.csv".format(dataCollectionId)
            with open(os.path.join(self.getWorkingDirectory(), dozorCsvFileName), "w") as gnuplotFile:
                gnuplotFile.write("# Data directory: {0}\n".format(self.directory))
                gnuplotFile.write("# File template: {0}\n".format(self.template.replace("%04d", "####")))
                gnuplotFile.write("# {0:>9s}{1:>16s}{2:>16s}{3:>16s}{4:>16s}{5:>16s}\n".format("'Image no'",
                                                                               "'Angle'",
                                                                               "'No of spots'",
                                                                               "'Main score (*10)'",
                                                                               "'Spot score'",
                                                                               "'Visible res.'",
                                                               ))
                for imageDozor in self.dataOutput.imageDozor:
                    gnuplotFile.write("{0:10d},{1:15.3f},{2:15d},{3:15.3f},{4:15.3f},{5:15.3f}\n".format(imageDozor.number.value,
                                                                                                       imageDozor.angle.value,
                                                                                                       imageDozor.spotsNumOf.value,
                                                                                                       10 * imageDozor.mainScore.value,
                                                                                                       imageDozor.spotScore.value,
                                                                                                       imageDozor.visibleResolution.value,
                                                                                                       ))
                    if minImageNumber is None or minImageNumber > imageDozor.number.value:
                        minImageNumber = imageDozor.number.value
                        minAngle = imageDozor.angle.value
                    if maxImageNumber is None or maxImageNumber < imageDozor.number.value:
                        maxImageNumber = imageDozor.number.value
                        maxAngle = imageDozor.angle.value
                    if minDozorValue is None or minDozorValue > imageDozor.mainScore.value:
                        minDozorValue = imageDozor.spotScore.value
                    if maxDozorValue is None or maxDozorValue < imageDozor.mainScore.value:
                        maxDozorValue = imageDozor.spotScore.value

                    # Min resolution: the higher the value the lower the resolution
                    if minResolution is None or minResolution < imageDozor.visibleResolution.value:
                        # Disregard resolution worse than 10.0
                        if imageDozor.visibleResolution.value < 10.0:
                            minResolution = imageDozor.visibleResolution.value

                    # Max resolution: the lower the number the better the resolution
                    if maxResolution is None or maxResolution > imageDozor.visibleResolution.value:
                        maxResolution = imageDozor.visibleResolution.value

            xtics = ""
            if minImageNumber is not None and minImageNumber == maxImageNumber:
                minAngle -= 1.0
                maxAngle += 1.0
            noImages = maxImageNumber - minImageNumber + 1
            if noImages <= 4:
                minImageNumber -= 0.1
                maxImageNumber += 0.1
                deltaAngle = maxAngle - minAngle
                minAngle -= deltaAngle * 0.1 / noImages
                maxAngle += deltaAngle * 0.1 / noImages
                xtics = "1"

            if maxResolution is None or maxResolution > 0.8:
                maxResolution = 0.8
            else:
                maxResolution = int(maxResolution * 10.0) / 10.0

            if minResolution is None or minResolution < 4.5:
                minResolution = 4.5
            else:
                minResolution = int(minResolution * 10.0) / 10.0 + 1

            if maxDozorValue < 0.001 and minDozorValue < 0.001:
                yscale = "set yrange [-0.5:0.5]\n    set ytics 1"
            else:
                yscale = "set autoscale  y"

            gnuplotFile.close()
            gnuplotScript = \
    """#
    set terminal png
    set output '{dozorPlotFileName}'
    set title '{title}'
    set grid x2 y2
    set xlabel 'Image number'
    set x2label 'Angle (degrees)'
    set y2label 'Resolution (A)'
    set ylabel 'Number of spots / Dozor score (*10)'
    set xtics {xtics} nomirror
    set x2tics 
    set ytics nomirror
    set y2tics
    set xrange [{minImageNumber}:{maxImageNumber}]
    set x2range [{minAngle}:{maxAngle}]
    {yscale}
    set y2range [{minResolution}:{maxResolution}]
    set key below
    plot '{dozorCsvFileName}' using 1:3 title 'Number of spots' axes x1y1 with points linetype rgb 'goldenrod' pointtype 7 pointsize 1.5, \
         '{dozorCsvFileName}' using 1:4 title 'Dozor score' axes x1y1 with points linetype 3 pointtype 7 pointsize 1.5, \
         '{dozorCsvFileName}' using 1:6 title 'Visible resolution' axes x1y2 with points linetype 1 pointtype 7 pointsize 1.5
    """.format(title=self.template.replace("%04d", "####"),
               dozorPlotFileName=dozorPlotFileName,
               dozorCsvFileName=dozorCsvFileName,
               minImageNumber=minImageNumber,
               maxImageNumber=maxImageNumber,
               minAngle=minAngle,
               maxAngle=maxAngle,
               minResolution=minResolution,
               maxResolution=maxResolution,
               xtics=xtics,
               yscale=yscale,
               )
            pathGnuplotScript = os.path.join(self.getWorkingDirectory(), "gnuplot.sh")
            data_file = open(pathGnuplotScript, "w")
            data_file.write(gnuplotScript)
            data_file.close()
            oldCwd = os.getcwd()
            os.chdir(self.getWorkingDirectory())
            os.system("{0} {1}".format(self.gnuplot, pathGnuplotScript))
            os.chdir(oldCwd)

            self.dataOutput.dozorPlot = XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), dozorPlotFileName)))

            if self.dataInput.processDirectory is not None:
                processDirectory = self.dataInput.processDirectory.path.value
            else:
                processDirectory = os.path.join(self.directory.replace("RAW_DATA", "PROCESSED_DATA"), "DozorPlot")
            resultsDirectory = os.path.join(processDirectory, "results")
            dozorPlotResultPath = os.path.join(resultsDirectory, dozorPlotFileName)
            dozorCsvResultPath = os.path.join(resultsDirectory, dozorCsvFileName)
            try:
                if not os.path.exists(resultsDirectory):
                    os.makedirs(resultsDirectory, 0o755)
                shutil.copy(os.path.join(self.getWorkingDirectory(), dozorPlotFileName), dozorPlotResultPath)
                shutil.copy(os.path.join(self.getWorkingDirectory(), dozorCsvFileName), dozorCsvResultPath)
            except:
                self.warning("Couldn't copy files to results directory: {0}".format(resultsDirectory))

            try:
                # Create paths on pyarch
                dozorPlotPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchFilePath(dozorPlotResultPath)
                dozorCsvPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchFilePath(dozorCsvResultPath)
                if not os.path.exists(os.path.dirname(dozorPlotPyarchPath)):
                    os.makedirs(os.path.dirname(dozorPlotPyarchPath), 0o755)
                shutil.copy(dozorPlotResultPath, dozorPlotPyarchPath)
                shutil.copy(dozorCsvResultPath, dozorCsvPyarchPath)
                # Upload to data collection
                xsDataInputISPyBSetImageQualityIndicatorsPlot = XSDataInputISPyBSetImageQualityIndicatorsPlot()
                xsDataInputISPyBSetImageQualityIndicatorsPlot.dataCollectionId = XSDataInteger(dataCollectionId)
                xsDataInputISPyBSetImageQualityIndicatorsPlot.imageQualityIndicatorsPlotPath = XSDataString(dozorPlotPyarchPath)
                xsDataInputISPyBSetImageQualityIndicatorsPlot.imageQualityIndicatorsCSVPath = XSDataString(dozorCsvPyarchPath)
                EDPluginISPyBSetImageQualityIndicatorsPlot = self.loadPlugin("EDPluginISPyBSetImageQualityIndicatorsPlotv1_4")
                EDPluginISPyBSetImageQualityIndicatorsPlot.dataInput = xsDataInputISPyBSetImageQualityIndicatorsPlot
                EDPluginISPyBSetImageQualityIndicatorsPlot.executeSynchronous()
            except:
                self.warning("Couldn't copy files to pyarch: {0}".format(dozorPlotPyarchPath))

        self.sendMessageToMXCuBE("Processing finished", "info")
        self.setStatusToMXCuBE("Success")
Example #27
0
 def testCheckParameters(self):
     xsDataInput = XSDataInputSaxsDelMetadatav1_0()
     xsDataInput.setInputImage(XSDataImage())
     edPluginExecSaxsDelMetadata = self.createPlugin()
     edPluginExecSaxsDelMetadata.setDataInput(xsDataInput)
     edPluginExecSaxsDelMetadata.checkParameters()
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecReadImageHeaderEiger4Mv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictEiger4MHeader = self.readHeaderEiger4M(strPath)
        if (dictEiger4MHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderEiger4Mv10.process : Cannot read header : %s" % strPath
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = 2070
            iNoPixelsY = 2167
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            # Pixel size
            listPixelSizeXY = dictEiger4MHeader[ "Pixel_size"   ].split(" ")
            fPixelSizeX = float(listPixelSizeXY[0]) * 1000
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(listPixelSizeXY[3]) * 1000
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            # Beam position
            listBeamPosition = dictEiger4MHeader["Beam_xy"].replace("(", " ").replace(")", " ").replace(",", " ").split()
            fBeamPositionX = float(listBeamPosition[1]) * fPixelSizeX
            fBeamPositionY = float(listBeamPosition[0]) * fPixelSizeY
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictEiger4MHeader[ "Detector_distance" ].split(" ")[0]) * 1000
            xsDataDetector.setDistance(XSDataLength(fDistance))
#            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictEiger4MHeader[ "header_size"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictEiger4MHeader[ "Detector:"   ]))
#            #xsDataDetector.setBin(                 XSDataString(   dictEiger4MHeader[ "BIN" ] ) ) )
#            #xsDataDetector.setDataType(            XSDataString(   dictEiger4MHeader[ "TYPE" ] ) ) )
#            #xsDataDetector.setByteOrder(           XSDataString(   dictEiger4MHeader[ "BYTE_ORDER" ] ) ) )
#            xsDataDetector.setImageSaturation(XSDataInteger(int(dictEiger4MHeader[ "saturation_level" ])))
            xsDataDetector.setName(XSDataString("EIGER 4M"))
            xsDataDetector.setType(XSDataString("eiger4m"))
            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictEiger4MHeader[ "Wavelength" ].split(" ")[0])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictEiger4MHeader[ "Exposure_time" ].split(" ")[0])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictEiger4MHeader[ "Start_angle" ].split(" ")[0])
            fOscillationWidth = float(dictEiger4MHeader[ "Angle_increment" ].split(" ")[0])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)
#
            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            if "DateTime" in dictEiger4MHeader:
                strTimeStamp = dictEiger4MHeader[ "DateTime" ]
                xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
    def postProcess(self, _edObject=None):
        """
complex type XSDataBioSaxsExperimentSetup extends XSData{
    detector : XSDataString optional
    detectorDistance : XSDataLength optional
    pixelSize_1 : XSDataLength optional
    pixelSize_2 : XSDataLength optional
    beamCenter_1 : XSDataDouble optional
    beamCenter_2 : XSDataDouble optional
    beamStopDiode : XSDataDouble optional
    wavelength : XSDataWavelength optional
    machineCurrent : XSDataDouble optional
    maskFile : XSDataImage optional
    normalizationFactor : XSDataDouble optional
    storageTemperature: XSDataDouble optional
    exposureTemperature: XSDataDouble optional
    exposureTime: XSDataTime optional
    frameNumber: XSDataInteger optional
    frameMax: XSDataInteger optional
}

complex type XSDataBioSaxsSample extends XSData {
    concentration : XSDataDouble optional
    comments : XSDataString optional
    code : XSDataString optional
    temperature: XSDataDouble optional
"""

        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginBioSaxsMetadatav1_1.postProcess")
        # Create some output data
        xsDataResult = XSDataResultBioSaxsMetadatav1_0()
        xsdSample = XSDataBioSaxsSample()
        xsdExperiment = XSDataBioSaxsExperimentSetup()
        if self.strOutputImage is not None:
            xsdImage = XSDataImage()
            xsdImage.setPath(XSDataString(self.strOutputImage))
            xsDataResult.setOutputImage(xsdImage)
        if self.detector is not None:
            xsdExperiment.detector = xsDataResult.detector = XSDataString(
                self.detector)
        if self.detectorDistance is not None:
            xsdExperiment.detectorDistance = xsDataResult.detectorDistance = XSDataLength(
                self.detectorDistance)
        if self.pixelSize_1 is not None:
            xsDataResult.pixelSize_1 = XSDataLength(self.pixelSize_1)
            xsdExperiment.pixelSize_1 = xsDataResult.pixelSize_1
        if self.pixelSize_2 is not None:
            xsDataResult.pixelSize_2 = XSDataLength(self.pixelSize_2)
            xsdExperiment.pixelSize_2 = xsDataResult.pixelSize_2
        if self.beamCenter_1 is not None:
            xsDataResult.beamCenter_1 = XSDataDouble(self.beamCenter_1)
            xsdExperiment.beamCenter_1 = xsDataResult.beamCenter_1
        if self.beamCenter_2 is not None:
            xsDataResult.beamCenter_2 = XSDataDouble(self.beamCenter_2)
            xsdExperiment.beamCenter_2 = xsDataResult.beamCenter_2
        if self.beamStopDiode is not None:
            xsdExperiment.beamStopDiode = xsDataResult.beamStopDiode = XSDataDouble(
                self.beamStopDiode)
        if self.wavelength is not None:
            xsdExperiment.wavelength = xsDataResult.wavelength = XSDataWavelength(
                self.wavelength)
        if self.maskFile is not None:
            xsdFile = XSDataImage()
            xsdFile.setPath(XSDataString(self.maskFile))
            xsdExperiment.maskFile = xsDataResult.maskFile = xsdFile
        if self.normalizationFactor is not None:
            xsdExperiment.normalizationFactor = xsDataResult.normalizationFactor = XSDataDouble(
                self.normalizationFactor)
        if self.machineCurrent is not None:
            xsdExperiment.machineCurrent = xsDataResult.machineCurrent = XSDataDouble(
                self.machineCurrent)
        if self.storageTemperature is not None:
            xsdExperiment.storageTemperature = xsDataResult.storageTemperature = XSDataDouble(
                self.storageTemperature)
        if self.exposureTemperature is not None:
            xsdExperiment.exposureTemperature = xsDataResult.exposureTemperature = XSDataDouble(
                self.exposureTemperature)
        if self.exposureTime is not None:
            xsdExperiment.exposureTime = xsDataResult.exposureTime = XSDataTime(
                self.exposureTime)
        if self.frameNumber is not None:
            xsdExperiment.frameNumber = xsDataResult.frameNumber = XSDataInteger(
                self.frameNumber)
        if self.frameMax is not None:
            xsdExperiment.frameMax = xsDataResult.frameMax = XSDataInteger(
                self.frameMax)
        if self.timeOfFrame is not None:
            xsdExperiment.timeOfFrame = xsDataResult.timeOfFrame = XSDataTime(
                self.timeOfFrame)
        if self.code is not None:
            xsdSample.code = xsDataResult.code = XSDataString(self.code)
        if self.comments is not None:
            xsdSample.comments = xsDataResult.comments = XSDataString(
                self.comments)
        if self.concentration is not None:
            xsdSample.concentration = xsDataResult.concentration = XSDataDouble(
                self.concentration)

        xsDataResult.sample = xsdSample
        xsDataResult.experimentSetup = xsdExperiment
        self.setDataOutput(xsDataResult)
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        EDVerbose.DEBUG("*** EDPluginExecReadImageHeaderADSCv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        strAbsolutePath = os.path.abspath(strPath)
        dictHeader = self.readHeaderADSC(strPath)
        if (dictHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderADSCv10.process : error when reading header from %s" % strAbsolutePath
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            xsDataDetector.setBeamPositionX(XSDataLength(float(dictHeader[ "BEAM_CENTER_X" ])))
            xsDataDetector.setBeamPositionY(XSDataLength(float(dictHeader[ "BEAM_CENTER_Y" ])))
            xsDataDetector.setDistance(XSDataLength(float(dictHeader[ "DISTANCE"   ])))
            fPixelSize = float(dictHeader[ "PIXEL_SIZE"   ])
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSize))
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSize))
            if "TWOTHETA" in dictHeader.keys():
                xsDataDetector.setTwoTheta(XSDataAngle(float(dictHeader[ "TWOTHETA"   ])))
            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictHeader[ "HEADER_BYTES"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictHeader[ "DETECTOR_SN"   ]))
            xsDataDetector.setNumberPixelX(XSDataInteger(int(dictHeader[ "SIZE1"   ])))
            xsDataDetector.setNumberPixelY(XSDataInteger(int(dictHeader[ "SIZE2"   ])))
            xsDataDetector.setBin(XSDataString(dictHeader[ "BIN" ]))
            xsDataDetector.setDataType(XSDataString(dictHeader[ "TYPE" ]))
            xsDataDetector.setByteOrder(XSDataString(dictHeader[ "BYTE_ORDER" ]))
            if "CCD_IMAGE_SATURATION" in dictHeader.keys():
                xsDataDetector.setImageSaturation(XSDataInteger(int(dictHeader[ "CCD_IMAGE_SATURATION" ])))

            # Determine type of detector...
            iNoPixelsX = xsDataDetector.getNumberPixelX().getValue()
            iNoPixelsY = xsDataDetector.getNumberPixelY().getValue()
            if (iNoPixelsX == 2304 and iNoPixelsY == 2304):
                xsDataDetector.setName(XSDataString("ADSC Q4"))
                xsDataDetector.setType(XSDataString("q4"))
            elif (iNoPixelsX == 1152 and iNoPixelsY == 1152):
                xsDataDetector.setName(XSDataString("ADSC Q4 bin 2x2"))
                xsDataDetector.setType(XSDataString("q4-2x"))
            elif (iNoPixelsX == 4096 and iNoPixelsY == 4096):
                xsDataDetector.setName(XSDataString("ADSC Q210"))
                xsDataDetector.setType(XSDataString("q210"))
            elif (iNoPixelsX == 2048 and iNoPixelsY == 2048):
                xsDataDetector.setName(XSDataString("ADSC Q210 bin 2x2"))
                xsDataDetector.setType(XSDataString("q210-2x"))
            elif (iNoPixelsX == 6144 and iNoPixelsY == 6144):
                xsDataDetector.setName(XSDataString("ADSC Q315"))
                xsDataDetector.setType(XSDataString("q315"))
            elif (iNoPixelsX == 3072 and iNoPixelsY == 3072):
                xsDataDetector.setName(XSDataString("ADSC Q315 bin 2x2"))
                xsDataDetector.setType(XSDataString("q315-2x"))
            else:
                strErrorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginExecReadImageHeaderADSCv10.process", "Unknown detector type")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictHeader[ "WAVELENGTH" ])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictHeader[ "TIME" ])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictHeader[ "OSC_START" ])
            fOscillationWidth = float(dictHeader[ "OSC_RANGE" ])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            strRotationAxis = None
            if ("AXIS" in dictHeader.keys()):
                strRotationAxis = dictHeader[ "AXIS" ]
            elif ("OSC_AXIS" in dictHeader.keys()):
                strRotationAxis = dictHeader[ "OSC_AXIS" ]
            else:
                strErrorMessage = "EDPluginExecReadImageHeaderADSCv10.process : Neither AXIS nor OSC_AXIS header item found."
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
            xsDataGoniostat.setRotationAxis(XSDataString(strRotationAxis))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)

            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strAbsolutePath))
            xsDataImage.setDate(XSDataString(dictHeader[ "DATE" ]))
            strFileName = os.path.basename(strPath)
            iImageNumber = EDUtilsImage.getImageNumber(strFileName)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)