From e45f7eaf67898086f7ed326871bc3cff0f1a6a13 Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Sun, 22 Jan 2017 03:20:46 +0000 Subject: [PATCH] After measuring phase response, write pcoeff file to the data directory. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7551 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/hspec.f90 | 5 +++-- lib/msk144signalquality.f90 | 45 +++++++++++++++---------------------- lib/mskrtd.f90 | 12 ++++------ mainwindow.cpp | 10 ++++++--- 4 files changed, 32 insertions(+), 40 deletions(-) diff --git a/lib/hspec.f90 b/lib/hspec.f90 index 53e09f3a8..b47cad76d 100644 --- a/lib/hspec.f90 +++ b/lib/hspec.f90 @@ -1,5 +1,5 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & - brxequal,btrain,ingain,mycall,hiscall,bshmsg,bswl,green,s,jh,line1,mygrid) + brxequal,btrain,ingain,mycall,hiscall,bshmsg,bswl,datadir,green,s,jh,line1,mygrid) ! Input: ! k pointer to the most recent new data @@ -19,6 +19,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & parameter (JZ=703) character*80 line1 + character*512 datadir character*12 mycall,hiscall character*6 mygrid integer*2 id2(0:120*12000-1) @@ -85,7 +86,7 @@ subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,bmsk144,bcontest, & tt2=sum(float(abs(id2(k0:k0+3583)))) if(tt1.ne.0.0 .and. tt2.ne.0) then call mskrtd(id2(k-7168+1:k),nutc0,tsec,ntol,nrxfreq,ndepth, & - mycall,mygrid,hiscall,bshmsg,bcontest,brxequal,btrain,bswl,line1) + mycall,mygrid,hiscall,bshmsg,bcontest,brxequal,btrain,bswl,datadir,line1) endif endif endif diff --git a/lib/msk144signalquality.f90 b/lib/msk144signalquality.f90 index 897e8b546..27b809d17 100644 --- a/lib/msk144signalquality.f90 +++ b/lib/msk144signalquality.f90 @@ -1,15 +1,16 @@ subroutine msk144signalquality(cframe,snr,freq,t0,softbits,msg,dxcall, & - btrain,nbiterrors,eyeopening,trained,pcoeffs) + btrain,datadir,nbiterrors,eyeopening,pcoeffs) character*22 msg,msgsent character*12 dxcall character*12 training_dxcall character*12 trained_dxcall character*6 mygrid - character*40 pcoeff_filename + character*512 pcoeff_filename character*8 date character*10 time character*5 zone + character*512 datadir complex cframe(864) complex cross(864) @@ -26,11 +27,9 @@ logical*1 btrain logical*1 first logical*1 currently_training - logical*1 trained logical*1 msg_has_dxcall logical*1 is_training_frame - real abscross_avg(864) real softbits(144) real waveform(0:863) real d(1024) @@ -40,7 +39,7 @@ real pcoeffs(3) data first/.true./ - save cross_avg,abscross_avg,wt_avg,first,currently_training, & + save cross_avg,wt_avg,first,currently_training, & navg,tlast,training_dxcall,trained_dxcall if (first) then @@ -51,14 +50,12 @@ tlast=0.0 trained_dxcall(1:12)=' ' training_dxcall(1:12)=' ' - trained=.false. currently_training=.false. pcoeffs(1:3)=0.0 first=.false. endif - if( (trained .and. (dxcall .ne. trained_dxcall)) .or. & - (currently_training .and. (dxcall .ne. training_dxcall)) .or. & + if( (currently_training .and. (dxcall .ne. training_dxcall)) .or. & (navg .gt. 10 )) then !reset and retrain navg=0 cross=cmplx(0.0,0.0) @@ -66,7 +63,6 @@ wt_avg=0.0 tlast=0.0 trained_dxcall(1:12)=' ' - trained=.false. currently_training=.false. training_dxcall(1:12)=' ' trained_dxcall(1:12)=' ' @@ -77,8 +73,7 @@ write(*,*) 'reset to untrained state ' indx_dxcall=index(msg,trim(dxcall)) msg_has_dxcall = indx_dxcall .ge. 4 - if( btrain .and. msg_has_dxcall .and. (.not. trained) .and. & - .not. currently_training ) then + if( btrain .and. msg_has_dxcall .and. (.not. currently_training) ) then currently_training=.true. training_dxcall=trim(dxcall) trained_dxcall(1:12)=' ' @@ -87,7 +82,6 @@ write(*,*) 'start training on call ',training_dxcall endif if( msg_has_dxcall .and. currently_training ) then - trained=.false. ! just to be sure trained_dxcall(1:12)=' ' training_dxcall=dxcall pcoeffs(1:3)=0.0 @@ -198,31 +192,28 @@ write(*,*) 'start training on call ',training_dxcall pp=a(1)+x*(a(2)+x*(a(3)+x*(a(4)+x*a(5)))) rmsdiff=sum( (pp-phase((864/2-nm/2):(864/2+nm/2)))**2 )/145.0 write(*,*) 'training ',navg,sqrt(chisqr),rmsdiff -! if( (sqrt(chisqr).lt.1.5) .and. (rmsdiff.lt.1.1) .and. (navg.ge.5) ) then if( (sqrt(chisqr).lt.1.8) .and. (rmsdiff.lt.0.5) .and. (navg.ge.2) ) then - open(18,file='phasefit.dat',status='unknown') - do i=1, 145 - write(18,*) x(i),pp(i),y(i),sigmay(i) - enddo - close(18) - open(19,file='cframe.dat',status='unknown') - do i=1,864 - write(19,*) i,real(cframe(i)),imag(cframe(i)),real(cross_avg(i)),imag(cross_avg(i)) - enddo - close(19) - pcoeffs=a(3:5) +! pcoeffs=a(3:5) trained_dxcall=dxcall training_dxcall(1:12)=' ' currently_training=.false. - trained=.true. btrain=.false. call date_and_time(date,time,zone,values) write(pcoeff_filename,'(i2.2,i2.2,i2.2,"_",i2.2,i2.2,i2.2)') & values(1)-2000,values(2),values(3),values(5),values(6),values(7) - pcoeff_filename=trim(trained_dxcall)//"_"//pcoeff_filename//".pcoeff" -write(*,*) pcoeff_filename + pcoeff_filename=trim(trained_dxcall)//"_"//trim(pcoeff_filename)//".pcoeff" + l1=index(datadir,char(0))-1 + datadir(l1+1:l1+1)="/" + pcoeff_filename=datadir(1:l1+1)//trim(pcoeff_filename) +write(*,*) 'trained - writing coefficients to: ',pcoeff_filename open(17,file=pcoeff_filename,status='new') write(17,'(i4,2f10.2,5f10.4)') navg,sqrt(chisqr),rmsdiff,a(1),a(2),a(3),a(4),a(5) + do i=1, 145 + write(17,*) x(i),pp(i),y(i),sigmay(i) + enddo + do i=1,864 + write(17,*) i,real(cframe(i)),imag(cframe(i)),real(cross_avg(i)),imag(cross_avg(i)) + enddo close(17) endif endif diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index d7b2cf819..4054b3f8c 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -1,5 +1,5 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & - bshmsg,bcontest,brxequal,btrain,bswl,line) + bshmsg,bcontest,brxequal,btrain,bswl,datadir,line) ! Real-time decoder for MSK144. ! Analysis block size = NZ = 7168 samples, t_block = 0.597333 s @@ -20,6 +20,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & character*6 mygrid character*12 recent_calls(NRECENT) character*22 recent_shmsgs(NSHMEM) + character*512 datadir complex cdat(NFFT1) !Analytic signal complex c(NSPM) !Coherently averaged complex data @@ -40,7 +41,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & logical*1 bshmsg,bcontest,brxequal,btrain,bswl logical*1 first - logical*1 trained logical*1 bshdecode logical*1 seenb4 logical*1 bflag @@ -53,7 +53,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & 1,1,1,1,1,0,0,0, & 1,1,1,1,1,1,1,0/ data xmc/2.0,4.5,2.5,3.5/ !Used to set time at center of averaging mask - save first,tsec0,nutc00,pnoise,cdat,pcoeffs,trained,msglast,msglastswl, & + save first,tsec0,nutc00,pnoise,cdat,pcoeffs,msglast,msglastswl, & nsnrlast,nsnrlastswl,recent_calls,nhasharray,recent_shmsgs if(first) then @@ -67,7 +67,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & do i=1,nshmem recent_shmsgs(i)(1:22)=' ' enddo - trained=.false. msglast=' ' msglastswl=' ' nsnrlast=-99 @@ -189,14 +188,11 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(.not. bshdecode) then call msk144signalquality(ct,snr0,fest,tdec,softbits,msgreceived,hiscall, & - btrain,ncorrected,eyeopening,trained,pcoeffs) + btrain,datadir,ncorrected,eyeopening,pcoeffs) endif decsym=' & ' if( brxequal ) decsym=' ^ ' -! if( brxequal .and. (.not. trained) ) decsym=' ^ ' -! if( brxequal .and. trained ) decsym=' $ ' -! if( (.not. brxequal) .and. trained ) decsym=' @ ' if( msgreceived(1:1).eq.'<') then ncorrected=0 eyeopening=0.0 diff --git a/mainwindow.cpp b/mainwindow.cpp index 24cf2525e..78ca367c8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -67,9 +67,9 @@ extern "C" { void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol, bool* bmsk144, bool* bcontest, bool* brxequalize, bool* btrain, int* ingain, - char mycall[], char hiscall[], bool* bshmsg, bool* bswl, float green[], + char mycall[], char hiscall[], bool* bshmsg, bool* bswl, char ddir[], float green[], float s[], int* jh, char line[], char mygrid[], - int len1, int len2, int len3, int len4); + int len1, int len2, int len3, int len4, int len5); void gen4_(char* msg, int* ichk, char* msgsent, int itone[], int* itext, int len1, int len2); @@ -1349,9 +1349,13 @@ void MainWindow::fastSink(qint64 frames) bool bswl=ui->cbSWL->isChecked(); strncpy(dec_data.params.hiscall,(hisCall + " ").toLatin1 ().constData (), 12); strncpy(dec_data.params.mygrid, (m_config.my_grid()+" ").toLatin1(),6); + QString dataDir; + dataDir = m_dataDir.absolutePath (); + char ddir[512]; + strncpy(ddir,dataDir.toLatin1(), sizeof (ddir) - 1); hspec_(dec_data.d2,&k,&nutc0,&nTRpDepth,&RxFreq,&m_Ftol,&bmsk144,&bcontest,&brxequalize, &m_bTrain,&m_inGain,&dec_data.params.mycall[0],&dec_data.params.hiscall[0],&bshmsg,&bswl, - fast_green,fast_s,&fast_jh,&line[0],&dec_data.params.mygrid[0],12,12,80,6); + &ddir[0],fast_green,fast_s,&fast_jh,&line[0],&dec_data.params.mygrid[0],12,12,512,80,6); float px = fast_green[fast_jh]; QString t; t.sprintf(" Rx noise: %5.1f ",px);