Commit 389464ba authored by Gonzalez, Miguel's avatar Gonzalez, Miguel
Browse files

Update to read correctly the last NeXus data format in Figaro (issue #49)

parent 0313124f
......@@ -27,124 +27,111 @@ pro figaro_grav,PP,XX,XT,NN
; the second controling chopper
;-
tofd = (PP[68]+PP[71])*1.e-3
poff = PP[55]
openoff = PP[56]
channelwidth = PP[58]*1e-6
edelay = PP[59]*1e-6
ntofchannels = PP[57]
case PP[48] of
1: begin
speed1 = PP[41]
phase1 = 0.0
end
2: begin
speed1 = PP[42]
phase1 = PP[45]
end
3: begin
speed1 = PP[43]
phase1 = PP[46]
end
else: return
endcase
case PP[49] of
2: begin
speed2 = PP[42]
phase2 = PP[45]
end
3: begin
speed2 = PP[43]
phase2 = PP[46]
end
4: begin
speed2 = PP[44]
phase2 = PP[47]
end
else: return
endcase
planckperkg = 3.956e-7
chopwin = 45.0
period = 60.0/speed1
openangle = chopwin - (phase2-phase1) - openoff
delayangle = phase1 + (poff-openangle)/2.
delay = edelay - (delayangle/360.0)*period
print,'Estimating lambda using:'
print,' TOF distance = ',tofd
print,' Poff = ',poff
print,' Open offset = ',openoff
print,' Channel width =',channelwidth
print,' E-delay = ',edelay
print,' Open angle = ',openangle
print,' Delay angle = ',delayangle
print,' Delay = ',delay
print
lambda = 1e10 * (planckperkg * ((findgen(ntofchannels) + 0.5) * channelwidth + delay) / tofd)
XX = lambda
XT = 'Wavelength'
;calculate corresponding wavelengths for monitor 2
monitor_tofd = (PP[68]+PP[72])*1.e-3
print,' Monitor TOF distance = ',monitor_tofd
monitor_beam = fltarr(ntofchannels) & monitor_beam = NN[*,1]
monitor_lambda = fltarr(ntofchannels)
monitor_lambda = 1e10 * (planckperkg * ((findgen(ntofchannels) + 0.5) * channelwidth + delay) / monitor_tofd)
;interpolate monitor_beam to wavelengths measured in detector
monitor_beam2 = fltarr(ntofchannels) & monitor_beam2 = interpol(monitor_beam,monitor_lambda,lambda)
NN[*,1] = monitor_beam2
print
print,'Correcting lambda for gravity effects'
newlambda = lambda
;newtheta = fltarr(tsize)
theta = PP[74]
print,' Theta0 =',theta
g = 9.81 ;gravity
th = theta * !dtor
cr = 305.e-3 ;chopper radius to the middle of guide
x1 = 0.37 ;distance from sample to slit s3 (just before sample)
y1 = tan(th)*x1
x2 = 2.535 ;distance from sample to s2 (first collimation slit)
y2 = tan(th)*x2
x3 = PP[68]*1.e-3 ;distance mid-chopper to sample
x4 = PP[71]*1.e-3 ;distance sample to detector
;origin is the centre of the sample
v = 3956./lambda ;neutron velocities
k = g/(2.*v^2) ;a characteristic inverse length
x0 = 0.5*(tan(th)/k-((x2^2-x1^2)/(x1-x2))) ; this is the distance in x to the top of the parabola
h = y1+k*(x1-x0)^2 ; h is the height fo the top of the parabola
;equation for parabola is y=h-(x-x0)^2
dh = (h-k*(x4+x0)^2)+x4*tan(th)
delta = x0-sqrt(h/k) ; shift in x along sample due to gravity
grad = (2.*k)*(x0-delta) ;gradient of parabola ( to find true theta at y=0)
;thetat = atan(grad)*!radeg
dz = h-k*(x0^2) ; if beam carrys on to x=0 what height would it be below sample
chopz = x3*tan(th)-(h-k*(x3-x0)^2)
poffoff = (chopz/cr) * !radeg
;print,' poffoff = ',poffoff(0)
;help,poffoff
gradc = (2.*k)*(x0-x3) ;gradient at the midchopper distance
openofflam = (atan(gradc)-th) * !radeg
newdelayangle = delayangle - poffoff/2.
;print,' newdelayangle = ',newdelayangle(0)
;help,newdelayangle
newdelay = edelay - (newdelayangle/360.)*period
newlambda = 1e10 * (planckperkg * (findgen(ntofchannels) * channelwidth + newdelay) / tofd)
XX = newlambda
XT = 'Wavelength'
if PP[98] ge 12 then begin
;list of parameters has changed in time, so it is not sure that this work with previous data formats
tofd = (PP[71]+PP[74])*1.e-3
poff = PP[58]
openoff = PP[59]
channelwidth = PP[61]*1e-6
edelay = PP[62]*1e-6
ntofchannels = PP[60]
;first controlling chopper
case PP[50] of
1: begin
speed1 = PP[43]
phase1 = 0.0
end
2: begin
speed1 = PP[44]
phase1 = PP[47]
end
3: begin
speed1 = PP[45]
phase1 = PP[48]
end
else: return
endcase
;second controlling chopper
case PP[51] of
2: begin
speed2 = PP[42]
phase2 = PP[45]
end
3: begin
speed2 = PP[43]
phase2 = PP[46]
end
4: begin
speed2 = PP[44]
phase2 = PP[47]
end
else: return
endcase
planckperkg = 3.956e-7
chopwin = 45.0
period = 60.0/speed1
openangle = chopwin - (phase2-phase1) - openoff
delayangle = phase1 + (poff-openangle)/2.
delay = edelay - (delayangle/360.0)*period
print, 'Estimating lambda using:'
print, ' TOF distance = ',tofd
print, ' Poff = ',poff
print, ' Open offset = ',openoff
print, ' Channel width =',channelwidth
print, ' E-delay = ',edelay
print, ' Open angle = ',openangle
print, ' Delay angle = ',delayangle
print, ' Delay = ',delay
print
lambda = 1e10 * (planckperkg * ((findgen(ntofchannels) + 0.5) * channelwidth + delay) / tofd)
XX = lambda
XT = 'Wavelength'
print
print, 'Correcting lambda for gravity effects'
newlambda = lambda
theta = PP[9]
print, ' Theta0 =',theta
g = 9.81 ;gravity
th = theta * !dtor
cr = 305.e-3 ;chopper radius to the middle of guide
x1 = 0.37 ;distance from sample to slit s3 (just before sample)
y1 = tan(th)*x1
x2 = 2.535 ;distance from sample to s2 (first collimation slit)
y2 = tan(th)*x2
x3 = PP[71]*1.e-3 ;distance mid-chopper to sample
x4 = PP[74]*1.e-3 ;distance sample to detector
;origin is the centre of the sample
v = 3956./lambda ;neutron velocities
k = g/(2.*v^2) ;a characteristic inverse length
x0 = 0.5*(tan(th)/k-((x2^2-x1^2)/(x1-x2))) ; this is the distance in x to the top of the parabola
h = y1+k*(x1-x0)^2 ; h is the height fo the top of the parabola
;equation for parabola is y=h-(x-x0)^2
dh = (h-k*(x4+x0)^2)+x4*tan(th)
delta = x0-sqrt(h/k) ; shift in x along sample due to gravity
grad = (2.*k)*(x0-delta) ;gradient of parabola ( to find true theta at y=0)
dz = h-k*(x0^2) ; if beam carrys on to x=0 what height would it be below sample
chopz = x3*tan(th)-(h-k*(x3-x0)^2)
poffoff = (chopz/cr) * !radeg
gradc = (2.*k)*(x0-x3) ;gradient at the midchopper distance
openofflam = (atan(gradc)-th) * !radeg
newdelayangle = delayangle - poffoff/2.
newdelay = edelay - (newdelayangle/360.)*period
newlambda = 1e10 * (planckperkg * (findgen(ntofchannels) * channelwidth + newdelay) / tofd)
XX = newlambda
XT = 'Wavelength'
endif
end
This diff is collapsed.
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