!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! THE WONDERFUL CLASS PROGRAM TO CATCH SPIKES ! 
! (c) Manuel Gonzalez and Christof Buchbender !
!                 June 2012                   !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!
! HELP
! 1.- Load in CLASS your spiky spectrum
! 2.- Tape @spikes. 
! 3.- A cursor will appear in your window
!     place it with the help of the mouse and
!     your keybord on your spike, and click
!     on the space bar. To exit from the cursor
!     mode click on 'E'
! 4.- In the prompt you will be asked by your
!     spike frequency (in MHz) Just copy the 
!     RestFrequency value.
! 5.- This wonderful program will give you the
!     Local oscillator and your IF frequency.
!
set format long
set plot histo
set unit f v
plot
draw

define double fspike
define double fcentral 
define double fimage
define double fact
define double fif
define double flo
define double ifreq

let fspike 
let fcentral R%HEAD%SPE%RESTF               !!Sky central frequency
let fimage R%HEAD%SPE%IMAGE                 !!Image frequency
let fact 1.0/(1.0+R%HEAD%SPE%DOPPLER)       !!Doppler correction
let fif (fimage-fcentral)/2.0*fact          !!if value (+-6.25, +-9.43)
let flo fcentral+fif
let ifreq abs(fspike-flo)/1000.0

if (ifreq.gt.8) then
let ifreq 15.68-ifreq
endif

say "f_LO (GHz)" 'flo/1000.0' /format a10 f9.2
say "IF_spike (GHz)" 'ifreq' /format a14 f9.2
