Ejemplo n.º 1
0
    def elementFactory(self, **kwds):
        datapath = kwds.get("idf-data-path")
        hdfpath = kwds.get("histogram-hdf-path")
        if datapath:
            from mccomponents.sample.idf import readSQE

            sqe = readSQE(datapath)
            pass
        elif hdfpath:
            from histogram.hdf import load

            try:
                sqe = load(hdfpath)
            except:
                import os, traceback

                f = os.path.dirname(hdfpath)
                e = os.path.basename(hdfpath)
                t = traceback.format_exc()
                raise IOError, "unable to load histogram from hdf5 file %s, entry %s. Original traceback:\n%s" % (
                    f,
                    e,
                    t,
                )
            pass
        else:
            raise ValueError, "GridSQE needs path to " "idf data files or " "histogram hdf5 file "

        auto_normalization = kwds.get("auto-normalization")
        if auto_normalization:
            auto_normalization = bool(auto_normalization)

        norm = _calcNorm(sqe)
        if abs(norm - 1) > 0.2:
            if auto_normalization:
                sqe.I /= norm
            else:
                raise RuntimeError, "S(Q,E) should average to ~1, got %s" % norm

        from mccomponents.sample import gridsqe

        return gridsqe(sqe)
Ejemplo n.º 2
0
    def elementFactory(self, **kwds):
        datapath = kwds.get('idf-data-path')
        hdfpath = kwds.get('histogram-hdf-path')
        if datapath:
            from mccomponents.sample.idf import readSQE
            sqe = readSQE(datapath)
            pass
        elif hdfpath:
            from histogram.hdf import load
            try:
                sqe = load(hdfpath)
            except:
                import os, traceback
                f = os.path.dirname(hdfpath)
                e = os.path.basename(hdfpath)
                t = traceback.format_exc()
                raise IOError, "unable to load histogram from hdf5 file %s, entry %s. Original traceback:\n%s" % (
                    f, e, t)
            pass
        else:
            raise ValueError, "GridSQE needs path to "\
                  "idf data files or "\
                  "histogram hdf5 file "

        auto_normalization = kwds.get('auto-normalization')
        if auto_normalization:
            auto_normalization = bool(auto_normalization)

        norm = _calcNorm(sqe)
        if abs(norm - 1) > 0.2:
            if auto_normalization:
                sqe.I /= norm
            else:
                raise RuntimeError, "S(Q,E) should average to ~1, got %s" % norm

        from mccomponents.sample import gridsqe
        return gridsqe(sqe)
Ejemplo n.º 3
0
from mccomponents.sample.idf import readSQE

sqe = readSQE('SQE-examples')
import histogram.hdf as hh

hh.dump(sqe, 'sqe.h5', '/', 'c')
Ejemplo n.º 4
0
 def test1(self):
     from mccomponents.sample.idf import readSQE
     sqe = readSQE(datapath)
     import pickle
     pickle.dump(sqe, open('sqehist.pkl', 'w'))
     return
Ejemplo n.º 5
0
from mccomponents.sample.idf  import readSQE
sqe = readSQE( 'SQE-examples' )
import histogram.hdf as hh
hh.dump( sqe, 'sqe.h5', '/', 'c' )
Ejemplo n.º 6
0
 def test1(self):
     from mccomponents.sample.idf import readSQE
     sqe = readSQE( datapath )
     import pickle
     pickle.dump(sqe, open('sqehist.pkl','w') )
     return
Ejemplo n.º 7
0
#!/usr/bin/env python
import sys
path = sys.argv[1]
from mccomponents.sample.idf  import readSQE
sqe = readSQE( path )
from histogram.plotter import defaultPlotter
defaultPlotter.plot( sqe )