Exemplo n.º 1
0
    def test1b(self):
        iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
        from multiphonon.sqe import interp

        newiqe = interp(iqehist, newE=np.arange(-50, 50, 1.0))
        DOS = sqe2dos.singlephonon_sqe2dos(newiqe, T=300, Ecutoff=65.0, elastic_E_cutoff=(-20.0, 6.7), M=50.94)
        # plot
        if interactive:
            H.plot(DOS)
        return
 def test2(self):
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     newsqe = interp(iqehist, newE=np.arange(-50, 50, 1.))
     mask = dynamical_range_mask(newsqe, Ei=120)
     # plot
     if interactive:
         import pylab
         pylab.imshow(mask.T[::-1])
         pylab.clim(0, None)
         pylab.colorbar()
         pylab.show()
     return
 def test2(self):
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     newsqe = interp(iqehist, newE=np.arange(-50, 50, 1.))
     mask = dynamical_range_mask(newsqe, Ei=120)
     # plot
     if interactive:
         import pylab
         pylab.imshow(mask.T[::-1])
         pylab.clim(0, None)
         pylab.colorbar()
         pylab.show()
     return
 def test1b2(self):
     "singlephonon_sqe2dos: check energy axis"
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-50.5, 50, 1.))
     from multiphonon.backward.singlephonon_sqe2dos import EnergyAxisMissingBinCenterAtZero
     with self.assertRaises(EnergyAxisMissingBinCenterAtZero):
         DOS = sqe2dos.singlephonon_sqe2dos(newiqe,
                                            T=300,
                                            Ecutoff=65.,
                                            elastic_E_cutoff=(-20., 6.7),
                                            M=50.94)
     return
Exemplo n.º 5
0
 def test1(self):
     "multiphonon.forward.dos2sqe"
     from dos import loadDOS
     E, g = loadDOS()
     Eaxis = H.axis('E', unit='meV', centers=E)
     doshist = H.histogram('DOS', [Eaxis], g)
     dE = E[1] - E[0]
     iqe = hh.load(os.path.join(datadir, 'V-iqe.h5'))
     from multiphonon.sqe import interp
     newiqe = interp(iqe, newE=np.arange(iqe.energy[0], 80., dE))
     hh.dump(newiqe, 'V-iqe-interped.h5')
     from multiphonon.forward import dos2sqe
     sqe = dos2sqe(doshist, 0.01, newiqe, 300, 50.94, 120.)
     return
Exemplo n.º 6
0
    def test2a(self):
        "sqe2dos: V exp"
        iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
        from multiphonon.sqe import interp
        newiqe = interp(iqehist, newE=np.arange(-15, 80, 1.))
        hh.dump(newiqe, 'V-iqe-interped.h5')
        iterdos = sqe2dos.sqe2dos(newiqe,
                                  T=300,
                                  Ecutoff=55.,
                                  elastic_E_cutoff=(-12., 6.7),
                                  M=50.94,
                                  C_ms=.2,
                                  Ei=120.,
                                  workdir='work-V')

        with warnings.catch_warnings(record=True) as ws:
            warnings.simplefilter('always')
            for i, dos in enumerate(iterdos):
                # print dos
                # plot
                if interactive:
                    # print '*' * 70
                    pylab.plot(dos.E, dos.I, label='%d' % i)
                    pass
            # check warning
            for w in ws:
                assert 'Scaling factor' not in str(w)

        path = os.path.join(here, 'expected_results',
                            'sqe2dos-test2a-final-dos.h5')
        # hh.dump(dos, path)
        expected = hh.load(path)
        self.assert_(np.allclose(dos.I, expected.I))
        self.assert_(np.allclose(dos.E2, expected.E2))
        if interactive:
            pylab.figure()
            pylab.errorbar(dos.E,
                           dos.I + dos.I.max() / 5.,
                           dos.E2**.5,
                           label='new')
            pylab.errorbar(expected.E,
                           expected.I,
                           expected.E2**.5,
                           label='expected')
            pylab.legend()
            pylab.show()
        return
 def test1b(self):
     "singlephonon_sqe2dos: exp vanadium SQE -> DOS"
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-50, 50, 1.))
     DOS = sqe2dos.singlephonon_sqe2dos(newiqe,
                                        T=300,
                                        Ecutoff=65.,
                                        elastic_E_cutoff=(-20., 6.7),
                                        M=50.94)
     path = os.path.join(here, 'expected_results', 'test1b-dos.h5')
     expected = hh.load(path)
     self.assert_(np.allclose(DOS.I, expected.I))
     self.assert_(np.allclose(DOS.E2, expected.E2))
     # plot
     if interactive:
         H.plot(DOS)
     return
Exemplo n.º 8
0
    def test2b(self):
        iqehist = hh.load(os.path.join(datadir, "Al-iqe.h5"))
        from multiphonon.sqe import interp

        newiqe = interp(iqehist, newE=np.arange(-40, 70, 1.0))
        hh.dump(newiqe, "Al-iqe-interped.h5")
        iterdos = sqe2dos.sqe2dos(
            newiqe, T=300, Ecutoff=50.0, elastic_E_cutoff=(-10.0, 7), M=26.98, C_ms=0.2, Ei=80.0, workdir="work-Al"
        )
        for i, dos in enumerate(iterdos):
            # print dos
            # plot
            if interactive:
                # print '*' * 70
                pylab.plot(dos.E, dos.I, label="%d" % i)
        if interactive:
            pylab.legend()
            pylab.show()
        return
Exemplo n.º 9
0
 def test2a2(self):
     "sqe2dos: check energy axis"
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-15.5, 80, 1.))
     iterdos = sqe2dos.sqe2dos(newiqe,
                               T=300,
                               Ecutoff=55.,
                               elastic_E_cutoff=(-12., 6.7),
                               M=50.94,
                               C_ms=.2,
                               Ei=120.,
                               workdir='work-V')
     from multiphonon.backward.singlephonon_sqe2dos import EnergyAxisMissingBinCenterAtZero
     with self.assertRaises(EnergyAxisMissingBinCenterAtZero):
         for i, dos in enumerate(iterdos):
             # print dos
             # plot
             if interactive:
                 # print '*' * 70
                 pylab.plot(dos.E, dos.I, label='%d' % i)
     return
Exemplo n.º 10
0
 def test2b(self):
     iqehist = hh.load(os.path.join(datadir, "Al-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-40, 70, 1.))
     hh.dump(newiqe, 'Al-iqe-interped.h5')
     iterdos = sqe2dos.sqe2dos(newiqe,
                               T=300,
                               Ecutoff=50.,
                               elastic_E_cutoff=(-10., 7),
                               M=26.98,
                               C_ms=0.2,
                               Ei=80.,
                               workdir='work-Al')
     for i, dos in enumerate(iterdos):
         # print dos
         # plot
         if interactive:
             # print '*' * 70
             pylab.plot(dos.E, dos.I, label='%d' % i)
     path = os.path.join(here, 'expected_results',
                         'sqe2dos-test2b-final-dos.h5')
     # hh.dump(dos, path)
     expected = hh.load(path)
     self.assert_(np.allclose(dos.I, expected.I))
     self.assert_(np.allclose(dos.E2, expected.E2))
     if interactive:
         pylab.figure()
         pylab.errorbar(dos.E,
                        dos.I + dos.I.max() / 5,
                        dos.E2**.5,
                        label='new')
         pylab.errorbar(expected.E,
                        expected.I,
                        expected.E2**.5,
                        label='expected')
         pylab.legend()
         pylab.show()
     return
Exemplo n.º 11
0
 def test1(self):
     "multiphonon.sqe.interp"
     sqe = hh.load(os.path.join(datadir, "V-iqe.h5"))
     newsqe = interp(sqe, newE=np.arange(-70, 70, 1.))
     hh.dump(newsqe, "V-iqe-interpd.h5")
     return
Exemplo n.º 12
0
# change into "examples" dir
here = os.path.dirname(__file__) or os.curdir
os.chdir(here)

# load I(Q,E) data (numpy arrays)
Q = np.load("data/Al-iqe-Q.npy") 
E = np.load("data/Al-iqe-E.npy") 
I = np.load("data/Al-iqe-I.npy") # 2D array of intensities
E2 = np.load("data/Al-iqe-E2.npy") # 2D array of errorbar squares

# create a histogram object from the numpy arrays
iqehist = H.histogram('IQE', [('Q', Q, '1./angstrom'), ('E', E, 'meV')], data=I, errors=E2)

# interpolate I(Q, E) data so that the energy axis has "zero" as a bin center
from multiphonon.sqe import interp
newiqe = interp(iqehist, newE = np.arange(-40, 70, 1.))

# save interpolated data just in case we need it later
hh.dump(newiqe, 'data/Al-iqe-interped.h5')

# create processing engine with processing parameters
from multiphonon.backward import sqe2dos
workdir='work-Al-from-nparrs'
iterdos = sqe2dos.sqe2dos(
    newiqe, T=300, Ecutoff=50., 
    elastic_E_cutoff=(-10., 7), M=26.98,
    C_ms=0.2, Ei=80., workdir=workdir)
# process and plot
for i, dos in enumerate(iterdos): 
    print "* Iteration", i
    if not headless:
Exemplo n.º 13
0
 def test1(self):
     "multiphonon.sqe.interp"
     sqe = hh.load(os.path.join(datadir, "V-iqe.h5"))
     newsqe = interp(sqe, newE=np.arange(-70, 70, 1.))
     hh.dump(newsqe, "V-iqe-interpd.h5")
     return