예제 #1
0
 def getInfo(self):
     text = ""
     text += "<nobr><H2><FONT color=#0000cc>"
     text += "Computed File :&nbsp;"
     text += "</FONT>"
     text += "<FONT color=#000000>"
     if self.fitfile is not None:
         if os.path.basename(self.fitfile) == self.fitfile:
             text += "<b><I>%s</I></b>" % (os.getcwd() + "/" + self.fitfile)
         else:
             text += "<b><I>%s</I></b>" % (self.fitfile)
     else:
         text += "<b><I>%s</I></b>" % (self.outdir + "/" + self.outfile +
                                       ".fit")
         #and I have to generate it!!!!!!!!!!!!"
         d = ConfigDict.ConfigDict(self.fitresult)
         try:
             os.remove(self.outdir + "/" + self.outfile + ".fit")
         except:
             pass
         if self.concentrations is not None:
             d['concentrations'] = self.concentrations
         d.write(self.outdir + "/" + self.outfile + ".fit")
     text += "</FONT>"
     text += "</H2>"
     text += "</nobr>"
     text += "<LEFT>"
     text += "<TABLE border=0>"
     text += "<TR><TD><SPACER TYPE=BLOCK WIDTH=50></TD><TD>"
     text += "<TABLE border=0 cellpadding=1 cellspacing=2>"
     text += "  <TR><TH ALIGN=LEFT>Source : &nbsp;</TH><TD ALIGN=LEFT>%s</TD></TR>" % (
         self.sourcename)
     text += "  <TR><TH ALIGN=LEFT>Selection : &nbsp;</TH><TD ALIGN=LEFT>%s</TD></TR>" % (
         self.selection)
     text += "  <TR><TH ALIGN=LEFT>Parameters : &nbsp;</TH><TD ALIGN=LEFT>"
     d = ConfigDict.ConfigDict(self.fitresult['result']['config'])
     try:
         os.remove(self.outdir + "/" + self.outfile + ".txt")
     except:
         pass
     d.write(self.outdir + "/" + self.outfile + ".txt")
     text += "<a HREF=" "%s" ">%s</a>" % (self.outfile + ".txt",
                                          self.outfile + ".txt")
     text += "</TD></TR>"
     """
     text+= "  <TR><TH ALIGN=RIGHT>Source : </TH><TD ALIGN=LEFT>%s</TD>"%(self.sourcename)
     text+= "  <TH ALIGN=RIGHT>Selection : </TH><TD ALIGN=LEFT>%s</TD></TR>"%(self.selection)
     keys= [ key for key in info.keys() if key not in ['paramfile', 'peakfile'] ]
     for idx in range(0, len(keys), 2):
         text+= "  <TR><TH ALIGN=RIGHT>%s : </TH><TD ALIGN=LEFT>%s</TD>"%(keys[idx], info[keys[idx]])
         if idx+1<len(keys):
             text+= "  <TH ALIGN=RIGHT>%s : </TH><TD ALIGN=LEFT>%s</TD></TR>"%(keys[idx+1], info[keys[idx+1]])
         else:
             text+= "  <TD COLSPAN=2></TD></TR>"
     """
     text += "</TABLE>"
     text += "</TD></TR></TABLE>"
     text += "</LEFT>"
     return text
예제 #2
0
    def testConfigDictIO(self):
        # create a dictionary
        from PyMca5.PyMcaIO import ConfigDict
        testDict = {}
        testDict['simple_types'] = {}
        testDict['simple_types']['float'] = 1.0
        testDict['simple_types']['int'] = 1
        testDict['simple_types']['string'] = "Hello World"
        testDict['simple_types']['string_with_1'] = "Hello World %"
        testDict['simple_types']['string_with_2'] = "Hello World %%"
        testDict['containers'] = {}
        testDict['containers']['list'] = [-1, 'string', 3.0]
        if ConfigDict.USE_NUMPY:
            import numpy
            testDict['containers']['array'] = numpy.array([1.0, 2.0, 3.0])
        testDict['containers']['dict'] = {'key1': 'Hello World', 'key2': 2.0}

        tmpFile = tempfile.mkstemp(text=False)
        os.close(tmpFile[0])
        self._tmpFileName = tmpFile[1]

        writeInstance = ConfigDict.ConfigDict(initdict=testDict)
        writeInstance.write(self._tmpFileName)

        #read the data back
        readInstance = ConfigDict.ConfigDict()
        readInstance.read(self._tmpFileName)

        # get read key list
        testDictKeys = list(testDict.keys())
        readKeys = list(readInstance.keys())
        self.assertTrue(
            len(readKeys) == len(testDictKeys),
            "Number of read keys not equal to number of written keys")

        topKey = 'simple_types'
        for key in testDict[topKey]:
            original = testDict[topKey][key]
            read = readInstance[topKey][key]
            self.assertTrue(read == original,
                            "Read <%s> instead of <%s>" % (read, original))

        topKey = 'containers'
        for key in testDict[topKey]:
            original = testDict[topKey][key]
            read = readInstance[topKey][key]
            if key == 'array':
                self.assertTrue(read.all() == original.all(),
                                "Read <%s> instead of <%s>" % (read, original))
            else:
                self.assertTrue(read == original,
                                "Read <%s> instead of <%s>" % (read, original))
예제 #3
0
 def save(self, filename):
     d= ConfigDict.ConfigDict()
     d['ROI'] = {}
     d['ROI'] = {'roilist': self.mcaROITable.roilist * 1,
                 'roidict':{}}
     d['ROI']['roidict'].update(self.mcaROITable.roidict)
     d.write(filename)
예제 #4
0
 def loadfrompymca(self, filename=None, config=None):
     if filename is not None:
         fconfig = ConfigDict.ConfigDict()
         fconfig.read(filename)
         self.mcafit.configure(fconfig)
     if config is not None:
         self.mcafit.configure(config)
예제 #5
0
파일: XRFMCHelper.py 프로젝트: gbzan/pymca
def getBasicSubprocessCommand(fitFile, outputDir=None, xmimsim_pymca=None):
     ddict = getOutputFileNames(fitFile, outputDir)
     scriptFile = getScriptFile(pathToExecutable=xmimsim_pymca,
                                    name=ddict['script'])
     if ddict['fit'] != fitFile:
         if outputDir is None:
             # this should never happen
            raise ValueError("Inconsistent internal behaviour!")
         # recreate input in output directory
         new = ConfigDict.ConfigDict()
         new.read(fitFile)
         if os.path.exists(ddict['fit']):
             os.remove(ddict['fit'])
         new.write(ddict['fit'])
         new = None
     speName = ddict['spe']
     csvName = ddict['csv']
     newFitFile = ddict['fit']
     xmsoName = ddict['xmsoName']
     args = [scriptFile,
            #"--enable-single-run",
            "--verbose",
            "--spe-file=%s" % speName,
            "--csv-file=%s" % csvName,
            #"--enable-roi-normalization",
            #"--disable-roi-normalization", #default
            #"--enable-pile-up"
            #"--disable-pile-up" #default
            #"--enable-poisson",
            #"--disable-poisson", #default no noise
            #"--set-threads=2", #overwrite default maximum
            newFitFile,
            xmsoName]
     return args
예제 #6
0
 def processList(self):
     for fitfile in self._filelist:
         self.onNewFile(fitfile, self._filelist)
         d = ConfigDict.ConfigDict()
         d.read(fitfile)
         f = open(os.path.join(self.outputdir,os.path.basename(fitfile)+".dat"),'w+')
         npoints = len(d['result']['xdata'])
         f.write("\n")
         f.write("#S 1 %s\n" % fitfile)
         i=0
         for parameter in d['result']['parameters']:
             f.write("#U%d %s %.6g +/- %.3g\n" % (i, parameter,
                                                  d['result']['fittedpar'][i],
                                                  d['result']['sigmapar'][i]))
             i+=1
         f.write("#N 6\n")
         f.write("#L Energy  channel  counts  fit  continuum  pileup\n")
         for i in range(npoints):
             f.write("%.6g  %.6g   %.6g  %.6g  %.6g  %.6g\n" % (d['result']['energy'][i],
                                d['result']['xdata'][i],
                                d['result']['ydata'][i],
                                d['result']['yfit'][i],
                                d['result']['continuum'][i],
                                d['result']['pileup'][i]))
         f.close()
     self.onEnd()
예제 #7
0
파일: XRFMCPyMca.py 프로젝트: sjmvm/pymca
    def fitFileChanged(self, ddict):
        #for the time being only one ...
        fitfile = ddict['filelist'][0]
        self.fitConfiguration = ConfigDict.ConfigDict()
        self.fitConfiguration.read(fitfile)
        if 'result' in self.fitConfiguration:
            matrix = self.fitConfiguration['result']\
                     ['config']['attenuators'].get('Matrix', None)
        else:
            matrix = self.fitConfiguration\
                     ['attenuators'].get('Matrix', None)

        if matrix is None:
            text = 'Undefined sample matrix in file %s' % fitfile
            title = "Invalid Matrix"
            self.errorMessage(text, title)
            return
        if matrix[0] != 1:
            text = 'Undefined sample matrix in file %s' % fitfile
            title = "Matrix not considered in fit"
            self.errorMessage(text, title)
            return
        if matrix[1] == '-':
            text = 'Invalid sample Composition "%s"' % matrix[1]
            title = "Invalid Sample"
            self.errorMessage(text, title)
            return

        if 'xrfmc' in self.fitConfiguration:
            if 'setup' in self.fitConfiguration['xrfmc']:
                self.parametersWidget.setParameters(self.fitConfiguration)

        if matrix[1] != "MULTILAYER":
            self.parametersWidget.setParameters({'layer': 1})
            self.parametersWidget.fitLayer.setMaximum(0)
예제 #8
0
 def saveDict(self):
     saveDir = PyMcaDirs.outputDir
     ffilter = ['PyMca (*.shift)']
     try:
         filename = PyMcaFileDialogs.\
                     getFileList(parent=self,
                         filetypelist=ffilter,
                         message='Save FFT Alignment shifts',
                         mode='SAVE',
                         single=True)[0]
     except IndexError:
         # Returned list is empty
         return False
     if len(filename) == 0:
         return False
     if not str(filename).endswith('.shift'):
         filename += '.shift'
     if DEBUG == 1:
         print('saveOptions -- Filename: "%s"' % filename)
     currentOrder = self.plugin.getOrder()
     outDict = ConfigDict.ConfigDict()
     llist, ddict = self.getDict()
     outDict['Order'] = {'Order': currentOrder}
     outDict['Shifts'] = ddict
     outDict['ShiftList'] = {
         'ShiftList':[ddict[legend] for legend in currentOrder]}
     try:
         outDict.write(filename)
     except IOError:
         msg = qt.QMessageBox()
         msg.setWindowTitle('FFTAlignment Save Error')
         msg.setText('Unable to write configuration to \'%s\''%filename)
         msg.exec_()
     return True
예제 #9
0
 def generateReportFromFitFile(self):
     d = ConfigDict.ConfigDict()
     d.read(self.fitfile)
     sourcename = "Unknown Source"
     selection = "Unknown Selection"
     if 'info' in d:
         if 'key' in d['info']:
             selection = d['info']['key']
         elif 'Key' in d['info']:
             selection = d['info']['Key']
         for key in d['info'].keys():
             if key.upper() == 'SOURCENAME':
                 sourcename = d['info'][key]
             elif (key.upper() == 'SELECTION') or\
                  (key.upper() == 'LEGEND'):
                 selection = d['info'][key]
     self.sourcename = sourcename
     self.selection = selection
     if self.outfile is None:
         if self.outdir is None:
             self.outdir = os.getcwd()
         self.outfile = os.path.basename(self.fitfile)
     else:
         if self.outdir is None:
             self.outdir = os.path.dirname(self.outfile)
         self.outfile = os.path.basename(self.outfile)
     if self.outdir == '': self.outdir = "."
     self.fitresult = d
     if 'concentrations' in d:
         self.concentrations = d['concentrations']
예제 #10
0
 def testNxProcess(self):
     with self.h5open('testNxProcess') as h5group:
         entry = NexusUtils.nxEntry(h5group, 'entry0001')
         configdict = ConfigDict.ConfigDict(initdict={'a': 1, 'b': 2})
         process = NexusUtils.nxProcess(entry, 'process0001', configdict=configdict)
         self.assertRaises(RuntimeError, NexusUtils.nxProcess,
                           h5group, 'process0002', configdict=configdict)
         self.validateNxProcess(process)
예제 #11
0
 def saveConfiguration(self, filename):
     d = ConfigDict.ConfigDict()
     d['XAS'] = {}
     ddict = self.getConfiguration()
     if 'XAS' in ddict:
         d['XAS'].update(ddict['XAS'])
     else:
         d['XAS'].update(ddict)
     d.write(filename)
예제 #12
0
 def configurationFileChanged(self, ddict):
     configFile= ddict['filelist'][0]
     configuration = ConfigDict.ConfigDict()
     configuration.read(configFile)
     if not ('setup' in configuration['xrfmc']):
         title = "Invalid file"
         text = "Invalid configuration file."
         self.errorMessage(text, title)
     else:
         self.parametersWidget.setParameters(configuration['xrfmc']['setup'])
예제 #13
0
 def saveConfiguration(self, filename):
     cfg = ConfigDict.ConfigDict(self.getConfiguration())
     try:
         cfg.write(filename)
         self.initDir = os.path.dirname(filename)
     except:
         if _logger.getEffectiveLevel() == logging.DEBUG:
             raise
         qt.QMessageBox.critical(self, "Save Parameters",
             "ERROR while saving parameters to\n%s"%filename,
             qt.QMessageBox.Ok, qt.QMessageBox.NoButton, qt.QMessageBox.NoButton)
 def load(self):
     fileList = PyMcaFileDialogs.getFileList(parent=self,
                                             filetypelist=["Fit files (*.cfg)"],
                                             message="Select a fit configuration file",
                                             mode="OPEN",
                                             getfilter=False,
                                             single=True)
     if len(fileList):
         d = ConfigDict.ConfigDict()
         d.read(fileList[0])
         self.setParameters(d)
예제 #15
0
 def saveConfiguration(self, filename):
     cfg = ConfigDict.ConfigDict(self.getConfiguration())
     if DEBUG:
         cfg.write(filename)
         self.initDir = os.path.dirname(filename)
     else:
         try:
             cfg.write(filename)
             self.initDir = os.path.dirname(filename)
         except:
             qt.QMessageBox.critical(self, "Save Parameters",
                 "ERROR while saving parameters to\n%s"%filename,
                 qt.QMessageBox.Ok, qt.QMessageBox.NoButton, qt.QMessageBox.NoButton)
예제 #16
0
def generateXRFConfig(modfunc=None):
    """
    :param callable modfunc: modify configuration on loading
    :returns: ConfigDict
    """
    from PyMca5.PyMcaDataDir import PYMCA_DATA_DIR as dataDir
    from PyMca5.PyMcaIO import ConfigDict
    configuration = ConfigDict.ConfigDict()
    cfg = os.path.join(dataDir, "Steel.cfg")
    configuration.read(cfg)
    if modfunc is not None:
        modfunc(configuration)
    return configuration
예제 #17
0
 def loadConfiguration(self, filename):
     cfg = ConfigDict.ConfigDict()
     try:
         cfg.read(filename)
         self.initDir = os.path.dirname(filename)
         self.setConfiguration(cfg)
     except:
         if DEBUG:
             raise
         qt.QMessageBox.critical(
             self, "Load Parameters",
             "ERROR while loading parameters from\n%s" % filename,
             qt.QMessageBox.Ok, qt.QMessageBox.NoButton,
             qt.QMessageBox.NoButton)
예제 #18
0
 def saveConfiguration(self):
     wdir = Object3DDirs.outputDir
     message = "Enter output scene configuration file name"
     filename = qt.QFileDialog.getSaveFileName(self, message, wdir,
                                               "*.scene")
     filename = str(filename)
     if not len(filename):
         return
     Object3DDirs.outputDir = os.path.dirname(filename)
     config = self.glWindow.scene.getConfiguration()
     d = ConfigDict.ConfigDict()
     if os.path.exists(filename):
         os.remove(filename)
     d.update(config)
     d.write(filename)
예제 #19
0
 def loadConfiguration(self, filename):
     cfg= ConfigDict.ConfigDict()
     try:
         cfg.read(filename)
         self.initDir = os.path.dirname(filename)
         self.setConfiguration(cfg)
     except:
         if DEBUG:
             raise
         msg = qt.QMessageBox(self)
         msg.setIcon(qt.QMessageBox.Critical)
         txt = "ERROR while loading parameters from\n%s\n" % filename
         msg.setInformativeText(str(sys.exc_info()[1]))
         msg.setDetailedText(traceback.format_exc())
         msg.exec_()
예제 #20
0
 def _updateFitFile(self, concentrations, outfile):
     """Add concentrations to fit file
     """
     try:
         f = ConfigDict.ConfigDict()
         f.read(outfile)
         f['concentrations'] = concentrations
         try:
             os.remove(outfile)
         except:
             _logger.error("error deleting fit file")
         f.write(outfile)
     except:
         _logger.error("Error writing concentrations to fit file")
         _logger.error(str(sys.exc_info()))
예제 #21
0
def test(filename):
    fitConfig = ConfigDict.ConfigDict()
    fitConfig.read(filename)
    ddict = getXRFMCCorrectionFactors(fitConfig, verbose=True)
    fitConfig = None
    for element in ddict:
        for line in ddict[element]:
            if line == "z":
                #atomic number
                continue
            if line in ['K', 'Ka', 'Kb', 'L', 'L1', 'L2', 'L3', 'M']:
                correction1 = ddict[element][line]['correction_factor'][1]
                correctionn = ddict[element][line]['correction_factor'][-1]
                print("Element %s Line %s Correction 2 = %f Correction n = %f" %\
                            (element, line,correction1, correctionn))
예제 #22
0
 def saveParameters(self, fname=None):
     if fname is None:
         fname = PyMcaFileDialogs.getFileList(self,
                                      filetypelist=["Configuration (*.ini)",
                                                    "Configuration (*.cfg)"],
                                      message="Please enter output file name",
                                      mode="SAVE",
                                      getfilter=False,
                                      single=True)
         if len(fname):
             fname = fname[0]
         else:
             return
     ddict = ConfigDict.ConfigDict()
     ddict["XASParameters"] = self.getParameters()
     ddict.write(fname)
예제 #23
0
    def _saveCounterTableConfiguration(self):
        fname = self.getOutputFilename()
        if not len(fname):
            return
        if not fname.endswith('.ini'):
            fname += '.ini'

        ddict = ConfigDict.ConfigDict()
        if "PyMcaDirs" in sys.modules:
            ddict['PyMca'] = {}
            ddict['PyMca']['HDF5'] = {'WidgetConfiguration':\
                                      self.getWidgetConfiguration()}
        else:
            ddict['HDF5'] ={'WidgetConfiguration':\
                             self.getWidgetConfiguration()}
        ddict.write(fname)
def main(fileName=None):
    app  = qt.QApplication(sys.argv)
    w = StrategyHandlerDialog()
    if fileName is not None:
        d = ConfigDict.ConfigDict()
        d.read(fileName)
        d["fit"]["strategy"] = "SingleLayerStrategy"
        d["SingleLayerStrategy"] = {}
        d["SingleLayerStrategy"]["iterations"] = 4
        d["SingleLayerStrategy"]["flags"] = 1, 1, 0, 1
        d["SingleLayerStrategy"]["peaks"] = "Cr K", "Fe K", "Mn K",  "Fe Ka"
        d["SingleLayerStrategy"]["materials"] = "-", "Goethite", "-", "Goethite"
        d["SingleLayerStrategy"]["completer"] = "Mo"
        w.setFitConfiguration(d)
    if w.exec_() == qt.QDialog.Accepted:
        print(w.getParameters())
예제 #25
0
    def testStackFastFit(self):
        # TODO: this is done in PyMcaBatchTest on multiple input formats
        # so not needed here
        return
        from PyMca5.PyMcaIO import specfilewrapper as specfile
        from PyMca5.PyMcaIO import ConfigDict
        from PyMca5.PyMcaCore import DataObject
        spe = os.path.join(self.dataDir, "Steel.spe")
        cfg = os.path.join(self.dataDir, "Steel.cfg")
        sf = specfile.Specfile(spe)
        self.assertTrue(len(sf) == 1, "File %s cannot be read" % spe)
        self.assertTrue(sf[0].nbmca() == 1, "Spe file should contain MCA data")

        counts = sf[0].mca(1)
        channels = numpy.arange(counts.size)
        sf = None
        configuration = ConfigDict.ConfigDict()
        configuration.read(cfg)
        calibration = configuration["detector"]["zero"], \
                      configuration["detector"]["gain"], 0.0
        initialTime = configuration["concentrations"]["time"]

        # Fit MCA data with different dimensions: vector, image, stack
        for ndim in [1, 2, 3]:
            # create the data
            imgShape = tuple(range(3, 3 + ndim))
            data = numpy.tile(counts, imgShape + (1, ))
            nTimes = 3
            live_time = numpy.arange(numpy.prod(imgShape), dtype=int)
            live_time = initialTime + (live_time % nTimes) * initialTime

            # create the stack data object
            stack = DataObject.DataObject()
            stack.data = data
            stack.info = {}
            stack.info["McaCalib"] = calibration
            stack.info["McaLiveTime"] = live_time
            stack.x = [channels]

            # Test the fast XRF
            # we need to make sure we use fundamental parameters and
            # the time read from the file
            configuration["concentrations"]["usematrix"] = 0
            configuration["concentrations"]["useautotime"] = 1
            # make sure we use the SNIP background
            configuration['fit']['stripalgorithm'] = 1
            self._verifyFastFit(stack, configuration, live_time, nTimes)
예제 #26
0
 def loadParameters(self, fname=None):
     if fname is None:
         fname = PyMcaFileDialogs.getFileList(self,
                                      filetypelist=["Configuration (*.ini)",
                                                    "Configuration (*.cfg)",
                                                    "All files (*)"],
                                      message="Please set input file name",
                                      mode="OPEN",
                                      getfilter=False,
                                      single=True)
         if len(fname):
             fname = fname[0]
         else:
             return
     d = ConfigDict.ConfigDict()
     d.read(fname)
     self.setParameters(d["XASParameters"])
예제 #27
0
 def load(self, filename):
     d = ConfigDict.ConfigDict()
     d.read(filename)
     current = ""
     if self.mcaROITable.rowCount():
         row = self.mcaROITable.currentRow()
         item = self.mcaROITable.item(row, 0)
         if item is not None:
             current = str(item.text())
     self.fillFromROIDict(roilist=d['ROI']['roilist'],
                          roidict=d['ROI']['roidict'])
     if current in d['ROI']['roidict'].keys():
         if current in d['ROI']['roilist']:
             row = d['ROI']['roilist'].index(current, 0)
             self.mcaROITable.setCurrentCell(row, 0)
             self.mcaROITable._cellChangedSlot(row, 2)
             return
     self.mcaROITable.setCurrentCell(0, 0)
     self.mcaROITable._cellChangedSlot(0, 2)
 def loadConfiguration(self, filename):
     cfg = ConfigDict.ConfigDict()
     _basename, extension = os.path.splitext(filename)
     try:
         if extension in self._HDF5_EXTENSIONS:
             initxt = self._loadIniFromHdf5(filename)
             cfg.readfp(StringIO(initxt))
         else:
             cfg.read(filename)
         self.initDir = os.path.dirname(filename)
         self.setConfiguration(cfg)
     except:
         if _logger.getEffectiveLevel() == logging.DEBUG:
             raise
         msg = qt.QMessageBox(self)
         msg.setIcon(qt.QMessageBox.Critical)
         txt = "ERROR while loading parameters from\n%s\n" % filename
         msg.setInformativeText(str(sys.exc_info()[1]))
         msg.setDetailedText(traceback.format_exc())
         msg.exec()
예제 #29
0
    def _getConfigurationFromFile(self, fname):
        ddict = ConfigDict.ConfigDict()
        ddict.read(fname)

        keys = ddict.keys
        if 'PyMca' in keys():
            ddict = ddict['PyMca']

        if 'HDF5' not in ddict.keys():
            msg = qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Information)
            msg.setText("File does not contain HDF5 configuration")
            msg.exec()
            return None

        if 'WidgetConfiguration' not in ddict['HDF5'].keys():
            msg = qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Information)
            msg.setText("File does not contain HDF5 WidgetConfiguration")
            msg.exec()
            return None

        ddict =ddict['HDF5']['WidgetConfiguration']
        keys = ddict.keys()

        if ('counters' not in keys) or\
           ('aliases' not in keys):
            msg = qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Information)
            msg.setText("File does not contain HDF5 counters information")
            msg.exec()
            return None

        if len(ddict['counters']) != len(ddict['aliases']):
            msg = qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Critical)
            msg.setText("Number of counters does not match number of aliases")
            msg.exec()
            return None

        return ddict
예제 #30
0
def main():
    import sys
    import getopt

    from PyMca5.PyMcaIO import ConfigDict

    if len(sys.argv) > 1:
        options = ''
        longoptions = ['flux=', 'time=', 'area=', 'distance=',
                       'attenuators=', 'usematrix=']
        tool = ConcentrationsTool()
        opts, args = getopt.getopt(
                        sys.argv[1:],
                        options,
                        longoptions)
        config = tool.configure()
        for opt, arg in opts:
            if opt in ('--flux'):
                config['flux'] = float(arg)
            elif opt in ('--area'):
                config['area'] = float(arg)
            elif opt in ('--time'):
                config['time'] = float(arg)
            elif opt in ('--distance'):
                config['distance'] = float(arg)
            elif opt in ('--attenuators'):
                config['useattenuators'] = int(float(arg))
            elif opt in ('--usematrix'):
                config['usematrix'] = int(float(arg))
        tool.configure(config)
        filelist = args
        for filename in filelist:
            d = ConfigDict.ConfigDict()
            d.read(filename)
            for material in d['result']['config']['materials'].keys():
                Elements.Material[material] =\
                    copy.deepcopy(d['result']['config']['materials'][material])
            print(tool.processFitResult(fitresult=d, elementsfrommatrix=True))
    else:
        print("Usage:")
        print("ConcentrationsTool [--flux=xxxx --area=xxxx] fitresultfile")
예제 #31
0
                msg = 'Select the configuration dataset by a double click'
                uri = getDatasetUri(parent=parent, filename=filename, message=msg)
                if uri:
                    newList.append(uri)
            else:
                newList.append(filename)
        fileList = newList
    if getfilter:
        return fileList, usedfilter
    else:
        return fileList

def getFitConfigurationDict(*var, **kw):
    selection = getFitConfigurationFilePath(*var, **kw)
    if selection:
        return ConfigDict.getDictFromPathOrUri(selection)

def getConfigurationDict(*var, **kw):
    selection = getConfigurationFilePath(*var, **kw)
    if selection:
        return ConfigDict.getDictFromPathOrUri(selection)

if __name__ == "__main__":
    app = qt.QApplication([])
    if len(sys.argv) > 1:
        config = ConfigDict.ConfigDict(filelist=sys.argv[1])
    else:
        config = getFitConfigurationDict()
    ConfigDict.prtdict(config)
    app = None
예제 #32
0
def getConfigurationDict(*var, **kw):
    selection = getConfigurationFilePath(*var, **kw)
    if selection:
        return ConfigDict.getDictFromPathOrUri(selection)