Go back to old version of pctile, using a full sort.

Better calc of snrdb, especially for strong signals.


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2719 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-11-12 18:28:28 +00:00
parent 5d030bd413
commit c35b1c13ad
6 changed files with 32 additions and 45 deletions

View File

@ -8,6 +8,7 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
parameter (NSMAX=22000) !Max length of saved spectra
character*22 msg
character*33 line
character*80 fmt
real*4 ccfred(NSMAX)
integer*1 i1SoftSymbols(207)
integer*2 id2
@ -38,18 +39,23 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
if(ntrMinutes.eq.1) then
nsps=6912
df3=1500.0/2048.0
fmt='(i4.4,i4,i5,f6.1,f8.0,f6.2,3x,a22)'
else if(ntrMinutes.eq.2) then
nsps=15360
df3=1500.0/2048.0
fmt='(i4.4,i4,i5,f6.1,f8.1,f6.2,3x,a22)'
else if(ntrMinutes.eq.5) then
nsps=40960
df3=1500.0/6144.0
fmt='(i4.4,i4,i5,f6.1,f8.1,f6.2,3x,a22)'
else if(ntrMinutes.eq.10) then
nsps=82944
df3=1500.0/12288.0
fmt='(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)'
else if(ntrMinutes.eq.30) then
nsps=252000
df3=1500.0/32768.0
fmt='(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)'
endif
if(nsps.eq.0) stop 'Error: bad TRperiod' !Better: return an error code###
@ -88,14 +94,13 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
if(ccfred(i).gt.sbest .and. fgood.eq.0.0) then
sbest=ccfred(i)
write(line,1010) nutc,nsync,nsnr,xdt,1000.0+fpk,width
write(line,fmt) nutc,nsync,nsnr,xdt,1000.0+fpk,width
if(nsync.gt.0) nsynced=1
endif
if(msg.ne.' ') then
write(13,1010) nutc,nsync,nsnr,xdt,1000.0+fpk,width,msg
1010 format(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)
write(14,1010) nutc,nsync,nsnr,xdt,1000.0+fpk,width,msg
write(13,fmt) nutc,nsync,nsnr,xdt,1000.0+fpk,width,msg
write(14,fmt) nutc,nsync,nsnr,xdt,1000.0+fpk,width,msg
fgood=f
nsynced=1
ndecoded=1

View File

@ -39,7 +39,7 @@ program jt9
nfa=1000
nfb=2000
! ntol=500
ntol=20
ntol=500
nfqso=1500
newdat=1
nb=0
@ -60,7 +60,7 @@ program jt9
if(ntrperiod.eq.5) nsps=40960
if(ntrperiod.eq.10) nsps=82944
if(ntrperiod.eq.30) nsps=252000
if(nsps.eq.0) stop 'Error: bad TRprtiod'
if(nsps.eq.0) stop 'Error: bad TRperiod'
kstep=nsps/2
tstep=kstep/12000.0

View File

@ -1,41 +1,21 @@
subroutine pctile(x,npts,npct,xmedian)
subroutine pctile(x,npts,npct,xpct)
real x(npts)
integer hist(0:1000)
parameter (NMAX=32768)
real*4 x(npts)
real*4 tmp(NMAX)
if(npts.le.0) then
xmedian=1.0
xpct=1.0
go to 900
endif
if(npts.gt.NMAX) stop
ave=sum(x)/npts
s=0.
ns=0
do i=1,npts
if(x(i).lt.3.0*ave) then
s=s+x(i)
ns=ns+1
endif
enddo
ave=s/ns
hist=0
do i=1,npts
j=nint(100.0*x(i)/ave)
if(j.lt.0) j=0
if(j.gt.1000) j=1000
hist(j)=hist(j)+1
enddo
nsum=0
ntest=nint(npts*float(npct)/100.0)
do j=0,1000
nsum=nsum+hist(j)
if(nsum.ge.ntest) exit
enddo
xmedian=j*ave/100.0
if(j.lt.10) xmedian=1.0
tmp(1:npts)=x
call sort(npts,tmp)
j=nint(npts*0.01*npct)
if(j.lt.1) j=1
if(j.gt.npts) j=npts
xpct=tmp(j)
900 continue
return

View File

@ -3,7 +3,8 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
parameter (MAXFFT=31500)
complex c0(0:npts8-1)
complex c1(0:2700000)
real ssym(0:7,69)
real*4 ssym(0:7,69)
real*4 sx(0:31500-1)
complex c(0:MAXFFT-1)
integer*1 i1SoftSymbolsScrambled(207)
integer*1 i1SoftSymbols(207)
@ -65,8 +66,8 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
call four2a(c,nfft,1,-1,1)
do i=0,nfft-1
sx=real(c(i))**2 + aimag(c(i))**2
if(i.ge.1 .and. i.le.8) ssym(ig(i-1),k)=sx
sx(i)=real(c(i))**2 + aimag(c(i))**2
if(i.ge.1 .and. i.le.8) ssym(ig(i-1),k)=sx(i)
enddo
enddo
@ -82,11 +83,12 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
sum=sum-smax
enddo
ave=sum/(69*7)
call pctile(sx,nsps8,50,xmed)
ssym=ssym/ave
sig=sig/69.
df8=1500.0/nsps8
t=max(1.0,sig/ave - 1.0)
snrdb=db(t) - db(2500.0/df8)
t=max(1.0,sig/xmed - 1.0)
snrdb=db(t) - db(2500.0/df8) - 5.0
m0=3
ntones=8

View File

@ -1,4 +1,4 @@
//--------------------------------------------------------------- MainWindow
//---------------------------------------------------------------- MainWindow
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "devsetup.h"

View File

@ -66,7 +66,7 @@
</size>
</property>
<property name="title">
<string> UTC Sync dB DT Freq Width</string>
<string> UTC Sync dB DT Freq Drift</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>