1 c===========================================================================
3 c This file is part of TISEAN
5 c Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
7 c TISEAN is free software; you can redistribute it and/or modify
8 c it under the terms of the GNU General Public License as published by
9 c the Free Software Foundation; either version 2 of the License, or
10 c (at your option) any later version.
12 c TISEAN is distributed in the hope that it will be useful,
13 c but WITHOUT ANY WARRANTY; without even the implied warranty of
14 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 c GNU General Public License for more details.
17 c You should have received a copy of the GNU General Public License
18 c along with TISEAN; if not, write to the Free Software
19 c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 c===========================================================================
24 c add Gaussian / uniform white noise
25 c author T. Schreiber (1998)
26 c===========================================================================
29 character*72 file, fout
32 data eps/0./, frac/0./, iuni/0/
35 call whatido("add Gaussian/uniform noise",iverb)
41 if(lopt("u",1).eq.1) iuni=1
42 isout=igetout(fout,iverb)
43 if(eps.eq.0.and.frac.eq.0.) call usage()
45 if(lopt("0",1).eq.1.and.eps.gt.0) then
46 if(isout.eq.1) fout="0_noisy"
54 call writefile(nmaxx,x,fout,iverb)
58 do 20 ifi=1,nstrings()
59 call nthstring(ifi,file)
61 call readfile(nmax,x,nexcl,jcol,file,iverb)
62 if(file.eq."-") file="stdin"
63 call rms(nmax,x,sc,sd)
64 if(frac.gt.0) eps=sd*frac
66 if(iv_io(iverb).eq.1) write(istderr(),*)
67 . "adding uniform noise in [0,", eps,"]"
69 if(iv_io(iverb).eq.1) write(istderr(),*)
70 . "adding Gaussian noise of amplitude", eps
72 if(sd.gt.0.and.iv_io(iverb).eq.1) write(istderr(),*)
73 . "that is",eps/sd,"* rms of data"
76 x(n)=x(n)+rand(0.0)*eps
78 x(n)=x(n)+rgauss(0.0,eps)
81 if(isout.eq.1) call addsuff(fout,file,"_noisy")
82 20 call writefile(nmax,x,fout,iverb)
89 . "[-r# | -v#] [-u -0 -o outfile -l# -x# -c# -V# -h] file(s)")
90 call ptext("either -r or -v must be present")
91 call popt("r","absolute noise level")
92 call popt("v","same as fraction of standard deviation")
93 call popt("u","add uniform noise (default Gaussian)")
94 call popt("0","do not read input, just issue random numbers")
95 call popt("l","number of values to be read (all)")
96 call popt("x","number of values to be skipped (0)")
97 call popt("c","column to be read (1 or file,#)")
98 call pout("file_noisy")