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
This commit is contained in:
Joe Taylor 2012-10-11 18:33:50 +00:00
parent d805132e17
commit e6b515a9f1
9 changed files with 64 additions and 135 deletions

View File

@ -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

View File

@ -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

25
lib/pctile.f90 Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -134,6 +134,7 @@ private:
qint32 m_NBslider;
qint32 m_TRperiod;
qint32 m_nsps;
qint32 m_hsymStop;
bool m_monitoring;
bool m_transmitting;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>602</width>
<height>502</height>
<height>480</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,7 +19,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>500</height>
<height>475</height>
</size>
</property>
<property name="maximumSize">
@ -35,13 +35,13 @@
<string notr="true"/>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>-10</y>
<x>11</x>
<y>2</y>
<width>565</width>
<height>467</height>
<height>423</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -62,7 +62,7 @@
<property name="maximumSize">
<size>
<width>620</width>
<height>200</height>
<height>300</height>
</size>
</property>
<property name="title">
@ -86,7 +86,7 @@
<property name="maximumSize">
<size>
<width>610</width>
<height>180</height>
<height>280</height>
</size>
</property>
<property name="font">

View File

@ -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++;
}