Ejemplo n.º 1
0
 def testCheckParameters(self):
     strPath = os.path.join(self.getPluginTestsDataHome(),
                            "XSDataInputWriteNexusFile_reference.xml")
     xsDataInputWriteNexusFile = XSDataInputWriteNexusFile.parseFile(
         strPath)
     edPluginExecWriteNexusFile = self.createPlugin()
     edPluginExecWriteNexusFile.setDataInput(xsDataInputWriteNexusFile)
     edPluginExecWriteNexusFile.checkParameters()
Ejemplo n.º 2
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
 def testCheckParameters(self):
     strPath = os.path.join(self.getPluginTestsDataHome(), "XSDataInputWriteNexusFile_reference.xml")
     xsDataInputWriteNexusFile = XSDataInputWriteNexusFile.parseFile(strPath)
     edPluginExecWriteNexusFile = self.createPlugin()
     edPluginExecWriteNexusFile.setDataInput(xsDataInputWriteNexusFile)
     edPluginExecWriteNexusFile.checkParameters()
Ejemplo n.º 4
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