WSJT-X/lib/hspec.f90

108 lines
2.8 KiB
Fortran
Raw Normal View History

2018-07-27 09:45:14 -04:00
subroutine hspec(id2,k,nutc0,ntrpdepth,nrxfreq,ntol,ncontest,bmsk144, &
btrain,pcoeffs,ingain,mycall,hiscall,bshmsg,bswl,datadir,green,s, &
jh,pxmax,dbNoGain,line1,mygrid)
! Input:
! k pointer to the most recent new data
! nutc0 UTC for display of decode(s)
! ntrpdepth TR period and 1000*ndepth
! nrxfreq Rx audio center frequency
! ntol Decoding range is +/- ntol
2018-07-27 09:45:14 -04:00
! ncontest Contest type (0=NONE 1=NA_VHF 2=EU_VHF 3=FIELD_DAY 4=RTTY)
! bmsk144 Boolean, true if in MSK144 mode
! btrain Boolean, turns on training in MSK144 mode
! ingain Relative gain for spectra
! Output:
! green() power
! s() spectrum for horizontal spectrogram
! jh index of most recent data in green(), s()
parameter (JZ=703)
character*80 line1
character*512 datadir
character*12 mycall,hiscall
character*6 mygrid
integer*2 id2(0:120*12000-1)
logical*1 bmsk144,bshmsg,btrain,bswl
real green(0:JZ-1)
real s(0:63,0:JZ-1)
real x(512)
real*8 pcoeffs(5)
complex cx(0:256)
data rms/999.0/,k0/99999999/
equivalence (x,cx)
save ja,rms0
ndepth=ntrpdepth/1000
ntrperiod=ntrpdepth - 1000*ndepth
gain=10.0**(0.1*ingain)
nfft=512
nstep=nfft
nblks=7
if(ntrperiod.lt.30) then
nstep=256
nblks=14
endif
if(k.gt.30*12000) go to 900
if(k.lt.nfft) then
jh=0
go to 900 !Wait for enough samples to start
endif
if(k.lt.k0) then !Start a new data block
ja=-nstep
jh=-1
rms0=0.0
endif
pxmax = 0;
do iblk=1,nblks
if(jh.lt.JZ-1) jh=jh+1
ja=ja+nstep
jb=ja+nfft-1
x=id2(ja:jb)
sq=dot_product(x,x)
xmax = maxval(x);
xmin = abs(minval(x));
if (xmin > xmax) xmax = xmin;
if (xmax.gt.0.0) pxmax=20.0*log10(xmax);
rms=sqrt(gain*sq/nfft)
rms2=sqrt(sq/nfft);
green(jh)=0.
if(rms.gt.0.0) then
green(jh)=20.0*log10(rms)
dbNoGain=20.0*log10(rms2);
endif
call four2a(x,nfft,1,-1,0) !Real-to-complex FFT
df=12000.0/nfft
fac=(1.0/nfft)**2
do i=1,64
j=2*i
sx=real(cx(j))**2 + aimag(cx(j))**2 + real(cx(j-1))**2 + &
aimag(cx(j-1))**2
s(i-1,jh)=fac*gain*sx
enddo
if(ja+2*nfft.gt.k) exit
enddo
k0=k
if(bmsk144) then
if(k.ge.7168) then
tsec=(k-7168)/12000.0
k0=k-7168
tt1=sum(float(abs(id2(k0:k0+3583))))
k0=k-3584
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,btrain,pcoeffs,bswl, &
First attempt at a UI phase compensation tool for MSK144 This builds on the static phase compensation in the MSK144 decoder and the phase analysis and polynomial fitting capabilities also in teh MSK144 decoder, by allowing captured data to be selected for phase equalization from the WSJT-X UI. Reads captured phase compensation curve estimate files containing fitted polynomial coefficients and measured phase data from MSK144 receptions. Intent is to select a compensation curve that is from a known transmitter like an SDR which have good phase linearity. Phase plots and compensation polynomials may be viewed and compared with the current compensation polynomial. A suitable polynomial can be applied to be use in all further decoding of MSK144 signals. Plots of the currently selected polynomial and its modified higher order terms polynomial which is actually used in equalization (this plot may be dropped - it is just for kicks at the moment). When a captured phase analysis file is loaded plots of the measured phase and the proposed best fit polynomial are shown. Basic maintenance is also included allowing clearing and loading captured plots and an option to revert to a flat no equalization curve. More to come on this as amplitude equalization is also possible, this will probably be similar, maybe even plotted on the same graph with dual axes for phase and amplitude. Amplitude correction from a measured reference spectrum could be viewed and selected for equalization for all modes. TBC... This change also introduces the QCustomPlot 3rd party widget. Currently this is statically linked from a qcp library built by the WSJT-X CMake script. This will probably be migrated to a shared object (DLL) build as a CMake external project, once some CMake script re-factoring has been completed, which is more in line with the QCustomPlot author's intentions. This will allow efficient reuse in other tools shipped with WSJT-X. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7570 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-02-20 21:13:13 -05:00
datadir,line1)
endif
endif
endif
900 return
end subroutine hspec