Blame view

src/idl/dustem_read_qabs_lv.pro 2.23 KB
2399e73e   Jean-Philippe Bernard   imprved towards r...
1
FUNCTION dustem_read_qabs_lv,file,silent=silent,read_densities=read_densities
427f1205   Jean-Michel Glorian   version 4.2 merged
2

476507cb   Jean-Philippe Bernard   modified
3
4
;stop

427f1205   Jean-Michel Glorian   version 4.2 merged
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
st=''
Nmax=10000L
sts=strarr(Nmax)
openr,unit,file,/get_lun

;==read comments
str='' & first_char='#'
WHILE first_char EQ '#' DO BEGIN
  readf,unit,str
  first_char=strmid(str,0,1)
ENDWHILE

;read number of sizes
Nsizes=fix(str)

;Get sizes
readf,unit,st
sizes=float(str_sep(strcompress(strtrim(st,2)),' '))
Ncol=Nsizes

2399e73e   Jean-Philippe Bernard   imprved towards r...
25
26
IF keyword_set(read_densities) THEN BEGIN
  readf,unit,st
d06cb418   Ilyes Choubani   Added PILOT filter
27
  ;stop
2399e73e   Jean-Philippe Bernard   imprved towards r...
28
29
30
31
32
33
34
35
36
37
  IF st EQ '#### Qabs ####' THEN BEGIN
    message,'Problem with size dependent densities in Qabs.DAT',/continue
    ;stop
  ENDIF
  densities=float(str_sep(strcompress(strtrim(st,2)),' '))
ENDIF ELSE BEGIN
  densities=fltarr(Nsizes)+la_undef()
ENDELSE
;stop

427f1205   Jean-Michel Glorian   version 4.2 merged
38
39
40
41
42
43
44
45
;==read comments
str='' & first_char='#'
WHILE first_char EQ '#' DO BEGIN
  readf,unit,str
  first_char=strmid(str,0,1)
ENDWHILE

;== read Qabs
2399e73e   Jean-Philippe Bernard   imprved towards r...
46
sts[0]=str
427f1205   Jean-Michel Glorian   version 4.2 merged
47
48
49
50
51
52
53
54
nlines=1L
first_char=' '
WHILE first_char NE '#' DO BEGIN
    readf,unit,st
    sts(nlines)=st
    nlines=nlines+1
    first_char=strmid(st,0,1)
ENDWHILE
2399e73e   Jean-Philippe Bernard   imprved towards r...
55
qabs_str=sts[0:nlines-2]
427f1205   Jean-Michel Glorian   version 4.2 merged
56
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

;==read comments
str='' & first_char='#'
WHILE first_char EQ '#' DO BEGIN
  readf,unit,str
  first_char=strmid(str,0,1)
ENDWHILE

;== read Qsca
sts(*)=''
sts(0)=str
nlines=1L
first_char=' '
WHILE not eof(unit) and first_char NE '#' DO BEGIN
    readf,unit,st
    sts(nlines)=st
    nlines=nlines+1
    first_char=strmid(st,0,1)
ENDWHILE
close,unit
free_lun,unit

qsca_str=sts(0:nlines-1)
d06cb418   Ilyes Choubani   Added PILOT filter
80
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
81
82
83
84
85

Nlines=n_elements(qsca_str)

qabs_values=fltarr(Nlines,Ncol)
qsca_values=fltarr(Nlines,Ncol)
2399e73e   Jean-Philippe Bernard   imprved towards r...
86
;stop
607060e5   Ilyes Choubani   test version
87
FOR i=0L,Nlines-2 DO BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  qabs_values(i,*)=str_sep(strcompress(strtrim(qabs_str(i),2)),' ')
  qsca_values(i,*)=str_sep(strcompress(strtrim(qsca_str(i),2)),' ')
ENDFOR

;== Make output structure
cmd='one_st={'
FOR i=0L,Ncol-1 DO BEGIN
  cmd=cmd+'v'+strtrim(i+1,2)+':'+'0.'
  IF i NE Ncol-1 THEN BEGIN
    cmd=cmd+','
  ENDIF ELSE BEGIN
    cmd=cmd+'}'
  ENDELSE
ENDFOR
toto=execute(cmd)
qabs_st=replicate(one_st,Nlines)
qsca_st=replicate(one_st,Nlines)

;=== fill in the qabs structure
FOR j=0L,Ncol-1 DO BEGIN
  qabs_st.(j)=reform(qabs_values(*,j))
  qsca_st.(j)=reform(qsca_values(*,j))
ENDFOR

2399e73e   Jean-Philippe Bernard   imprved towards r...
112
full_st={file:file,Nsizes:Nsizes,sizes:sizes,densities:densities,Qabs:qabs_st,Qsca:qsca_st}
427f1205   Jean-Michel Glorian   version 4.2 merged
113
114
115
116

return,full_st

END