-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfoxsi4_get_pinhole_attenuation_factor.pro
53 lines (46 loc) · 1.57 KB
/
foxsi4_get_pinhole_attenuation_factor.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FUNCTION foxsi4_get_pinhole_attenuation_factor, energy_arr=energy_arr
; :Project:
; FOXSI-4 sounding rocket simulation
;
; :description:
; This function returns the attenuation factor for the initial pinhole attenuator (see Dan for details)
;
; :inputs:
;
; :outputs:
; The function returns a structure that contains the energy array and the corresponding attenuation factor
;
; :keywords:
; energy_arr: array of energies for which attenuation is calculated, in keV
;
; :call:
; This procedure will open a text file containing the attenuation factor at given energies
;
; :example:
; res = foxsi4_get_pinhole_attenuation_factor(energy_arr = energy_out)
;
; :history:
; 2019/10/28, SMusset (UMN), initial release
; 2020/09/16, SMusset (UoG), change path to file
; 2020/10/06, SMusset (UoG), change path to file and make it compatible with Unix and Mac
;
; :to be done:
;-
os=!VERSION.OS_FAMILY
IF os EQ 'Windows' THEN sep_char='\' ELSE sep_char='/'
mypath = routine_filepath()
sep = strpos(mypath,sep_char,/reverse_search)
path = strmid(mypath, 0, sep)
file = path+'/material_data/pinhole_attenuation_factor.txt'
read_list_txt, file=file, tab=tab
energy_att_kev = double(reform(tab[*,0]))
factor_att = double(reform(tab[*,1]))
IF keyword_set(energy_arr) THEN BEGIN
factor = interpol(factor_att, energy_att_kev, energy_arr)
ENDIF ELSE BEGIN
energy_arr = energy_att_kev
factor = factor_att
ENDELSE
result = create_struct("energy_keV", energy_arr, "att_factor", factor)
RETURN, result
END