From c7d68d0d48a87ec30135a45edd6085a0aee0fc40 Mon Sep 17 00:00:00 2001
From: Joe Taylor <k1jt@arrl.org>
Date: Fri, 24 Mar 2006 19:12:51 +0000
Subject: [PATCH] Small tweak to deep search algorithm. Don't compute waterfall
 spectrum while decoding. Force upper case for decoded test.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@132 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
---
 deep65.f     | 26 ++++++++++++++++----------
 demod64a.f   |  3 +++
 ftn_init.f90 |  2 +-
 specjt.py    |  6 ++++--
 wsjt65.f     |  8 ++++++--
 5 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/deep65.f b/deep65.f
index 0ef46fcc8..8f7a49a5e 100644
--- a/deep65.f
+++ b/deep65.f
@@ -12,6 +12,7 @@
       character*4 rpt(MAXRPT)
       logical first
       integer ncode(63,2*MAXCALLS)
+      common/tmp9/ mrs(63),mrs2(63)
 
       data neme0/-99/
       data rpt/'-01','-02','-03','-04','-05',
@@ -89,13 +90,9 @@
  20   ntot=k
       neme0=neme
 
-      sum0=0.
+      ref0=0.
       do j=1,63
-         smax=-1.e30
-         do i=1,64
-            smax=max(smax,s3(i,j))
-         enddo
-         sum0=sum0+smax
+         ref0=ref0 + s3(mrs(j),j)
       enddo
 
       p1=-1.e30
@@ -104,20 +101,29 @@
 C  If sync=OOO, no CQ messages
          if(flip.lt.0.0 .and. testmsg(k)(1:3).eq.'CQ ') go to 30
          sum=0.
+         ref=ref0
+         nhard=0
          do j=1,63
             i=ncode(j,k)+1
             sum=sum + s3(i,j)
+            if(i.eq.mrs(j)) then
+               ref=ref - s3(i,j) + s3(mrs2(j),j)
+               nhard=nhard+1
+            endif
          enddo
+         sum=sum/ref
          if(sum.gt.p1) then
             p1=sum
             ip1=k
+            ref1=ref
+            nhard1=nhard
          endif
  30   enddo
 
-      p1=p1/sum0
-      qual=100.0*(p1-0.40)
-      if(mode65.eq.1) qual=100.0*(p1-0.33)
-      if(mode65.eq.4) qual=100.0*(p1-0.50)
+      qual=100.0*(p1-0.405)
+      print*,nhard1,ref1/ref0,qual,100.0*(p1*(ref1/ref0)-0.40)
+      if(mode65.eq.1) qual=100.0*(p1-0.335)
+      if(mode65.eq.4) qual=100.0*(p1-0.505)
       if(qual.lt.0.) qual=0.
       if(qual.gt.10.) qual=10.
       decoded='                      '
diff --git a/demod64a.f b/demod64a.f
index 700ef7b85..fc024f862 100644
--- a/demod64a.f
+++ b/demod64a.f
@@ -14,6 +14,7 @@ C     mr2prob  probability that mr2sym was the transmitted value
       real*4 signal(64,63)
       real*8 fs(64)
       integer mrsym(63),mrprob(63),mr2sym(63),mr2prob(63)
+      common/tmp9/ mrs(63),mrs2(63)
 
       afac=1.1 * float(nadd)**0.64
       scale=255.999
@@ -54,6 +55,8 @@ C  Compute probabilities for most reliable symbol values
          mr2sym(j)=i2-1
          mrprob(j)=scale*p1
          mr2prob(j)=scale*p2
+         mrs(j)=i1
+         mrs2(j)=i2
       enddo
 
       sum=0.
diff --git a/ftn_init.f90 b/ftn_init.f90
index b98252410..61b7948d0 100644
--- a/ftn_init.f90
+++ b/ftn_init.f90
@@ -18,7 +18,7 @@
 !------------------------------------------------ ftn_init
 subroutine ftn_init
 
-  character*1 cjunk,fname*80
+  character*1 cjunk
   include 'gcom1.f90'
   include 'gcom2.f90'
   include 'gcom3.f90'
diff --git a/specjt.py b/specjt.py
index c59ecf86d..013681974 100644
--- a/specjt.py
+++ b/specjt.py
@@ -217,7 +217,10 @@ def update():
     contrast=sc2.get()
     logm=logmap.get()
     g0=sc3.get()
-    if Audio.gcom2.monitoring or Audio.gcom2.ndiskdat:
+    
+# Don't calculate spectra for waterfall while decoding
+    if Audio.gcom2.ndecoding==0 and \
+           (Audio.gcom2.monitoring or Audio.gcom2.ndiskdat):
         Audio.spec(brightness,contrast,logm,g0,nspeed,a) #Call Fortran routine spec
         newdat=Audio.gcom1.newdat                   #True if new data available
     else:
@@ -253,7 +256,6 @@ def update():
             if minsep.get():
                 draw.line((0,0,749,0),fill=128)     #Draw the minute separator
 
-# Don't update waterfall while decoding
         pim=ImageTk.PhotoImage(im)              #Convert Image to PhotoImage
         graph1.delete(ALL)
         #For some reason, top two lines are invisible, so we move down 2
diff --git a/wsjt65.f b/wsjt65.f
index 280cb9218..4fcdf4677 100644
--- a/wsjt65.f
+++ b/wsjt65.f
@@ -15,7 +15,7 @@ C  already been done.
       character decoded*22,cfile6*6,special*5,cooo*3
       character*22 avemsg1,avemsg2,deepmsg,deepbest
       character*67 line,ave1,ave2
-      character*1 csync
+      character*1 csync,c1
       character*12 mycall
       character*12 hiscall
       character*6 hisgrid
@@ -160,6 +160,10 @@ C  result from the Reed-Solomon decoder.
       if(flip.lt.0.0 .and. (kvqual.eq.1 .or. nqual.ge.nq2)) cooo='OOO'
       if(kvqual.eq.0.and.nqual.ge.nq1.and.nqual.lt.nq2) cooo(2:3)=' ?'
       if(decoded.eq.'                      ') cooo='   '
+      do i=1,22
+         c1=decoded(i:i)
+         if(c1.ge.'a' .and. c1.le.'z') decoded(i:i)=char(ichar(c1)-32)
+      enddo
       write(line,1010) cfile6,nsync,nsnr,dtx-1.0,ndf,
      +    nint(width),csync,special,decoded(1:18),cooo,kvqual,nqual,itry
  1010 format(a6,i3,i5,f5.1,i5,i3,1x,a1,1x,a5,a18,1x,a3,i5,i3,i2)
@@ -175,7 +179,7 @@ C  Blank DT if shorthand message  (### wrong logic? ###)
       endif
 
 C  Blank the end-of-line numbers
-      if(naggressive.eq.0) line(58:67)='         '
+      if(naggressive.eq.0 .and. ndiag.eq.0) line(58:67)='         '
       if(ndiag.eq.0) line(66:67)='  '
 
       if(lcum) write(21,1011) line