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===========================================================================
22 c notch filter in the time domain
24 c===========================================================================
27 dimension x(nx), y(nx)
28 character*72 file, fout
29 data h/1./, w/0.01/, pi/3.1415926/
32 call whatido("notch filter",iverb)
40 isout=igetout(fout,iverb)
42 do 10 ifi=1,nstrings()
43 call nthstring(ifi,file)
45 call readfile(nmax,x,nexcl,jcol,file,iverb)
46 if(file.eq."-") file="stdin"
47 d=fnotch(nmax,x,y,fw,w)
48 if(isout.eq.1) call addsuff(fout,file,"_notch")
49 10 call writefile(nmax,y,fout,iverb)
52 function fnotch(nmax,x,y,fw,w)
53 dimension x(nmax), y(nmax)
59 d1= 2*(1-w**2*fw**2-fw**2)/a
60 d2= -((1-w*fw)**2+fw**2)/a
63 y(2)=c0*x(2)+c1*x(1)+d1*y(1)
65 10 y(n)=c0*x(n)+c1*x(n-1)+c2*x(n-2)+d1*y(n-1)+d2*y(n-2)
68 20 fnotch=fnotch+(x(n)-y(n))**2
69 fnotch=sqrt(fnotch/nmax)
76 . "-X# [-f# -w# -o outfile -l# -x# -c# -V# -h] file(s)")
77 call popt("X","frequency to be cancelled")
78 call popt("f","sampling rate of data (1)")
79 call popt("w","width of filter (f/100)")
80 call popt("l","number of values to be read (all)")
81 call popt("x","number of values to be skipped (0)")
82 call popt("c","column to be read (1 or file,#)")
83 call pout("file_notch")