Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/examples/Inverse_Methods/DATA/AddNoise.py
3206 views
1
import numpy as np
2
from pylab import genfromtxt;
3
4
STD=1.0
5
6
fname="MacAyeal_VELOCITIES.txt"
7
mat = genfromtxt(fname);
8
9
npoints=np.size(mat,0)
10
11
noiseU = np.random.normal(0, STD, npoints)
12
noiseV = np.random.normal(0, STD, npoints)
13
14
rms=np.sqrt(np.sum((noiseU*noiseU)+(noiseV*noiseV))/npoints)
15
print(rms)
16
17
matn=mat
18
matn[:,2]=mat[:,2]+noiseU
19
matn[:,3]=mat[:,3]+noiseV
20
21
np.savetxt('MacAyeal_VELOCITIES_NOISE.txt',matn, delimiter=' ')
22
23