Beispiel #1
0
 def testSimpleSpecfileVersusPyMca(self):
     import glob
     import PyMca5
     from PyMca5 import PyMcaDataDir
     from PyMca5.PyMcaIO import specfilewrapper as Specfile
     fileList = glob.glob(os.path.join(PyMcaDataDir.PYMCA_DATA_DIR, '*.dat'))
     self.testSimpleSpecfileImport()
     for filename in fileList:
         self._sf = self.specfileClass(filename)
         a = self._sf
         nScans = a.getNumberOfScans()
         sf = Specfile.Specfile(filename)
         for i in range(nScans):
             scan = sf[i]
             if PyMca5.version() > "5.1.1":
                 # previous versions of PyMca5 could segfault here
                 labels0 = a.getScanLabels(i)
                 labels1 = scan.alllabels()
                 for j in range(len(labels0)):
                     self.assertEqual(labels0[j], labels1[j],
                                 "Read <%s> instead of <%s>" %\
                                      (labels0[j], labels1[j]))
             data0 = a.getScanData(i)
             data1 = scan.data().T
             M = abs(data0 - data1).max()
             if M > 1.0e-8:
                 raise ValueError("Error reading data")        
Beispiel #2
0
 def testSimpleSpecfileVersusPyMca(self):
     import glob
     import PyMca5
     from PyMca5 import PyMcaDataDir
     from PyMca5.PyMcaIO import specfilewrapper as Specfile
     fileList = glob.glob(
         os.path.join(PyMcaDataDir.PYMCA_DATA_DIR, '*.dat'))
     self.testSimpleSpecfileImport()
     for filename in fileList:
         self._sf = self.specfileClass(filename)
         a = self._sf
         nScans = a.getNumberOfScans()
         sf = Specfile.Specfile(filename)
         for i in range(nScans):
             scan = sf[i]
             if PyMca5.version() > "5.1.1":
                 # previous versions of PyMca5 could segfault here
                 labels0 = a.getScanLabels(i)
                 labels1 = scan.alllabels()
                 for j in range(len(labels0)):
                     self.assertEqual(labels0[j], labels1[j],
                                 "Read <%s> instead of <%s>" %\
                                      (labels0[j], labels1[j]))
             data0 = a.getScanData(i)
             data1 = scan.data().T
             M = abs(data0 - data1).max()
             if M > 1.0e-8:
                 raise ValueError("Error reading data")
Beispiel #3
0
for f in ['qt', 'qttable', 'qtcanvas', 'Qwt5']:
    excludes.append(f)

buildOptions = dict(
        compressed = True,
        include_files = include_files,
        excludes = excludes,
        includes = includes,
        #includes = ["scipy.interpolate", "scipy.linalg"]
        #optimize=2,
        #packages = packages,
        #includes = ["Object3D"],
        #path = [PyMcaDir] + sys.path
        )

install_dir = PyMcaDir + " " + PyMca5.version()
if not sys.platform.startswith('win'):
    install_dir = install_dir.replace(" ","")
if os.path.exists(install_dir):
    try:
        def dir_cleaner(directory):
            for f in glob.glob(os.path.join(directory,'*')):
                if os.path.isfile(f):
                    try:
                        os.remove(f)
                    except:
                        print("file <%s> not deleted" % f)
                if os.path.isdir(f):
                    dir_cleaner(f)
            try:
                os.rmdir(directory)
Beispiel #4
0
packages = ["PyMca5"]  # ["silx"]

includes = []


# modules excluded from library.zip
excludes = ["collections.abc", "tcl", "tk", "OpenGL", "scipy", ]

build_options = {
    "packages": packages,
    "includes": includes,
    "include_files": include_files,
    "excludes": excludes, }
    #"compressed": True, }

install_options = {}

executables = [
    Executable('scripts/pymca_launcher',
               # base="Win32GUI" if sys.platform == 'win32' else None,
               base="Console" if sys.platform == 'win32' else None,)
               # compress=True)
]

setup(name='pymca',
      version=PyMca5.version(),
      description="PyMca %s" % PyMca5.version(),
      options=dict(build_exe=build_options,
                   install_exe=install_options),
      executables=executables)
Beispiel #5
0
for f in ['qt', 'qttable', 'qtcanvas', 'Qwt5']:
    excludes.append(f)

buildOptions = dict(
        compressed = True,
        include_files = include_files,
        excludes = excludes,
        includes = includes,
        #includes = ["scipy.interpolate", "scipy.linalg"]
        #optimize=2,
        #packages = packages,
        #includes = ["Object3D"],
        #path = [PyMcaDir] + sys.path
        )

install_dir = PyMcaDir + " " + PyMca5.version()
if not sys.platform.startswith('win'):
    install_dir = install_dir.replace(" ","")
if os.path.exists(install_dir):
    try:
        def dir_cleaner(directory):
            for f in glob.glob(os.path.join(directory,'*')):
                if os.path.isfile(f):
                    try:
                        os.remove(f)
                    except:
                        print("file <%s> not deleted" % f)
                if os.path.isdir(f):
                    dir_cleaner(f)
            try:
                os.rmdir(directory)
Beispiel #6
0
    def _appendOneResultToHdf5(self, resultDict):
        # Get all the  necessary data (TODO: pass it to method as attrs)
        idx = self._currentFitIndex
        end_time = self._currentFitEndTime
        start_time = self._currentFitStartTime
        sigma = self._currentSigma
        legend = self.legends[idx]
        xlabel = self.xlabels[idx]
        ylabel = self.ylabels[idx]
        x, y, _inSigma, xMin, xMax = self.getFitInputValues(idx)
        fitted_data = self.fit.evaluateDefinedFunction(x)
        configIni = ConfigDict.ConfigDict(self.fit.getConfiguration()).tostring()
        fit_paramlist = self.fit.paramlist
        filename = self.getOutputFileName()

        # Write the data to file (append)
        with h5py.File(filename, mode="r+") as h5f:
            entry = h5f.create_group("fit_curve_%d" % idx)
            entry.attrs["NX_class"] = to_h5py_utf8("NXentry")
            entry.attrs["default"] = to_h5py_utf8("fit_process/results/plot")
            entry.create_dataset("start_time",
                                 data=to_h5py_utf8(start_time))
            entry.create_dataset("end_time", data=to_h5py_utf8(end_time))
            entry.create_dataset("title",
                                 data=to_h5py_utf8("Fit of '%s'" % legend))

            process = entry.create_group("fit_process")
            process.attrs["NX_class"] = to_h5py_utf8("NXprocess")
            process.create_dataset("program", data=to_h5py_utf8("pymca"))
            process.create_dataset("version", data=to_h5py_utf8(PyMca5.version()))
            process.create_dataset("date", data=to_h5py_utf8(end_time))

            configuration = process.create_group("configuration")
            configuration.attrs["NX_class"] = to_h5py_utf8("NXnote")
            configuration.create_dataset("type", data=to_h5py_utf8("text/plain"))
            configuration.create_dataset("data", data=to_h5py_utf8(configIni))
            configuration.create_dataset("file_name", data=to_h5py_utf8("SimpleFit.ini"))
            configuration.create_dataset("description",
                                         data=to_h5py_utf8("Fit configuration"))

            results = process.create_group("results")
            results.attrs["NX_class"] = to_h5py_utf8("NXcollection")

            estimation = results.create_group("estimation")
            estimation.attrs["NX_class"] = to_h5py_utf8("NXcollection")

            for p in fit_paramlist:
                pgroup = estimation.create_group(p["name"])
                # constraint code can be an int, convert to str
                if numpy.issubdtype(numpy.array(p['code']).dtype,
                                    numpy.integer):
                    pgroup.create_dataset('code', data=to_h5py_utf8(CONS[p['code']]))
                else:
                    pgroup.create_dataset('code', data=to_h5py_utf8(p['code']))
                pgroup.create_dataset('cons1', data=p['cons1'])
                pgroup.create_dataset('cons2', data=p['cons2'])
                pgroup.create_dataset('estimation', data=p['estimation'])

            for key, value in resultDict.items():
                if not numpy.issubdtype(type(key), numpy.character):
                    _logger.debug("skipping key %s (not a text string)", key)
                    continue
                if key == "fittedvalues":
                    output_key = "parameter_values"
                elif key == "parameters":
                    output_key = "parameter_names"
                elif key == "sigma_values":
                    output_key = "parameter_sigmas"
                else:
                    output_key = key

                value_dtype = numpy.array(value).dtype
                if numpy.issubdtype(value_dtype, numpy.number) or\
                        numpy.issubdtype(value_dtype, numpy.bool_):
                    # straightforward conversion to HDF5
                    results.create_dataset(output_key,
                                           data=value)
                elif numpy.issubdtype(value_dtype, numpy.character):
                    # ensure utf-8 output
                    results.create_dataset(output_key,
                                           data=to_h5py_utf8(value))

            plot = results.create_group("plot")
            plot.attrs["NX_class"] = to_h5py_utf8("NXdata")
            plot.attrs["signal"] = to_h5py_utf8("raw_data")
            plot.attrs["auxiliary_signals"] = to_h5py_utf8(["fitted_data"])
            plot.attrs["axes"] = to_h5py_utf8(["x"])
            plot.attrs["title"] = to_h5py_utf8("Fit of '%s'" % legend)
            signal = plot.create_dataset("raw_data", data=y)
            if ylabel is not None:
                signal.attrs["long_name"] = to_h5py_utf8(ylabel)
            axis = plot.create_dataset("x", data=x)
            if xlabel is not None:
                axis.attrs["long_name"] = to_h5py_utf8(xlabel)
            if sigma is not None:
                plot.create_dataset("errors", data=sigma)
            plot.create_dataset("fitted_data", data=fitted_data)
Beispiel #7
0
for f in ['qt', 'qttable', 'qtcanvas', 'Qwt5']:
    excludes.append(f)

buildOptions = dict(
    compressed=True,
    include_files=include_files,
    excludes=excludes,
    includes=includes,
    #includes = ["scipy.interpolate", "scipy.linalg"]
    #optimize=2,
    #packages = packages,
    #includes = ["Object3D"],
    #path = [PyMcaDir] + sys.path
)

install_dir = PyMcaDir + " " + PyMca5.version()
if not sys.platform.startswith('win'):
    install_dir = install_dir.replace(" ", "")
if os.path.exists(install_dir):
    try:

        def dir_cleaner(directory):
            for f in glob.glob(os.path.join(directory, '*')):
                if os.path.isfile(f):
                    try:
                        os.remove(f)
                    except:
                        print("file <%s> not deleted" % f)
                if os.path.isdir(f):
                    dir_cleaner(f)
            try: