;+
; Project     : SOHO - CDS     
;                   
; Name        : SYNOP_STAB_DEMO
;               
; Purpose     : Demonstrate further temperature/wavecal effects.
;               
; Explanation : The mean centroid of the OV 630A line is plotted for a
;               number of synoptic rasters.  It is shown that the line 
;               changes during the series of rasters and that the start
;               position is dependent upon the thermal history of the CDS
;               in the few hours prior to the start of the synoptic
;               observations.  By the end of the synoptic series, the CDS
;               has stabilised and the centroid is reproduced with a sigma
;               of about 0.01 pixels.
;               
; Use         : IDL> synop_stab_demo
;    
; Inputs      : None
;               
; Opt. Inputs : None
;               
; Outputs     : None
;               
; Opt. Outputs: None
;               
; Keywords    : None
;
; Calls       : None
;
; Common      : None
;               
; Restrictions: None
;               
; Side effects: None
;               
; Category    : Calibration
;               
; Prev. Hist. : None
;
; Written     : C D Pike, RAL, 13-Nov-96
;               
; Modified    : 
;
; Version     : Version 1, 13-Nov-96
;-            

pro synop_stab_demo

parm = 0
s4575 = [7.780, 7.782, -0.1, 17.3,$
         7.905, 7.943, -2.1, 20.3, $
         7.991, 8.045, -3.0, 19.6,$
         8.029, 8.071, -2.4, 21.0,$
         8.081, 8.115, -1.9, 22.7,$
         8.108, 8.142, -1.9, 21.1,$
         8.118, 8.152, -1.9, 20.3,$
         8.098, 8.143, -2.5, 18.6,$
         8.010, 7.985, 1.4,  18.9]
s4575 = reform(s4575,4,9)

s4593 = [7.963, 7.981, -1.0, 17.0,$
         8.035, 8.057, -1.2, 19.6,$
         8.080, 8.121, -2.3, 20.3,$
         8.102, 8.146, -2.5, 21.9,$
         8.128, 8.158, -1.7, 21.5,$
         8.159, 8.205, -2.6, 20.3,$
         8.157, 8.199, -2.4, 19.8,$
         8.122, 8.171, -2.7, 19.5,$
         8.035, 8.018, 0.9, 18.8]
s4593 = reform(s4593,4,9)

s4611 = [7.793, 7.811, -1.0, 17.0,$
         7.907, 7.932, -1.4, 20.7,$
         7.999, 8.029, -1.6, 20.2,$
         8.053, 8.087, -1.9, 21.1,$
         8.097, 8.123, -1.5, 21.5,$
         8.111, 8.155, -2.5, 21.1,$
         8.122, 8.174, -2.9, 19.7,$
         8.106, 8.136, -1.7, 19.1,$
         8.023, 8.000, 1.3,  18.9]
s4611 = reform(s4611,4,9)


s4658 = [7.804, 7.827, -1.3, 16.8,$
         7.914, 7.924, -0.6, 19.8,$
         8.008, 8.060, -2.9, 20.8,$
         8.061, 8.109, -2.7, 21.2,$
         8.106, 8.145, -2.2, 20.1,$
         8.127, 8.180, -2.9, 21.0,$
         8.130, 8.163, -1.9, 20.2,$
         8.114, 8.133, -1.0, 18.3,$
         8.012, 8.006, 0.3,  18.7]
s4658 = reform(s4658,4,9)


s4682 = [7.910, 7.934, -1.3, 17.2,$
         7.986, 8.008, -1.2, 20.0,$
         8.055, 8.092, -2.0, 21.1,$
         8.089, 8.147, -3.2, 20.9,$
         8.111, 8.160, -2.7, 21.4,$
         8.141, 8.181, -2.2, 21.4,$
         8.136, 8.163, -1.5, 20.7,$
         8.102, 8.148, -2.6, 18.8,$
         8.022, 8.012, 0.5, 19.0]
s4682 = reform(s4682,4,9)

s4700 = [7.732, 7.773, -2.3, 16.3,$
         7.869, 7.873, -0.2, 20.0,$
         7.975, 8.028, -2.9, 21.5,$
         8.048, 8.096, -2.7, 20.4,$
         8.078, 8.123, -2.5, 21.9,$
         8.124, 8.161, -2.0, 21.2,$
         8.133, 8.168, -1.9, 20.2,$
         8.115, 8.130, -0.9, 19.0,$
         8.020, 8.005, 0.8,  19.3]
s4700 = reform(s4700,4,9)


s4879 = [8.060, 8.074, -0.8, 17.8,$
         8.108, 8.105, 0.2, 18.1,$
         8.116, 8.148, -1.8, 20.7,$
         8.119, 8.166, -2.7, 20.7,$
         8.145, 8.191, -2.6, 22.3,$
         8.140, 8.192, -2.9, 20.8,$
         8.159, 8.198, -2.2, 20.9,$
         8.133, 8.188, -3.1, 19.5,$
         8.052, 8.058, -0.3, 17.2]
s4879 = reform(s4879,4,9)


!p.multi=0
circle_sym
yran = [7.6,8.2] 
xran = [-1,9]
yt = 'OV 629A mean centroid (pixels)'
title = 'Synoptic scan wavelength stability'
ang = indgen(9)
xtxt = 'Raster (North Limb --> South Limb)'
s = indgen(9)
s = -s
plot,ang,s4879(parm,*),xr=xran,yr=yran,psym=s(8),/xst,/yst,$
            syms=1.5,xtit=xtxt,$
            ytit=yt,$
            tit=title,chars=1.3,line=2
oplot,ang,s4593(parm,*),psym=s(4),syms=1.8,line=2  
oplot,ang,s4611(parm,*),psym=s(5),syms=1.8,line=2  
oplot,ang,s4658(parm,*),psym=s(6),syms=1.8,line=2  
oplot,ang,s4682(parm,*),psym=s(7),syms=1.8,line=2  
oplot,ang,s4700(parm,*),psym=s(2),syms=1.8,line=2  
oplot,ang,s4575(parm,*),psym=s(1),syms=1.8,line=2  
oplot,[7,7],[7.65,7.83],th=2
oplot,[6.9,7.1],[7.65,7.65],th=2
oplot,[6.9,7.1],[7.83,7.83],th=2
xyouts,7.05,7.74,'10 km/s',chars=1.5

ew = fltarr(9,7)
ew(*,0) = reform(s4575(parm,*))
ew(*,1) = reform(s4593(parm,*))
ew(*,2) = reform(s4611(parm,*))
ew(*,3) = reform(s4658(parm,*))
ew(*,4) = reform(s4682(parm,*))
ew(*,5) = reform(s4700(parm,*))
ew(*,6) = reform(s4879(parm,*))

errw = fltarr(9)
wav = fltarr(9)
for i=0,8 do errw(i) = stdev(ew(i,*))
for i=0,8 do wav(i) = average(ew(i,*))

!p.multi=0

print,' '
print,'The plots show the results for a number of synoptic observations.'
print,'The mean OV 630 line profile centroid is plotted as a function'
print,'of raster number for seven days of data.  It can clearly be seen'
print,'that the wavelength calibration is unstable for the first few rasters'
print,'and gradually stabilises as the synoptic observations proceed.  This'
print,'instability at the start can be traced to the thermal history of the '
print,'CDS in the few hours before the synoptic scans started.  For those'
print,'observations giving a low mean centroid for raster #0 (*), CDS was '
print,'pointing off-limb prior to the synoptic.  Prior to the observation'
print,'giving the highest centroid (open circles) for raster #0, CDS was near'
print,'sun centre for 5 hrs before the synoptic started.  All the other '
print,'intermediate cases have histories between these two extremes.'
print,' '
end

