Exemplo n.º 1
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
        ################################################################################
        # Compare XSDataResults
        ################################################################################

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        #        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsMetadatav1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same",
                                _strExcluded="bioSaxs")

        ################################################################################
        # Compare dictionary:
        ################################################################################
        edfRef = EdfFile.EdfFile(
            xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = EdfFile.EdfFile(
            os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        ########################################################################
        # DEPRECATED PLUGIN => DEPREFCATED TESTS
        ########################################################################
        #        headerRef = edfRef.GetHeader(0)
        #        headerObt = edfObt.GetHeader(0)
        #        keysRef = headerRef.keys()
        #        keysObt = headerObt.keys()
        #        keysRef.sort()
        #        keysObt.sort()
        #        for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation", "Center_1", "Center_2", "Code", "Comments", "Concentration",
        #                    "VersionNumber",'time_of_day', ]:
        #            if key in keysObt: keysObt.remove(key)
        #            if key in keysRef: keysRef.remove(key)
        #        EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary")
        #        for key in keysRef:
        #            EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")

        ################################################################################
        # Compare images
        ################################################################################

        outputData = edfObt.GetData(0)
        referenceData = edfRef.GetData(0)
        EDAssert.arraySimilar(outputData,
                              referenceData,
                              _fAbsMaxDelta=0.1,
                              _fScaledMaxDelta=0.05,
                              _strComment="Images-data are the same")
Exemplo n.º 2
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 testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
 ################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsMetadatav1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare dictionary: 
################################################################################
        edfRef = EdfFile.EdfFile(xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        ########################################################################
        # DEPRECATED PLUGIN => DEPREFCATED TESTS
        ########################################################################
#        headerRef = edfRef.GetHeader(0)
#        headerObt = edfObt.GetHeader(0)
#        keysRef = headerRef.keys()
#        keysObt = headerObt.keys()
#        keysRef.sort()
#        keysObt.sort()
#        for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation", "Center_1", "Center_2", "Code", "Comments", "Concentration",
#                    "VersionNumber",'time_of_day', ]:
#            if key in keysObt: keysObt.remove(key)
#            if key in keysRef: keysRef.remove(key)
#        EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary")
#        for key in keysRef:
#            EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")


################################################################################
# Compare images 
################################################################################

        outputData = edfObt.GetData(0)
        referenceData = edfRef.GetData(0)
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same")
 def preProcess(self):
     """
     PreProcess of the execution test: download a set of images  from http://www.edna-site.org
     and remove any existing output file 
     """
     EDTestCasePluginExecute.preProcess(self)
     self.loadTestImage([ "bioSaxsRaw.edf", "bioSaxsMetadata.edf"])
     strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
     EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput)
     xsDataResultReference = XSDataResultBioSaxsMetadatav1_0.parseString(strExpectedOutput)
     self.outputImage = xsDataResultReference.getOutputImage().getPath().value
     EDVerbose.DEBUG("Output file is %s" % self.outputImage)
     if not os.path.isdir(os.path.dirname(self.outputImage)):
         os.makedirs(os.path.dirname(self.outputImage))
     if os.path.isfile(self.outputImage):
         EDVerbose.DEBUG(" Output Image file exists %s, I will remove it" % self.outputImage)
         os.remove(self.outputImage)
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
 ################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsMetadatav1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare dictionary
################################################################################
        edfRef = fabio.open(xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = fabio.open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        keysRef = edfRef.header_keys
        keysObt = edfObt.header_keys
        keysRef.sort()
        keysObt.sort()

        for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation" ]:
            if key in keysObt: keysObt.remove(key)
            if key in keysRef: keysRef.remove(key)
#        print edfObt.header
        EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary")
        for key in keysRef:
            EDAssert.strAlmostEqual(edfRef.header[key], edfObt.header[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")


################################################################################
# Compare images 
################################################################################

        outputData = edfObt.data
        referenceData = edfRef.data
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same")
Exemplo n.º 6
0
    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)