Blame view

src/idl/dustem_read_align.pro 3.89 KB
427f1205   Jean-Michel Glorian   version 4.2 merged
1
2
FUNCTION dustem_read_align,dir_in,st_grains,silent=silent

66aff855   Jean-Philippe Bernard   modified to impro...
3
4
5
6
7
8
;moved to dustem_init.pro
;defsysv, '!run_circ', 0.  
;defsysv, '!run_anis', 0.  
;defsysv, '!run_rrf', 0.    
;defsysv, '!run_univ', 0.    
;defsysv, '!run_lin', 0.    
427f1205   Jean-Michel Glorian   version 4.2 merged
9
10
11
12
13
14
15
16
17
18
19

file=dir_in+(*!dustem_inputs).align
openr,unit,file,/get_lun
Nlines=0L
str=''
WHILE not eof(unit) DO BEGIN
      readf,unit,str
      Nlines=Nlines+1
ENDWHILE
close,unit
free_lun,unit
b5ccb706   Jean-Philippe Bernard   improved to fit p...
20

427f1205   Jean-Michel Glorian   version 4.2 merged
21
22
23
24
25
26
27
28
29
30
31
;== now read the file
openr,unit,file,/get_lun
ncurrent=0L
REPEAT BEGIN
      readf,unit,str
      ncurrent=ncurrent+1
      first_char=strmid(str,0,1)
ENDREP UNTIL first_char NE '#'
key_str=str

IF stregex(key_str, 'lin', /bool) THEN !run_lin = 1
e69bf245   Jean-Philippe Bernard   improved
32
33
IF stregex(key_str, 'univ', /bool) THEN BEGIN
  !run_univ = 1
8357b327   Jean-Philippe Bernard   removed a stop
34
  ;stop
e69bf245   Jean-Philippe Bernard   improved
35
ENDIF
759a527d   Ilyes Choubani   general update
36

427f1205   Jean-Michel Glorian   version 4.2 merged
37
38
39
40
41
42
43
44
IF stregex(key_str, 'circ', /bool) THEN !run_circ = 1
IF stregex(key_str, 'anis', /bool) THEN !run_anis = 1
IF stregex(key_str, 'rrf', /bool) THEN !run_rrf = 1

readf,unit,str,format='(A100)'
xx=strsplit(str,' ',/regex,/extr)
anisG0 = float(xx(0))
ncurrent+=+1
759a527d   Ilyes Choubani   general update
45
nalig=nlines-ncurrent  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
46
47
;stop

427f1205   Jean-Michel Glorian   version 4.2 merged
48
one_st={aligned:0.,law:'',athresh:0.,plev:0.,pstiff:0.,TdsTg:0.,a0:0.,rvcut:0.}
b5ccb706   Jean-Philippe Bernard   improved to fit p...
49
50
;Ngrains=st_grains.Ngrains
Ngrains=n_elements(st_grains)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
51
st=replicate(one_st,Ngrains)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
52
;st.aligned = stregex(st_grains.grains.type_keywords, 'pol', /bool) 
36e8b879   Jean-Michel Glorian   update from deborah
53
;count=0
b5ccb706   Jean-Philippe Bernard   improved to fit p...
54

d012e324   Ilyes Choubani   FIX to the use of...
55
is_aligned=stregex(st_grains.type_keywords, 'pol', /bool)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
56
FOR i=0L,Ngrains-1 DO BEGIN
d012e324   Ilyes Choubani   FIX to the use of...
57
  ;stop 
b5ccb706   Jean-Philippe Bernard   improved to fit p...
58
  ;stop
b5ccb706   Jean-Philippe Bernard   improved to fit p...
59
  ;IF st(i).aligned then begin
d012e324   Ilyes Choubani   FIX to the use of...
60
  IF is_aligned[i] THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    ;stop
    readf,unit,str,format='(A100)'
    strv=str_sep(strcompress(strtrim(str,2)),' ')
    Nstrv=n_elements(strv)
  
    ii=0L
    st(i).law=strv(ii) & ii=ii+1

    ; IDG
    IF stregex(st(i).law, 'idg', /bool) THEN BEGIN
      st[i].TdsTg = strv[ii] & ii=ii+1
      st[i].a0    = strv[ii] & ii=ii+1
      st[i].rvcut = strv[ii] & ii=ii+1
    ENDIF

    ; RAT
    IF stregex(st(i).law, 'rat', /bool) THEN BEGIN
    ENDIF

    ; PARAMETRIC
    IF stregex(st(i).law, 'par', /bool) THEN BEGIN
      ; Grain radius Threshold for alignment, given in microns and converted in cm
      st[i].athresh = strv(ii) & ii=ii+1
      st[i].pstiff  = strv(ii) & ii=ii+1
      st[i].plev    = strv(ii) & ii=ii+1
    ENDIF
759a527d   Ilyes Choubani   general update
87
    
d012e324   Ilyes Choubani   FIX to the use of...
88
    st[i].aligned = stregex(st_grains(i).type_keywords, 'pol', /bool)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
89
90
91
    IF !run_univ eq 1 THEN BEGIN
      st = replicate(st(i),Ngrains)
      ;st.aligned = stregex(st_grains.grains.type_keywords, 'pol', /bool) 
d06cb418   Ilyes Choubani   Added PILOT filter
92
      st(i).aligned = stregex(st_grains(i).type_keywords, 'pol', /bool)
d012e324   Ilyes Choubani   FIX to the use of...
93
94
95
96
      ind=where(is_aligned eq 0)
      st(ind)=one_st
      ;stop
      break  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
97
    ENDIF
759a527d   Ilyes Choubani   general update
98
    
b5ccb706   Jean-Philippe Bernard   improved to fit p...
99
100
101
102
103
104
105
106
  ENDIF
ENDFOR

; FOR i=0L,st_grains.Ngrains-1 DO BEGIN
;    IF st(i).aligned then begin
;         ; if count EQ 0. then begin   
;          readf,unit,str,format='(A100)'   
;       ;endif 
36e8b879   Jean-Michel Glorian   update from deborah
107
     
b5ccb706   Jean-Philippe Bernard   improved to fit p...
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
;       	strv=str_sep(strcompress(strtrim(str,2)),' ')
;       	Nstrv=n_elements(strv)

; 	ii=0L
;       	st(i).law=strv(ii) & ii=ii+1 

; 	; IDG
;         IF stregex(st(i).law, 'idg', /bool) THEN begin
;            ii=ii+1 
;       		st(i).TdsTg = strv(ii) & ii=ii+1
;       		st(i).a0    = strv(ii) & ii=ii+1
;       		st(i).rvcut = strv(ii) & ii=ii+1
; 	endif

; 	; RAT
;       	IF stregex(st(i).law, 'rat', /bool) THEN begin
; 	endif

; 	; PARAMETRIC
;         IF stregex(st(i).law, 'par', /bool) THEN begin
;                                 ; Grain radius Threshold for
;                                 ; alignment, given in microns and
;                                 ; converted in cm
;       		st(i).athresh = strv(ii) & ii=ii+1
;       		st(i).pstiff  = strv(ii) & ii=ii+1
;                 st(i).plev    = strv(ii) & ii=ii+1
;                 ; count=1
; 	endif

;         IF !run_univ eq 1 then begin
; 		st = replicate(st(i),st_grains.Ngrains)
;                 st.aligned = stregex(st_grains.grains.type_keywords, 'pol', /bool)
;                 ;stop
; 		break
; 	endif
36e8b879   Jean-Michel Glorian   update from deborah
143
144
145
       
    
       
b5ccb706   Jean-Philippe Bernard   improved to fit p...
146
;       ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
147

b5ccb706   Jean-Philippe Bernard   improved to fit p...
148
; ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
149
150
151
152
153

close,unit
free_lun,unit

full_st={keywords:key_str,anisG0:anisG0,gamma:0,grains:st}
427f1205   Jean-Michel Glorian   version 4.2 merged
154
155
RETURN,full_st

759a527d   Ilyes Choubani   general update
156
157


427f1205   Jean-Michel Glorian   version 4.2 merged
158
END