Blame view

src/idl/dustem_read_all_release.pro 6.98 KB
d9ec9405   Annie Hughes   updated for release
1
FUNCTION dustem_read_all_release,dir_in,silent=silent,help=help
64128627   Annie Hughes   Copy without subs...
2
3
4
5

;+
; NAME:
;    dustem_read_all_release
eafc1f8f   Annie Hughes   updated help info
6
;
64128627   Annie Hughes   Copy without subs...
7
; PURPOSE:
eafc1f8f   Annie Hughes   updated help info
8
9
;    Reads all Dustem input data
;
64128627   Annie Hughes   Copy without subs...
10
; CATEGORY:
eafc1f8f   Annie Hughes   updated help info
11
12
;    Dustem, Distributed, High-Level, Initialization
;
64128627   Annie Hughes   Copy without subs...
13
14
; CALLING SEQUENCE:
;    st=dustem_read_all_release(dir_in[,/silent])
eafc1f8f   Annie Hughes   updated help info
15
;
64128627   Annie Hughes   Copy without subs...
16
17
; INPUTS:
;    dir_in: input directory
eafc1f8f   Annie Hughes   updated help info
18
;
64128627   Annie Hughes   Copy without subs...
19
20
; OPTIONAL INPUT PARAMETERS:
;    None
eafc1f8f   Annie Hughes   updated help info
21
;
64128627   Annie Hughes   Copy without subs...
22
23
; OUTPUTS:
;    None
eafc1f8f   Annie Hughes   updated help info
24
;
64128627   Annie Hughes   Copy without subs...
25
26
; OPTIONAL OUTPUT PARAMETERS:
;    None
eafc1f8f   Annie Hughes   updated help info
27
;
64128627   Annie Hughes   Copy without subs...
28
29
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
eafc1f8f   Annie Hughes   updated help info
30
31
;    silent    = If set, keep silent
;
64128627   Annie Hughes   Copy without subs...
32
33
; COMMON BLOCKS:
;    None
eafc1f8f   Annie Hughes   updated help info
34
;
64128627   Annie Hughes   Copy without subs...
35
36
; SIDE EFFECTS:
;    None
eafc1f8f   Annie Hughes   updated help info
37
;
64128627   Annie Hughes   Copy without subs...
38
; RESTRICTIONS:
eafc1f8f   Annie Hughes   updated help info
39
40
;    The DustEMWrap IDL code must be installed
;
64128627   Annie Hughes   Copy without subs...
41
42
; PROCEDURE:
;    None
eafc1f8f   Annie Hughes   updated help info
43
;
64128627   Annie Hughes   Copy without subs...
44
45
46
; EXAMPLES
;    
; MODIFICATION HISTORY:
d9ec9405   Annie Hughes   updated for release
47
48
49
;    Written by JP Bernard
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
64128627   Annie Hughes   Copy without subs...
50
51
52
53
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_read_all_release' 
eafc1f8f   Annie Hughes   updated help info
54
  st=0.
64128627   Annie Hughes   Copy without subs...
55
56
57
  goto,the_end
ENDIF

b05b5475   Ilyes Choubani   adding test so th...
58
59
if strmid(!dustem_dat,0,/reverse) ne '/' then !dustem_dat=!dustem_dat+'/' 

64128627   Annie Hughes   Copy without subs...
60
61
62
63
64
65
66
67
dir_in_dat=dir_in+'data/'
dir_in_qabs=dir_in+'oprop/'
dir_in_capa=dir_in+'hcap/'

file=dir_in_dat+(*!dustem_inputs).grain
;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)
64128627   Annie Hughes   Copy without subs...
68
69
70
71

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

64128627   Annie Hughes   Copy without subs...
72
73
74
75
76
77
78
79
80
81
82
83
84
file=dir_in_dat+'GAS.DAT'
st_gas=dustem_read_gas(file,silent=silent)

;=== Read Qabs

st_qabs=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
  read_densities=0
  IF st_grains[i].rho LE 0 THEN read_densities=1
  Qabs_file=dir_in_qabs+'Q_'+st_grains(i).grain_type+'.DAT'
  st=dustem_read_qabs_lv(Qabs_file,silent=silent,read_densities=read_densities)
  st_qabs(i)=ptr_new(st)
ENDFOR
64128627   Annie Hughes   Copy without subs...
85
86
87
88
89
;=== Read heat capacities
st_calor=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
  Calor_file=dir_in_capa+'C_'+st_grains(i).grain_type+'.DAT'
  st=dustem_read_calor_lv(Calor_file,silent=silent)
d9ec9405   Annie Hughes   updated for release
90
  st_calor(i)=ptr_new(st)   
64128627   Annie Hughes   Copy without subs...
91
92
93
94
95
96
ENDFOR

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

64128627   Annie Hughes   Copy without subs...
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;=== Read size distribution files
st_size=ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
  IF stregex(st_grains(i).type_keywords, 'size', /bool) THEN BEGIN
    Size_file=dir_in_dat+'SIZE_'+st_grains(i).grain_type+'.DAT'
    st=dustem_read_size(Size_file,silent=silent)
    st_size(i)=ptr_new(st)
  ENDIF ELSE BEGIN
    st_size(i) = ptr_new()
  ENDELSE
ENDFOR

;stop
;=== Read MIX files
st_mix = ptrarr(Ngrains)
FOR i=0L,Ngrains-1 DO BEGIN
   IF stregex(st_grains(i).type_keywords, 'mix', /bool) THEN BEGIN
      Mix_file=dir_in_dat+'MIX_'+st_grains(i).grain_type+'.DAT'
      st=dustem_read_mix(Mix_file,silent=silent)
      st_mix(i)=ptr_new(st)
   ENDIF ELSE BEGIN
      st_mix(i)=ptr_new()
   ENDELSE
ENDFOR

;=== 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

;stop

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

;=== 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)

IF !run_pol THEN BEGIN
   st_align=dustem_read_align(dir_in_dat,st_grains,silent=silent)
   FOR i=0L,Ngrains-1 DO BEGIN
      i_alig = 0
      ;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
            ;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'
            st=dustem_read_qabs_lv(Q_file,silent=silent)
            st_qpol(i_axis-1,i)=ptr_new(st)
          ENDFOR
        ENDIF
         
      	IF (st_align.anisG0 > 0) THEN BEGIN
          FOR i_axis = 1, 2 DO BEGIN
               ;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'
               st=dustem_read_qabs_lv(Q_file,silent=silent)
               st_qH(i_axis-1,i)=ptr_new(st)
          ENDFOR
	      ENDIF

      	IF stregex(st_align.keywords, 'circ', /bool) THEN BEGIN
            ;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'
            st=dustem_read_qabs_lv(Q_file,silent=silent)
            st_qcirc(i)=ptr_new(st)
	      ENDIF
      ENDIF ELSE BEGIN
         st_qpol(0:1,i)=ptr_new()
         st_qH(0:1,i)=ptr_new()
         st_qcirc(i)=ptr_new()
      ENDELSE
   ENDFOR
   st_pol={qpol:st_qpol,qH:st_qH,qcirc:st_qcirc}
ENDIF

;DP :ADD DTLS
ef1e3d9d   Annie Hughes   corrections for TLS
197
198
199
200
201
202
203
204
205
206
207
; WRONG
;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.}

; !!! %&%&%&%&
; structure must have same order of tags as in dustem_read_all_release.pro
; !!! %&%&%&%&
one_st={file:'',vt:0.,lc:0.,a_dtls:0. $
         ,Pmu:0.,gamma_e:0., omega_m:0. $
         ,c_delta:0.,tau_0:0. $
         ,V0:0.,Vmin:0.,Vm:0.,ldtresh:0.}

64128627   Annie Hughes   Copy without subs...
208
209
210
211
st_tls = replicate(one_st,Ngrains)

if !run_tls then begin
   FOR i=0L,Ngrains-1 DO BEGIN
ef1e3d9d   Annie Hughes   corrections for TLS
212
213
214
215
216
      IF stregex(st_grains[i].type_keywords, 'dtls', /bool) THEN BEGIN
;         TLS_file='DTLS_'+st_grains.grains(i).grain_type+'.DAT'
         TLS_file='DTLS_'+st_grains[i].grain_type+'.DAT'
;         st=dustem_read_tls(dir_in,TLS_file,silent=silent)
         st_tls[i]=dustem_read_tls(dir_in,TLS_file,silent=silent)
64128627   Annie Hughes   Copy without subs...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
      ENDIF ELSE BEGIN
         st_tls(i)=one_st
      ENDELSE
   ENDFOR
ENDIF

;=== This will become !dustem_params - MAYBE THIS WILL NEED TO BE CHANGED FOR THE G0 TREATMENT

;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

64128627   Annie Hughes   Copy without subs...
234
235
236
237
238
the_end:

RETURN,st

END