diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /map65/libm65/decode1a.f90 | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'map65/libm65/decode1a.f90')
| -rw-r--r-- | map65/libm65/decode1a.f90 | 135 |
1 files changed, 115 insertions, 20 deletions
diff --git a/map65/libm65/decode1a.f90 b/map65/libm65/decode1a.f90 index 4219c004..691593fd 100644 --- a/map65/libm65/decode1a.f90 +++ b/map65/libm65/decode1a.f90 @@ -1,3 +1,7 @@ +module decode1a_mod + implicit none +contains + subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & mycall,hiscall,hisgrid,neme,ndepth,nqd,dphi,ndphi, & nutc,nkhz,ndf,ipol,ntol,sync2,a,dt,pol,nkv,nhist,nsum,nsave, & @@ -6,29 +10,72 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & ! Apply AFC corrections to a candidate JT65 signal, then decode it. use timer_module, only: timer - parameter (NMAX=60*96000) !Samples per 60 s - real*4 dd(4,NMAX) !92 MB: raw data from Linrad timf2 - complex cx(NMAX/64), cy(NMAX/64) !Data at 1378.125 samples/s - complex c5x(NMAX/256),c5y(NMAX/256) !Data at 344.53125 Hz + use iso_c_binding, only: c_ptr, c_loc + use, intrinsic :: ieee_arithmetic, only: ieee_is_finite + use debug_log + use afc65b_mod + use filbig_mod + use decode65b_mod + use s3avg_mod + use four2a_mod + use timf2_mod + use fil6521_mod + use twkfreq_xy_mod + use npar_ptrs_mod, only: nsmax_active + use sec_midn_mod, only: sec_midn + + implicit none + + real(real32), intent(in) :: dd(4, nsmax_active) !92 MB: raw data from Linrad timf2 + integer, intent(in) :: nflip, mode65, nfsample + logical, intent(in) :: xpol + character(len=12), intent(in) :: mycall, hiscall + character(len=6), intent(in) :: hisgrid + integer, intent(in) :: neme, ndepth, nqd, ndphi + real, intent(in) :: dphi + real(real64), intent(in) :: f0 + integer, intent(in) :: nutc, nkhz, ndf, ntol + integer, intent(inout) :: ipol + real, intent(inout):: sync2, a(5), dt, pol, qual + integer, intent(inout):: nkv, nhist, nsum, nsave, newdat + character(len=22), intent(out) :: decoded + + complex cx(nsmax_active/64), cy(nsmax_active/64) !Data at 1378.125 samples/s + complex c5x(nsmax_active/256), c5y(nsmax_active/256) !Data at 344.53125 Hz + complex c5a(512) complex z real s2(66,126) real s3(64,63),sy(63) - real a(5) - logical first,xpol - character decoded*22 - character mycall*12,hiscall*12,hisgrid*6 + + real :: aa, bb, ccfbest, dt00, flip + real :: dtbest, fsample, sq0, sqa, sqb, syncbest + integer :: i, i0, ihzdiff, j, jj, jjjmax, jjjmin, k, n, n5 + integer :: n6, nadd, nfft, nhz, nhz0, npol, nsym, nutc0, nz + logical first + +! real(kind=8) :: s2sum, s2mean +! integer :: ii,kk + +! real(c_double), dimension(*) :: dd data first/.true./,jjjmin/1000/,jjjmax/-1000/ - data nutc0/-999/,nhz0/-9999999/ + data nutc0/-999/,nhz0/-9999999/ save - + ! Mix sync tone to baseband, low-pass filter, downsample to 1378.125 Hz dt00=dt call timer('filbig ',0) - call filbig(dd,NMAX,f0,newdat,nfsample,xpol,cx,cy,n5) -! NB: cx, cy have sample rate 96000*77125/5376000 = 1378.125 Hz + + if (.not. ieee_is_finite(f0)) then + write(*,*) 'DECODE1A: bad f0, skipping filbig. f0=', f0 + return + end if + call filbig(dd, nsmax_active, f0, newdat, nfsample, xpol, cx, cy, n5) + call timer('filbig ',1) - if(mode65.eq.0) goto 900 + +! NB: cx, cy have sample rate 96000*77125/5376000 = 1378.125 Hz + if(mode65.eq.0) return sqa=0. sqb=0. do i=1,n5 @@ -50,10 +97,14 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & if(xpol) then c5y(:nadd)=0. call fil6521(cy,n5,c5y(nadd+1),n6) + else + c5y(:n6+nadd)=0. endif n6=n6+nadd - fsample=1378.125/4. + ! JT65 uses quarter-rate for symbol timing + fsample = 1378.125/4.0 + a(5)=dt00 i0=nint((a(5)+0.5)*fsample) - 2 + nadd if(i0.lt.1) then @@ -63,10 +114,30 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & endif nz=n6+1-i0 + ! 2026-09-12: instrumentation for the "identical anomalous dtbest despite + ! identical, legitimate dt00" investigation. dt00 itself is now confirmed + ! correct and consistent between working (nqd=1) and failing (nqd=0) + ! decodes of the same signal (traced to ccf65's lagpk, a genuine + ! correlation-peak lag, not a fallback constant) -- so the actual sample + ! window afc65b searches (c5x/c5y from i0 to i0+nz-1) is the next place to + ! look. Logging i0/nz and a cheap fingerprint (sum of magnitudes) of that + ! exact window so a live capture can show directly whether the underlying + ! data itself differs between a working and failing case. + if (nz .ge. 1 .and. i0 .ge. 1 .and. i0 + nz - 1 .le. nsmax_active/256) then + call dbg('decode1a: pre-afc65b at t=' // rtoa(sec_midn()) // & + ' i0=' // itoa(i0) // ' nz=' // itoa(nz) // ' n5=' // itoa(n5) // & + ' n6=' // itoa(n6) // ' dt00=' // rtoa(dt00) // & + ' c5x_sum_abs=' // rtoa(sum(abs(c5x(i0:i0+nz-1)))) // & + ' c5x_i0=' // rtoa(real(c5x(i0))) // ',' // rtoa(aimag(c5x(i0)))) + else + call dbg('decode1a: pre-afc65b at t=' // rtoa(sec_midn()) // & + ' i0=' // itoa(i0) // ' nz=' // itoa(nz) // ' (OUT OF RANGE, skipping fingerprint)') + endif + ! We're looking only at sync tone here... so why not downsample by another ! factor of 1/8, say? Should be a significant execution speed-up. ! Best fit for DF, f1, f2, pol - call afc65b(c5x(i0),c5y(i0),nz,fsample,nflip,ipol,xpol,ndphi,a,ccfbest,dtbest) +call afc65b(c5x(i0), c5y(i0), nz, fsample, nflip, ipol, xpol, ndphi, a, ccfbest, dtbest) pol=a(4)/57.2957795 aa=cos(pol) @@ -74,6 +145,13 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & sq0=aa*aa*sqa + bb*bb*sqb sync2=3.7*ccfbest/sq0 + ! TEMP diagnostic 2026-09-10 for the freq/time-sync-vs-false-decode investigation. + call dbg('decode1a: afc65b fit at t=' // rtoa(sec_midn()) // & + ' f0=' // rtoa(real(f0)) // ' dt00=' // rtoa(dt00) // ' dtbest=' // rtoa(dtbest) // & + ' ccfbest=' // rtoa(ccfbest) // ' a1(df)=' // rtoa(a(1)) // ' a2=' // rtoa(a(2)) // & + ' a3=' // rtoa(a(3)) // ' a4(pol_deg)=' // rtoa(a(4)) // ' sync2=' // rtoa(sync2) // & + ' nflip=' // itoa(nflip) // ' ipol=' // itoa(ipol)) + ! Apply AFC corrections to the time-domain signal ! Now we are back to using the 1378.125 Hz sample rate, enough to ! accommodate the full JT65C bandwidth. @@ -87,7 +165,9 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & nsym=126 nfft=512 - j=(dt00+dtbest+2.685)*1378.125 + j = (dt00 + dtbest + 2.685)*1378.125 +! fs_out = real(n5) / 60.0 ! actual sample rate from filbig +! j = (dt00 + dtbest + 2.685) * fs_out if(j.lt.0) j=0 @@ -98,7 +178,7 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & ! do n=1,mode65 do n=1,1 do i=1,nfft - j=min(j+1,NMAX/64) + j = min(j+1, nsmax_active/64) c5a(i)=aa*cx(j) + bb*cy(j) enddo call four2a(c5a,nfft,1,1,1) @@ -120,8 +200,22 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & flip=nflip call timer('dec65b ',0) + +! After filling s2(66,126), just before: +! call decode65b(...) + +!s2sum = 0.0d0 +!do kk = 1, nsym +! do ii = 1, 66 +! s2sum = s2sum + dble(s2(ii,kk)) +! end do +!end do + +!s2mean = s2sum / dble(66*nsym) + call decode65b(s2,flip,mycall,hiscall,hisgrid,mode65,neme,ndepth, & nqd,nkv,nhist,qual,decoded,s3,sy) + dt=dt00 + dtbest + 1.7 call timer('dec65b ',1) @@ -134,12 +228,13 @@ subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, & nsave=mod(nsave-1,64)+1 npol=nint(57.296*pol) - call s3avg(nsave,mode65,nutc,nhz,xdt,npol,ntol,s3,nsum,nkv,decoded) + call s3avg(nsave,mode65,nutc,nhz,dt,npol,nflip,ntol,s3,nsum,nkv,decoded) syncbest=sync2 nhz0=nhz endif nutc0=nutc endif - -900 return + end subroutine decode1a + +end module decode1a_mod |
