Blame view

src/idl/dustem_read_align.pro 3.23 KB
52a3c8dc   Jean-Philippe Bernard   mise a jour
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
FUNCTION dustem_read_align,dir_in,st_grains,help=help,silent=silent

;+
; NAME:
;   dustem_read_align
; PURPOSE:
;   reads the ALIGN.DAT file
; CATEGORY:
;    DustEMWrap, Distributed, HighLevel, Initialization
; CALLING SEQUENCE:
;   dustem_read_align,dir_in,st_grains[,/help]
; INPUTS:
;    dir_in      : input directory where to read the file from
;    st_grains   : structure describing grain parameters for various grains (usually !dustem.grains)
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    silent       : if set, run silent (not used, actually)
;    help         : writes this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    a File is written
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap idl code must be installed
; PROCEDURES AND SUBROUTINES USED  
; EXAMPLES
; MODIFICATION HISTORY:
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_read_align'
  full_st=-1
  goto,the_end
ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
43
44
45
46
47
48
49
50
51
52
53

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...
54

427f1205   Jean-Michel Glorian   version 4.2 merged
55
56
57
58
59
60
61
62
63
64
65
;== 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
52a3c8dc   Jean-Philippe Bernard   mise a jour
66
IF stregex(key_str, 'univ', /bool) THEN !run_univ = 1
427f1205   Jean-Michel Glorian   version 4.2 merged
67
68
69
70
71
72
73
74
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
75
nalig=nlines-ncurrent  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
76
77
;stop

427f1205   Jean-Michel Glorian   version 4.2 merged
78
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...
79
Ngrains=n_elements(st_grains)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
80
st=replicate(one_st,Ngrains)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
81

d012e324   Ilyes Choubani   FIX to the use of...
82
is_aligned=stregex(st_grains.type_keywords, 'pol', /bool)
52a3c8dc   Jean-Philippe Bernard   mise a jour
83

b5ccb706   Jean-Philippe Bernard   improved to fit p...
84
FOR i=0L,Ngrains-1 DO BEGIN
d012e324   Ilyes Choubani   FIX to the use of...
85
  IF is_aligned[i] THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
86
87
88
89
90
    readf,unit,str,format='(A100)'
    strv=str_sep(strcompress(strtrim(str,2)),' ')
    Nstrv=n_elements(strv)
  
    ii=0L
52a3c8dc   Jean-Philippe Bernard   mise a jour
91
    st(i).law=strv[ii] & ii=ii+1
b5ccb706   Jean-Philippe Bernard   improved to fit p...
92
93
94
95
96
97
98
99
100

    ; 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
52a3c8dc   Jean-Philippe Bernard   mise a jour
101
    IF stregex(st[i].law, 'rat', /bool) THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
102
103
104
    ENDIF

    ; PARAMETRIC
52a3c8dc   Jean-Philippe Bernard   mise a jour
105
    IF stregex(st[i].law, 'par', /bool) THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
106
      ; Grain radius Threshold for alignment, given in microns and converted in cm
52a3c8dc   Jean-Philippe Bernard   mise a jour
107
108
109
      st[i].athresh = strv[ii] & ii=ii+1
      st[i].pstiff  = strv[ii] & ii=ii+1
      st[i].plev    = strv[ii] & ii=ii+1
b5ccb706   Jean-Philippe Bernard   improved to fit p...
110
    ENDIF
759a527d   Ilyes Choubani   general update
111
    
52a3c8dc   Jean-Philippe Bernard   mise a jour
112
    st[i].aligned = stregex(st_grains[i].type_keywords, 'pol', /bool)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
113
114
    IF !run_univ eq 1 THEN BEGIN
      st = replicate(st(i),Ngrains)
52a3c8dc   Jean-Philippe Bernard   mise a jour
115
      st[i].aligned = stregex(st_grains[i].type_keywords, 'pol', /bool)
d012e324   Ilyes Choubani   FIX to the use of...
116
117
      ind=where(is_aligned eq 0)
      st(ind)=one_st
d012e324   Ilyes Choubani   FIX to the use of...
118
      break  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
119
    ENDIF
759a527d   Ilyes Choubani   general update
120
    
b5ccb706   Jean-Philippe Bernard   improved to fit p...
121
122
123
  ENDIF
ENDFOR

427f1205   Jean-Michel Glorian   version 4.2 merged
124
125
126
127
close,unit
free_lun,unit

full_st={keywords:key_str,anisG0:anisG0,gamma:0,grains:st}
52a3c8dc   Jean-Philippe Bernard   mise a jour
128
129
130
131


the_end:

427f1205   Jean-Michel Glorian   version 4.2 merged
132
133
RETURN,full_st

759a527d   Ilyes Choubani   general update
134
135


427f1205   Jean-Michel Glorian   version 4.2 merged
136
END