Waveform filter programs

◆ resamp()

subroutine resamp ( real, dimension(nsamp2)  data2,
real, dimension(nsamp1)  data3,
integer  nsamp1,
integer  nsamp2,
real  tanf1,
real  dt1,
real  tanf2 
)

Definition at line 281 of file dise.f.

Referenced by dise().

281  & ifirst, ilast)
282 c
283  real data2(nsamp2), data3(nsamp1)
284  integer nsamp1, nsamp2, ifirst, ilast
285  real tanf1, tanf2, dt1, dt2
286 c
287  logical verbose
288  parameter(verbose=.true.)
289 c
290  integer maxspec
291  parameter(maxspec=100000)
292  complex spect(maxspec)
293  integer nspec
294 c
295  real pi, t, sum,dper,selbeg,selend,oselbeg,oselend
296  integer ispec,i,oifirst,oilast,onspec,nout
297  integer limit,percount,nextper
298  complex ime, expfac, expfacbase
299  parameter(pi=3.1415926535897931159979,ime=(0.,1.))
300 c
301  if (verbose) then
302  print *,' '
303  print *,'do some resampling...'
304  endif
305 c
306  selbeg=(ifirst-1)*dt1+tanf1
307  selend=(ilast-1)*dt1+tanf1
308  oifirst=int((selbeg-tanf2)/dt2)
309  oilast=2+int((selend-tanf2)/dt2)
310  if ((oifirst.gt.oilast).or.(oifirst.lt.1).or.(oilast.gt.nsamp2))
311  & stop 'ERROR: check times'
312  onspec=oilast-oifirst+1
313  nout=ilast-ifirst+1
314  oselbeg=(oifirst-1)*dt2+tanf2
315  oselend=(oilast-1)*dt2+tanf2
316 c
317  print *,' original trace:'
318  print *,' first sample: ',tanf2,'sec; last sample: ',
319  & (nsamp2-1)*dt2+tanf2,'sec'
320  print *,' sampling interval: ',dt2,'sec'
321  print *,' selected first sample: ',oifirst
322  print *,' selected last sample: ',oilast
323  print *,' selected start time: ',oselbeg,'sec'
324  print *,' selected end time: ',oselend,'sec'
325  print *,' master trace:'
326  print *,' first sample: ',tanf1,'sec; last sample: ',
327  & (nsamp1-1)*dt1+tanf1,'sec'
328  print *,' sampling interval: ',dt1,'sec'
329  print *,' selected first sample: ',ifirst
330  print *,' selected last sample: ',ilast
331  print *,' selected start time: ',selbeg,'sec'
332  print *,' selected end time: ',selend,'sec'
333 c
334  nspec=2
335  do while(nspec.lt.onspec)
336  nspec=nspec*2
337  enddo
338  if (nspec.gt.maxspec) stop 'ERROR: maxspec too small!'
339 c
340  print *,'preparing spectrum with ',nspec,' samples'
341  do i=1,nspec
342  spect(i)=(0.,0.)
343  enddo
344 c
345  print *,' extracting'
346  print *,' original trace ',oifirst,'-',oifirst-1+onspec
347  print *,' to spectrum trace ',1,'-',onspec
348  do i=1,onspec
349  spect(i)=cmplx(data2(oifirst+i-1))
350  enddo
351 c
352  call tf_fork(nspec,spect,-1.)
353 c
354  if (verbose) then
355  print *,' we hold the spectrum now'
356  print *,' going to perform resampling DFT (which will be slow)...'
357  endif
358 c
359 c
360 c dt*sqrt(nsamples) is the factor we have to multiply in order to get
361 c spectral coefficients corresponding to a foruier integral transform
362 c
363 c dt*(nsamples-1) is the time length of the original trace, which is the
364 c recurrence time of the time limited fourier signal
365 c
366 c 1./(dt*nsamples) is the frequency step size
367 c
368  if (dt1.gt.dt2) then
369  print *,' old sampling interval (',dt2,'sec)'
370  print *,' is less than new one (',dt1,'sec) !'
371  print *,
372  & ' it''s up to you to perform a correct low pass filtering'
373  endif
374 c
375 c
376  expfacbase=2.*pi*ime/(dt2*float(nspec))
377  limit=nspec/2
378  dper=10.
379  percount=1
380  nextper=nout*dper/100.
381 c
382  do i=1,nout
383  t=(i-1)*dt1+selbeg
384 c print *,'calc sample ',i,' at ',t,'sec'
385  expfac=expfacbase*(t-oselbeg)
386  if ((t.lt.oselbeg).or.(t.gt.oselend)) then
387  data3(i)=0.
388  print *,'trapped'
389  else
390  sum=0.5*real(spect(1))
391  do ispec=2,limit
392  sum=sum+real(spect(ispec)*cexp(expfac*float(ispec-1)))
393  enddo
394  sum=sum+0.5*real(spect(limit+1)*cexp(expfac*(limit)))
395  data3(i)=2.*sum/sqrt(float(nspec))
396  endif
397  if (i.gt.nextper) then
398  print *,' finished ',percount*dper,'%'
399  percount=percount+1
400  nextper=percount*nout*dper/100.
401  endif
402  enddo
403  print *,' finished 100.%'
404 c
405  return
Here is the caller graph for this function: