From e6b515a9f16270ca504c59f51d02832ab5d6a8af Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 11 Oct 2012 18:33:50 +0000 Subject: [PATCH] Normalize the current and cumulative plots automatically. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2659 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/genjt8.f90 | 96 ------------------------------------------------- lib/pctile.f | 13 ------- lib/pctile.f90 | 25 +++++++++++++ lib/symspec.f90 | 22 ++++++++---- lib/timf2.f90 | 2 +- mainwindow.cpp | 12 ++++--- mainwindow.h | 1 + mainwindow.ui | 16 ++++----- plotter.cpp | 12 +++---- 9 files changed, 64 insertions(+), 135 deletions(-) delete mode 100644 lib/genjt8.f90 delete mode 100644 lib/pctile.f create mode 100644 lib/pctile.f90 diff --git a/lib/genjt8.f90 b/lib/genjt8.f90 deleted file mode 100644 index b98bc379a..000000000 --- a/lib/genjt8.f90 +++ /dev/null @@ -1,96 +0,0 @@ -subroutine genjt8(message,iwave,nwave,nbit,msgsent) - -! Generate a JT8 wavefile. - - parameter (NMAX=60*12000) !Max length of wave file - character*24 message !Message to be generated - character*24 msgsent !Message as it will be received - character cmode*5 - real*8 t,dt,phi,f,f0,dfgen,dphi,twopi,tsymbol - integer*2 iwave(NMAX) !Generated wave file - integer iu(3) - integer gsym(372) !372 is needed for JT8 mode - integer sent(144) - integer ic8(8) - data ic8/3,6,2,4,5,0,7,1/ - data nsps/4096/ - data twopi/6.283185307d0/ - save - - cmode='JT8' !### temp ? ### - call srcenc(cmode,message,nbit,iu) -! In JT8 mode, message length is always nbit=78 - if(nbit.ne.78) then - print*,'genjt8, nbit=',nbit - stop - endif - -! Apply FEC and do the channel encoding - call chenc(cmode,nbit,iu,gsym) - -! Remove source encoding, recover the human-readable message. - call srcdec(cmode,nbit,iu,msgsent) - -! Insert 8x8 Costas array at beginning and end of array sent(). - sent(1:8)=ic8 - sent(135:142)=ic8 -! Insert two symbols after each Costas array to specify message length. - if(nbit.eq.30) then - sent(9)=2 - sent(10)=2 - sent(143)=2 - sent(144)=2 - else if(nbit.eq.48) then - sent(9)=3 - sent(10)=3 - sent(143)=3 - sent(144)=3 - else - sent(9)=6 - sent(10)=6 - sent(143)=6 - sent(144)=6 - endif - -! Insert the 3-bit data symbols - sent(11:134)=gsym(1:124) - -! Use the four free symbols in 30-bit mode - if(nbit.eq.30) then - sent(121)=sent(20) - sent(122)=sent(45) - sent(123)=sent(70) - sent(124)=sent(95) - endif - -! Set up necessary constants - nsym=144 - tsymbol=nsps/12000.d0 - dt=1.d0/12000.d0 - f0=1270.46d0 - dfgen=12000.d0/nsps - t=0.d0 - phi=0.d0 - k=0 - j0=0 - ndata=(nsym*12000.d0*tsymbol)/2 - ndata=2*ndata - do i=1,ndata - t=t+dt - j=int(t/tsymbol) + 1 !Symbol number, 1-nsym - if(j.ne.j0) then - f=f0 - k=k+1 - if(k.le.144) f=f0+(sent(k))*dfgen !### Fix need for this ### - dphi=twopi*dt*f - j0=j - endif - phi=phi+dphi - iwave(i)=32767.0*sin(phi) - enddo - - iwave(ndata+1:)=0 - nwave=ndata+6000 !0.5 s buffer before CW ID - - return -end subroutine genjt8 diff --git a/lib/pctile.f b/lib/pctile.f deleted file mode 100644 index 8cfedc154..000000000 --- a/lib/pctile.f +++ /dev/null @@ -1,13 +0,0 @@ - subroutine pctile(x,tmp,nmax,npct,xpct) - real x(nmax),tmp(nmax) - - do i=1,nmax - tmp(i)=x(i) - enddo - call sort(nmax,tmp) - j=nint(nmax*0.01*npct) - if(j.lt.1) j=1 - xpct=tmp(j) - - return - end diff --git a/lib/pctile.f90 b/lib/pctile.f90 new file mode 100644 index 000000000..13e193648 --- /dev/null +++ b/lib/pctile.f90 @@ -0,0 +1,25 @@ +subroutine pctile(x,npts,npct,xmedian) + + real x(npts) + integer hist(0:1000) + + ave=sum(x)/npts + 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 + + return +end subroutine pctile diff --git a/lib/symspec.f90 b/lib/symspec.f90 index 3dcd0f150..dccc08ff9 100644 --- a/lib/symspec.f90 +++ b/lib/symspec.f90 @@ -24,10 +24,10 @@ subroutine symspec(k,ntrperiod,nsps,ndiskdat,nb,nbslider,pxdb,s,f0a,df3, & parameter (NFFT2=1024,NFFT2A=NFFT2/8) parameter (MAXFFT3=32768) real*4 s(NSMAX),w(NFFT1),w3(MAXFFT3) - real*4 stmp(NFFT2/2) real*4 x0(NFFT1),x1(NFFT1) real*4 x2(NFFT1+105) real*4 xx(NMAX) + real*4 ssum(NSMAX) complex cx(0:MAXFFT3-1) logical*1 lstrong(0:1023) !Should be (0:512) integer*2 id2 @@ -54,13 +54,12 @@ subroutine symspec(k,ntrperiod,nsps,ndiskdat,nb,nbslider,pxdb,s,f0a,df3, & do i=1,nfft3 w3(i)=2.0*(sin(i*pi/nfft3))**2 !Window for nfft3 enddo - stmp=0. nfft3z=nfft3 endif if(k.lt.k0) then ja=-3*jstep - savg=0. + ssum=0. ihsym=0 k1=0 k8=0 @@ -131,15 +130,24 @@ subroutine symspec(k,ntrperiod,nsps,ndiskdat,nb,nbslider,pxdb,s,f0a,df3, & if(j.lt.0) j=j+nfft3 sx=fac*(real(cx(j))**2 + aimag(cx(j))**2) ss(n,i)=sx - savg(i)=savg(i) + sx + ssum(i)=ssum(i) + sx s(i)=sx enddo endif 999 continue -! write(71,3003) k,nsps,ihsym,nfft3,pxdb,df3,s(250) -!3003 format(4i9,3f11.3) -! flush(71) + + + call pctile(s,iz,50,xmed0) + s(1:iz)=s(1:iz)/xmed0 + call pctile(ssum,iz,50,xmed1) + savg(1:iz)=ssum(1:iz)/xmed1 + +! if(ihsym.ge.1) then +! write(71,3003) ihsym,ave0,xmed0,smax0,ave1,xmed1,smax1 +!3003 format(i3,6f12.6) +! flush(71) +! endif return end subroutine symspec diff --git a/lib/timf2.f90 b/lib/timf2.f90 index 13973535e..bd39824bd 100644 --- a/lib/timf2.f90 +++ b/lib/timf2.f90 @@ -77,7 +77,7 @@ subroutine timf2(x0,k,nfft,nwindow,nb,peaklimit,faclim,x1, & ! ntot=ntot+1 ! if(mod(ntot,128).eq.5) then -! call pctile(s,stmp,nh,50,xmedian) +! call pctile(s,nh,50,xmedian) ! slimit=faclim*xmedian ! endif diff --git a/mainwindow.cpp b/mainwindow.cpp index 9b139331c..2e058aaa3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -330,7 +330,6 @@ void MainWindow::dataSink(int k) trmin=m_TRperiod/60; symspec_(&k, &trmin, &m_nsps, &ndiskdat, &nb, &m_NBslider, &px, s, &f0a, &df3, &ihsym, &nzap, &slimit, lstrong); -// qDebug() << "a" << k << m_nsps << ihsym << px << df3 << s[250]; if(ihsym <=0) return; QString t; m_pctZap=nzap/178.3; @@ -367,7 +366,7 @@ void MainWindow::dataSink(int k) ntr0=ntr; n=0; } - if(ihsym == 179) { + if(ihsym == m_hsymStop) { jt9com_.newdat=1; jt9com_.nagain=0; QDateTime t = QDateTime::currentDateTimeUtc(); @@ -722,10 +721,10 @@ void MainWindow::diskDat() //diskDat() { int kstep=m_nsps/2; m_diskData=true; - for(int n=1; n<=184; n++) { // Do the half-symbol FFTs + for(int n=1; n<=m_hsymStop; n++) { // Do the half-symbol FFTs int k=(n+1)*kstep; dataSink(k); - if(n%10 == 0) qApp->processEvents(); //Keep the GUI responsive + if(n%10 == 1 or n == m_hsymStop) qApp->processEvents(); //Keep GUI responsive } } @@ -1317,6 +1316,7 @@ void MainWindow::on_actionJT9_1_triggered() m_mode="JT9-1"; m_TRperiod=60; m_nsps=6912; + m_hsymStop=181; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); @@ -1330,6 +1330,7 @@ void MainWindow::on_actionJT9_2_triggered() m_mode="JT9-2"; m_TRperiod=120; m_nsps=15360; + m_hsymStop=178; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); @@ -1343,6 +1344,7 @@ void MainWindow::on_actionJT9_5_triggered() m_mode="JT9-5"; m_TRperiod=300; m_nsps=40960; + m_hsymStop=172; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); @@ -1356,6 +1358,7 @@ void MainWindow::on_actionJT9_10_triggered() m_mode="JT9-10"; m_TRperiod=600; m_nsps=82944; + m_hsymStop=171; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); @@ -1369,6 +1372,7 @@ void MainWindow::on_actionJT9_30_triggered() m_mode="JT9-30"; m_TRperiod=1800; m_nsps=252000; + m_hsymStop=167; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); diff --git a/mainwindow.h b/mainwindow.h index a02c787d7..fb5fd39fd 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -134,6 +134,7 @@ private: qint32 m_NBslider; qint32 m_TRperiod; qint32 m_nsps; + qint32 m_hsymStop; bool m_monitoring; bool m_transmitting; diff --git a/mainwindow.ui b/mainwindow.ui index ab46498f3..22e906e9b 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 602 - 502 + 480 @@ -19,7 +19,7 @@ 0 - 500 + 475 @@ -35,13 +35,13 @@ - + - 10 - -10 + 11 + 2 565 - 467 + 423 @@ -62,7 +62,7 @@ 620 - 200 + 300 @@ -86,7 +86,7 @@ 610 - 180 + 280 diff --git a/plotter.cpp b/plotter.cpp index 299fcc1f1..58c1ab789 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -67,8 +67,6 @@ void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent() m_2DPixmap.fill(Qt::black); m_ScalePixmap = QPixmap(m_w,30); m_ScalePixmap.fill(Qt::white); - - qDebug() << "A" << m_h << m_h1 << m_h2 ; } DrawOverlay(); } @@ -119,18 +117,19 @@ void CPlotter::draw(float swide[], int i0) //draw() swide[i]=-swide[i]; } y = 10.0*log10(swide[i]); - int y1 = 5.0*gain*(y + 37 - m_plotZero); + int y1 = 5.0*gain*y + 10*m_plotZero; if (y1<0) y1=0; if (y1>254) y1=254; if (swide[i]>1.e29) y1=255; m_hist1[y1]++; painter1.setPen(m_ColorTbl[y1]); painter1.drawPoint(i,0); - int y2 = 0.7*gain*(y + 54 - m_plotZero); - if(!m_bCurrent) y2=10.0*jt9com_.savg[i]; + int y2 = gain*y + 30; + if(!m_bCurrent) y2=5.0*gain*jt9com_.savg[i] + 20; if (y2<0) y2=0; if (y2>254) y2=254; if (swide[i]>1.e29) y2=255; + if(strong != strong0 or i==m_w-1) { painter2D.drawPolyline(LineBuf,j); j=0; @@ -139,7 +138,8 @@ void CPlotter::draw(float swide[], int i0) //draw() if(!strong0) painter2D.setPen(Qt::green); } LineBuf[j].setX(i); - LineBuf[j].setY(m_h-y2-320); + LineBuf[j].setY(m_h-(y2+180)); +// if(m_line==10) qDebug() << i << FreqfromX(i) << m_h << y2 << m_h-y2; j++; }