283 real data2(nsamp2), data3(nsamp1)
284 integer nsamp1, nsamp2, ifirst, ilast
285 real tanf1, tanf2, dt1, dt2
288 parameter(verbose=.true.)
291 parameter(maxspec=100000)
292 complex spect(maxspec)
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.))
303 print *,
'do some resampling...' 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
314 oselbeg=(oifirst-1)*dt2+tanf2
315 oselend=(oilast-1)*dt2+tanf2
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' 335 do while(nspec.lt.onspec)
338 if (nspec.gt.maxspec) stop
'ERROR: maxspec too small!' 340 print *,
'preparing spectrum with ',nspec,
' samples' 345 print *,
' extracting' 346 print *,
' original trace ',oifirst,
'-',oifirst-1+onspec
347 print *,
' to spectrum trace ',1,
'-',onspec
349 spect(i)=cmplx(data2(oifirst+i-1))
352 call tf_fork(nspec,spect,-1.)
355 print *,
' we hold the spectrum now' 356 print *,
' going to perform resampling DFT (which will be slow)...' 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
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
366 c 1./(dt*nsamples) is the frequency step
size 369 print *,
' old sampling interval (',dt2,
'sec)' 370 print *,
' is less than new one (',dt1,
'sec) !' 372 &
' it''s up to you to perform a correct low pass filtering' 376 expfacbase=2.*pi*ime/(dt2*float(nspec))
380 nextper=nout*dper/100.
384 c print *,
'calc sample ',i,
' at ',t,
'sec' 385 expfac=expfacbase*(t-oselbeg)
386 if ((t.lt.oselbeg).or.(t.gt.oselend))
then 390 sum=0.5*
real(spect(1))
392 sum=sum+
real(spect(ispec)*cexp(expfac*float(ispec-1)))
394 sum=sum+0.5*
real(spect(limit+1)*cexp(expfac*(limit)))
395 data3(i)=2.*sum/sqrt(float(nspec))
397 if (i.gt.nextper)
then 398 print *,
' finished ',percount*dper,
'%' 400 nextper=percount*nout*dper/100.
403 print *,
' finished 100.%'