Waveform filter programs
tsfilt.f
Go to the documentation of this file.
1 c this is <tsfilt.f>
2 c ----------------------------------------------------------------------------
3 c
4 c Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
5 c
6 c filter a time series given as a singal table
7 c
8 c ----
9 c This program is free software; you can redistribute it and/or modify
10 c it under the terms of the GNU General Public License as published by
11 c the Free Software Foundation; either version 2 of the License, or
12 c (at your option) any later version.
13 c
14 c This program is distributed in the hope that it will be useful,
15 c but WITHOUT ANY WARRANTY; without even the implied warranty of
16 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 c GNU General Public License for more details.
18 c
19 c You should have received a copy of the GNU General Public License
20 c along with this program; if not, write to the Free Software
21 c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 c ----
23 c
24 c REVISIONS and CHANGES
25 c 24/05/2002 V1.0 Thomas Forbriger
26 c
27 c ============================================================================
28 c
29  program tsfilt
30 c
31  character*(*) version
32  parameter(version=
33  & 'TSFILT V1.0 filter a time series given as a signal table')
34 c
35  character*80 infile, outfile, filtfile
36  integer lui,luo,luf
37  parameter(lui=10,luo=11,luf=12)
38  integer msamp,nsamp,i
39  parameter(msamp=1000000)
40  real tmin,tsec,dt
41  integer tfstr_trimlen
42  character*120 par,msg
43  character*3 typ
44  double precision x(msamp),t(msamp)
45 c commandline
46  integer maxopt, lastarg, iargc
47  character*80 argument
48  parameter(maxopt=2)
49  character*2 optid(maxopt)
50  character*40 optarg(maxopt)
51  logical optset(maxopt), opthasarg(maxopt)
52 c debugging
53  logical debug, verbose
54 c here are the keys to our commandline options
55  data optid/2h-d, 2h-v/
56  data opthasarg/2*.false./
57  data optarg/2*1h-/
58 c
59 c------------------------------------------------------------------------------
60 c basic information
61 c
62 c
63  argument=' '
64  if (iargc().eq.1) call getarg(1, argument)
65  if ((argument(1:5).eq.'-help').or.(iargc().lt.3)) then
66  print *,version
67  print *,'Usage: tsfilt infile outfile filtfile'
68  print *,' or: tsfilt -help'
69  if (argument(1:5).ne.'-help')
70  & stop 'ERROR: wrong number of arguments'
71  print *,' '
72  print *,'infile input signal'
73  print *,'outfile output signal'
74  print *,'filtfile seife control file (see stufi)'
75  print *,' '
76  print *,'infile and outfile are two-column ASCII data files.'
77  print *,'The first column contains time in seconds, the'
78  print *,'second column provides the respective sample values.'
79  print *,'Sampling is assumed to be equidistant. This'
80  print *,'assumption is not(!) checked against actual sample'
81  print *,'times. The time of first sample and the sampling'
82  print *,'interval are derived from the first two time'
83  print *,'values.'
84  stop
85  endif
86 c
87 c------------------------------------------------------------------------------
88 c read command line arguments
89  call getarg(1,infile)
90  call getarg(2,outfile)
91  call getarg(3,filtfile)
92 c
93  call tf_cmdline(1, lastarg, maxopt, optid,
94  & optarg, optset, opthasarg)
95  debug=optset(1)
96  verbose=optset(2)
97 c
98 c------------------------------------------------------------------------------
99 c go
100  nsamp=1
101  open(lui,file=infile)
102  1 read(lui, *, err=99, end=2) t(nsamp),x(nsamp)
103  nsamp=nsamp+1
104  goto 1
105  2 close(lui)
106  nsamp=nsamp-1
107 c
108  dt=t(2)-t(1)
109  tsec=t(1)
110  tmin=int(tsec/60.)
111  tsec=tsec-60.*tmin
112 c
113  open(luf,file=filtfile)
114  3 read(luf, '(a120)') msg
115  if (msg(1:3).eq.'end') goto 4
116  typ=msg(1:3)
117  par=msg(4:)
118  call seife(typ, par, nsamp, dt, tmin, tsec, x, msg)
119  print *,msg(1:tfstr_trimlen(msg))
120  goto 3
121  4 close(luf)
122 c
123  open(luo,file=outfile)
124  do i=1,nsamp
125  write(luo, 50) tmin*60.+tsec+(i-1)*dt,x(i)
126  enddo
127  close(luo)
128 c
129  stop
130  50 format(2(2x,g20.14))
131  99 stop 'ERROR: reading data'
132  end
133 c
134 c ----- END OF tsfilt.f -----
program tsfilt
Definition: tsfilt.f:29