Move blanking from symspec() to fst240_decode(). Do not apply RefSpec corrections to data read from disk.

This commit is contained in:
Joe Taylor 2020-07-23 10:58:10 -04:00
parent 97773af107
commit 77a6f8f514
5 changed files with 182 additions and 204 deletions

View File

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

View File

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

View File

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

View File

@ -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<QVariant> 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<QVariant> {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<int> (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);
}

View File

@ -554,7 +554,46 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0,0,0,0">
<item row="0" column="3" rowspan="3">
<item row="3" column="2">
<widget class="QLabel" name="labUTC">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QLabel {
font-family: MS Shell Dlg 2;
font-size: 16pt;
background-color : black;
color : yellow;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt; 2015 Jun 17 &lt;/p&gt;&lt;p align=&quot;center&quot;&gt; 01:23:45 &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item row="0" column="3" rowspan="4">
<widget class="QStackedWidget" name="controls_stack_widget">
<property name="currentIndex">
<number>0</number>
@ -2401,45 +2440,6 @@ list. The list can be maintained in Settings (F2).</string>
</widget>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labUTC">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QLabel {
font-family: MS Shell Dlg 2;
font-size: 16pt;
background-color : black;
color : yellow;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt; 2015 Jun 17 &lt;/p&gt;&lt;p align=&quot;center&quot;&gt; 01:23:45 &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label">
<property name="text">
@ -2447,7 +2447,7 @@ list. The list can be maintained in Settings (F2).</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QWidget" name="DX_controls_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2468,7 +2468,7 @@ list. The list can be maintained in Settings (F2).</string>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2560,7 +2560,42 @@ list. The list can be maintained in Settings (F2).</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="labAz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>Az: 251 16553 km</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="dxCallEntry">
<property name="toolTip">
<string>Callsign of station to be worked</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -2652,20 +2687,7 @@ list. The list can be maintained in Settings (F2).</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="dxCallEntry">
<property name="toolTip">
<string>Callsign of station to be worked</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QPushButton" name="lookupButton">
<property name="toolTip">
<string>Search for callsign in database</string>
@ -2675,7 +2697,7 @@ list. The list can be maintained in Settings (F2).</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="dxGridEntry">
<property name="toolTip">
<string>Locator of station to be worked</string>
@ -2688,29 +2710,7 @@ list. The list can be maintained in Settings (F2).</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labAz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>Az: 251 16553 km</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>4</number>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QPushButton" name="addButton">
<property name="toolTip">
<string>Add callsign and locator to database</string>
@ -2723,6 +2723,28 @@ list. The list can be maintained in Settings (F2).</string>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="bandComboBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select operating band or enter frequency in MHz or enter kHz increment followed by k.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Frequency entry</string>
</property>
<property name="accessibleDescription">
<string>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QPushButton" name="readFreq">
<property name="enabled">
@ -2765,7 +2787,7 @@ QPushButton[state=&quot;ok&quot;] {
</property>
</widget>
</item>
<item row="1" column="4" rowspan="2">
<item row="2" column="4" rowspan="2">
<widget class="QSlider" name="outAttenuation">
<property name="toolTip">
<string>Adjust Tx audio level</string>
@ -2793,25 +2815,37 @@ QPushButton[state=&quot;ok&quot;] {
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="bandComboBox">
<item row="2" column="0" rowspan="2">
<widget class="SignalMeter" name="signal_meter_widget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select operating band or enter frequency in MHz or enter kHz increment followed by k.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;30dB recommended when only noise present&lt;br/&gt;Green when good&lt;br/&gt;Red when clipping may occur&lt;br/&gt;Yellow when too low&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Frequency entry</string>
<string>Rx Signal</string>
</property>
<property name="accessibleDescription">
<string>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</string>
<string>30dB recommended when only noise present
Green when good
Red when clipping may occur
Yellow when too low</string>
</property>
<property name="editable">
<bool>true</bool>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
@ -2849,78 +2883,22 @@ QLabel[oob=&quot;true&quot;] {
</property>
</widget>
</item>
<item row="1" column="0" rowspan="2">
<widget class="SignalMeter" name="signal_meter_widget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="0">
<widget class="QSpinBox" name="sbNB">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
<property name="suffix">
<string> %</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;30dB recommended when only noise present&lt;br/&gt;Green when good&lt;br/&gt;Red when clipping may occur&lt;br/&gt;Yellow when too low&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="prefix">
<string>NB </string>
</property>
<property name="accessibleName">
<string>Rx Signal</string>
</property>
<property name="accessibleDescription">
<string>30dB recommended when only noise present
Green when good
Red when clipping may occur
Yellow when too low</string>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
<property name="maximum">
<number>25</number>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_NB">
<item>
<widget class="QLabel" name="labNB">
<property name="text">
<string>NB</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbNB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labNpct">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
@ -2931,7 +2909,7 @@ Yellow when too low</string>
<x>0</x>
<y>0</y>
<width>805</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">