objective = args.objective
    nsamples = args.nsamples

    sigma_obs = 1e-10
    sigma_prior = 0.5


    dirname ="base_solution"
    y, u, R11, R12, R22, R33, omega = load_solution_stressomega(dirname)
    eqn = StressOmegaEquation(y, u, R11, R12, R22, R33, omega, Retau)
    eqn.writedir = "/tmp"
    # first dt can be large as we restart from a good solution
    eqn.force_boundary = False
    eqn.tol = tol
    eqn.dt = 1e1
    eqn.solve()
    beta_prior = np.ones_like(eqn.beta)
    eqn_prior = copy.deepcopy(eqn)
    up_prior = eqn.up.copy()

    Q_prior = np.zeros([np.size(eqn.q), nsamples])

    sample = 0
    while sample < nsamples:
        print "\rSampling prior %i of %i"%(sample, nsamples),
        sys.stdout.flush()
        eqn.dt = dt
        eqn.q[:] = eqn_prior.q[:]
        eqn.beta[:] = beta_prior + np.random.randn(np.size(beta_prior))*sigma_prior
        print np.mean(eqn.beta)
        print np.std(eqn.beta)
    def objective(self, val, param):
        J_obs = sum((val[::6] - self.val_target)**2)/self.sigma_obs
        J_prior = sum((param - self.param_prior)**2)/self.sigma_prior**2
        J = 0.5*(J_obs + J_prior)
        return J


dirname ="base_solution"
y, u, R11, R12, R22, R33, omega = load_solution_stressomega(dirname)
Retau = 5.467390699999999697e+02
eqn = StressOmegaEquation(y, u, R11, R12, R22, R33, omega, Retau)
eqn.writedir = "solution/stress_omega"
eqn.dt = 1e2
eqn.force_boundary = False
eqn.tol = 1e-5
eqn.solve()
eqn_prior = copy.deepcopy(eqn)
up_prior = eqn.up.copy()

dns = np.loadtxt("data/DNSsol.dat")
utau = Retau*eqn.nu*2.0
ydns = dns[:,0]*0.5
udns = dns[:,2]*utau
f = interp1d(ydns, udns)
utarget = f(eqn.y)



beta_prior = eqn.beta.copy()
sigma_obs = 1e-10
sigma_prior = 1.0