Commit 352e2c5a authored by Miguel Angel Gonzalez's avatar Miguel Angel Gonzalez
Browse files

Update to handle new chopper in D17

parent bffd8e54
......@@ -4032,8 +4032,19 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
;MAG: Setting arrays sizes from numor
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
; New and Old detector
if c_params.data_format gt 1 then c_params.pcen=132.5 else c_params.pcen=135.79
; History of detector centers
case c_params.data_format of
1: c_params.pcen = 135.79
2: c_params.pcen = 132.5
3: c_params.pcen = 132.5
4: c_params.pcen = 132.5
5: c_params.pcen = 106.0
else: begin
cosmos_logmessage, 'c_params.data_format = ' + string(c_params.data_format) + ' not handled!', /WARNING
cosmos_logmessage, 'Using c_params.pcen = 106', /WARNING
c_params.pcen = 106.0
end
endcase
;pixels_x
tmp = long(par1[98]-par1[97]+1)
......@@ -4133,28 +4144,23 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
if float(par2[14]) gt 0.0 then begin
if float(par2[14]) lt 10.0 then begin
c_params.chopsep = float(par2[14])*1.e-2 ;separation given in cm in numor file
endif else begin
c_params.chopsep = float(par2[14])*1.e-3 ;separation given in mm in numor file
endelse
;until cycle 183, chopper gap was correctly written in par2[14],
;but this is not the case from cycle 191 onwards, so relying on
;hard-coded values only
if c_params.data_format le 2 then begin
c_params.chopsep = c_params.chopsep_d17[0]
c_params.chopwin = c_params.chopwin_d17[0]
c_params.cr = c_params.cr_d17[0]
endif else if c_params.data_format eq 3 then begin
c_params.chopsep = c_params.chopsep_d17[1]
c_params.chopwin = c_params.chopwin_d17[1]
c_params.cr = c_params.cr_d17[1]
endif else begin
c_params.chopsep = c_params.chopsep_d17
c_params.chopsep = c_params.chopsep_d17[2]
c_params.chopwin = c_params.chopwin_d17[2]
c_params.cr = c_params.cr_d17[2]
endelse
;check if separation between choppers is reasonable - if not, use default value
if c_params.chopsep lt 79e-3 or c_params.chopsep gt 87e-3 then begin
;separation between choppers = 85 mm before 2012 and 81.1 mm since 2012
if detector_format ge 2 then c_params.chopsep = c_params.chopsep_d17 else c_params.chopsep = 85.e-3
cosmos_logmessage, 'No valid value for chopsep in numor ' + file_name, /WARNING
cosmos_logmessage, 'Using default value = ' + cosmos_str_make(c_params.chopsep), /WARNING
endif
c_params.chopwin = c_params.chopwin_d17
;PG on 07/08/2017: Added chopper radius
c_params.cr = c_params.cr_d17 ;
;PG: Corrected for reading in actual interslit distance
c_params.interslit = float(par1[58])-float(par1[59])
if c_params.interslit lt 3000.0 then c_params.interslit = c_params.interslit_d17
......@@ -4492,7 +4498,7 @@ pro cosmos_raw_read, files, monitors, counts, params, path, override, reflect=re
endfor
endif else if (c_params.data_format eq 3) then begin
endif else if (c_params.data_format ge 3) then begin
; New data format (version 3) produced by new kinetic acquisition card (used from 21/02/2013)
......@@ -4729,11 +4735,13 @@ pro cosmos_raw_read_nexus, files, monitors, counts, params, path, override, refl
id = h5d_open(file, '/entry0/instrument/name')
c_params.inst = (strtrim(h5d_read(id), 2))[0]
;MISSING NXS --> read format version when it will be added (meanwhile hardcoded)
id = h5d_open(file, '/entry0/instrument/version')
nxs_version = (h5d_read(id))[0]
;adjust NXS version to correspond to ASCII version numbering
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
detector_format = 3
detector_format = nxs_version + 3
endif else if (strcmp(strtrim(c_params.inst,2),'figaro',/FOLD_CASE)) then begin
detector_format = 12
detector_format = nxs_version + 11
endif else begin
cosmos_logmessage, 'Instrument name not recognized!', /WARNING
endelse
......@@ -4965,7 +4973,19 @@ pro cosmos_raw_read_nexus, files, monitors, counts, params, path, override, refl
;Setting arrays sizes from numor
if (strcmp(strtrim(c_params.inst,2),'d17',/FOLD_CASE)) then begin
c_params.pcen = 132.5
; History of detector centers
case c_params.data_format of
1: c_params.pcen = 135.79
2: c_params.pcen = 132.5
3: c_params.pcen = 132.5
4: c_params.pcen = 132.5
5: c_params.pcen = 106.0
else: begin
cosmos_logmessage, 'c_params.data_format = ' + string(c_params.data_format) + ' not handled!', /WARNING
cosmos_logmessage, 'Using c_params.pcen = 106', /WARNING
c_params.pcen = 106.0
end
endcase
id = h5d_open(file, '/entry0/instrument/PSD/detsize')
tmp = (h5d_read(id))[0]
......@@ -5035,10 +5055,14 @@ pro cosmos_raw_read_nexus, files, monitors, counts, params, path, override, refl
id = h5d_open(file, '/entry0/instrument/Distance/ChopperGap')
tmp = (h5d_read(id))[0]
;MISSING NXS --> units are set as mm, but value given as m (check units only after this is corrected)
;id2 = h5a_open_name(id, 'units')
;units = h5a_read(id2)
;tmp = cosmos_convert_units(tmp, units, 'm')
if tmp lt 0.1 then begin
;NeXus at cycle <= 201, value written in m instead of mm
c_params.data_format -= 1
endif else begin
id2 = h5a_open_name(id, 'units')
units = h5a_read(id2)
tmp = cosmos_convert_units(tmp, units, 'm')
endelse
if (tmp gt 0.0) then begin
c_params.chopsep = tmp
endif else begin
......@@ -5046,8 +5070,13 @@ pro cosmos_raw_read_nexus, files, monitors, counts, params, path, override, refl
cosmos_logmessage, 'Using default value = ' + cosmos_str_make(c_params.chopsep_d17), /WARNING
endelse
c_params.chopwin = c_params.chopwin_d17 ;chopper opening window
c_params.cr = c_params.cr_d17 ;chopper radius
;chopper opening window
if c_params.data_format le 3 then c_params.chopwin = c_params.chopwin_d17[1] $
else c_params.chopwin = c_params.chopwin_d17[2]
;chopper radius
if c_params.data_format le 3 then c_params.cr = c_params.cr_d17[1] $
else c_params.cr = c_params.cr_d17[2]
id = h5d_open(file, '/entry0/instrument/Distance/S2_S3')
tmp = (h5d_read(id))[0]
......
......@@ -226,16 +226,18 @@ pro cosmos_globals
c_params = {cosmos_constants, $
months : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], $
planckperkg : 3.956e-7, $
chopsep_d17 : 81.1e-3 , $
;values for old chopper (before August 2020) and new chopper in D17
;coded values correspond to formats <=2 (old chopper with 85 mm gap), 3 (old chopper with 81.1 mm gap), and >=4 (new chopper)
chopsep_d17 : [85.0e-3, 81.1e-3, 75.21e-3], $
chopwin_d17 : [45.0, 45.0, 20.0], $
cr_d17 : [0.36, 0.36, 0.27], $
chopsep12_fig : 0.0972 , $
chopsep13_fig : 0.3472 , $
chopsep14_fig : 0.7972 , $
chopsep23_fig : 0.2472 , $
chopsep24_fig : 0.6972 , $
chopsep34_fig : 0.4472 , $
chopwin_d17 : 45.0 , $
chopwin_fig : 45.0 , $
cr_d17 : 0.36 , $
cr_fig : 0.305 , $
interslit_d17 : 3500.0 , $
interslit_fig : 2165.0 , $
......@@ -342,10 +344,17 @@ pro cosmos_globals
c_results = {}
cosmos_version = '3.3.14'
cosmos_version = '3.3.15'
cosmos_help_message = [$
'',$
'COSMOS V. 3.3.15',$
'25 January 2021',$
'Version able to work with old and new D17 chopper.',$
'Fixed a type in cosmos_tofpolcorr_two affecting the error calculation of the 11 state.',$
'Set pcen=106 for D17 version 5 (cycle 211 onwards).',$
'',$
'',$
'COSMOS V. 3.3.14',$
'27 February 2020',$
'Added analyzer to san dan options in coherent and incoherent case.',$
......@@ -356,7 +365,6 @@ pro cosmos_globals
'Continuing work to use NeXus files for D17 and Figaro.',$
'',$
'',$
'',$
'COSMOS V. 3.3.13',$
'14 October 2019',$
'Added routines to be able to read and use NeXus files (not functional for Figaro yet).',$
......
......@@ -154,6 +154,7 @@ end
function cosmos_get_mft_parameter, numor, name
common cosmos_settings, c_settings
common cosmos_params, c_params
;Figaro output for Motofit
if c_settings.mftinstr eq 0 then begin
......@@ -280,7 +281,7 @@ function cosmos_get_mft_parameter, numor, name
'S3 - Sample distance (m)': value = cosmos_read_mft_parameter(numor, 1, 59)/1000.0
'Sample - Detector distance (m)': value = cosmos_read_mft_parameter(numor, 1, 14)/1000.0
'Chopper 1 actual speed': value = cosmos_read_mft_parameter(numor, 2, 44)
'Chopper 1 opening requested': value = 45.0 - (cosmos_read_mft_parameter(numor, 2, 43) - cosmos_read_mft_parameter(numor, 2, 41)) - cosmos_read_mft_parameter(numor, 1, 56)
'Chopper 1 opening requested': value = c_params.chopwin - (cosmos_read_mft_parameter(numor, 2, 43) - cosmos_read_mft_parameter(numor, 2, 41)) - cosmos_read_mft_parameter(numor, 1, 56)
'Interchopper distance': begin
value = cosmos_read_mft_parameter(numor, 2, 14)/100.0
if (value gt 0.5) or (value le 0.01) then value = 0.08111 ;interchopper distance
......
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