diff options
Diffstat (limited to 'lib/msk40spd.f90')
| -rw-r--r-- | lib/msk40spd.f90 | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/msk40spd.f90 b/lib/msk40spd.f90 index 63532ae9..65321849 100644 --- a/lib/msk40spd.f90 +++ b/lib/msk40spd.f90 @@ -3,7 +3,9 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & ! msk40 short-ping-decoder use packjt77 + use msk_spectrum, only: msk_clip_spectrum_window,msk_peak_offset use timer_module, only: timer + use, intrinsic :: ieee_arithmetic, only: ieee_is_finite parameter (NSPM=240, MAXSTEPS=150, NFFT=NSPM, MAXCAND=5, NPATTERNS=6) character*12 mycall,hiscall @@ -20,6 +22,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & integer navmask(3) integer nstart(MAXCAND) logical ismask(NFFT) + logical high_window_usable,low_window_usable logical*1 bswl real detmet(-2:MAXSTEPS+3) real detmet2(-2:MAXSTEPS+3) @@ -29,7 +32,8 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & real snrs(MAXCAND) real tonespec(NFFT) real tpat(NPATTERNS) - real*8 dt, df, fs, pi, twopi + real*8 dt,df,fs,pi,twopi,nfhi,nflo + real*8 ihlo_requested,ihhi_requested,illo_requested,ilhi_requested logical first data first/.true./ data navpatterns/ & @@ -42,6 +46,10 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & data tpat/1.5,0.5,2.5,1.0,2.0,1.5/ save df,first,fs,pi,twopi,dt,tframe,rcw + nsuccess=0 + msgreceived=' ' + if(n.lt.3*NSPM .or. ntol.lt.0 .or. .not.ieee_is_finite(fc)) return + if(first) then nmatchedfilter=1 ! define half-sine pulse and raised-cosine edge window @@ -62,16 +70,21 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & ! fill the detmet, detferr arrays - nstep=(n-NSPM)/60 ! 20ms/4=5ms steps + nstep=min(MAXSTEPS,(n-NSPM)/60) ! 20ms/4=5ms steps detmet=0 detmet2=0 detfer=-999.99 - nfhi=2*(fc+500) - nflo=2*(fc-500) - ihlo=nint((nfhi-2*ntol)/df)+1 - ihhi=nint((nfhi+2*ntol)/df)+1 - illo=nint((nflo-2*ntol)/df)+1 - ilhi=nint((nflo+2*ntol)/df)+1 + nfhi=2d0*(dble(fc)+500d0) + nflo=2d0*(dble(fc)-500d0) + ihlo_requested=(nfhi-2d0*dble(ntol))/df + 1d0 + ihhi_requested=(nfhi+2d0*dble(ntol))/df + 1d0 + illo_requested=(nflo-2d0*dble(ntol))/df + 1d0 + ilhi_requested=(nflo+2d0*dble(ntol))/df + 1d0 + call msk_clip_spectrum_window(NFFT,ihlo_requested,ihhi_requested,ihlo,ihhi, & + high_window_usable) + call msk_clip_spectrum_window(NFFT,illo_requested,ilhi_requested,illo,ilhi, & + low_window_usable) + if(.not.high_window_usable .or. .not.low_window_usable) return i2000=nint(nflo/df)+1 i4000=nint(nfhi/df)+1 do istp=1,nstep @@ -94,7 +107,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & ismask(ihlo:ihhi)=.true. ! high tone search window iloc=maxloc(tonespec,ismask) ihpk=iloc(1) - deltah=-real( (ctmp(ihpk-1)-ctmp(ihpk+1)) / (2*ctmp(ihpk)-ctmp(ihpk-1)-ctmp(ihpk+1)) ) + deltah=msk_peak_offset(ctmp,ihpk) ah=tonespec(ihpk) ahavp=(sum(tonespec,ismask)-ah)/count(ismask) trath=ah/(ahavp+0.01) @@ -102,7 +115,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & ismask(illo:ilhi)=.true. ! window for low tone iloc=maxloc(tonespec,ismask) ilpk=iloc(1) - deltal=-real( (ctmp(ilpk-1)-ctmp(ilpk+1)) / (2*ctmp(ilpk)-ctmp(ilpk-1)-ctmp(ilpk+1)) ) + deltal=msk_peak_offset(ctmp,ilpk) al=tonespec(ilpk) alavp=(sum(tonespec,ismask)-al)/count(ismask) tratl=al/(alavp+0.01) @@ -121,6 +134,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & call indexx(detmet(1:nstep),nstep,indices) !find median of detection metric vector xmed=detmet(indices(nstep/4)) + if(xmed.le.0.0 .or. .not.ieee_is_finite(xmed)) return detmet=detmet/xmed ! noise floor of detection metric is 1.0 ndet=0 @@ -152,8 +166,6 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & enddo endif - nsuccess=0 - msgreceived=' ' npeaks=2 ntol0=29 deltaf=7.2 |
