Correct several flaws in the way Q65 sync curves orange (current) and red (avg) are plotted.

This commit is contained in:
Joe Taylor 2023-01-12 15:25:17 -05:00
parent 9ec349dd26
commit 0bf8193601
2 changed files with 25 additions and 15 deletions

View File

@ -21,8 +21,8 @@ module q65
real, allocatable :: s1(:,:) !Symbol spectra w/suppressed peaks
real, allocatable :: s1w(:,:) !Symbol spectra w/suppressed peaks !w3sz added
real, allocatable,save :: s1a(:,:,:) !Cumulative symbol spectra
real, allocatable,save :: ccf2(:) !Max CCF(freq) at any lag, single seq
real, allocatable,save :: ccf2_avg(:) !Like ccf2, but for accumulated average
real, allocatable,save :: ccf2(:) !Max CCF(freq) at any lag (orange curve)
real, allocatable,save :: ccf2_avg(:) !Like ccf2, but for avg (red curve)
real sync(85) !sync vector
real df,dtstep,dtdec,f0dec,ftol,plog,drift
@ -126,7 +126,10 @@ subroutine q65_dec0(iavg,nutc,iwave,ntrperiod,nfqso,ntol,ndepth,lclearave, &
lclearave=.false.
endif
ccf1=0.
if(iavg.eq.0) ccf2_avg=0.
if(iavg.eq.0) then
ccf2=0.
ccf2_avg=0.
endif
dtstep=nsps/(NSTEP*12000.0) !Step size in seconds
lag1=-1.0/dtstep
lag2=1.0/dtstep + 0.9999
@ -714,12 +717,18 @@ subroutine q65_write_red(iz,xdt,ccf2_avg,ccf2)
rewind 17
write(17,1000) xdt,minval(ccf2_avg),maxval(ccf2_avg)
do i=max(1,nint(nfa/df)),min(iz,int(nfb/df))
i1=max(1,nint(nfa/df))
i2=min(iz,int(nfb/df))
y0=minval(ccf2(i1:i2))
y0_avg=minval(ccf2_avg(i1:i2))
g=1.0/(maxval(ccf2(i1:i2))-y0)
g_avg=0.
if(maxval(ccf2_avg(i1:i2)).ne.y0_avg) g_avg=1.0/(maxval(ccf2_avg(i1:i2))-y0_avg)
do i=i1,i2
freq=i*df
y1=ccf2_avg(i)
if(y1.gt.10.0) y1=10.0 + 2.0*log10(y1/10.0)
y2=ccf2(i)
if(y2.gt.10.0) y2=10.0 + 2.0*log10(y2/10.0)
y1=g_avg*(ccf2_avg(i)-y0_avg)
y2=g*(ccf2(i)-y0)
write(17,1000) freq,y1,y2
1000 format(3f10.3)
enddo

View File

@ -280,27 +280,28 @@ void CPlotter::draw(float swide[], bool bScroll, bool bRed)
painter2D.drawText(x1-4,y,"73");
}
if(bRed and m_bQ65_Sync) { //Plot the Q65 red/orange sync curves
if(bRed and m_bQ65_Sync) { //Plot the Q65 orange (current) and red (average) sync curves
int k=0;
int k2=0;
std::ifstream f;
f.open(m_redFile.toLatin1());
if(f) {
int x,y;
float freq,xdt,smin,smax,sync,sync2;
float freq,xdt,smin,smax,sync_avg,sync_current;
f >> xdt >> smin >> smax;
if(f) {
for(int i=0; i<99999; i++) {
f >> freq >> sync >> sync2;
f >> freq >> sync_avg >> sync_current;
if(!f or f.eof() or k>=MAX_SCREENSIZE or k2>=MAX_SCREENSIZE) break;
x=XfromFreq(freq);
if(sync > -99.0 and (smin!=0.0 or smax != 0.0)) {
y=m_h2*(0.9 - 0.09*gain2d*sync) - m_plot2dZero - 10;
LineBuf2[k2].setX(x); //Red sync curve
// Plot the red curve only if we have averaged 2 or more Rx sequences.
if(sync_avg > -99.0 and (smin!=0.0 or smax != 0.0)) {
y=m_h2*(0.9 - 0.09*gain2d*gain2d*sync_avg) - m_plot2dZero - 10;
LineBuf2[k2].setX(x); //Red sync curve (average)
LineBuf2[k2].setY(y);
k2++;
}
y=m_h2*(0.9 - 0.09*gain2d*sync2) - m_plot2dZero;
y=m_h2*(0.9 - 0.09*gain2d*gain2d*sync_current) - m_plot2dZero;
LineBuf3[k].setX(x); //Orange sync curve
LineBuf3[k].setY(y);
k++;