From 77a6f8f51431fc0e0041c9ed355a3a1c1c024381 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 23 Jul 2020 10:58:10 -0400 Subject: [PATCH] Move blanking from symspec() to fst240_decode(). Do not apply RefSpec corrections to data read from disk. --- lib/blanker.f90 | 39 +++--- lib/fst240_decode.f90 | 12 +- lib/symspec.f90 | 11 +- widgets/mainwindow.cpp | 24 ++-- widgets/mainwindow.ui | 300 +++++++++++++++++++---------------------- 5 files changed, 182 insertions(+), 204 deletions(-) diff --git a/lib/blanker.f90 b/lib/blanker.f90 index a5c334e3f..6dd496f81 100644 --- a/lib/blanker.f90 +++ b/lib/blanker.f90 @@ -1,14 +1,11 @@ -subroutine blanker(iwave,nz,dwell_time,fblank,npct) +subroutine blanker(iwave,nz,ndropmax,npct,c_bigfft) integer*2 iwave(nz) + complex c_bigfft(0:nz/2) integer hist(0:32768) - real dwell_time !Blanking dwell time (s) real fblank !Fraction of points to be blanked - data ncall/0/,thresh/0.0/,fblanked/0.0/ - save ncall,thresh,fblanked - ncall=ncall+1 - ndropmax=nint(1.0 + dwell_time*12000.0) + fblank=0.01*npct hist=0 do i=1,nz n=abs(iwave(i)) @@ -19,34 +16,40 @@ subroutine blanker(iwave,nz,dwell_time,fblank,npct) n=n+hist(i) if(n.ge.nint(nz*fblank/ndropmax)) exit enddo - thresh=thresh + 0.01*(i-thresh) - if(ncall.eq.1) thresh=i - nthresh=nint(thresh) + nthresh=i ndrop=0 ndropped=0 - + + xx=0. do i=1,nz i0=iwave(i) if(ndrop.gt.0) then - iwave(i)=0 + i0=0 ndropped=ndropped+1 ndrop=ndrop-1 - cycle endif ! Start to apply blanking - if(abs(iwave(i)).gt.nthresh) then - iwave(i)=0 + if(abs(i0).gt.nthresh) then + i0=0 ndropped=ndropped+1 ndrop=ndropmax endif + +! Now copy the data into c_bigfft + if(iand(i,1).eq.1) then + xx=i0 + else + yy=i0 + j=i/2 - 1 + c_bigfft(j)=cmplx(xx,yy) + endif enddo fblanked=fblanked + 0.1*(float(ndropped)/nz - fblanked) - if(ncall.eq.1) fblanked=float(ndropped)/nz - npct=nint(100.0*fblanked) -! if(mod(ncall,4).eq.0) write(*,3001) thresh,dwell_time,fblank,fblanked,npct -!3001 format(f8.1,f8.4,f6.2,f7.3,i6) + fblanked=float(ndropped)/nz +! write(*,3001) npct,nthresh,fblanked +!3001 format(2i5,f7.3) return end subroutine blanker diff --git a/lib/fst240_decode.f90 b/lib/fst240_decode.f90 index 779c3da73..9b52f285e 100644 --- a/lib/fst240_decode.f90 +++ b/lib/fst240_decode.f90 @@ -80,8 +80,6 @@ contains data first/.true./ save first,apbits,nappasses,naptypes,mycall0,hiscall0 -! call blanker(iwave,ntrperiod*12000,0.0,0.2) - this%callback => callback dxcall13=hiscall ! initialize for use in packjt77 @@ -246,12 +244,14 @@ contains norder=3 endif + ndropmax=1 + npct=nexp_decode/256 + call blanker(iwave,nfft1,ndropmax,npct,c_bigfft) + ! The big fft is done once and is used for calculating the smoothed spectrum ! and also for downconverting/downsampling each candidate. - do i=0,nfft1/2 - c_bigfft(i)=cmplx(float(iwave(2*i+1)),float(iwave(2*i+2))) - enddo - call four2a(c_bigfft,nfft1,1,-1,0) + call four2a(c_bigfft,nfft1,1,-1,0) !r2c +! call blank2(nfa,nfb,nfft1,c_bigfft,iwave) if(hmod.eq.1) then if(fMHz.lt.2.0) then diff --git a/lib/symspec.f90 b/lib/symspec.f90 index 5bd0fd902..a3bed192f 100644 --- a/lib/symspec.f90 +++ b/lib/symspec.f90 @@ -1,5 +1,5 @@ subroutine symspec(shared_data,k,TRperiod,nsps,ingain,bLowSidelobes, & - nminw,pxdb,s,df3,ihsym,npts8,pxdbmax,bblank,npct) + nminw,pxdb,s,df3,ihsym,npts8,pxdbmax,npct) ! Input: ! k pointer to the most recent new data @@ -29,7 +29,7 @@ subroutine symspec(shared_data,k,TRperiod,nsps,ingain,bLowSidelobes, & real*4 tmp(NSMAX) complex cx(0:MAXFFT3/2) integer nch(7) - logical*1 bLowSidelobes,bblank + logical*1 bLowSidelobes common/spectra/syellow(NSMAX),ref(0:3456),filter(0:3456) data k0/99999999/,nfft3z/0/ @@ -64,10 +64,9 @@ subroutine symspec(shared_data,k,TRperiod,nsps,ingain,bLowSidelobes, & sq=0. pxmax=0.; - dwell_time=0.0001 - fblank=0.15 - if(k.gt.k0 .and. bblank) call blanker(shared_data%id2(k0+1:k), & - k-k0,dwell_time,fblank,npct) +! dwell_time=0.0001 +! if(k.gt.k0 .and. npct.gt.0) call blanker(shared_data%id2(k0+1:k), & +! k-k0,dwell_time,npct) do i=k0+1,k x1=shared_data%id2(i) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index fcad7d1f3..43b6dbabd 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -91,7 +91,7 @@ extern "C" { //----------------------------------------------------- C and Fortran routines void symspec_(struct dec_data *, int* k, double* trperiod, int* nsps, int* ingain, bool* bLowSidelobes, int* minw, float* px, float s[], float* df3, - int* nhsym, int* npts8, float *m_pxmax, bool *bblank, int* npct); + int* nhsym, int* npts8, float *m_pxmax, int* npct); void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol, bool* bmsk144, bool* btrain, double const pcoeffs[], int* ingain, @@ -1131,7 +1131,7 @@ void MainWindow::writeSettings() m_settings->setValue ("FT8AP", ui->actionEnable_AP_FT8->isChecked ()); m_settings->setValue ("JT65AP", ui->actionEnable_AP_JT65->isChecked ()); m_settings->setValue("SplitterState",ui->splitter->saveState()); - m_settings->setValue("Blanker",ui->cbNB->isChecked()); + m_settings->setValue("Blanker",ui->sbNB->value()); { QList coeffs; // suitable for QSettings @@ -1232,7 +1232,7 @@ void MainWindow::readSettings() ui->actionEnable_AP_FT8->setChecked (m_settings->value ("FT8AP", false).toBool()); ui->actionEnable_AP_JT65->setChecked (m_settings->value ("JT65AP", false).toBool()); ui->splitter->restoreState(m_settings->value("SplitterState").toByteArray()); - ui->cbNB->setChecked(m_settings->value("Blanker",false).toBool()); + ui->sbNB->setValue(m_settings->value("Blanker",0).toInt()); { auto const& coeffs = m_settings->value ("PhaseEqualizationCoefficients" , QList {0., 0., 0., 0., 0.}).toList (); @@ -1377,8 +1377,10 @@ void MainWindow::dataSink(qint64 frames) } m_bUseRef=m_wideGraph->useRef(); - refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec, - &m_bUseRef,c_fname,len); + if(!m_diskData) { + refspectrum_(&dec_data.d2[k-m_nsps/2],&m_bClearRefSpec,&m_bRefSpec, + &m_bUseRef,c_fname,len); + } m_bClearRefSpec=false; if(m_mode=="ISCAT" or m_mode=="MSK144" or m_bFast9) { @@ -1393,13 +1395,10 @@ void MainWindow::dataSink(qint64 frames) if(m_bFastMode) nsps=6912; int nsmo=m_wideGraph->smoothYellow()-1; bool bLowSidelobes=m_config.lowSidelobes(); - bool bblank=ui->cbNB->isChecked() and m_mode.startsWith("FST240"); int npct=0; + if(m_mode.startsWith("FST240")) npct=ui->sbNB->value(); symspec_(&dec_data,&k,&m_TRperiod,&nsps,&m_inGain,&bLowSidelobes,&nsmo,&m_px,s, - &m_df3,&m_ihsym,&m_npts8,&m_pxmax,&bblank,&npct); - QString t=" "; - if(bblank) t=QString::number(npct); - ui->labNpct->setText(t); + &m_df3,&m_ihsym,&m_npts8,&m_pxmax,&npct); if(m_mode=="WSPR" or m_mode=="FST240W") wspr_downsample_(dec_data.d2,&k); if(m_ihsym <=0) return; if(ui) ui->signal_meter_widget->setValue(m_px,m_pxmax); // Update thermometer @@ -2991,6 +2990,7 @@ void MainWindow::decode() //decode() dec_data.params.nexp_decode = static_cast (m_config.special_op_id()); if(m_config.single_decode()) dec_data.params.nexp_decode += 32; if(m_config.enable_VHF_features()) dec_data.params.nexp_decode += 64; + if(m_mode.startsWith("FST240")) dec_data.params.nexp_decode += 256*ui->sbNB->value(); ::memcpy(dec_data.params.datetime, m_dateTime.toLatin1()+" ", sizeof dec_data.params.datetime); ::memcpy(dec_data.params.mycall, (m_config.my_callsign()+" ").toLatin1(), sizeof dec_data.params.mycall); @@ -5837,9 +5837,7 @@ void MainWindow::displayWidgets(qint64 n) ui->sbSerialNumber->setVisible(b); m_lastCallsign.clear (); // ensures Tx5 is updated for new modes b=m_mode.startsWith("FST240"); - ui->labNpct->setVisible(b); - ui->labNB->setVisible(b); - ui->cbNB->setVisible(b); + ui->sbNB->setVisible(b); genStdMsgs (m_rpt, true); } diff --git a/widgets/mainwindow.ui b/widgets/mainwindow.ui index 823ece909..cfff2fad3 100644 --- a/widgets/mainwindow.ui +++ b/widgets/mainwindow.ui @@ -554,7 +554,46 @@ - + + + + + 0 + 0 + + + + QLabel { + font-family: MS Shell Dlg 2; + font-size: 16pt; + background-color : black; + color : yellow; +} + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 2 + + + 0 + + + <html><head/><body><p align="center"> 2015 Jun 17 </p><p align="center"> 01:23:45 </p></body></html> + + + Qt::AlignCenter + + + 5 + + + + 0 @@ -2401,45 +2440,6 @@ list. The list can be maintained in Settings (F2). - - - - - 0 - 0 - - - - QLabel { - font-family: MS Shell Dlg 2; - font-size: 16pt; - background-color : black; - color : yellow; -} - - - QFrame::StyledPanel - - - QFrame::Sunken - - - 2 - - - 0 - - - <html><head/><body><p align="center"> 2015 Jun 17 </p><p align="center"> 01:23:45 </p></body></html> - - - Qt::AlignCenter - - - 5 - - - @@ -2447,7 +2447,7 @@ list. The list can be maintained in Settings (F2). - + @@ -2468,7 +2468,7 @@ list. The list can be maintained in Settings (F2). 0 - + @@ -2560,7 +2560,42 @@ list. The list can be maintained in Settings (F2). - + + + + + 0 + 0 + + + + true + + + Az: 251 16553 km + + + Qt::AlignCenter + + + 4 + + + + + + + Callsign of station to be worked + + + + + + Qt::AlignCenter + + + + @@ -2652,20 +2687,7 @@ list. The list can be maintained in Settings (F2). - - - - Callsign of station to be worked - - - - - - Qt::AlignCenter - - - - + Search for callsign in database @@ -2675,7 +2697,7 @@ list. The list can be maintained in Settings (F2). - + Locator of station to be worked @@ -2688,29 +2710,7 @@ list. The list can be maintained in Settings (F2). - - - - - 0 - 0 - - - - true - - - Az: 251 16553 km - - - Qt::AlignCenter - - - 4 - - - - + Add callsign and locator to database @@ -2723,6 +2723,28 @@ list. The list can be maintained in Settings (F2). + + + + <html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html> + + + Frequency entry + + + Select operating band or enter frequency in MHz or enter kHz increment followed by k. + + + true + + + QComboBox::NoInsert + + + QComboBox::AdjustToMinimumContentsLength + + + @@ -2765,7 +2787,7 @@ QPushButton[state="ok"] { - + Adjust Tx audio level @@ -2793,25 +2815,37 @@ QPushButton[state="ok"] { - - + + + + + 0 + 0 + + + + + 100 + 16777215 + + - <html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html> + <html><head/><body><p>30dB recommended when only noise present<br/>Green when good<br/>Red when clipping may occur<br/>Yellow when too low</p></body></html> - Frequency entry + Rx Signal - Select operating band or enter frequency in MHz or enter kHz increment followed by k. + 30dB recommended when only noise present +Green when good +Red when clipping may occur +Yellow when too low - - true + + QFrame::Panel - - QComboBox::NoInsert - - - QComboBox::AdjustToMinimumContentsLength + + QFrame::Sunken @@ -2849,78 +2883,22 @@ QLabel[oob="true"] { - - - - - 0 - 0 - + + + + Qt::AlignCenter - - - 100 - 16777215 - + + % - - <html><head/><body><p>30dB recommended when only noise present<br/>Green when good<br/>Red when clipping may occur<br/>Yellow when too low</p></body></html> + + NB - - Rx Signal - - - 30dB recommended when only noise present -Green when good -Red when clipping may occur -Yellow when too low - - - QFrame::Panel - - - QFrame::Sunken + + 25 - - - - - - NB - - - - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - @@ -2931,7 +2909,7 @@ Yellow when too low 0 0 805 - 22 + 21