2007-01-13 15:21:32 -05:00
|
|
|
subroutine spec(brightness,contrast,ngain,nspeed,a,a2)
|
2005-12-23 12:07:54 -05:00
|
|
|
|
2007-06-29 10:45:15 -04:00
|
|
|
parameter (NX=750,NY=130,NTOT=NX*NY)
|
2005-12-23 12:07:54 -05:00
|
|
|
|
|
|
|
! Input:
|
|
|
|
integer brightness,contrast !Display parameters
|
|
|
|
integer ngain !Digital gain for input audio
|
|
|
|
integer nspeed !Scrolling speed index
|
2007-01-12 12:57:41 -05:00
|
|
|
|
2005-12-23 12:07:54 -05:00
|
|
|
! Output:
|
2007-01-09 12:46:02 -05:00
|
|
|
integer*2 a(NTOT) !Pixel values for NX x NY array
|
2007-01-13 15:21:32 -05:00
|
|
|
integer*2 a2(NTOT) !Pixel values for NX x NY array
|
2005-12-23 12:07:54 -05:00
|
|
|
|
2007-01-12 14:56:45 -05:00
|
|
|
logical first
|
2007-01-13 15:21:32 -05:00
|
|
|
integer nstep(5)
|
2007-12-27 15:16:42 -05:00
|
|
|
integer hist(0:1000)
|
2007-01-17 12:50:59 -05:00
|
|
|
! Could save memory by doing the averaging-by-7 (or 10?) of ss5 in symspec.
|
2007-06-29 10:45:15 -04:00
|
|
|
include 'spcom.f90'
|
2007-12-27 15:16:42 -05:00
|
|
|
real s(NFFT,NY),savg2(NFFT)
|
2005-12-23 12:07:54 -05:00
|
|
|
include 'gcom1.f90'
|
|
|
|
include 'gcom2.f90'
|
|
|
|
include 'gcom3.f90'
|
|
|
|
include 'gcom4.f90'
|
2007-01-12 14:56:45 -05:00
|
|
|
data first/.true./
|
2007-01-14 11:53:10 -05:00
|
|
|
data nstep/28,20,14,10,7/ !Integration limits
|
2005-12-23 12:07:54 -05:00
|
|
|
save
|
|
|
|
|
2007-01-12 14:56:45 -05:00
|
|
|
if(first) then
|
|
|
|
df=96000.0/nfft
|
|
|
|
call zero(a,NX*NY/2)
|
2007-01-13 15:21:32 -05:00
|
|
|
call zero(a2,NX*NY/2)
|
2007-01-12 14:56:45 -05:00
|
|
|
first=.false.
|
|
|
|
endif
|
2007-01-12 12:57:41 -05:00
|
|
|
|
|
|
|
nadd=nstep(nspeed)
|
|
|
|
nlines=322/nadd
|
2007-01-13 15:21:32 -05:00
|
|
|
call zero(s,NFFT*NY)
|
2007-01-12 14:56:45 -05:00
|
|
|
k=0
|
2007-01-14 11:53:10 -05:00
|
|
|
do j=1,nlines
|
|
|
|
do n=1,nadd
|
2007-01-13 15:21:32 -05:00
|
|
|
k=k+1
|
|
|
|
do i=1,NFFT
|
2007-01-17 12:50:59 -05:00
|
|
|
s(i,j)=s(i,j) + ss5(k,i)
|
2007-01-13 15:21:32 -05:00
|
|
|
enddo
|
2006-03-22 08:51:17 -05:00
|
|
|
enddo
|
2007-01-12 14:56:45 -05:00
|
|
|
enddo
|
2007-12-27 15:16:42 -05:00
|
|
|
call zero(savg2,NFFT)
|
|
|
|
do j=1,nlines
|
|
|
|
do i=1,NFFT
|
|
|
|
savg2(i)=savg2(i) + s(i,j)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
ia=0.08*NFFT
|
|
|
|
ib=0.92*NFFT
|
|
|
|
smin=1.e30
|
|
|
|
smax=-smin
|
|
|
|
sum=0.
|
|
|
|
nsum=0
|
|
|
|
do i=ia,ib
|
|
|
|
smin=min(savg2(i),smin)
|
|
|
|
smax=max(savg2(i),smax)
|
|
|
|
if(savg2(i).lt.10000.0) then
|
|
|
|
sum=sum + savg2(i)
|
|
|
|
nsum=nsum+1
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
ave=sum/nsum
|
|
|
|
call zero(hist,1001)
|
|
|
|
do i=ia,ib
|
|
|
|
n=savg2(i) * (300.0/ave)
|
|
|
|
if(n.gt.1000) n=1000
|
2007-12-28 16:22:31 -05:00
|
|
|
if(n.ge.0 .and. n.le.1000) hist(n)=hist(n)+1
|
2007-12-27 15:16:42 -05:00
|
|
|
enddo
|
|
|
|
|
|
|
|
sum=0.
|
|
|
|
do i=0,1000
|
|
|
|
sum=sum + float(hist(i))/(ib-ia+1)
|
|
|
|
if(sum.gt.0.4) go to 10
|
|
|
|
enddo
|
|
|
|
10 base=i*ave/300.0
|
|
|
|
base=base/(nadd*nlines)
|
2005-12-23 12:07:54 -05:00
|
|
|
|
2007-01-12 14:56:45 -05:00
|
|
|
newpts=NX*nlines
|
|
|
|
do i=newpts+1,NX*NY
|
|
|
|
a(i)=a(i-newpts)
|
2007-01-13 15:21:32 -05:00
|
|
|
a2(i)=a2(i-newpts)
|
2007-01-12 14:56:45 -05:00
|
|
|
enddo
|
2007-01-12 12:57:41 -05:00
|
|
|
|
2007-12-28 12:33:18 -05:00
|
|
|
logmap=1
|
2007-01-12 14:56:45 -05:00
|
|
|
gamma=1.3 + 0.01*contrast
|
|
|
|
offset=(brightness+64.0)/2
|
2007-12-28 12:33:18 -05:00
|
|
|
if(logmap.eq.1) then
|
|
|
|
gain=40*sqrt(nstep(nspeed)/5.0) * 5.0**(0.01*contrast)
|
|
|
|
offset=brightness/2 + 10
|
|
|
|
endif
|
2007-11-13 13:39:44 -05:00
|
|
|
fac=20.0/nadd
|
2007-12-27 15:16:42 -05:00
|
|
|
fac=fac*0.065/base
|
|
|
|
! fac=fac*(0.1537/base)
|
2007-07-10 17:07:19 -04:00
|
|
|
foffset=0.001*(1270+nfcal)
|
2007-07-10 14:27:56 -04:00
|
|
|
nbpp=(nfb-nfa)*NFFT/(96.0*NX) !Bins per pixel in wideband (upper) waterfall
|
2008-07-22 20:16:16 -04:00
|
|
|
fselect=mousefqso + foffset - 1000.d0*(fcenter-144.125d0)
|
2007-07-10 14:27:56 -04:00
|
|
|
imid=nint(1000.0*(fselect-125.0+48.0)/df)
|
2007-07-10 17:07:19 -04:00
|
|
|
fmid=0.5*(nfa+nfb) + foffset
|
|
|
|
imid0=nint(1000.0*(fmid-125.0+48.0)/df) - nbpp/2 !Last term is empirical
|
|
|
|
i0=imid-375
|
|
|
|
ii0=imid0-375*nbpp
|
2008-07-23 16:27:47 -04:00
|
|
|
! if(nfullspec.eq.1) then
|
|
|
|
! nbpp=NFFT/NX
|
|
|
|
! ii0=0
|
|
|
|
! endif
|
2007-07-10 14:27:56 -04:00
|
|
|
|
|
|
|
k=0
|
|
|
|
do j=nlines,1,-1 !Reverse order so last will be on top
|
2007-01-13 15:21:32 -05:00
|
|
|
do i=1,NX
|
2007-01-12 14:56:45 -05:00
|
|
|
k=k+1
|
2007-01-12 12:57:41 -05:00
|
|
|
n=0
|
2007-01-13 15:21:32 -05:00
|
|
|
x=0.
|
2007-07-10 14:27:56 -04:00
|
|
|
iia=(i-1)*nbpp + ii0 + 1
|
|
|
|
iib=i*nbpp + ii0
|
|
|
|
do ii=iia,iib
|
2007-01-13 15:21:32 -05:00
|
|
|
x=max(x,s(ii,j))
|
|
|
|
enddo
|
|
|
|
x=fac*x
|
2007-12-28 12:33:18 -05:00
|
|
|
if(x.gt.0.0 .and. logmap.eq.0) n=(2.0*x)**gamma + offset
|
|
|
|
if(x.gt.0.0 .and. logmap.eq.1) n=gain*log10(1.0*x) + offset
|
2007-01-12 12:57:41 -05:00
|
|
|
n=min(252,max(0,n))
|
2007-01-12 14:56:45 -05:00
|
|
|
a(k)=n
|
2007-01-13 15:21:32 -05:00
|
|
|
|
2007-07-10 14:27:56 -04:00
|
|
|
! Now do the lower (zoomed) waterfall with one FFT bin per pixel.
|
2007-01-13 15:21:32 -05:00
|
|
|
n=0
|
2007-07-10 14:27:56 -04:00
|
|
|
x=fac*s(i0+i-1,j)
|
2007-12-28 12:33:18 -05:00
|
|
|
if(x.gt.0.0 .and. logmap.eq.0) n=(3.0*x)**gamma + offset
|
|
|
|
if(x.gt.0.0 .and. logmap.eq.1) n=1.2*gain*log10(1.0*x) + offset
|
2007-01-13 15:21:32 -05:00
|
|
|
n=min(252,max(0,n))
|
|
|
|
a2(k)=n
|
|
|
|
|
2007-01-12 12:57:41 -05:00
|
|
|
enddo
|
2005-12-23 12:07:54 -05:00
|
|
|
enddo
|
|
|
|
|
|
|
|
return
|
|
|
|
end subroutine spec
|