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([ "bioSaxsMask.edf", "bioSaxsNormalized.edf", "bioSaxsIntegrated.dat", "bioSaxsIntegrated.edf", "bioSaxsCorrected.edf"]) strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) self.integratedCurve = xsDataResultReference.getIntegratedCurve().getPath().value EDVerbose.DEBUG("Output file is %s" % self.integratedCurve) if not os.path.isdir(os.path.dirname(self.integratedCurve)): os.makedirs(os.path.dirname(self.integratedCurve)) if os.path.isfile(self.integratedCurve): EDVerbose.DEBUG(" Output Integrated Curve file exists %s, I will remove it" % self.integratedCurve) os.remove(self.integratedCurve) self.integratedImage = xsDataResultReference.getIntegratedImage().getPath().value EDVerbose.DEBUG("Output Integrated Image file is %s" % self.integratedImage) if not os.path.isdir(os.path.dirname(self.integratedImage)): os.makedirs(os.path.dirname(self.integratedImage)) if os.path.isfile(self.integratedImage): EDVerbose.DEBUG(" Output Integrated Image file exists %s, I will remove it" % self.integratedImage) os.remove(self.integratedImage) self.correctedImage = xsDataResultReference.getCorrectedImage().getPath().value EDVerbose.DEBUG("Output Corrected Image file is %s" % self.correctedImage) if not os.path.isdir(os.path.dirname(self.correctedImage)): os.makedirs(os.path.dirname(self.correctedImage)) if os.path.isfile(self.correctedImage): EDVerbose.DEBUG(" Output Corrected Image file exists %s, I will remove it" % self.correctedImage) os.remove(self.correctedImage)
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([ "bioSaxsMask.edf", "bioSaxsNormalized.edf", "bioSaxsIntegratedv1_2.dat", "bioSaxsIntegrated.edf", "bioSaxsCorrected.edf"]) strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) self.integratedCurve = xsDataResultReference.getIntegratedCurve().getPath().value EDVerbose.DEBUG("Output file is %s" % self.integratedCurve) if not os.path.isdir(os.path.dirname(self.integratedCurve)): os.makedirs(os.path.dirname(self.integratedCurve)) if os.path.isfile(self.integratedCurve): EDVerbose.DEBUG(" Output Integrated Curve file exists %s, I will remove it" % self.integratedCurve) os.remove(self.integratedCurve) self.integratedImage = xsDataResultReference.getIntegratedImage().getPath().value EDVerbose.DEBUG("Output Integrated Image file is %s" % self.integratedImage) if not os.path.isdir(os.path.dirname(self.integratedImage)): os.makedirs(os.path.dirname(self.integratedImage)) if os.path.isfile(self.integratedImage): EDVerbose.DEBUG(" Output Integrated Image file exists %s, I will remove it" % self.integratedImage) os.remove(self.integratedImage)
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare spectrum ascii Files ################################################################################ outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep) referenceData = EDUtilsFile.readFileAndParseVariables(os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_3.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep) outputData = os.linesep.join([i for i in outputData if not i.startswith("# History")]) referenceData = os.linesep.join([i for i in referenceData if not i.startswith("# History")]) EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare Ascii HEADER files ################################################################################ asciiObt = os.linesep.join([i.strip() for i in open(xsDataResultObtained.integratedCurve.path.value) if i.startswith("#") and "Raster" not in i]) asciiRef = os.linesep.join([i.strip() for i in open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) if i.startswith("#") and "Raster" not in i]) EDAssert.strAlmostEqual(asciiObt, asciiRef, _strComment="ascii header files are the same", _fRelError=0.1, _strExcluded=os.environ["USER"]) dataObt = numpy.loadtxt(xsDataResultObtained.integratedCurve.path.value) dataRef = numpy.loadtxt(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 1]), (dataRef[:, 0], dataRef[:, 1]), "data are the same", 0.6) EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 2]), (dataRef[:, 0], dataRef[:, 2]), "errors are the same", 0.6) EDVerbose.screen("Execution time for %s: %.3fs" % (plugin.getClassName(), plugin.getRunTime()))
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([ "bioSaxsMask.edf", "bioSaxsNormalized.edf", "bioSaxsIntegratedv1_3.dat", "bioSaxsCorrected.edf"]) strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) self.integratedCurve = xsDataResultReference.getIntegratedCurve().getPath().value EDVerbose.DEBUG("Output file is %s" % self.integratedCurve) if not os.path.isdir(os.path.dirname(self.integratedCurve)): os.makedirs(os.path.dirname(self.integratedCurve)) if os.path.isfile(self.integratedCurve): EDVerbose.DEBUG(" Output Integrated Curve file exists %s, I will remove it" % self.integratedCurve) os.remove(self.integratedCurve) EDUtilsParallel.initializeNbThread() # self.correctedImage = xsDataResultReference.getCorrectedImage().getPath().value # EDVerbose.DEBUG("Output Corrected Image file is %s" % self.correctedImage) # if not os.path.isdir(os.path.dirname(self.correctedImage)): # os.makedirs(os.path.dirname(self.correctedImage)) # if os.path.isfile(self.correctedImage): # EDVerbose.DEBUG(" Output Corrected Image file exists %s, I will remove it" % self.correctedImage) # os.remove(self.correctedImage) if not pyFAI.version.startswith("0.7"): EDVerbose.ERROR('pyFAI is not the right version, tested only with 0.7.2, here running version %s' % pyFAI.version)
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString( strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare Ascii HEADER files ################################################################################ asciiObt = os.linesep.join([ i.strip() for i in open(xsDataResultObtained.integratedCurve.path.value) if i.startswith("#") and "Raster" not in i ]) asciiRef = os.linesep.join([ i.strip() for i in open( os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) if i.startswith("#") and "Raster" not in i ]) EDAssert.strAlmostEqual(asciiObt, asciiRef, _strComment="ascii header files are the same", _fRelError=0.1, _strExcluded=os.environ["USER"]) dataObt = numpy.loadtxt( xsDataResultObtained.integratedCurve.path.value) dataRef = numpy.loadtxt( os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 1]), (dataRef[:, 0], dataRef[:, 1]), "data are the same", 0.6) EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 2]), (dataRef[:, 0], dataRef[:, 2]), "errors are the same", 0.6) EDVerbose.screen("Execution time for %s: %.3fs" % (plugin.getClassName(), plugin.getRunTime()))
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString( strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare spectrum ascii Files ################################################################################ outputData = open( xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep) referenceData = EDUtilsFile.readFileAndParseVariables( os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_3.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep) outputData = os.linesep.join( [i for i in outputData if not i.startswith("# History")]) referenceData = os.linesep.join( [i for i in referenceData if not i.startswith("# History")]) EDAssert.strAlmostEqual( referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")
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([ "bioSaxsMask.edf", "bioSaxsNormalized.edf", "bioSaxsIntegratedv1_3.dat", "bioSaxsCorrected.edf" ]) strExpectedOutput = self.readAndParseFile( self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsAzimutIntv1_0.parseString( strExpectedOutput) self.integratedCurve = xsDataResultReference.getIntegratedCurve( ).getPath().value EDVerbose.DEBUG("Output file is %s" % self.integratedCurve) if not os.path.isdir(os.path.dirname(self.integratedCurve)): os.makedirs(os.path.dirname(self.integratedCurve)) if os.path.isfile(self.integratedCurve): EDVerbose.DEBUG( " Output Integrated Curve file exists %s, I will remove it" % self.integratedCurve) os.remove(self.integratedCurve) EDUtilsParallel.initializeNbThread() # self.correctedImage = xsDataResultReference.getCorrectedImage().getPath().value # EDVerbose.DEBUG("Output Corrected Image file is %s" % self.correctedImage) # if not os.path.isdir(os.path.dirname(self.correctedImage)): # os.makedirs(os.path.dirname(self.correctedImage)) # if os.path.isfile(self.correctedImage): # EDVerbose.DEBUG(" Output Corrected Image file exists %s, I will remove it" % self.correctedImage) # os.remove(self.correctedImage) if not pyFAI.version.startswith("0.7"): EDVerbose.ERROR( 'pyFAI is not the right version, tested only with 0.7.2, here running version %s' % pyFAI.version)
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare spectrum ascii Files ################################################################################ outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep) referenceData = EDUtilsFile.readFileAndParseVariables(os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_2.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep) outputData = os.linesep.join([i for i in outputData if not i.startswith("# History")]) referenceData = os.linesep.join([i for i in referenceData if not i.startswith("# History")]) EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ # edfObt = EdfFile.EdfFile(xsDataResultObtained.getCorrectedImage().getPath().value) # edfRef = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsCorrected.edf")) # outputData = edfObt.GetData(0) # referenceData = edfRef.GetData(0) # EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Corrected images are the same") # headerRef = edfRef.GetHeader(0) # headerObt = edfObt.GetHeader(0) # keysRef = headerRef.keys() # keysObt = headerObt.keys() # keysRef.sort() # keysObt.sort() # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary for Corrected Images") # for key in keysRef: # EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value in Corrected %s are the same" % key, _strExcluded="bioSaxs") edfObt = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegrated.edf")) edfRef = EdfFile.EdfFile(xsDataResultObtained.getIntegratedImage().getPath().value) outputData = edfObt.GetData(0) referenceData = edfRef.GetData(0) EDAssert.arraySimilar(outputData, referenceData , _fScaledMaxDelta=0.05, _strComment="Integrated images are the same") 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", "History-1", "History-1~1"]: 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 Integrated Images") for key in keysRef: EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value in Integrated %s are the same" % key, _strExcluded="bioSaxs")
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 = XSDataResultBioSaxsAzimutIntv1_0.parseString( strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare spectrum ascii Files ################################################################################ outputData = open( xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep) referenceData = EDUtilsFile.readFileAndParseVariables( os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_1.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep) outputData = os.linesep.join([ i for i in outputData if not (i.startswith("# History") or i.startswith("# Raster")) ]) referenceData = os.linesep.join([ i for i in referenceData if not (i.startswith("# History") or i.startswith("# Raster")) ]) EDAssert.strAlmostEqual( referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ # edfObt = EdfFile.EdfFile(xsDataResultObtained.getCorrectedImage().getPath().value) # edfRef = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsCorrected.edf")) # outputData = edfObt.GetData(0) # referenceData = edfRef.GetData(0) # EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Corrected images are the same") # headerRef = edfRef.GetHeader(0) # headerObt = edfObt.GetHeader(0) # keysRef = headerRef.keys() # keysObt = headerObt.keys() # keysRef.sort() # keysObt.sort() # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary for Corrected Images") # for key in keysRef: # EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value in Corrected %s are the same" % key, _strExcluded="bioSaxs") edfObt = EdfFile.EdfFile( os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegrated.edf")) edfRef = EdfFile.EdfFile( xsDataResultObtained.getIntegratedImage().getPath().value) outputData = edfObt.GetData(0) referenceData = edfRef.GetData(0) EDAssert.arraySimilar(outputData, referenceData, _fScaledMaxDelta=0.05, _strComment="Integrated images are the same") 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", "History-1", "History-1~1", "History-2" ]: 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 Integrated Images") for key in keysRef: EDAssert.strAlmostEqual( headerRef[key], headerObt[key], _strComment="header value in Integrated %s are the same" % key, _strExcluded="bioSaxs")