Path: blob/devel/elmerice/examples/Inverse_Methods/MassConservation/src/MakeObs.py
3206 views
###############################################################1# Generate synthetic thickness observations along lines at given2# x positions3###############################################################4import numpy as np56# parameters H = Hgl + dhdx * x7Hgl = 400.08dhdx = -1.0e-3910# mu and sigma to generate noise from a normal distribution11mu = 0.012sigma = 20.01314# the ice true thickness15def H(x):16z = Hgl + dhdx*x17return z1819# make the obs20def MakeObs(x,y):212223nn=len(x)*len(y)24r = np.random.normal(mu, sigma, nn)2526with open('Hflight.txt', 'w') as f:27for i in range(len(x)):28for j in range(len(y)):29h = H(x[i]) + r[i*len(y)+j]30f.write("{} {} {}\n".format(x[i], y[j], h))31f.close()3233if __name__ == "__main__":343536# generate 3 lines at x=37x = np.linspace(50e3, 150e3, 3)3839# resolution along y40y = np.linspace(0.0, 50e3, 51)4142MakeObs(x,y)43444546