Blame view

src/idl/dustem_read_align.pro 3.25 KB
52a3c8dc   Jean-Philippe Bernard   mise a jour
1
2
3
4
5
FUNCTION dustem_read_align,dir_in,st_grains,help=help,silent=silent

;+
; NAME:
;   dustem_read_align
eafc1f8f   Annie Hughes   updated help info
6
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
7
8
; PURPOSE:
;   reads the ALIGN.DAT file
eafc1f8f   Annie Hughes   updated help info
9
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
10
11
; CATEGORY:
;    DustEMWrap, Distributed, HighLevel, Initialization
eafc1f8f   Annie Hughes   updated help info
12
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
13
14
; CALLING SEQUENCE:
;   dustem_read_align,dir_in,st_grains[,/help]
eafc1f8f   Annie Hughes   updated help info
15
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
16
17
18
; INPUTS:
;    dir_in      : input directory where to read the file from
;    st_grains   : structure describing grain parameters for various grains (usually !dustem.grains)
eafc1f8f   Annie Hughes   updated help info
19
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
20
21
; OPTIONAL INPUT PARAMETERS:
;    None
eafc1f8f   Annie Hughes   updated help info
22
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
23
; OUTPUTS:
eafc1f8f   Annie Hughes   updated help info
24
25
;    st : dustem data structure
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
26
27
; OPTIONAL OUTPUT PARAMETERS:
;    None
eafc1f8f   Annie Hughes   updated help info
28
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
29
30
31
; ACCEPTED KEY-WORDS:
;    silent       : if set, run silent (not used, actually)
;    help         : writes this help
eafc1f8f   Annie Hughes   updated help info
32
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
33
34
; COMMON BLOCKS:
;    None
eafc1f8f   Annie Hughes   updated help info
35
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
36
; SIDE EFFECTS:
eafc1f8f   Annie Hughes   updated help info
37
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
38
39
40
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap idl code must be installed
eafc1f8f   Annie Hughes   updated help info
41
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
42
; PROCEDURES AND SUBROUTINES USED  
eafc1f8f   Annie Hughes   updated help info
43
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
44
; EXAMPLES
eafc1f8f   Annie Hughes   updated help info
45
;
52a3c8dc   Jean-Philippe Bernard   mise a jour
46
47
48
49
50
51
52
; 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'
eafc1f8f   Annie Hughes   updated help info
53
  full_st=0.
52a3c8dc   Jean-Philippe Bernard   mise a jour
54
55
  goto,the_end
ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
56
57
58
59
60
61
62
63
64
65
66

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

427f1205   Jean-Michel Glorian   version 4.2 merged
68
69
70
71
72
73
74
75
76
77
78
;== 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
79
IF stregex(key_str, 'univ', /bool) THEN !run_univ = 1
427f1205   Jean-Michel Glorian   version 4.2 merged
80
81
82
83
84
85
86
87
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
88
nalig=nlines-ncurrent  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
89
90
;stop

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

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

b5ccb706   Jean-Philippe Bernard   improved to fit p...
97
FOR i=0L,Ngrains-1 DO BEGIN
d012e324   Ilyes Choubani   FIX to the use of...
98
  IF is_aligned[i] THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
99
100
101
102
103
    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
104
    st(i).law=strv[ii] & ii=ii+1
b5ccb706   Jean-Philippe Bernard   improved to fit p...
105
106
107
108
109
110
111
112
113

    ; 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
114
    IF stregex(st[i].law, 'rat', /bool) THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
115
116
117
    ENDIF

    ; PARAMETRIC
52a3c8dc   Jean-Philippe Bernard   mise a jour
118
    IF stregex(st[i].law, 'par', /bool) THEN BEGIN
b5ccb706   Jean-Philippe Bernard   improved to fit p...
119
      ; Grain radius Threshold for alignment, given in microns and converted in cm
52a3c8dc   Jean-Philippe Bernard   mise a jour
120
121
122
      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...
123
    ENDIF
759a527d   Ilyes Choubani   general update
124
    
52a3c8dc   Jean-Philippe Bernard   mise a jour
125
    st[i].aligned = stregex(st_grains[i].type_keywords, 'pol', /bool)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
126
127
    IF !run_univ eq 1 THEN BEGIN
      st = replicate(st(i),Ngrains)
52a3c8dc   Jean-Philippe Bernard   mise a jour
128
      st[i].aligned = stregex(st_grains[i].type_keywords, 'pol', /bool)
d012e324   Ilyes Choubani   FIX to the use of...
129
130
      ind=where(is_aligned eq 0)
      st(ind)=one_st
d012e324   Ilyes Choubani   FIX to the use of...
131
      break  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
132
    ENDIF
759a527d   Ilyes Choubani   general update
133
    
b5ccb706   Jean-Philippe Bernard   improved to fit p...
134
135
136
  ENDIF
ENDFOR

427f1205   Jean-Michel Glorian   version 4.2 merged
137
138
139
140
close,unit
free_lun,unit

full_st={keywords:key_str,anisG0:anisG0,gamma:0,grains:st}
52a3c8dc   Jean-Philippe Bernard   mise a jour
141
142
143
144


the_end:

427f1205   Jean-Michel Glorian   version 4.2 merged
145
146
RETURN,full_st

759a527d   Ilyes Choubani   general update
147
148


427f1205   Jean-Michel Glorian   version 4.2 merged
149
END