예제 #1
0
 def testKillAllWorkers(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(
         self.strReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.killAllWorkers()
예제 #2
0
 def testCheckParameters(self):
     edPluginSPD = self.createPlugin()
     edStringXMLInput = EDUtilsTest.readAndParseFile(
         self.m_edStringReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(edStringXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.checkParameters()
예제 #3
0
 def testCheckParameters(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(
         self.strReferenceInputFileName, {"${EDNA_TESTIMAGES}": "toto"})
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.checkParameters()
    def testSpatialDistortion(self):
        strRefX = "spline-3-18x.edf"
        strRefY = "spline-3-18y.edf"
        self.loadTestImage([strRefX, strRefY])
        edPluginSPD = self.createPlugin()
        strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName)
        xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
        edPluginSPD.setDataInput(xsDataInputSPDCake)
        edPluginSPD.configure()
        edPluginSPD.getInputParameter()
        ########################################################################
        # Enforce some values
        ########################################################################
        edPluginSPD.dictGeometry["SpatialDistortionFile"] = os.path.join(self.getTestsDataImagesHome(), "frelon_spline_file_to_correct_SPD.spline")
        edPluginSPD.dictGeometry["TiltRotation"] = 18
        edPluginSPD.dictGeometry["AngleOfTilt"] = 3
        spline = Spline()
        spline.read(edPluginSPD.dictGeometry["SpatialDistortionFile"])
        edPluginSPD.dictGeometry["PixelSizeX"], edPluginSPD.dictGeometry["PixelSizeY"] = spline.getPixelSize()
        edPluginSPD.createDisplacementMatrix(spline)
        edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())

        refX = fabio.openimage.openimage(os.path.join(self.getTestsDataImagesHome(), strRefX)).data
        obtX = fabio.openimage.openimage(os.path.join(edPluginSPD.getWorkingDirectory(), "frelon_spline_file_to_correct_SPD-tilted-x.edf")).data
        refY = fabio.openimage.openimage(os.path.join(self.getTestsDataImagesHome(), strRefY)).data
        obtY = fabio.openimage.openimage(os.path.join(edPluginSPD.getWorkingDirectory(), "frelon_spline_file_to_correct_SPD-tilted-y.edf")).data

#        print edPluginSPD.dictGeometry
        EDAssert.arraySimilar(obtX, refX , _fAbsMaxDelta=0.1, _strComment="X displacement Matrix is the same")
        EDAssert.arraySimilar(obtY, refY , _fAbsMaxDelta=0.1, _strComment="Y displacement Matrix is the same")
 def testCleanDispMat(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName, EDUtilsPath.getDictOfPaths())
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     if EDVerbose.isVerboseDebug():
          edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())
     else:
         edPluginSPD.cleanDispMat()
 def testPopulateXSDataInputSPDCake(self):
     edPluginControlID11 = self.createPlugin()
     xsDataInputSPDCake = edPluginControlID11.populateXSDataInputSPDCake(self.dictID11Reference)
     strDataPath = self.getPluginTestsDataHome()
     strReferenceFile = "XSDataInputSPDCake_fromDict.xml"
     strPath = os.path.join(strDataPath, strReferenceFile)
     xsDataInputSPDCakeReference = XSDataInputSPDCake.parseString(self.readAndParseFile(strPath))
     xsDataInputSPDCakeReference.setDeleteCorImg(XSDataBoolean(not (EDVerbose.isVerboseDebug())))
     EDAssert.equal(xsDataInputSPDCakeReference.marshal(), xsDataInputSPDCake.marshal())
 def testCleanDispMat(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsTest.readAndParseFile(self.strReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     if EDVerbose.isVerboseDebug():
          edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())
     else:
         edPluginSPD.cleanDispMat()
예제 #8
0
 def testCleanDispMat(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(
         self.strReferenceInputFileName, EDUtilsPath.getDictOfPaths())
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     if EDVerbose.isVerboseDebug():
         edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())
     else:
         edPluginSPD.cleanDispMat()
 def testPopulateXSDataInputSPDCake(self):
     edPluginControlID11 = self.createPlugin()
     xsDataInputSPDCake = edPluginControlID11.populateXSDataInputSPDCake(
         self.dictID11Reference)
     strDataPath = self.getPluginTestsDataHome()
     strReferenceFile = "XSDataInputSPDCake_fromDict.xml"
     strPath = os.path.join(strDataPath, strReferenceFile)
     xsDataInputSPDCakeReference = XSDataInputSPDCake.parseString(
         self.readAndParseFile(strPath))
     xsDataInputSPDCakeReference.setDeleteCorImg(
         XSDataBoolean(not (EDVerbose.isVerboseDebug())))
     EDAssert.equal(xsDataInputSPDCakeReference.marshal(),
                    xsDataInputSPDCake.marshal())
예제 #10
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlID11v1_0.preProcess")
        # Read the parameter file
        if self.getDataInput().getCorrectMask() is not None:
            self.bCorrectMask = bool(
                self.getDataInput().getCorrectMask().getValue())

        strPathToParameterFile = self.getDataInput().getParameterFile(
        ).getPath().getValue()

        if os.path.exists(strPathToParameterFile):
            EDPluginControlID11v1_0.__semaphore.acquire()
            if strPathToParameterFile in EDPluginControlID11v1_0.__dictParamID11XSD:
                self.__dictID11, strInputSPDCake = EDPluginControlID11v1_0.__dictParamID11XSD[
                    strPathToParameterFile]
                self.__xsDataInputSPDCake = XSDataInputSPDCake.parseString(
                    strInputSPDCake)
            else:
                self.parseParameterFiles(strPathToParameterFile)
                self.__xsDataInputSPDCake = self.populateXSDataInputSPDCake()
                EDPluginControlID11v1_0.__dictParamID11XSD[
                    strPathToParameterFile] = (
                        self.__dictID11, self.__xsDataInputSPDCake.marshal())
            EDPluginControlID11v1_0.__semaphore.release()
            # Load the execution plugin
            self.synchronizeOn()
            self.__edPluginWaitMultipleFile = self.loadPlugin(
                self.__strControlledPluginWait)
            self.synchronizeOff()
            #            self.__edPluginEDF = self.loadPlugin(self.__strControlledPluginEDF)
            # Paths to the data files
            self.__xsDataInputWaitMultipleFile = XSDataInputWaitMultiFile()
            for xsDataFile in self.getDataInput().getDataFile():
                self.__xsDataInputWaitMultipleFile.addExpectedFile(xsDataFile)
            # we are expecting unsigned int
            self.__xsDataInputWaitMultipleFile.setExpectedSize(
                XSDataInteger(512 + 2 * int(self.__dictID11["DIM1_DATA"]) *
                              int(self.__dictID11["DIM2_DATA"])))
            self.__edPluginWaitMultipleFile.setDataInput(
                self.__xsDataInputWaitMultipleFile)

        else:
            self.ERROR("Path to parameter file does not exist: %s" %
                       strPathToParameterFile)
            self.setFailure()
        xsdOutputDir = self.getDataInput().getOutputdir()
        if xsdOutputDir is not None:
            self.__xsDataInputSPDCake.setOutputDir(xsdOutputDir)
            self.__dictID11["output_dir"] = xsdOutputDir.getPath().getValue()
예제 #11
0
    def testSpatialDistortion(self):
        strRefX = "spline-3-18x.edf"
        strRefY = "spline-3-18y.edf"
        self.loadTestImage([strRefX, strRefY])
        edPluginSPD = self.createPlugin()
        strXMLInput = EDUtilsFile.readFileAndParseVariables(
            self.strReferenceInputFileName)
        xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
        edPluginSPD.setDataInput(xsDataInputSPDCake)
        edPluginSPD.configure()
        edPluginSPD.getInputParameter()
        ########################################################################
        # Enforce some values
        ########################################################################
        edPluginSPD.dictGeometry["SpatialDistortionFile"] = os.path.join(
            self.getTestsDataImagesHome(),
            "frelon_spline_file_to_correct_SPD.spline")
        edPluginSPD.dictGeometry["TiltRotation"] = 18
        edPluginSPD.dictGeometry["AngleOfTilt"] = 3
        spline = Spline()
        spline.read(edPluginSPD.dictGeometry["SpatialDistortionFile"])
        edPluginSPD.dictGeometry["PixelSizeX"], edPluginSPD.dictGeometry[
            "PixelSizeY"] = spline.getPixelSize()
        edPluginSPD.createDisplacementMatrix(spline)
        edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())

        refX = fabio.openimage.openimage(
            os.path.join(self.getTestsDataImagesHome(), strRefX)).data
        obtX = fabio.openimage.openimage(
            os.path.join(
                edPluginSPD.getWorkingDirectory(),
                "frelon_spline_file_to_correct_SPD-tilted-x.edf")).data
        refY = fabio.openimage.openimage(
            os.path.join(self.getTestsDataImagesHome(), strRefY)).data
        obtY = fabio.openimage.openimage(
            os.path.join(
                edPluginSPD.getWorkingDirectory(),
                "frelon_spline_file_to_correct_SPD-tilted-y.edf")).data

        #        print edPluginSPD.dictGeometry
        EDAssert.arraySimilar(obtX,
                              refX,
                              _fAbsMaxDelta=0.1,
                              _strComment="X displacement Matrix is the same")
        EDAssert.arraySimilar(obtY,
                              refY,
                              _fAbsMaxDelta=0.1,
                              _strComment="Y displacement Matrix is the same")
 def testGenerateSPDCommand(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName, EDUtilsPath.getDictOfPaths())
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.configure()
     edPluginSPD.getInputParameter()
     #edPluginSPD.preProcess()
     edPluginSPD.generateSPDCommand()
     EDVerbose.screen("SPD configuration:\n%s" % edPluginSPD.getSPDConfig())
     if EDVerbose.isVerboseDebug():
         expected = """off_1=0 off_2=0 verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #"do_distortion=2 off_1=0 off_2=0  verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     else:
         expected = """off_1=0 off_2=0 verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #do_distortion=2 off_1=0 off_2=0  verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     EDAssert.equal(edPluginSPD.getSPDConfig(), expected)
예제 #13
0
    def testGenerateSPDCommand(self):
        edPluginSPD = self.createPlugin()
        edStringXMLInput = EDUtilsTest.readAndParseFile(self.m_edStringReferenceInputFileName)
        xsDataInputSPDCake = XSDataInputSPDCake.parseString(edStringXMLInput)
        edPluginSPD.setDataInput(xsDataInputSPDCake)
        edPluginSPD.configure()
        edPluginSPD.getInputParameter()
        #edPluginSPD.preProcess()
        edPluginSPD.generateSPDCommand()
        EDVerbose.screen("SPD configuration:\n %s" % edPluginSPD.getSPDConfig())
        if EDVerbose.isVerboseDebug():
            expected = """off_1=0 off_2=0 verbose=2 src_ext=.edf wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0 cor_ext=.cor azim_int=1 azim_pass=0 azim_ext=.cor azim_r_num=1489"""
#            """do_distortion=2 off_1=0 off_2=0  verbose=2 src_ext=.edf wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0 cor_ext=.cor azim_int=1 azim_pass=0 azim_ext=.cor azim_r_num=1489"""
        else:
            expected = """off_1=0 off_2=0 verbose=0 src_ext=.edf wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0 cor_ext=.cor azim_int=1 azim_pass=0 azim_ext=.cor azim_r_num=1489"""
#            """do_distortion=2 off_1=0 off_2=0  verbose=0 src_ext=.edf wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0 cor_ext=.cor azim_int=1 azim_pass=0 azim_ext=.cor azim_r_num=1489"""

        EDAssert.equal(edPluginSPD.getSPDConfig(), expected)
예제 #14
0
 def testGenerateSPDCommand(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(
         self.strReferenceInputFileName, EDUtilsPath.getDictOfPaths())
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.configure()
     edPluginSPD.getInputParameter()
     #edPluginSPD.preProcess()
     edPluginSPD.generateSPDCommand()
     EDVerbose.screen("SPD configuration:\n%s" % edPluginSPD.getSPDConfig())
     if EDVerbose.isVerboseDebug():
         expected = """off_1=0 off_2=0 verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #"do_distortion=2 off_1=0 off_2=0  verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     else:
         expected = """off_1=0 off_2=0 verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #do_distortion=2 off_1=0 off_2=0  verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     EDAssert.equal(edPluginSPD.getSPDConfig(), expected)
예제 #15
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        self.DEBUG("EDPluginControlID11v1_0.preProcess")
        # Read the parameter file
        if self.getDataInput().getCorrectMask() is not None:
            self.bCorrectMask = bool(self.getDataInput().getCorrectMask().getValue())

        strPathToParameterFile = self.getDataInput().getParameterFile().getPath().getValue()

        if os.path.exists(strPathToParameterFile):
            EDPluginControlID11v1_0.__semaphore.acquire()
            if strPathToParameterFile in EDPluginControlID11v1_0.__dictParamID11XSD:
                self.__dictID11, strInputSPDCake = EDPluginControlID11v1_0.__dictParamID11XSD[strPathToParameterFile]
                self.__xsDataInputSPDCake = XSDataInputSPDCake.parseString(strInputSPDCake)
            else:
                self.parseParameterFiles(strPathToParameterFile)
                self.__xsDataInputSPDCake = self.populateXSDataInputSPDCake()
                EDPluginControlID11v1_0.__dictParamID11XSD[strPathToParameterFile] = (self.__dictID11, self.__xsDataInputSPDCake.marshal())
            EDPluginControlID11v1_0.__semaphore.release()
            # Load the execution plugin
            self.synchronizeOn()
            self.__edPluginWaitMultipleFile = self.loadPlugin(self.__strControlledPluginWait)
            self.synchronizeOff()
#            self.__edPluginEDF = self.loadPlugin(self.__strControlledPluginEDF)
            # Paths to the data files
            self.__xsDataInputWaitMultipleFile = XSDataInputWaitMultiFile()
            for xsDataFile in self.getDataInput().getDataFile():
                self.__xsDataInputWaitMultipleFile.addExpectedFile(xsDataFile)
            # we are expecting unsigned int 
            self.__xsDataInputWaitMultipleFile.setExpectedSize(XSDataInteger(512 + 2 * int(self.__dictID11["DIM1_DATA"]) * int(self.__dictID11["DIM2_DATA"])))
            self.__edPluginWaitMultipleFile.setDataInput(self.__xsDataInputWaitMultipleFile)

        else:
            self.ERROR("Path to parameter file does not exist: %s" % strPathToParameterFile)
            self.setFailure()
        xsdOutputDir = self.getDataInput().getOutputdir()
        if xsdOutputDir is not None:
            self.__xsDataInputSPDCake.setOutputDir(xsdOutputDir)
            self.__dictID11["output_dir"] = xsdOutputDir.getPath().getValue()
 def testCleanDispMat(self):
     edPluginSPD = self.createPlugin()
     edStringXMLInput = EDUtilsTest.readAndParseFile(self.m_edStringReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(edStringXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.cleanDispMat()
 def testKillAllWorkers(self):
     edPluginSPD = self.createPlugin()
     edStringXMLInput = EDUtilsTest.readAndParseFile(self.m_edStringReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(edStringXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.killAllWorkers()
 def testKillAllWorkers(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.killAllWorkers()
 def testCheckParameters(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName, {"${EDNA_TESTIMAGES}":"toto"})
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.checkParameters()
 def testCheckParameters(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsTest.readAndParseFile(self.strReferenceInputFileName)
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.checkParameters()