当前位置: 首页>>代码示例>>Python>>正文


Python PyMcaIO.ArraySave类代码示例

本文整理汇总了Python中PyMca5.PyMcaIO.ArraySave的典型用法代码示例。如果您正苦于以下问题:Python ArraySave类的具体用法?Python ArraySave怎么用?Python ArraySave使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArraySave类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onProcessStackFinished

 def onProcessStackFinished(self):
     _logger.debug("Stack proccessed")
     self._status = "Stack Fitting finished"
     if self.fixedLenghtOutput:
         self._status = "Writing output files"
         nParameters = len(self._parameters)
         datalist = [None] * (2*len(self._sigmas.keys())+1)
         labels = []
         for i in range(nParameters):
             parameter = self._parameters[i]
             datalist[2*i] = self._images[parameter]
             datalist[2*i + 1] = self._sigmas[parameter]
             labels.append(parameter)
             labels.append('s(%s)' % parameter)
         datalist[-1] = self._images['chisq']
         labels.append('chisq')
         filenames = self.getOutputFileNames()
         csvName = filenames['csv']
         edfName = filenames['edf']
         ArraySave.save2DArrayListAsASCII(datalist,
                                          csvName,
                                          labels=labels,
                                          csv=True,
                                          csvseparator=";")
         ArraySave.save2DArrayListAsEDF(datalist,
                                        edfName,
                                        labels = labels,
                                        dtype=numpy.float32)
开发者ID:vasole,项目名称:pymca,代码行数:28,代码来源:StackSimpleFit.py

示例2: saveStackAsSimplestHDF5

 def saveStackAsSimplestHDF5(self):
     filename = self._getOutputHDF5Filename()
     if not len(filename):
         return
     view = self._getCroppedView()
     ArraySave.save3DArrayAsHDF5(view, filename,
                                 labels = None, dtype=None, mode='simplest')
开发者ID:t20100,项目名称:pymca,代码行数:7,代码来源:QStackWidget.py

示例3: saveStackAsNeXus

    def saveStackAsNeXus(self, dtype=None, interpretation=None, compression=False):
        mcaIndex = self._stack.info.get('McaIndex', -1)
        if interpretation is None:
            if mcaIndex in [0]:
                interpretation = "image"
            else:
                interpretation = "spectrum"
        if interpretation not in ["spectrum", "image"]:
            raise ValueError("Unknown data interpretation %s" % interpretation)
        filename = self._getOutputHDF5Filename()
        if not len(filename):
            return

        # get only the seen stack portion
        view = self._getCroppedView()

        # the current graph axis is saved
        axes = [None] * len(self._stack.data.shape)
        labels = [None] * len(self._stack.data.shape)
        try:
            xLabel = qt.safe_str(self.mcaWidget.graph.getGraphXLabel())
        except:
            xLabel = None
        try:
            xData, y, legend, info = self.mcaWidget.getActiveCurve()[:4]
        except:
            xData = self._mcaData0.x[0]
            xLabel = 'Channels'
        if interpretation == 'image':
            labels[0] = xLabel
            axes[0] = xData
        else:
            labels[-1] = xLabel
            axes[-1] = xData
        try:
            ArraySave.save3DArrayAsHDF5(view,
                                    filename,
                                    axes=axes,
                                    labels=labels,
                                    dtype=dtype,
                                    mode='nexus',
                                    mcaindex=mcaIndex,
                                    interpretation=interpretation,
                                    compression=compression)
        except:
            msg = qt.QMessageBox(self)
            msg.setIcon(qt.QMessageBox.Critical)
            msg.setWindowTitle("Save error")
            msg.setText("An error has occured while saving the data:")
            msg.setInformativeText(qt.safe_str(sys.exc_info()[1]))
            msg.setDetailedText(traceback.format_exc())
            msg.exec_()
开发者ID:t20100,项目名称:pymca,代码行数:52,代码来源:QStackWidget.py

示例4: saveStackAsMonochromaticTiffImages

    def saveStackAsMonochromaticTiffImages(self, dtype=None):
        if dtype is None:
            dtype = self._stack.data.dtype
        if dtype in [numpy.uint32, numpy.uint64]:
            dtype = numpy.float32
        elif dtype in [numpy.int32, numpy.int64]:
            dtype = numpy.float32

        mcaIndex = self._stack.info.get('McaIndex', -1)

        filename = self._getOutputTiffFilename()
        if not len(filename):
            return

        ArraySave.save3DArrayAsMonochromaticTiff(self._stack.data,
                                    filename,
                                    labels = None,
                                    dtype=dtype,
                                    mcaindex=mcaIndex)
开发者ID:aaron-parsons,项目名称:pymca,代码行数:19,代码来源:QStackWidget.py

示例5: initializeHDF5File

    def initializeHDF5File(self, fname):
        #for the time being overwriting
        if os.path.exists(fname):
            os.remove(fname)
        hdf = h5py.File(fname, 'w')
        entryName = "entry_000"
        nxEntry = hdf.require_group(entryName)
        if 'NX_class' not in nxEntry.attrs:
            nxEntry.attrs['NX_class'] = 'NXentry'.encode('utf-8')
        nxEntry['title'] = numpy.string_("PyMca saved 3D Array".encode('utf-8'))
        nxEntry['start_time'] = numpy.string_(ArraySave.getDate().encode('utf-8'))

        alignmentGroup = nxEntry.require_group('Alignment')
        dataGroup = nxEntry.require_group('Data')
        dataGroup.attrs['NX_class'] = 'NXdata'.encode('utf-8')
        return hdf
开发者ID:maurov,项目名称:pymca,代码行数:16,代码来源:ImageAlignmentStackPlugin.py

示例6: _handleSaveIcon

        def _handleSaveIcon(self, event):
            """Handle save icon events.

            Get current active image and save it as a file.
            """
            if event['event'] == 'iconClicked' and event['key'] == 'save':
                imageData = self.getActiveImage()
                if imageData is None:
                    qt.QMessageBox.information(self, "No Data",
                                               "No image to be saved")
                    return
                data, legend, info, pixmap = imageData
                imageList = [data]
                labels = ['value']

                # Copied from MaskImageWidget.saveImageList
                filename = self.getOutputFileName()
                if not len(filename):
                    return

                # Add PNG and JPG adapted from PlotWindow.defaultSaveAction
                if 'WIDGET' in self._saveFilter.upper():
                    fformat = self._saveFilter[-3:].upper()
                    pixmap = qt.QPixmap.grabWidget(self._imagePlot)
                    # Use the following instead to grab the image + histograms
                    # pixmap = qt.QPixmap.grabWidget(self)
                    if not pixmap.save(filename, fformat):
                        msg = qt.QMessageBox(self)
                        msg.setIcon(qt.QMessageBox.Critical)
                        msg.setInformativeText(str(sys.exc_info()[1]))
                        msg.setDetailedText(traceback.format_exc())
                        msg.exec_()
                    return

                if filename.lower().endswith(".edf"):
                    ArraySave.save2DArrayListAsEDF(imageList, filename, labels)
                elif filename.lower().endswith(".csv"):
                    if "," in self._saveFilter:
                        csvseparator = ","
                    elif ";" in self._saveFilter:
                        csvseparator = ";"
                    else:
                        csvseparator = "\t"
                    ArraySave.save2DArrayListAsASCII(imageList, filename, labels,
                                                     csv=True,
                                                     csvseparator=csvseparator)
                else:
                    ArraySave.save2DArrayListAsASCII(imageList, filename, labels,
                                                     csv=False)
开发者ID:lucarebuffi,项目名称:XOPPY,代码行数:49,代码来源:xoppy_util.py

示例7: saveImageList

    def saveImageList(self, filename, imageList, labels,
                      csvseparator=None):
        if not imageList:
            qt.QMessageBox.information(
                    self,
                    "No Data",
                    "Image list is empty.\nNothing to be saved")
            return

        if filename.lower().endswith(".edf"):
            ArraySave.save2DArrayListAsEDF(imageList, filename, labels)
        elif filename.lower().endswith(".tif"):
            ArraySave.save2DArrayListAsMonochromaticTiff(imageList,
                                                         filename,
                                                         labels)
        elif filename.lower().endswith(".csv"):
            assert csvseparator is not None
            ArraySave.save2DArrayListAsASCII(imageList, filename, labels,
                                             csv=True,
                                             csvseparator=csvseparator)
        else:
            ArraySave.save2DArrayListAsASCII(imageList, filename, labels,
                                             csv=False)
开发者ID:maurov,项目名称:pymca,代码行数:23,代码来源:SilxMaskImageWidget.py

示例8: finishHDF5File

 def finishHDF5File(self, hdf):
     #add final date
     toplevelEntry = hdf["entry_000"]
     toplevelEntry['end_time'] = numpy.string_(ArraySave.getDate().encode('utf-8'))
     hdf.flush()
     hdf.close()
开发者ID:maurov,项目名称:pymca,代码行数:6,代码来源:ImageAlignmentStackPlugin.py

示例9: _threadFinished

    def _threadFinished(self):
        result = self.thread.result
        self.thread = None
        if type(result) == type((1,)):
            #if we receive a tuple there was an error
            if len(result):
                if result[0] == "Exception":
                    # somehow this exception is not caught
                    raise Exception(result[1], result[2])#, result[3])
                    return
        imageNames = result['names']
        images = result["images"]
        nImages = images.shape[0]
        self._widget = StackPluginResultsWindow.StackPluginResultsWindow(\
                                        usetab=False)
        self._widget.buildAndConnectImageButtonBox(replace=True,
                                                  multiple=True)
        qt = StackPluginResultsWindow.qt
        self._widget.sigMaskImageWidgetSignal.connect(self.mySlot)
        self._widget.setStackPluginResults(images,
                                          image_names=imageNames)
        self._showWidget()

        # save to output directory
        parameters = self.configurationWidget.getParameters()
        outputDir = parameters["output_dir"]
        if outputDir in [None, ""]:
            if DEBUG:
                print("Nothing to be saved")
                return
        if parameters["file_root"] is None:
            fileRoot = ""
        else:
            fileRoot = parameters["file_root"].replace(" ","")
        if fileRoot in [None, ""]:
            fileRoot = "images"
        if not os.path.exists(outputDir):
            os.mkdir(outputDir)
        imagesDir = os.path.join(outputDir, "IMAGES")
        if not os.path.exists(imagesDir):
            os.mkdir(imagesDir)
        imageList = [None] * (nImages)
        fileImageNames = [None] * (nImages)
        j = 0
        for i in range(nImages):
            name = imageNames[i].replace(" ","-")
            fileImageNames[j] = name
            imageList[j] = images[i]
            j += 1
        fileName = os.path.join(imagesDir, fileRoot+".edf")
        ArraySave.save2DArrayListAsEDF(imageList, fileName,
                                       labels=fileImageNames)
        fileName = os.path.join(imagesDir, fileRoot+".csv")
        ArraySave.save2DArrayListAsASCII(imageList, fileName, csv=True,
                                         labels=fileImageNames)
        if parameters["tiff"]:
            i = 0
            for i in range(len(fileImageNames)):
                label = fileImageNames[i]
                mass_fraction  = "_" + label
                fileName = os.path.join(imagesDir,
                                        fileRoot + mass_fraction + ".tif")
                ArraySave.save2DArrayListAsMonochromaticTiff([imageList[i]],
                                        fileName,
                                        labels=[label],
                                        dtype=numpy.float32)
开发者ID:dnaudet,项目名称:pymca,代码行数:66,代码来源:StackROIBatchPlugin.py

示例10: saveStackAsSimplestHDF5

 def saveStackAsSimplestHDF5(self):
     filename = self._getOutputHDF5Filename()
     if not len(filename):
         return
     ArraySave.save3DArrayAsHDF5(self._stack.data, filename,
                                 labels = None, dtype=None, mode='simplest')
开发者ID:aaron-parsons,项目名称:pymca,代码行数:6,代码来源:QStackWidget.py

示例11: saveStackAsNeXusPlus

 def saveStackAsNeXusPlus(self):
     filename = self._getOutputHDF5Filename()
     if not len(filename):
         return
     ArraySave.save3DArrayAsHDF5(self._stack.data, filename,
                                 labels = None, dtype=None, mode='nexus+')
开发者ID:aaron-parsons,项目名称:pymca,代码行数:6,代码来源:QStackWidget.py

示例12: threadFinished

    def threadFinished(self):
        result = self.thread.result
        self.thread = None
        if type(result) == type((1,)):
            #if we receive a tuple there was an error
            if len(result):
                if result[0] == "Exception":
                    # somehow this exception is not caught
                    raise Exception(result[1], result[2])
                    return
        if 'concentrations' in result:
            imageNames = result['names']
            images = numpy.concatenate((result['parameters'],
                                        result['concentrations']), axis=0)
        else:
            images = result['parameters']
            imageNames = result['names']
        nImages = images.shape[0]
        self._widget = StackPluginResultsWindow.StackPluginResultsWindow(\
                                        usetab=False)
        self._widget.buildAndConnectImageButtonBox()
        qt = StackPluginResultsWindow.qt
        self._widget.sigMaskImageWidgetSignal.connect(self.mySlot)
        self._widget.setStackPluginResults(images,
                                          image_names=imageNames)
        self._showWidget()

        # save to output directory
        parameters = self.configurationWidget.getParameters()
        outputDir = parameters["output_dir"]
        if outputDir in [None, ""]:
            if DEBUG:
                print("Nothing to be saved")
                return
        if parameters["file_root"] is None:
            fileRoot = ""
        else:
            fileRoot = parameters["file_root"].replace(" ","")
        if fileRoot in [None, ""]:
            fileRoot = "images"
        if not os.path.exists(outputDir):
            os.mkdir(outputDir)
        imagesDir = os.path.join(outputDir, "IMAGES")
        if not os.path.exists(imagesDir):
            os.mkdir(imagesDir)
        imageList = [None] * (nImages + len(result['uncertainties']))
        fileImageNames = [None] * (nImages + len(result['uncertainties']))
        j = 0
        for i in range(nImages):
            name = imageNames[i].replace(" ","-")
            fileImageNames[j] = name
            imageList[j] = images[i]
            j += 1
            if not imageNames[i].startswith("C("):
                # fitted parameter
                fileImageNames[j] = "s(%s)" % name
                imageList[j] = result['uncertainties'][i]
                j += 1
        fileName = os.path.join(imagesDir, fileRoot+".edf")
        ArraySave.save2DArrayListAsEDF(imageList, fileName,
                                       labels=fileImageNames)
        fileName = os.path.join(imagesDir, fileRoot+".csv")
        ArraySave.save2DArrayListAsASCII(imageList, fileName, csv=True,
                                         labels=fileImageNames)
开发者ID:isaxs,项目名称:pymca,代码行数:64,代码来源:FastXRFLinearFitStackPlugin.py

示例13: loadFileList


#.........这里部分代码省略.........
                    self.onProgress(self.incrProgressBar)
                filecounter = 1
        elif shape is None:
            #it can only be here if there is one scan per file
            try:
                self.data = numpy.zeros((self.nbFiles,
                                   numberofmca/numberofdetectors,
                                   arrRet.shape[0]),
                                   arrRet.dtype.char)
                filecounter         = 0
                for tempFileName in filelist:
                    tempInstance=specfile.Specfile(tempFileName)
                    #it can only be here if there is one scan per file
                    #prevent problems if the scan number is different
                    #scan = tempInstance.select(keylist[-1])
                    scan = tempInstance[-1]
                    for i in iterlist:
                        #mcadata = scan_obj.mca(i)
                        self.data[filecounter,
                                  0,
                                  :] = scan.mca(i)[:]
                        self.incrProgressBar += 1
                        self.onProgress(self.incrProgressBar)
                    filecounter += 1
            except MemoryError:
                qtflag = False
                if ('PyQt4.QtCore' in sys.modules) or\
                   ('PySide' in sys.modules) or\
                   ('PyMca5.PyMcaGui.PyMcaQt' in sys.modules):
                    qtflag = True
                hdf5done = False
                if HDF5 and qtflag:
                    from PyMca5.PyMcaGui import PyMcaQt as qt
                    from PyMca5.PyMcaIO import ArraySave
                    msg=qt.QMessageBox.information( None,
                      "Memory error\n",
                      "Do you want to convert your data to HDF5?\n",
                      qt.QMessageBox.Yes,qt.QMessageBox.No)
                    if msg != qt.QMessageBox.No:
                        hdf5file = qt.QFileDialog.getSaveFileName(None,
                                    "Please select output file name",
                                    os.path.dirname(filelist[0]),
                                    "HDF5 files *.h5")
                        if not len(hdf5file):
                            raise IOError("Invalid output file")
                        hdf5file = qt.safe_str(hdf5file)
                        if not hdf5file.endswith(".h5"):
                            hdf5file += ".h5"

                        #get the final shape
                        from PyMca5.RGBCorrelatorWidget import ImageShapeDialog
                        stackImageShape = self.nbFiles,\
                                     int(numberofmca/numberofdetectors)
                        dialog = ImageShapeDialog(None, shape =stackImageShape)
                        dialog.setModal(True)
                        ret = dialog.exec_()
                        if ret:
                            stackImageShape= dialog.getImageShape()
                            dialog.close()
                            del dialog
                        hdf, self.data =  ArraySave.getHDF5FileInstanceAndBuffer(hdf5file,
                                       (stackImageShape[0],
                                        stackImageShape[1],
                                        arrRet.shape[0]),
                                       compression=None,
                                       interpretation="spectrum")
开发者ID:dnaudet,项目名称:pymca,代码行数:67,代码来源:SpecFileStack.py


注:本文中的PyMca5.PyMcaIO.ArraySave类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。