Blame view

src/idl/dustem_read_align.pro 2.45 KB
427f1205   Jean-Michel Glorian   version 4.2 merged
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
FUNCTION dustem_read_align,dir_in,st_grains,silent=silent

defsysv, '!run_circ', 0.  
defsysv, '!run_anis', 0.  
defsysv, '!run_rrf', 0.    
defsysv, '!run_univ', 0.    
defsysv, '!run_lin', 0.    

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
;== 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
IF stregex(key_str, 'univ', /bool) THEN !run_univ = 1
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
nalig=nlines-ncurrent

one_st={aligned:0.,law:'',athresh:0.,plev:0.,pstiff:0.,TdsTg:0.,a0:0.,rvcut:0.}
st=replicate(one_st,st_grains.Ngrains)

st.aligned = stregex(st_grains.grains.type_keywords, 'pol', /bool) 
36e8b879   Jean-Michel Glorian   update from deborah
45
;count=0
427f1205   Jean-Michel Glorian   version 4.2 merged
46
FOR i=0L,st_grains.Ngrains-1 DO BEGIN
36e8b879   Jean-Michel Glorian   update from deborah
47
48
49
50
51
   IF st(i).aligned then begin
        ; if count EQ 0. then begin   
         readf,unit,str,format='(A100)'   
      ;endif 
     
427f1205   Jean-Michel Glorian   version 4.2 merged
52
53
      	strv=str_sep(strcompress(strtrim(str,2)),' ')
      	Nstrv=n_elements(strv)
36e8b879   Jean-Michel Glorian   update from deborah
54

427f1205   Jean-Michel Glorian   version 4.2 merged
55
	ii=0L
36e8b879   Jean-Michel Glorian   update from deborah
56
      	st(i).law=strv(ii) & ii=ii+1 
427f1205   Jean-Michel Glorian   version 4.2 merged
57
58

	; IDG
36e8b879   Jean-Michel Glorian   update from deborah
59
60
        IF stregex(st(i).law, 'idg', /bool) THEN begin
           ii=ii+1 
427f1205   Jean-Michel Glorian   version 4.2 merged
61
62
63
64
65
66
67
68
69
70
      		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
36e8b879   Jean-Michel Glorian   update from deborah
71
72
73
74
        IF stregex(st(i).law, 'par', /bool) THEN begin
                                ; Grain radius Threshold for
                                ; alignment, given in microns and
                                ; converted in cm
427f1205   Jean-Michel Glorian   version 4.2 merged
75
76
      		st(i).athresh = strv(ii) & ii=ii+1
      		st(i).pstiff  = strv(ii) & ii=ii+1
36e8b879   Jean-Michel Glorian   update from deborah
77
78
                st(i).plev    = strv(ii) & ii=ii+1
                ; count=1
427f1205   Jean-Michel Glorian   version 4.2 merged
79
80
81
82
	endif

        IF !run_univ eq 1 then begin
		st = replicate(st(i),st_grains.Ngrains)
36e8b879   Jean-Michel Glorian   update from deborah
83
84
                st.aligned = stregex(st_grains.grains.type_keywords, 'pol', /bool)
                ;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
85
86
		break
	endif
36e8b879   Jean-Michel Glorian   update from deborah
87
88
89
       
    
       
427f1205   Jean-Michel Glorian   version 4.2 merged
90
91
92
93
94
95
96
97
      ENDIF

ENDFOR

close,unit
free_lun,unit

full_st={keywords:key_str,anisG0:anisG0,gamma:0,grains:st}
36e8b879   Jean-Michel Glorian   update from deborah
98

427f1205   Jean-Michel Glorian   version 4.2 merged
99
100
101
RETURN,full_st

END