Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/examples/Inverse_Methods/MassConservation/src/MakeObs.py
3206 views
1
###############################################################
2
# Generate synthetic thickness observations along lines at given
3
# x positions
4
###############################################################
5
import numpy as np
6
7
# parameters H = Hgl + dhdx * x
8
Hgl = 400.0
9
dhdx = -1.0e-3
10
11
# mu and sigma to generate noise from a normal distribution
12
mu = 0.0
13
sigma = 20.0
14
15
# the ice true thickness
16
def H(x):
17
z = Hgl + dhdx*x
18
return z
19
20
# make the obs
21
def MakeObs(x,y):
22
23
24
nn=len(x)*len(y)
25
r = np.random.normal(mu, sigma, nn)
26
27
with open('Hflight.txt', 'w') as f:
28
for i in range(len(x)):
29
for j in range(len(y)):
30
h = H(x[i]) + r[i*len(y)+j]
31
f.write("{} {} {}\n".format(x[i], y[j], h))
32
f.close()
33
34
if __name__ == "__main__":
35
36
37
# generate 3 lines at x=
38
x = np.linspace(50e3, 150e3, 3)
39
40
# resolution along y
41
y = np.linspace(0.0, 50e3, 51)
42
43
MakeObs(x,y)
44
45
46