Commit ddd4a94c authored by Gonzalez, Miguel's avatar Gonzalez, Miguel
Browse files

Formatting

parent 05aed439
......@@ -75,7 +75,7 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
COMMON c_lamp_access, inst
COMMON printing, iprint, outstring
IF iprint THEN PRINT,'Start normalise_tof:'
IF iprint THEN PRINT, 'Start normalise_tof:'
TAKE_DATP, datp
......@@ -87,8 +87,8 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
nchannels = sw[1]
IF sw[0] EQ 3 THEN nruns = sw[3] ELSE nruns = 1
IF iprint THEN BEGIN
PRINT,' nchannels =',nchannels
PRINT,' nruns =',nruns
PRINT, ' nchannels = ', nchannels
PRINT, ' nruns = ', nruns
ENDIF
parp = datp.p
......@@ -96,30 +96,31 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
IF nruns EQ 1 THEN parv = parp
IF (insU EQ 'IN4') THEN BEGIN
nspectra=parp[15]
nmon=parp[16]
mon=w_in[*,nspectra:nspectra+nmon-1,*]
nspectra = parp[15]
nmon = parp[16]
mon = w_in[*,nspectra:nspectra+nmon-1,*]
monarr = datp.n
ENDIF ELSE BEGIN
IF sw[0] EQ 1 THEN nspectra = 1 ELSE $
IF sw[0] EQ 1 THEN nspectra = 1 ELSE $
IF sw[0] GE 2 THEN nspectra = sw[2]
mon=datp.n & monarr=mon
mon = datp.n
monarr = mon
ENDELSE
x_in = datp.x
y_in = datp.y
norm = 1
IF N_ELEMENTS(inorm) GE 1 THEN norm = inorm
IF iprint THEN PRINT, ' norm = ',norm
IF iprint THEN PRINT, ' norm = ', norm
gauss = FLTARR(4)
dgauss = FLTARR(4)
IF iprint THEN PRINT,'normalise_tof: End of setup data section'
IF iprint THEN PRINT, 'normalise_tof: End of setup data section'
; ------------------------------------------------------------------------------
;Find elastic peak in detectors
i=WHERE(y_in GT 10. AND y_in LT 120.)
xtot = x_in
i = WHERE(y_in GT 10. AND y_in LT 120.)
xtot = x_in
IF nruns EQ 1 THEN BEGIN
ytot = TOTAL(w_in[*,i],2)
ENDIF ELSE BEGIN
......@@ -132,11 +133,11 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
FITGAUSS, xtot, ytot, etot, xmin, xmax, gauss, dgauss
chel = gauss[2]
chel = gauss[2]
IF (insU NE 'MIBEMOL') AND (insU NE 'DCSASC') THEN parv[9,*]=chel
IF (insU NE 'MIBEMOL') AND (insU NE 'DCSASC') THEN parv[9,*] = chel
IF iprint THEN PRINT,'End of elastic peak section'
IF iprint THEN PRINT, 'End of elastic peak section'
; ** Normalization for mibemol data and DCS
......@@ -144,45 +145,51 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
; ** *************************************
CASE insU OF
'MIBEMOL':BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon=1000 & mod_datp, datp, "n",mon
; GOTO, mibdcs
END
'DCSASC':BEGIN
normff = TOTAL(monarr)
normff = normff/1000.
chel = gauss[2] & parp[10] = chel
mon=1000 & mod_datp, datp, "n",mon
; GOTO, mibdcs
END
'FOCUS':BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon=1000 & mod_datp, datp, "n",mon
; print,"nruns=",nruns
; GOTO, mibdcs
END
'TOFTOF':BEGIN
CASE (norm) OF
0: normff=1
1: normff = monarr[1]/1000.
2: normff = monarr[0]/60
else:
ENDCASE
chel = gauss[2] & parp[9] = chel
; mon=1000 & mod_datp, datp, "n",mon
END
'NEAT':BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon=1000 & mod_datp, datp, "n",mon
END
ELSE:
'MIBEMOL': BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon = 1000
mod_datp, datp, "n",mon
END
'DCSASC': BEGIN
normff = TOTAL(monarr)
normff = normff/1000.
chel = gauss[2] & parp[10] = chel
mon = 1000
mod_datp, datp, "n",mon
END
'FOCUS': BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon = 1000
mod_datp, datp, "n",mon
END
'TOFTOF': BEGIN
CASE (norm) OF
0: normff = 1
1: normff = monarr[1]/1000.
2: normff = monarr[0]/60
else:
ENDCASE
chel = gauss[2] & parp[9] = chel
END
'NEAT': BEGIN
normff = TOTAL(monarr)/N_ELEMENTS(monarr)
normff = normff/1000.
chel = gauss[2] & parp[9] = chel
mon=1000
mod_datp, datp, "n",mon
END
ELSE:
ENDCASE
; -----------------------------------------------------------------------------
;Find monitor peak, integrate and normalise
......@@ -192,6 +199,7 @@ FUNCTION normalise_tof, w_in, inorm, keepmons
e_out = FLTARR(nchannels,nspectra,nruns)
FOR irun = 0, nruns - 1 DO BEGIN
IF (insU EQ 'MIBEMOL') OR (insU EQ 'FOCUS') OR $
(insU EQ 'DCSASC') OR (insU EQ 'TOFTOF') OR (insU EQ 'NEAT') THEN BEGIN
normf[irun]=normff
......@@ -233,79 +241,87 @@ mibdcs:
e_out[*,*,irun] = SQRT(w_in[*,0:nspectra-1,irun]) / normf[irun]
ENDFOR
IF iprint THEN PRINT,'End of monitor peak section'
IF iprint THEN PRINT, 'End of monitor peak section'
; ------------------------------------------------------------------------------
;For IN4, calibrate wavelength
IF (insU EQ 'IN4') AND (norm EQ 1) THEN BEGIN
chw = parv[18] ;channel time width
rpm = parv[19]*2. ;pulse frequency
IF centre GT chel THEN BEGIN
deadtime = (60./rpm) - (nchannels*chw/1.e6)
diff_chan = nchannels - centre + chel
diff_time = (chw/1.e6)*diff_chan + deadtime
ENDIF ELSE BEGIN
diff_chan = chel - centre
diff_time = (chw/1.e6)*diff_chan
chw = parv[18] ;channel time width
rpm = parv[19]*2. ;pulse frequency
IF centre GT chel THEN BEGIN
;monitor measure in pulse i, detector in pulse i+1
time_det_mon = (chw/1.e6) * (centre-chel)
diff_time = (60./rpm) - time_det_mon ;dt = time between pulses - (M-D) time
ENDIF ELSE BEGIN
;monitor and detector in same pulse
diff_time = (chw/1.e6) * (chel-centre)
ENDELSE
L_mon2dets = 2.3039
L_mon2dets = 2.3039 ; distance between monitor and detector
speed = L_mon2dets / (diff_time*1000.) ; in km/s
lambda = 3.956076 / speed ; in Angstroms
lambda = 3.956076 / speed ; in Angstroms
if lambda lt 0.7 then begin
diff_time=diff_time+60./(parv[19]*2.)
speed = L_mon2dets / (diff_time*1000.) ; in km/s
lambda = 3.956076 / speed ; in Angstroms
; need to add an extra pulse
diff_time = diff_time + (60./rpm)
speed = L_mon2dets / (diff_time*1000.) ; in km/s
lambda = 3.956076 / speed ; in Angstroms
endif
parv[21,*] = lambda
IF iprint THEN PRINT,'End of wavelength calibration section'
IF iprint THEN PRINT, 'End of wavelength calibration section'
ENDIF
; ------------------------------------------------------------------------------
;Return parameters and exit
s = STRTRIM(STRING(chel),2) & i = STRPOS(s,'.') & chel = STRMID(s,0,i[0]+3)
s = STRTRIM(STRING(normf),2) & i = STRPOS(s,'.') & normf = STRMID(s,0,i[0]+3)
s = STRTRIM(STRING(chel),2) & i = STRPOS(s,'.') & chel = STRMID(s,0,i[0]+3)
s = STRTRIM(STRING(normf),2) & i = STRPOS(s,'.') & normf = STRMID(s,0,i[0]+3)
lambdast = ''
lstring = ''
CASE norm OF
0: BEGIN
nors = '/raw'
nstring = 'not normalised. '
datp.z_tit = 'Counts '
END
1: BEGIN
nors = '/m'
IF (insU EQ 'IN4') THEN BEGIN
s = STRTRIM(STRING(lambda),2)
i = STRPOS(s,'.')
lambda = STRMID(s,0,i[0]+4)
lambdast = ',lambda='+lambda
lstring = 'Calculated wavelength='+lambda
lambdast = ', lambda = ' + lambda
lstring = ' Calculated wavelength = ' + lambda
ENDIF
nstring = 'normalised to '+normf+'/1000 M1 counts. '
nstring = 'normalised to ' + normf + '/1000 M1 counts. '
datp.z_tit = 'Counts / 1000 M1'
END
2: BEGIN
nors = '/t'
nstring='normalised to '+normf+' minutes. '
nstring = ' normalised to ' + normf + ' minutes. '
datp.z_tit = 'Counts / min'
END
else:
ELSE:
ENDCASE
normalisation = ' no('+nors+',ce='+chel+lambdast[0]+')'
cstring='Elastic channel='+chel+'. '
outstring=nstring+cstring+lstring
normalisation = ' no(' + nors + ', ce = ' + chel + lambdast[0] + ')'
cstring = 'Elastic channel = ' + chel + '. '
outstring = nstring + cstring + lstring
IF nruns EQ 1 THEN datp.p = parv ELSE BEGIN
datp.pv = parv
datp.p = parv[*,nruns-1]
ENDELSE
s = datp.other_tit & i = strpos(/reverse_search,s,' ') & n = STRLEN(s) & numor = STRMID(s,i+1,n-1)
IF (STRPOS(numor,'>') EQ -1) THEN $
numor = STRTRIM(STRING(LONG(parp[10])),2)
s = datp.other_tit & i = strpos(/reverse_search,s,' ') & n = STRLEN(s) & numor = STRMID(s,i+1,n-1)
IF (STRPOS(numor,'>') EQ -1) THEN numor = STRTRIM(STRING(LONG(parp[10])),2)
datp.other_tit = inst + ' #' + numor + normalisation
datp.x_tit = 'Channel number'
......@@ -333,7 +349,7 @@ FUNCTION normalise_d7, w_in0, inorm, ikeep, zeroshift
COMMON c_lamp_access, inst
COMMON printing, iprint, outstring
IF iprint THEN PRINT,'Start normalise_d7:'
IF iprint THEN PRINT, 'Start normalise_d7:'
TAKE_DATP, datp
; ------------------------------------------------------------------------------
......@@ -365,19 +381,16 @@ FUNCTION normalise_d7, w_in0, inorm, ikeep, zeroshift
IF nspectra LT 114 THEN nvers = 4 ; 2004 (1st MP detector bank installed)
IF nspectra EQ 114 THEN nvers = 5 ; 2006 (2nd MP detector bank installed)
IF nspectra EQ 148 THEN nvers = 6 ; 2007 (3rd MP detector bank installed)
IF nspectra EQ 132 THEN nvers = 7 ; 2007 (Bank 1 removed)
IF nspectra EQ 132 THEN nvers = 7 ; 2007 (Bank 1 removed)
IF TOF AND nspectra EQ 150 THEN nvers = 6 ; TOF
IF TOF AND nspectra EQ 135 THEN nvers = 7
IF nspectra EQ 135 AND datp.p[48] EQ 6.0 THEN nvers = 8 ; March 2009-
IF nspectra EQ 150 AND datp.p[48] EQ 6.0 THEN nvers = 9 ; TOF
ENDIF
IF datp.p[48] EQ 6.0 THEN BEGIN
nvers=8 ; March 2009 and onwards
ENDIF
IF datp.p[48] EQ 7.0 THEN BEGIN
nvers=10 ;June and onwards
ENDIF
rearrange = 0
IF datp.p[48] EQ 6.0 THEN nvers=8 ; March 2009 and onwards
IF datp.p[48] EQ 7.0 THEN nvers=10 ;June and onwards
rearrange = 0
IF NOT TOF AND (nphases EQ 1) THEN BEGIN
IF N_ELEMENTS(sw) EQ 4 THEN nruns = 1 ELSE nruns = sw[sw[0]]
......@@ -548,7 +561,7 @@ rearrange = 0
IF iprint THEN PRINT, 'Normalise: Elastic channel = ' + $
STRTRIM(STRING(chel),2)
IF iprint THEN PRINT,'End of "elastic peak" section'
IF iprint THEN PRINT, 'End of "elastic peak" section'
ENDIF
; ------------------------------------------------------------------------------
......@@ -582,6 +595,7 @@ rearrange = 0
y_out = INTARR(nruns)
y_out = LONG(parv[0,*])
ENDELSE
ENDIF ELSE BEGIN
x_out = x_in
y_out = FLTARR(nspectra*nphases)
......@@ -634,7 +648,7 @@ rearrange = 0
PRINT,'size(z_out)=',size(z_out)
ENDIF
IF iprint THEN PRINT,'End of "Perform normalisation" section'
IF iprint THEN PRINT, 'End of "Perform normalisation" section'
; ------------------------------------------------------------------------------
;Recalculate and sort detector angles from YIG calibration
......@@ -704,19 +718,19 @@ rearrange = 0
phi = [bank4,bank3,bank2]
z_out = phi[goodspecs,*]
ENDIF ELSE IF nvers EQ 7 THEN BEGIN ; Data from May 2007 onwards
ENDIF ELSE IF nvers EQ 7 THEN BEGIN ; Data from May 2007 onwards
bank = FLTARR(4,nruns)
IF nruns EQ 1 THEN bank = parp[[16,17,18,19]] $
ELSE bank = parv[[16,17,18,19],*]
ELSE bank = parv[[16,17,18,19],*]
offset4 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset4[ispec] = -0.999537*(ispec + 1) + 28.504 ELSE $
offset4[ispec] = -0.999752*(ispec + 1) + 28.243
offset3 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset3[ispec] = -0.99647*(ispec + 1) + 25.419 ELSE $
offset3[ispec] = -0.99469*(ispec + 1) + 25.106
offset2 = FLTARR(44)
offset2 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset2[ispec] = -0.99776*(ispec + 1) + 19.083 ELSE $
offset2[ispec] = -0.99828*(ispec + 1) + 18.805
......@@ -736,16 +750,16 @@ rearrange = 0
ENDIF ELSE IF nvers EQ 6 THEN BEGIN ; Data from January 2007 onwards
bank = FLTARR(4,nruns)
IF nruns EQ 1 THEN bank = parp[[16,17,18,19]] $
ELSE bank = parv[[16,17,18,19],*]
ELSE bank = parv[[16,17,18,19],*]
offset4 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset4[ispec] = -0.999537*(ispec + 1) + 28.504 ELSE $
offset4[ispec] = -0.999752*(ispec + 1) + 28.243
offset3 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset3[ispec] = -0.99647*(ispec + 1) + 25.419 ELSE $
offset3[ispec] = -0.99469*(ispec + 1) + 25.106
offset2 = FLTARR(44)
offset2 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ FLOAT(ispec + 1)/2. THEN $
offset2[ispec] = -0.99776*(ispec + 1) + 19.083 ELSE $
offset2[ispec] = -0.99828*(ispec + 1) + 18.805
......@@ -768,16 +782,16 @@ rearrange = 0
ENDIF ELSE IF nvers EQ 5 THEN BEGIN ; Data from June 2006 onwards
bank = FLTARR(4,nruns)
IF nruns EQ 1 THEN bank = parp[[16,17,18,19]] $
ELSE bank = parv[[16,17,18,19],*]
ELSE bank = parv[[16,17,18,19],*]
offset4 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ float(ispec + 1)/2. THEN $
offset4[ispec] = -1.002*(ispec + 1) + (15.0*2.) ELSE $
offset4[ispec] = -1.002*(ispec + 1) + (14.851*2.)
offset3 = FLTARR(44)
offset3 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ float(ispec + 1)/2. THEN $
offset3[ispec] = -1.002*(ispec + 1) + (13.4725*2.) ELSE $
offset3[ispec] = -1.002*(ispec + 1) + (13.434*2.)
offset2 = FLTARR(10)
offset2 = FLTARR(10)
FOR ispec = 0,9 DO IF (ispec + 1)/2 EQ float(ispec + 1)/2. THEN $
offset2[ispec] = -1.002*(ispec + 1) + 1. ELSE $
offset2[ispec] = -1.002*(ispec + 1) + 1.
......@@ -800,7 +814,7 @@ rearrange = 0
ENDIF ELSE IF nvers EQ 4 THEN BEGIN ; Data from Mar 2004 till Aug 2005
bank = FLTARR(4,nruns)
IF nruns EQ 1 THEN bank = parp[[16,17,18,19]] $
ELSE bank = parv[[16,17,18,19],*]
ELSE bank = parv[[16,17,18,19],*]
offset4 = FLTARR(44)
FOR ispec = 0,43 DO IF (ispec + 1)/2 EQ float(ispec + 1)/2. THEN $
offset4[ispec] = -1.002*(ispec + 1) + (15.0*2.) ELSE $
......@@ -1016,7 +1030,7 @@ FUNCTION normalise_het, w_in, ei = ei
PRINT, 'Nchannels = ', nchannels
ENDIF
IF iprint THEN PRINT,'Normalise_HET: End of check dimensions, etc. section'
IF iprint THEN PRINT, 'Normalise_HET: End of check dimensions, etc. section'
; ------------------------------------------------------------------------------------
; Find elastic lines
......@@ -1126,7 +1140,7 @@ FUNCTION normalise, w_in, RAW=raw, MONITOR=monitor, TIME=time, $
iprint = 0 ; if iprint>0, show debugging messages
IF iprint THEN PRINT,'Start normalise:'
IF iprint THEN PRINT, 'Start normalise:'
IF N_ELEMENTS(inorm) EQ 0 THEN inorm = 1 ;default
IF KEYWORD_SET(raw) THEN inorm = 0
......@@ -1157,7 +1171,7 @@ FUNCTION normalise, w_in, RAW=raw, MONITOR=monitor, TIME=time, $
w_out=normalise_HET(w_in, ei = ei) $
ELSE BEGIN
s = STRARR(13)
s[0] = 'Normalise: Instrument must be specfied as one of the following'
s[0] = 'Normalise: Instrument must be specified as one of the following'
s[1] = ''
s[2] = 'IN4'
s[3] = 'IN5'
......@@ -1177,7 +1191,7 @@ FUNCTION normalise, w_in, RAW=raw, MONITOR=monitor, TIME=time, $
; ------------------------------------------------------------------------------
;Return parameters and exit
PRINT,'normalise: ' + outstring
PRINT, 'normalise: ' + outstring
finished:
RETURN, w_out
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment