コード例 #1
0
ファイル: sitedoc.py プロジェクト: jvstealer99/bumps
def plot_model(filename):
    from matplotlib import pyplot as plt
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    np.random.seed(SEED)
    p = load_model(os.path.join(example_dir(), filename))
    p.plot()
    plt.show()
コード例 #2
0
def plot_model(filename):
    from matplotlib import pyplot as plt
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    np.random.seed(SEED)
    p = load_model(os.path.join(example_dir(), filename))
    p.plot()
    plt.show()
コード例 #3
0
ファイル: sitedoc.py プロジェクト: yusufameri/refl1d
def fit_model(filename):
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    numpy.random.seed(SEED)
    p =load_model([os.path.join(example_dir(),filename)])
    #x.fx = RLFit(p).solve(steps=1000, burn=99)
    x,fx = DEFit(p).solve(steps=200, pop=10)
    #x,fx = PTFit(p).solve(steps=100,burn=400)
    #x.fx = BFGSFit(p).solve(steps=200)
    chisq = p(x)
    print("chisq=%g"%chisq)
    if chisq>2:
        raise RuntimeError("Fit did not converge")
    p.plot()
    pylab.show()
コード例 #4
0
def fit_model(filename):
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    numpy.random.seed(SEED)
    p = load_model(os.path.join(example_dir(), filename))
    #x.fx = fit.RLFit(p).solve(steps=1000, burn=99)
    #x,fx = fit.DEFit(p).solve(steps=200, pop=10)
    #x,fx = fit.PTFit(p).solve(steps=100,burn=400)
    #x.fx = fit.BFGSFit(p).solve(steps=200)
    x, fx = fit.SimplexFit(p).solve(steps=200)
    chisq = p(x)
    print("chisq=%g" % chisq)
    if chisq > 2:
        raise RuntimeError("Fit did not converge")
    p.plot()
    pylab.show()
コード例 #5
0
ファイル: sitedoc.py プロジェクト: jvstealer99/bumps
def fit_model(filename):
    from matplotlib import pyplot as plt
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    np.random.seed(SEED)
    p =load_model(os.path.join(example_dir(),filename))
    #x.fx = fit.RLFit(p).solve(steps=1000, burn=99)
    #x,fx = fit.DEFit(p).solve(steps=200, pop=10)
    #x,fx = fit.PTFit(p).solve(steps=100,burn=400)
    #x.fx = fit.BFGSFit(p).solve(steps=200)
    x,fx = fit.SimplexFit(p).solve(steps=1000)
    chisq = p(x)
    print("chisq=%g"%chisq)
    if chisq>2:
        raise RuntimeError("Fit did not converge")
    p.plot()
    plt.show()
コード例 #6
0
def main():
    parser = argparse.ArgumentParser(
        description="run bumps model through emcee",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        )
    parser.add_argument('-b', '--burn', type=int, default=100, help='Number of burn iterations')
    parser.add_argument('-n', '--steps', type=int, default=400, help='Number of collection iterations')
    parser.add_argument('-N', '--samples', type=int, default=None, help='Number of samples to keep [default is steps*dim*npop]')
    parser.add_argument('-i', '--init', choices='eps lhs cov random'.split(), default='eps', help='Population initialization method')
    parser.add_argument('-k', '--npop', type=int, default=2, help='Population multiplier (must be even)')
    parser.add_argument('-p', '--pars', type=str, default="", help='retrieve starting point from .par file')
    parser.add_argument('-t', '--nT', type=int, default=20, help='Number of temperatures')
    parser.add_argument('-m', '--Tmax', type=float, default=None, help='Max temperature for exponential ladder [default is dT^(nT-1)]')
    parser.add_argument('-d', '--dT', type=float, default=np.sqrt(2.0), help='Temperature steps for exponential ladder if Tmax is not provided')
    parser.add_argument('-r', '--resume', type=str, default=None, help='Resume from file')
    parser.add_argument('-s', '--store', type=str, default='mc.out', help='Save to file')
    parser.add_argument('-x', '--thin', type=int, default=1, help='Number of iterations between collected points')
    parser.add_argument('modelfile', type=str, nargs=1, help='bumps model file')
    parser.add_argument('modelopts', type=str, nargs='*', help='options passed to the model')
    opts = parser.parse_args()

    problem = load_model(opts.modelfile[0], model_options=opts.modelopts)
    if opts.pars:
        load_best(problem, opts.pars)
    dim = len(problem.getp())
    steps = (opts.steps if opts.samples is None
             else (opts.samples+dim*opts.npop-1)//(dim*opts.npop))
    preserved, state, tail = load_state(opts, dim, steps)
    sampler = walk(problem,
                   init=opts.init, state=state,
                   burn=opts.burn if not preserved else 0,
                   steps=steps-preserved, nthin=opts.thin,
                   ntemps=opts.nT, maxtemp=opts.Tmax, dtemp=opts.dT,
                   npop=opts.npop)
    save_state(opts.store, sampler, tail, labels=problem.labels())
    plot_results(problem, sampler, tail, tempstats=False)
    plt.show()
コード例 #7
0
    for entry in arr:
        if entry not in uniques:
            uniques.append(entry)
        else:
            lyrs = [ param for param in uniques if entry in param ]
            layer_number = len(lyrs)
            temp_entry = entry + "_" + str(layer_number)
            uniques.append(temp_entry)
    return uniques

#model = r"superlattice\Triple5data\T5unpol\T5fit.py"
store = r"C:\Users\oliver\OneDrive - UNSW\code\jackson_superlattice\superlattice\Triple5data\1 Tesla\de_mag_interface"
cwd = os.getcwd()

# load model, then from this model load best fit
model = load_model(os.path.join(store, "Triple_five_1T_v2.py"))
p_fit = load_best(model, store)

p = p_fit.getp()
STO = SLD (name = 'SrTiO3', rho = 3.54)
LSMO = SLD(name="LSMO", rho=p[1])
LNO = SLD(name="LNO", rho=p[4])
thetaM = 90

LSMO_mag = FreeMagnetism( z = np.linspace(0,1,9), rhoM = np.full(9,5), thetaM = np.full(9,90) )
LNO_mag = FreeMagnetism( z = np.linspace(0,1,3), rhoM = np.full(3,0.2), thetaM = np.full(3,90) )

#LSMO_lyrs_mag = [ LSMO_mag for i in range(1,16) ]
LNO_lyrs_mag = [ LNO_mag for i in range(1,16) ]

LSMO_lyrs_mag = [ Magnetism( rhoM=1, thetaM=90, interface_above=2, name="LSMO_mag_" + str(i) ) for i in range(1,16)]
コード例 #8
0
        if entry not in uniques:
            uniques.append(entry)
        else:
            lyrs = [param for param in uniques if entry in param]
            layer_number = len(lyrs)
            temp_entry = entry + "_" + str(layer_number)
            uniques.append(temp_entry)
    return uniques


#model = r"superlattice\Triple5data\T5unpol\T5fit.py"
store = r"C:\Users\oliver\OneDrive - UNSW\code\jackson_superlattice\superlattice\Triple5data\T5unpol\OP_diff-ev1"
cwd = os.getcwd()

# load model, then from this model load best fit
model = load_model(os.path.join(store, "T5fit.py"))
p_fit = load_best(model, store)

p = p_fit.getp()
STO = SLD(name='SrTiO3', rho=3.54)
LSMO = SLD(name="LSMO", rho=p[1])
LNO = SLD(name="LNO", rho=p[4])
thetaM = 90

LSMO_mag = FreeMagnetism(z=np.linspace(0, 1, 9),
                         rhoM=np.full(9, 5),
                         thetaM=np.full(9, 90))
LNO_mag = FreeMagnetism(z=np.linspace(0, 1, 3),
                        rhoM=np.full(3, 0.2),
                        thetaM=np.full(3, 90))
コード例 #9
0
ファイル: sitedoc.py プロジェクト: agreen991/refl1d
def plot_model(filename):
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    numpy.random.seed(SEED)
    p = load_model(os.path.join(example_dir(), filename))
    p.plot()
    pylab.show()
コード例 #10
0
def plot_model(filename):
    #import sys; print >>sys.stderr, "in plot with",filename, example_dir()
    numpy.random.seed(SEED)
    p = load_model(os.path.join(example_dir(), filename))
    p.plot()
    pylab.show()