コード例 #1
0
 def unitTestArraytoXsdNoNumpy(self):
     """
     test the execution of detectNumberOfCPUs
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsArray.unitTestArraytoXsdNoNumpy")
     EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                             EDUtilsArray.arrayToXSData(self.arrayNumpy, _bForceNoNumpy=True).marshal(),
                             _strComment="XSDataArray from (numpyArray) are the same (forced No Numpy)")
     EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                             EDUtilsArray.arrayToXSData(self.arrayNoNumpy, _bForceNoNumpy=True).marshal(),
                             _strComment="XSDataArray from (list of lists) are the same (forced No Numpy)")
コード例 #2
0
 def unitTestArraytoXsd(self):
     """
     test the execution of xsDataToArray static method
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsArray.unitTestArraytoXsd")
     if numpy is not None:
         EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNumpy).marshal(),
                                 EDUtilsArray.arrayToXSData(self.arrayNumpy).marshal(),
                                 _strComment="XSDataArray from (numpyArray) are the same")
     else:
         EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                                 EDUtilsArray.arrayToXSData(self.arrayNumpy).marshal(),
                                 _strComment="XSDataArray from (Non numpy Array) are the same")
コード例 #3
0
    def __init__(self, _strTestName=None):
        EDTestCase.__init__(self, "EDUtilsArray")
        self.strXSDataArrayNumpy = """<?xml version="1.0" ?>
<XSDataArray>
        <shape>10</shape>
        <shape>10</shape>
        <size>100</size>
        <dtype>uint8</dtype>
        <data>AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiYw==</data>
        <coding><value>base64</value></coding>
        <md5sum><value>7acedd1a84a4cfcb6e7a16003242945e</value></md5sum>
</XSDataArray>"""
        self.xsDataArrayNumpy = XSDataArray.parseString(
            self.strXSDataArrayNumpy)
        self.strXSDataArrayNoNumpy = """<?xml version="1.0" ?>
<XSDataArray>
        <shape>10</shape>
        <shape>10</shape>
        <size>100</size>
        <dtype>int64</dtype>
        <data>AAAAAAAAAAABAAAAAAAAAAIAAAAAAAAAAwAAAAAAAAAEAAAAAAAAAAUAAAAAAAAABgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAACQAAAAAAAAAKAAAAAAAAAAsAAAAAAAAADAAAAAAAAAANAAAAAAAAAA4AAAAAAAAADwAAAAAAAAAQAAAAAAAAABEAAAAAAAAAEgAAAAAAAAATAAAAAAAAABQAAAAAAAAAFQAAAAAAAAAWAAAAAAAAABcAAAAAAAAAGAAAAAAAAAAZAAAAAAAAABoAAAAAAAAAGwAAAAAAAAAcAAAAAAAAAB0AAAAAAAAAHgAAAAAAAAAfAAAAAAAAACAAAAAAAAAAIQAAAAAAAAAiAAAAAAAAACMAAAAAAAAAJAAAAAAAAAAlAAAAAAAAACYAAAAAAAAAJwAAAAAAAAAoAAAAAAAAACkAAAAAAAAAKgAAAAAAAAArAAAAAAAAACwAAAAAAAAALQAAAAAAAAAuAAAAAAAAAC8AAAAAAAAAMAAAAAAAAAAxAAAAAAAAADIAAAAAAAAAMwAAAAAAAAA0AAAAAAAAADUAAAAAAAAANgAAAAAAAAA3AAAAAAAAADgAAAAAAAAAOQAAAAAAAAA6AAAAAAAAADsAAAAAAAAAPAAAAAAAAAA9AAAAAAAAAD4AAAAAAAAAPwAAAAAAAABAAAAAAAAAAEEAAAAAAAAAQgAAAAAAAABDAAAAAAAAAEQAAAAAAAAARQAAAAAAAABGAAAAAAAAAEcAAAAAAAAASAAAAAAAAABJAAAAAAAAAEoAAAAAAAAASwAAAAAAAABMAAAAAAAAAE0AAAAAAAAATgAAAAAAAABPAAAAAAAAAFAAAAAAAAAAUQAAAAAAAABSAAAAAAAAAFMAAAAAAAAAVAAAAAAAAABVAAAAAAAAAFYAAAAAAAAAVwAAAAAAAABYAAAAAAAAAFkAAAAAAAAAWgAAAAAAAABbAAAAAAAAAFwAAAAAAAAAXQAAAAAAAABeAAAAAAAAAF8AAAAAAAAAYAAAAAAAAABhAAAAAAAAAGIAAAAAAAAAYwAAAAAAAAA=</data>
        <coding><value>base64</value></coding>
        <md5sum><value>13e5d157161f66d98fe0b75ce51c982b</value></md5sum>
</XSDataArray>"""

        self.arrayNoNumpy = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                             [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
                             [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
                             [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
                             [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
                             [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
                             [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
                             [70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
                             [80, 81, 82, 83, 84, 85, 86, 87, 88, 89],
                             [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]]
        if numpy is not None:
            self.arrayNumpy = numpy.arange(100, dtype="uint8").reshape(
                (10, 10))
        else:
            self.arrayNumpy = self.arrayNoNumpy
コード例 #4
0
    def __init__(self, _strTestName=None):
        EDTestCase.__init__(self, "EDUtilsArray")
        self.strXSDataArrayNumpy = """<?xml version="1.0" ?>
<XSDataArray>
        <shape>10</shape>
        <shape>10</shape>
        <size>100</size>
        <dtype>uint8</dtype>
        <data>AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiYw==</data>
        <coding><value>base64</value></coding>
        <md5sum><value>7acedd1a84a4cfcb6e7a16003242945e</value></md5sum>
</XSDataArray>"""
        self.xsDataArrayNumpy = XSDataArray.parseString(self.strXSDataArrayNumpy)
        self.strXSDataArrayNoNumpy = """<?xml version="1.0" ?>
<XSDataArray>
        <shape>10</shape>
        <shape>10</shape>
        <size>100</size>
        <dtype>int64</dtype>
        <data>AAAAAAAAAAABAAAAAAAAAAIAAAAAAAAAAwAAAAAAAAAEAAAAAAAAAAUAAAAAAAAABgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAACQAAAAAAAAAKAAAAAAAAAAsAAAAAAAAADAAAAAAAAAANAAAAAAAAAA4AAAAAAAAADwAAAAAAAAAQAAAAAAAAABEAAAAAAAAAEgAAAAAAAAATAAAAAAAAABQAAAAAAAAAFQAAAAAAAAAWAAAAAAAAABcAAAAAAAAAGAAAAAAAAAAZAAAAAAAAABoAAAAAAAAAGwAAAAAAAAAcAAAAAAAAAB0AAAAAAAAAHgAAAAAAAAAfAAAAAAAAACAAAAAAAAAAIQAAAAAAAAAiAAAAAAAAACMAAAAAAAAAJAAAAAAAAAAlAAAAAAAAACYAAAAAAAAAJwAAAAAAAAAoAAAAAAAAACkAAAAAAAAAKgAAAAAAAAArAAAAAAAAACwAAAAAAAAALQAAAAAAAAAuAAAAAAAAAC8AAAAAAAAAMAAAAAAAAAAxAAAAAAAAADIAAAAAAAAAMwAAAAAAAAA0AAAAAAAAADUAAAAAAAAANgAAAAAAAAA3AAAAAAAAADgAAAAAAAAAOQAAAAAAAAA6AAAAAAAAADsAAAAAAAAAPAAAAAAAAAA9AAAAAAAAAD4AAAAAAAAAPwAAAAAAAABAAAAAAAAAAEEAAAAAAAAAQgAAAAAAAABDAAAAAAAAAEQAAAAAAAAARQAAAAAAAABGAAAAAAAAAEcAAAAAAAAASAAAAAAAAABJAAAAAAAAAEoAAAAAAAAASwAAAAAAAABMAAAAAAAAAE0AAAAAAAAATgAAAAAAAABPAAAAAAAAAFAAAAAAAAAAUQAAAAAAAABSAAAAAAAAAFMAAAAAAAAAVAAAAAAAAABVAAAAAAAAAFYAAAAAAAAAVwAAAAAAAABYAAAAAAAAAFkAAAAAAAAAWgAAAAAAAABbAAAAAAAAAFwAAAAAAAAAXQAAAAAAAABeAAAAAAAAAF8AAAAAAAAAYAAAAAAAAABhAAAAAAAAAGIAAAAAAAAAYwAAAAAAAAA=</data>
        <coding><value>base64</value></coding>
        <md5sum><value>13e5d157161f66d98fe0b75ce51c982b</value></md5sum>
</XSDataArray>"""

        self.arrayNoNumpy = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
 [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
 [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
 [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
 [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
 [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
 [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
 [70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
 [80, 81, 82, 83, 84, 85, 86, 87, 88, 89],
 [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]]
        if numpy is not None:
            self.arrayNumpy = numpy.arange(100, dtype="uint8").reshape((10, 10))
        else:
            self.arrayNumpy = self.arrayNoNumpy
コード例 #5
0
 def process(self, _edObject=None):
     EDPluginControl.process(self)
     self.DEBUG("EDPluginControlTRExafsv1_0.process")
     self.checkMandatoryParameters(self.dataInput, "Data Input is None")
     # Load from disk if necessary
     if self.dataInput.energy is None:
         if self.dataInput.pathToEnergyArray is None:
             strErrorMessage = "Data Input 'energy' is None"
             self.addErrorMessage(strErrorMessage)
             self.setFailure()
             return
         else:
             strXmlArray = EDUtilsFile.readFile(
                 self.dataInput.pathToEnergyArray.path.value)
             self.dataInput.energy = XSDataArray.parseString(strXmlArray)
     if self.dataInput.dataArray is None:
         if self.dataInput.pathToDataArray is None:
             strErrorMessage = "Data Input 'dataArray' is None"
             self.addErrorMessage(strErrorMessage)
             self.setFailure()
             return
         else:
             strXmlArray = EDUtilsFile.readFile(
                 self.dataInput.pathToDataArray.path.value)
             self.dataInput.dataArray = XSDataArray.parseString(strXmlArray)
     self.checkMandatoryParameters(self.dataInput.dataArray,
                                   "Data Input 'dataArray' is None")
     #
     numpyDataArray = EDUtilsArray.xsDataToArray(self.dataInput.dataArray)
     numpyEnergyCalibrationArray = EDUtilsArray.xsDataToArray(
         self.dataInput.energy)
     numpySpectraArray = numpy.arange((numpyDataArray.shape[1]))
     # Launch Jesf
     listEdPluginExecJesf = self.launchJesfPlugins(
         numpyDataArray, numpyEnergyCalibrationArray)
     # Create nexus file
     xsDataInputWriteNexusFile = XSDataInputWriteNexusFile()
     xsDataInputWriteNexusFile.instrument = self.dataInput.instrument
     xsDataInputWriteNexusFile.outputFileName = self.dataInput.nexusFileName
     # Raw data
     xsDataNexusArrayGroupRawData = self.createNexusGroup(
         _numpyDataArray=numpyDataArray,
         _groupTitle="Raw data",
         _groupLongName="Raw data",
         _numpyXAxisDataArray=numpyEnergyCalibrationArray,
         _xAxisTitle="e",
         _xAxisLongName="Energy",
         _xAxisUnit="kev",
         _numpyYAxisDataArray=numpySpectraArray,
         _yAxisTitle="n",
         _yAxisLongName="Spectra",
         _yAxisUnit="")
     xsDataInputWriteNexusFile.addNexusGroup(xsDataNexusArrayGroupRawData)
     # Create result data arrays
     dictResultArrays = self.createResultArrays(listEdPluginExecJesf)
     # Add results arrays to nexus file
     self.addResultArraysToNexusFile(dictResultArrays,
                                     xsDataInputWriteNexusFile)
     #
     edPluginExecWriteNexusData = self.loadPlugin(
         self.strWriteNexusFilePluginName)
     edPluginExecWriteNexusData.dataInput = xsDataInputWriteNexusFile
     edPluginExecWriteNexusData.executeSynchronous()
     xsDataResultTRExafs = XSDataResultTRExafs()
     if not edPluginExecWriteNexusData.isFailure():
         xsDataNexusFile = edPluginExecWriteNexusData.dataOutput.outputFilePath
         xsDataResultTRExafs.nexusFile = xsDataNexusFile
     #
     self.dataOutput = xsDataResultTRExafs
コード例 #6
0
 def process(self, _edObject = None):
     EDPluginControl.process(self)
     self.DEBUG("EDPluginControlTRExafsv1_0.process")
     self.checkMandatoryParameters(self.dataInput, "Data Input is None")
     # Load from disk if necessary
     if self.dataInput.energy is None:
         if self.dataInput.pathToEnergyArray is None:
             strErrorMessage = "Data Input 'energy' is None"
             self.addErrorMessage(strErrorMessage)
             self.setFailure()
             return
         else:
             strXmlArray = EDUtilsFile.readFile(self.dataInput.pathToEnergyArray.path.value)
             self.dataInput.energy = XSDataArray.parseString(strXmlArray)
     if self.dataInput.dataArray is None:
         if self.dataInput.pathToDataArray is None:
             strErrorMessage = "Data Input 'dataArray' is None"
             self.addErrorMessage(strErrorMessage)
             self.setFailure()
             return
         else:
             strXmlArray = EDUtilsFile.readFile(self.dataInput.pathToDataArray.path.value)
             self.dataInput.dataArray = XSDataArray.parseString(strXmlArray)
     self.checkMandatoryParameters(self.dataInput.dataArray, "Data Input 'dataArray' is None")
     #
     numpyDataArray = EDUtilsArray.xsDataToArray(self.dataInput.dataArray)
     numpyEnergyCalibrationArray = EDUtilsArray.xsDataToArray(self.dataInput.energy)
     numpySpectraArray = numpy.arange((numpyDataArray.shape[0]))
     # Launch Jesf
     listEdPluginExecJesf = self.launchJesfPlugins(numpyDataArray, numpyEnergyCalibrationArray)
     # Create nexus file
     xsDataInputWriteNexusFile = XSDataInputWriteNexusFile()
     xsDataInputWriteNexusFile.instrument = self.dataInput.instrument
     xsDataInputWriteNexusFile.outputFileName = self.dataInput.nexusFileName
     # Raw data
     xsDataNexusArrayGroupRawData = self.createNexusGroup(
         _numpyDataArray = numpyDataArray, 
         _groupTitle = "Raw data", 
         _groupLongName = "Raw data", 
         _numpyXAxisDataArray = numpyEnergyCalibrationArray, 
         _xAxisTitle = "e", 
         _xAxisLongName = "Energy", 
         _xAxisUnit = "kev", 
         _numpyYAxisDataArray = numpySpectraArray, 
         _yAxisTitle = "n", 
         _yAxisLongName = "Spectra", 
         _yAxisUnit = "")
     xsDataInputWriteNexusFile.addNexusGroup(xsDataNexusArrayGroupRawData)
     # Create result data arrays
     dictResultArrays = self.createResultArrays(listEdPluginExecJesf)
     # Add results arrays to nexus file
     self.addResultArraysToNexusFile(dictResultArrays, xsDataInputWriteNexusFile)
     # 
     edPluginExecWriteNexusData = self.loadPlugin(self.strWriteNexusFilePluginName)
     edPluginExecWriteNexusData.dataInput = xsDataInputWriteNexusFile
     edPluginExecWriteNexusData.executeSynchronous()
     xsDataResultTRExafs = XSDataResultTRExafs()
     if not edPluginExecWriteNexusData.isFailure():
         xsDataNexusFile =  edPluginExecWriteNexusData.dataOutput.outputFilePath
         xsDataResultTRExafs.nexusFile = xsDataNexusFile
     #
     self.dataOutput = xsDataResultTRExafs