Blame view

src/idl/dustem_read_all_web3p8.pro 6.72 KB
b7f936fc   Ilyes Choubani   to JP: initial fi...
1
FUNCTION dustem_read_all_web3p8,dir_in,silent=silent,help=help,kwords=kwords
68d2f391   Jean-Philippe Bernard   modified to cope ...
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

;+
; NAME:
;    dustem_read_all_web3p8
; PURPOSE:
;    Reads all Dustem input data, as of the web available dustem fortran version
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    st=dustem_read_all_web3p8(dir_in[,/silent])
; INPUTS:
;    dir_in: input directory
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
;    sielnt    = If set, keep silent
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
;-

IF keyword_set(help) THEN BEGIN
4750086c   Ilyes Choubani   nouvelle philosph...
40
  doc_library,'dustem_read_all_web3p8' 
68d2f391   Jean-Philippe Bernard   modified to cope ...
41
42
43
  st=0
  goto,the_end
ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
44

d06cb418   Ilyes Choubani   Added PILOT filter
45
46
47
dir_in_dat=dir_in+'data/'
dir_in_qabs=dir_in+'oprop/'
dir_in_capa=dir_in+'hcap/'
427f1205   Jean-Michel Glorian   version 4.2 merged
48
49

file=dir_in_dat+(*!dustem_inputs).grain
6730c3f8   Jean-Philippe Bernard   modified to be co...
50
51
52
53
;st_grains=dustem_read_grain(file,silent=silent)
st_grains=dustem_read_grain(file,silent=silent,key_str=key_str,G0=G0)
Ngrains=n_elements(st_grains)
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
54
55
56
57

file=dir_in_dat+'ISRF.DAT'
st_isrf=dustem_read_isrf(file,silent=silent,Nisrf=Nisrf)

e71a7ada   Jean-Philippe Bernard   modified to work ...
58
59
;stop

68d2f391   Jean-Philippe Bernard   modified to cope ...
60
61
62
file=dir_in_dat+'GAS.DAT'
st_gas=dustem_read_gas(file,silent=silent)

427f1205   Jean-Michel Glorian   version 4.2 merged
63
;=== Read Qabs
6730c3f8   Jean-Philippe Bernard   modified to be co...
64

427f1205   Jean-Michel Glorian   version 4.2 merged
65
66
st_qabs=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
2399e73e   Jean-Philippe Bernard   imprved towards r...
67
68
  read_densities=0
  IF st_grains[i].rho LE 0 THEN read_densities=1
6730c3f8   Jean-Philippe Bernard   modified to be co...
69
  Qabs_file=dir_in_qabs+'Q_'+st_grains(i).grain_type+'.DAT'
2399e73e   Jean-Philippe Bernard   imprved towards r...
70
  st=dustem_read_qabs_lv(Qabs_file,silent=silent,read_densities=read_densities)
427f1205   Jean-Michel Glorian   version 4.2 merged
71
72
  st_qabs(i)=ptr_new(st)
ENDFOR
266ae799   Ilyes Choubani   General update
73
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
74
75
76
;=== Read heat capacities
st_calor=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
6730c3f8   Jean-Philippe Bernard   modified to be co...
77
  Calor_file=dir_in_capa+'C_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
78
79
80
81
82
83
84
85
  st=dustem_read_calor_lv(Calor_file,silent=silent)
  st_calor(i)=ptr_new(st)
ENDFOR

;=== Read lambda
file=dir_in_qabs+'LAMBDA.DAT'
st_lambda=dustem_read_lambda(file,silent=silent)

b7f936fc   Ilyes Choubani   to JP: initial fi...
86
87
88
89
90
91
if keyword_set(kwords) then begin
    FOR i=0L,n_elements(kwords)-1 DO BEGIN
        st_grains(i).type_keywords=kwords(i)
    ENDFOR
endif

427f1205   Jean-Michel Glorian   version 4.2 merged
92
93
94
;=== Read size distribution files
st_size=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
6730c3f8   Jean-Philippe Bernard   modified to be co...
95
96
  IF stregex(st_grains(i).type_keywords, 'size', /bool) THEN BEGIN
    Size_file=dir_in_dat+'SIZE_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
97
98
99
100
101
102
103
    st=dustem_read_size(Size_file,silent=silent)
    st_size(i)=ptr_new(st)
  ENDIF ELSE BEGIN
    st_size(i) = ptr_new()
  ENDELSE
ENDFOR

68d2f391   Jean-Philippe Bernard   modified to cope ...
104
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
105
106
107
;=== Read MIX files
st_mix = ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
6730c3f8   Jean-Philippe Bernard   modified to be co...
108
109
   IF stregex(st_grains(i).type_keywords, 'mix', /bool) THEN BEGIN
      Mix_file=dir_in_dat+'MIX_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
110
111
112
113
114
115
116
      st=dustem_read_mix(Mix_file,silent=silent)
      st_mix(i)=ptr_new(st)
   ENDIF ELSE BEGIN
      st_mix(i)=ptr_new()
   ENDELSE
ENDFOR

68d2f391   Jean-Philippe Bernard   modified to cope ...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
;=== Read CHRG files
st_chrg = ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
   IF stregex(st_grains(i).type_keywords, 'chrg', /bool) THEN BEGIN
      chrg_file=dir_in_dat+'CHRG_'+st_grains(i).grain_type+'.DAT'
      st=dustem_read_chrg(chrg_file,silent=silent)
      st_chrg(i)=ptr_new(st)
   ENDIF ELSE BEGIN
      st_chrg(i)=ptr_new()
   ENDELSE
ENDFOR

;=== Read SPIN files
st_spin = ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
   IF stregex(st_grains(i).type_keywords, 'spin', /bool) THEN BEGIN
      chrg_file=dir_in_dat+'SPIN_'+st_grains[i].grain_type+'.DAT'
      st=dustem_read_spin(chrg_file,silent=silent)
      st_spin[i]=ptr_new(st)
   ENDIF ELSE BEGIN
      st_spin[i]=ptr_new()
   ENDELSE
ENDFOR

427f1205   Jean-Michel Glorian   version 4.2 merged
141
142
143
144
145
146
147
;stop

;=== Read POL and Qabs files
st_qpol = ptrarr(2,Ngrains)
st_qH = ptrarr(2,Ngrains)
st_qcirc = ptrarr(Ngrains)

6730c3f8   Jean-Philippe Bernard   modified to be co...
148
149
150
;=== JPB : this organisation may not be optimal
st_pol={file:'',qpol:st_qpol,qH:st_qH,qcirc:st_qcirc}
;st_pol = replicate(one_st,Ngrains)
427f1205   Jean-Michel Glorian   version 4.2 merged
151

6730c3f8   Jean-Philippe Bernard   modified to be co...
152
IF !run_pol THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
153
   st_align=dustem_read_align(dir_in_dat,st_grains,silent=silent)
427f1205   Jean-Michel Glorian   version 4.2 merged
154
   FOR i=0L,Ngrains-1 DO BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
155
      i_alig = 0
6730c3f8   Jean-Philippe Bernard   modified to be co...
156
157
158
159
      ;IF stregex(st_grains.grains(i).type_keywords, 'pol', /bool) THEN BEGIN
      IF stregex(st_grains(i).type_keywords, 'pol', /bool) THEN BEGIN
	      IF not stregex(st_align.keywords, 'rrf', /bool) THEN BEGIN
          FOR i_axis = 1, 2 DO BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
160
161
            ;Q_file=dir_in_qabs+'Q'+strtrim(i_axis,2)+'_'+st_grains.grains(i).grain_type+'.DAT'
            Q_file=dir_in_qabs+'Q'+strtrim(i_axis,2)+'_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
162
163
            st=dustem_read_qabs_lv(Q_file,silent=silent)
            st_qpol(i_axis-1,i)=ptr_new(st)
6730c3f8   Jean-Philippe Bernard   modified to be co...
164
165
          ENDFOR
        ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
166
         
6730c3f8   Jean-Philippe Bernard   modified to be co...
167
168
      	IF (st_align.anisG0 > 0) THEN BEGIN
          FOR i_axis = 1, 2 DO BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
169
170
               ;Q_file=dir_in_qabs+'QH'+strtrim(i_axis,2)+'_'+st_grains.grains(i).grain_type+'.DAT'
               Q_file=dir_in_qabs+'QH'+strtrim(i_axis,2)+'_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
171
172
               st=dustem_read_qabs_lv(Q_file,silent=silent)
               st_qH(i_axis-1,i)=ptr_new(st)
6730c3f8   Jean-Philippe Bernard   modified to be co...
173
174
          ENDFOR
	      ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
175

6730c3f8   Jean-Philippe Bernard   modified to be co...
176
      	IF stregex(st_align.keywords, 'circ', /bool) THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
177
178
            ;Q_file=dir_in_qabs+'Qc_'+st_grains.grains(i).grain_type+'.DAT'
            Q_file=dir_in_qabs+'Qc_'+st_grains(i).grain_type+'.DAT'
427f1205   Jean-Michel Glorian   version 4.2 merged
179
180
            st=dustem_read_qabs_lv(Q_file,silent=silent)
            st_qcirc(i)=ptr_new(st)
6730c3f8   Jean-Philippe Bernard   modified to be co...
181
	      ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
182
183
184
185
186
      ENDIF ELSE BEGIN
         st_qpol(0:1,i)=ptr_new()
         st_qH(0:1,i)=ptr_new()
         st_qcirc(i)=ptr_new()
      ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
187
   ENDFOR
6730c3f8   Jean-Philippe Bernard   modified to be co...
188
   st_pol={qpol:st_qpol,qH:st_qH,qcirc:st_qcirc}
427f1205   Jean-Michel Glorian   version 4.2 merged
189
190
191
192
193
194
195
196
ENDIF

;DP :ADD DTLS
one_st={file:'',a_dtls:0.,lc:0.,c_delta:0.,vt:0.,Pmu:0.,gamma_e:0.,omega_m:0.,tau_0:0.,V0:0.,Vmin:0.,Vm:0.,ldtresh:0.}
st_tls = replicate(one_st,Ngrains)

if !run_tls then begin
   FOR i=0L,Ngrains-1 DO BEGIN
6730c3f8   Jean-Philippe Bernard   modified to be co...
197
      IF stregex(st_grains(i).type_keywords, 'dtls', /bool) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
198
199
200
201
202
203
204
205
206
         TLS_file='DTLS_'+st_grains.grains(i).grain_type+'.DAT'
         st=dustem_read_tls(dir_in,TLS_file,silent=silent)
         st_tls(i)=st
      ENDIF ELSE BEGIN
         st_tls(i)=one_st
      ENDELSE
   ENDFOR
ENDIF

4750086c   Ilyes Choubani   nouvelle philosph...
207
208
;=== This will become !dustem_params - MAYBE THIS WILL NEED TO BE CHANGED FOR THE G0 TREATMENT

b5ccb706   Jean-Philippe Bernard   improved to fit p...
209
210
211
212
213
214
215
216
217
218
;st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains, $
;    isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,pol:st_pol,tls:st_tls}
;VG Add NH
if !run_pol then begin
  st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains,isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,align:st_align,qpol:st_qpol,qcirc:st_qcirc,qH:st_qH,tls:st_tls}
endif else begin
  st={Ngrains:Ngrains,G0:G0,Keywords:key_str,grains:st_grains,isrf:st_isrf,qabs:st_qabs,calor:st_calor,lambda:st_lambda,size:st_size,mix:st_mix,chrg:st_chrg,gas:st_gas,spin:st_spin,tls:st_tls}
endelse

;stop
68d2f391   Jean-Philippe Bernard   modified to cope ...
219
220

the_end:
427f1205   Jean-Michel Glorian   version 4.2 merged
221
222
223
224

RETURN,st

END