IMplement new spectrum flattening.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3642 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2014-01-17 14:46:23 +00:00
parent 7cf44f5f54
commit 65cc741b31
7 changed files with 159 additions and 193 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
subroutine symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
subroutine symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8)
! Input:
! k pointer to the most recent new data
@ -20,7 +20,6 @@ subroutine symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
include 'constants.f90'
real*4 w3(MAXFFT3)
real*4 s(NSMAX)
real*4 scale(NSMAX)
real*4 ssum(NSMAX)
real*4 xc(0:MAXFFT3-1)
complex cx(0:MAXFFT3/2)
@ -28,7 +27,7 @@ subroutine symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
ntr,mousefqso,newdat,npts8a,nfa,nfsplit,nfb,ntol,kin,nzhsym, &
nsave,nagain,ndepth,ntxmode,nmode,junk(5)
data rms/999.0/,k0/99999999/,nfft3z/0/,slope0/0.0/
data rms/999.0/,k0/99999999/,nfft3z/0/
equivalence (xc,cx)
save
@ -41,23 +40,14 @@ subroutine symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
go to 900 !Wait for enough samples to start
endif
if(nfft3.ne.nfft3z .or. slope.ne.slope0) then
! Compute new window and adjust scale factor
if(nfft3.ne.nfft3z) then
! Compute new window
pi=4.0*atan(1.0)
do i=1,nfft3
w3(i)=2.0*(sin(i*pi/nfft3))**2 !Window for nfft3 spectrum
enddo
nfft3z=nfft3
nh=NSMAX/2
if(abs(slope+0.1).gt.0.05) then
do i=1,NSMAX
x=slope*float(i)/nh - 1.0 + 2.6
scale(i)=10.0**x
enddo
else
scale=1.0
endif
slope0=slope
endif
if(k.lt.k0) then !Start a new data block
@ -109,10 +99,9 @@ subroutine symspec(k,ntrperiod,nsps,ingain,slope,pxdb,s,df3,ihsym,npts8)
s(i)=gain*sx
enddo
s=scale*s
savg=scale*ssum/ihsym
savg=ssum/ihsym
if(abs(slope+0.1).lt.0.01) then
if(nflatten.ne.0) then
call flat3(s,iz,nfa,nfb,3,1.0,s)
call flat3(savg,iz,nfa,nfb,3,1.0,savg)
savg=7.0*savg

View File

@ -699,9 +699,9 @@ void MainWindow::dataSink(qint64 frames)
static int nzap=0;
static int trmin;
static int npts8;
static int nflatten=0;
static float px=0.0;
static float df3;
static float slope;
if(m_diskData) {
jt9com_.ndiskdat=1;
@ -711,12 +711,12 @@ void MainWindow::dataSink(qint64 frames)
// Get power, spectrum, and ihsym
trmin=m_TRperiod/60;
slope=0.0;
slope=(float)m_wideGraph->getSlope();
int k (frames - 1);
jt9com_.nfa=m_wideGraph->nStartFreq();
jt9com_.nfb=m_wideGraph->getFmax();
symspec_(&k,&trmin,&m_nsps,&m_inGain,&slope,&px,s,&df3,&ihsym,&npts8);
nflatten=0;
if(m_wideGraph->flatten()) nflatten=1;
symspec_(&k,&trmin,&m_nsps,&m_inGain,&nflatten,&px,s,&df3,&ihsym,&npts8);
if(ihsym <=0) return;
QString t;
m_pctZap=nzap*100.0/m_nsps;

View File

@ -426,7 +426,7 @@ extern int ptt(int nport, int ntx, int* iptt, int* nopen);
extern "C" {
//----------------------------------------------------- C and Fortran routines
void symspec_(int* k, int* ntrperiod, int* nsps, int* ingain, float* slope,
void symspec_(int* k, int* ntrperiod, int* nsps, int* ingain, int* nflatten,
float* px, float s[], float* df3, int* nhsym, int* npts8);
void genjt9_(char* msg, int* ichk, char* msgsent, int itone[],

View File

@ -26,6 +26,9 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) :
connect(ui->widePlot, SIGNAL(setFreq1(int,int)),this,
SLOT(setFreq2(int,int)));
connect (ui->cbFlatten, SIGNAL(toggled(bool)),this,
SLOT(on_cbFlatten_toggled(bool)));
//Restore user's settings
m_settings->beginGroup("WideGraph");
restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ());
@ -35,6 +38,8 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) :
ui->gainSpinBox->setValue(ui->widePlot->getPlotGain());
int n = m_settings->value("FreqSpan",2).toInt();
int w = m_settings->value("PlotWidth",1000).toInt();
m_bFlatten=m_settings->value("Flatten",true).toBool();
ui->cbFlatten->setChecked(m_bFlatten);
ui->widePlot->m_w=w;
ui->freqSpanSpinBox->setValue(n);
ui->widePlot->setNSpan(n);
@ -46,8 +51,6 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) :
if(ui->widePlot->m_bCumulative) ui->spec2dComboBox->setCurrentIndex(1);
int nbpp=m_settings->value("BinsPerPixel",2).toInt();
ui->widePlot->setBinsPerPixel(nbpp);
m_slope=m_settings->value("Slope",0.0).toDouble();
ui->slopeSpinBox->setValue(m_slope);
ui->widePlot->setStartFreq(m_settings->value("StartFreq",0).toInt());
ui->fStartSpinBox->setValue(ui->widePlot->startFreq());
m_waterfallPalette=m_settings->value("WaterfallPalette","Default").toString();
@ -95,10 +98,10 @@ void WideGraph::saveSettings()
m_settings->setValue ("Current", ui->widePlot->m_bCurrent);
m_settings->setValue ("Cumulative", ui->widePlot->m_bCumulative);
m_settings->setValue ("BinsPerPixel", ui->widePlot->binsPerPixel ());
m_settings->setValue ("Slope", m_slope);
m_settings->setValue ("StartFreq", ui->widePlot->startFreq ());
m_settings->setValue ("WaterfallPalette", m_waterfallPalette);
m_settings->setValue ("Fmin", m_fMin);
m_settings->setValue("Flatten",m_bFlatten);
m_settings->endGroup ();
}
@ -288,26 +291,11 @@ void WideGraph::on_fMinSpinBox_valueChanged(int n)
setRxRange(m_fMin);
}
void WideGraph::on_slopeSpinBox_valueChanged(double d)
{
m_slope=d;
}
void WideGraph::setSlope(double d)
{
m_slope=d;
ui->slopeSpinBox->setValue(d);
}
void WideGraph::setLockTxFreq(bool b)
{
m_lockTxFreq=b;
ui->widePlot->m_lockTxFreq=b;
}
double WideGraph::getSlope()
{
return m_slope;
}
void WideGraph::setFreq2(int rxFreq, int txFreq)
{
@ -364,3 +352,14 @@ void WideGraph::on_paletteComboBox_activated(const QString &palette)
m_waterfallPalette=palette;
readPalette("Palettes/" + palette + ".pal");
}
void WideGraph::on_cbFlatten_toggled(bool b)
{
m_bFlatten=b;
}
bool WideGraph::flatten()
{
return m_bFlatten;
}

View File

@ -33,11 +33,10 @@ public:
void setTxFreq(int n);
void setMode(QString mode);
void setModeTx(QString modeTx);
void setSlope(double d);
void setLockTxFreq(bool b);
double getSlope();
double fGreen();
void readPalette(QString fileName);
bool flatten();
signals:
void freezeDecode2(int n);
@ -61,9 +60,9 @@ private slots:
void on_gainSpinBox_valueChanged(int arg1);
void on_spec2dComboBox_currentIndexChanged(const QString &arg1);
void on_fMinSpinBox_valueChanged(int n);
void on_slopeSpinBox_valueChanged(double d);
void on_fStartSpinBox_valueChanged(int n);
void on_paletteComboBox_activated(const QString &palette);
void on_cbFlatten_toggled(bool b);
private:
QScopedPointer<Ui::WideGraph> ui;
@ -72,7 +71,6 @@ private:
qint32 m_rxFreq;
qint32 m_txFreq;
double m_slope;
double m_dialFreq;
qint32 m_waterfallAvg;
@ -84,6 +82,7 @@ private:
qint32 m_fMax;
bool m_lockTxFreq;
bool m_bFlatten;
QString m_mode;
QString m_modeTx;

View File

@ -52,18 +52,34 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="6">
<widget class="QLabel" name="labPalette">
<property name="text">
<string>Palette</string>
<item row="1" column="6">
<widget class="QComboBox" name="spec2dComboBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select data for spectral display&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Current</string>
</property>
</item>
<item>
<property name="text">
<string>Cumulative</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="zeroSpinBox">
<item row="1" column="2">
<widget class="QSpinBox" name="waterfallAvgSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
@ -77,78 +93,21 @@
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Constant offset applied to spectra&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string/>
<string>Number of FFTs averaged (controls waterfall scrolling rate)</string>
</property>
<property name="prefix">
<string>Zero </string>
<string>N Avg </string>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="gainSpinBox">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>38</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gain (dB) applied to spectra before display&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefix">
<string>Gain </string>
</property>
<property name="minimum">
<number>-20</number>
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="fStartSpinBox">
<item row="1" column="4">
<widget class="QComboBox" name="paletteComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -162,13 +121,45 @@
</size>
</property>
<property name="toolTip">
<string>Frequency (Hz) at left edge of waterfall</string>
<string>Select waterfall palette</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="labPalette">
<property name="text">
<string> Palette</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="fMinSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Decode JT65 below this frequency, JT9 above</string>
</property>
<property name="suffix">
<string> Hz</string>
<string> JT9</string>
</property>
<property name="prefix">
<string>Start </string>
<string>JT65 </string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>5000</number>
@ -176,6 +167,9 @@
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>3000</number>
</property>
</widget>
</item>
<item row="0" column="1">
@ -221,8 +215,8 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="fMinSpinBox">
<item row="0" column="2">
<widget class="QSpinBox" name="fStartSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -231,21 +225,18 @@
</property>
<property name="minimumSize">
<size>
<width>110</width>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Decode JT65 below this frequency, JT9 above</string>
<string>Frequency (Hz) at left edge of waterfall</string>
</property>
<property name="suffix">
<string> JT9</string>
<string> Hz</string>
</property>
<property name="prefix">
<string>JT65 </string>
</property>
<property name="minimum">
<number>0</number>
<string>Start </string>
</property>
<property name="maximum">
<number>5000</number>
@ -253,66 +244,36 @@
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>3000</number>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QComboBox" name="paletteComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="0" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="minimumSize">
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>0</height>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Select waterfall palette</string>
</property>
</widget>
</spacer>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="slopeSpinBox">
<property name="minimumSize">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>0</height>
<width>40</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Correction applied to flatted displayed spectra</string>
</property>
<property name="prefix">
<string>Slope </string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>-2.000000000000000</double>
</property>
<property name="maximum">
<double>2.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</spacer>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="waterfallAvgSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="1" column="3">
<widget class="QSpinBox" name="gainSpinBox">
<property name="minimumSize">
<size>
<width>80</width>
@ -326,37 +287,55 @@
</size>
</property>
<property name="toolTip">
<string>Number of FFTs averaged (controls waterfall scrolling rate)</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Gain (dB) applied to spectra before display&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefix">
<string>N Avg </string>
<string>Gain </string>
</property>
<property name="minimum">
<number>1</number>
<number>-20</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="spec2dComboBox">
<item row="0" column="3">
<widget class="QSpinBox" name="zeroSpinBox">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>38</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select data for spectral display&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Constant offset applied to spectra&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="currentIndex">
<number>1</number>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string>Zero </string>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QCheckBox" name="cbFlatten">
<property name="text">
<string>Flatten</string>
</property>
<item>
<property name="text">
<string>Current</string>
</property>
</item>
<item>
<property name="text">
<string>Cumulative</string>
</property>
</item>
</widget>
</item>
</layout>