Blame view

src/idl/dustem_read_dustem_lv.pro 2.67 KB
632162b9   Jean-Philippe Bernard   commented and add...
1
2
3
4
5
FUNCTION dustem_read_dustem_lv,file,silent=silent,help=help

;+
; NAME:
;    dustem_read_dustem_lv
a5d1ca4f   Annie Hughes   updated doc help
6
;
632162b9   Jean-Philippe Bernard   commented and add...
7
8
; PURPOSE:
;    Reads all Dustem SED output
a5d1ca4f   Annie Hughes   updated doc help
9
;
632162b9   Jean-Philippe Bernard   commented and add...
10
; CATEGORY:
a5d1ca4f   Annie Hughes   updated doc help
11
12
;    DustEMWrap, Distributed, High-Level, User-Convenience
;
632162b9   Jean-Philippe Bernard   commented and add...
13
14
; CALLING SEQUENCE:
;    st=dustem_read_dustem_lv,file,[/silent],[/help])
a5d1ca4f   Annie Hughes   updated doc help
15
;
632162b9   Jean-Philippe Bernard   commented and add...
16
17
; INPUTS:
;    file: file to be read
a5d1ca4f   Annie Hughes   updated doc help
18
;
632162b9   Jean-Philippe Bernard   commented and add...
19
20
; OPTIONAL INPUT PARAMETERS:
;    None
a5d1ca4f   Annie Hughes   updated doc help
21
;
632162b9   Jean-Philippe Bernard   commented and add...
22
23
24
25
26
27
28
29
30
31
32
33
; OUTPUTS:
;    st: Dustem output structure
;      structure:
;      IDL> help,st,/str
;      ** Structure <1733e38>, 7 tags, length=28, data length=28, refs=2:
;      WAV             FLOAT         0.0400000
;      EM_GRAIN_1      FLOAT           0.00000
;      EM_GRAIN_2      FLOAT           0.00000
;      EM_GRAIN_3      FLOAT           0.00000
;      EM_GRAIN_4      FLOAT           0.00000
;      EM_GRAIN_5      FLOAT           0.00000
;      EM_TOT          FLOAT           0.00000
a5d1ca4f   Annie Hughes   updated doc help
34
;
632162b9   Jean-Philippe Bernard   commented and add...
35
36
; OPTIONAL OUTPUT PARAMETERS:
;    None
a5d1ca4f   Annie Hughes   updated doc help
37
;
632162b9   Jean-Philippe Bernard   commented and add...
38
39
40
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
;    silent    = If set, function is silent
a5d1ca4f   Annie Hughes   updated doc help
41
;
632162b9   Jean-Philippe Bernard   commented and add...
42
43
; COMMON BLOCKS:
;    None
a5d1ca4f   Annie Hughes   updated doc help
44
;
632162b9   Jean-Philippe Bernard   commented and add...
45
46
; SIDE EFFECTS:
;    None
a5d1ca4f   Annie Hughes   updated doc help
47
;
632162b9   Jean-Philippe Bernard   commented and add...
48
; RESTRICTIONS:
6e97b9fe   Annie Hughes   forced reading du...
49
;    The DustEMWrap IDL code must be installed
a5d1ca4f   Annie Hughes   updated doc help
50
;
632162b9   Jean-Philippe Bernard   commented and add...
51
52
; PROCEDURE:
;    None
a5d1ca4f   Annie Hughes   updated doc help
53
;
632162b9   Jean-Philippe Bernard   commented and add...
54
55
56
57
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard
a5d1ca4f   Annie Hughes   updated doc help
58
59
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
632162b9   Jean-Philippe Bernard   commented and add...
60
61
;-

a5d1ca4f   Annie Hughes   updated doc help
62

632162b9   Jean-Philippe Bernard   commented and add...
63
64
65
66
67
68
IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_read_dustem_lv'
  st=0.
  goto,the_end
ENDIF

5eebdedb   Jean-Philippe Bernard   changed plugin st...
69
message,'Reading file '+file,/info
427f1205   Jean-Michel Glorian   version 4.2 merged
70
71
72
73
74
75
76
77
78
79
80
81
;=== determine the number of grains
str='                               '
OPENR,unit,file,/get_lun
;==read comments
str='' & first_char='#'
WHILE first_char EQ '#' DO BEGIN
  readf,unit,str
  first_char=strmid(str,0,1)
ENDWHILE
;readf,unit,str
CLOSE,unit
free_lun,unit
a84e0595   Jean-Philippe Bernard   modified plugin s...
82

427f1205   Jean-Michel Glorian   version 4.2 merged
83
84
85
str=strcompress(str)
str=strtrim(str,2)
vv=str_sep(str,' ')
632162b9   Jean-Philippe Bernard   commented and add...
86
Ngrains=vv[0]
427f1205   Jean-Michel Glorian   version 4.2 merged
87
88
89
90
;Ngrains=!dustem_params.Ngrains

;Read model output
instruc='readcol,file,wav,'
6e97b9fe   Annie Hughes   forced reading du...
91
92
fstr=strarr(Ngrains) & fstr[*]='D,'
format_str='D,'+strjoin(fstr)+'D'
427f1205   Jean-Michel Glorian   version 4.2 merged
93
94
95
FOR i=0L,Ngrains-1 DO BEGIN
  instruc=instruc+'em_grain_'+strtrim(i+1,2)+','
ENDFOR
6e97b9fe   Annie Hughes   forced reading du...
96
instruc=instruc+"em_tot,silent=silent,format='"+format_str+"'"
5eebdedb   Jean-Philippe Bernard   changed plugin st...
97
message,'Executing '+instruc,/info
427f1205   Jean-Michel Glorian   version 4.2 merged
98
99
toto=execute(instruc)

427f1205   Jean-Michel Glorian   version 4.2 merged
100
101
102
103
Nlines=n_elements(wav)

instruc='one_st={wav:0.,'
FOR i=0L,Ngrains-1 DO BEGIN
a84e0595   Jean-Philippe Bernard   modified plugin s...
104
  instruc=instruc+'em_grain_'+strtrim(i+1,2)+':0.D0,'
427f1205   Jean-Michel Glorian   version 4.2 merged
105
ENDFOR
a84e0595   Jean-Philippe Bernard   modified plugin s...
106
instruc=instruc+'em_tot:0.D0}'
5eebdedb   Jean-Philippe Bernard   changed plugin st...
107
message,'Executing '+instruc,/info
427f1205   Jean-Michel Glorian   version 4.2 merged
108
toto=execute(instruc)
427f1205   Jean-Michel Glorian   version 4.2 merged
109
110
st=replicate(one_st,Nlines)

427f1205   Jean-Michel Glorian   version 4.2 merged
111
112
st.wav=wav
FOR i=0L,Ngrains-1 DO BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
113
  instruc='st.(i+1)='+'em_grain_'+strtrim(i+1,2)
5eebdedb   Jean-Philippe Bernard   changed plugin st...
114
  message,'Executing '+instruc,/info
427f1205   Jean-Michel Glorian   version 4.2 merged
115
  toto=execute(instruc)
a84e0595   Jean-Philippe Bernard   modified plugin s...
116
  ;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
117
ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
118
119
st.em_tot=em_tot

632162b9   Jean-Philippe Bernard   commented and add...
120
IF !dustem_redshift NE 0. THEN BEGIN
ef5ea826   Annie Hughes   removed comment
121
   st.wav=st.wav*(1+!dustem_redshift)
632162b9   Jean-Philippe Bernard   commented and add...
122
123
ENDIF

8aa65102   Jean-Philippe Bernard   commented and add...
124
125
;stop

632162b9   Jean-Philippe Bernard   commented and add...
126
127
128
the_end:

RETURN,st
427f1205   Jean-Michel Glorian   version 4.2 merged
129
130

END