Blame view

src/idl/dustem_read_dustem_lv.pro 2.64 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:
a5d1ca4f   Annie Hughes   updated doc help
49
50
;    The DustEMWrap idl code must be installed
;
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
69
IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_read_dustem_lv'
  st=0.
  goto,the_end
ENDIF

message,'Reading file '+file,/continue
427f1205   Jean-Michel Glorian   version 4.2 merged
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;=== 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
str=strcompress(str)
str=strtrim(str,2)
vv=str_sep(str,' ')
632162b9   Jean-Philippe Bernard   commented and add...
85
Ngrains=vv[0]
427f1205   Jean-Michel Glorian   version 4.2 merged
86
87
88
89
90
91
92
93
;Ngrains=!dustem_params.Ngrains

;Read model output
instruc='readcol,file,wav,'
FOR i=0L,Ngrains-1 DO BEGIN
  instruc=instruc+'em_grain_'+strtrim(i+1,2)+','
ENDFOR
instruc=instruc+'em_tot,silent=silent'
632162b9   Jean-Philippe Bernard   commented and add...
94
message,'Executing '+instruc,/continue
427f1205   Jean-Michel Glorian   version 4.2 merged
95
96
toto=execute(instruc)

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

instruc='one_st={wav:0.,'
FOR i=0L,Ngrains-1 DO BEGIN
  instruc=instruc+'em_grain_'+strtrim(i+1,2)+':0.,'
ENDFOR
instruc=instruc+'em_tot:0.}'
632162b9   Jean-Philippe Bernard   commented and add...
104
message,'Executing '+instruc,/continue
427f1205   Jean-Michel Glorian   version 4.2 merged
105
106
107
108
toto=execute(instruc)

st=replicate(one_st,Nlines)

427f1205   Jean-Michel Glorian   version 4.2 merged
109
110
st.wav=wav
FOR i=0L,Ngrains-1 DO BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
111
  instruc='st.(i+1)='+'em_grain_'+strtrim(i+1,2)
632162b9   Jean-Philippe Bernard   commented and add...
112
  message,'Executing '+instruc,/continue
427f1205   Jean-Michel Glorian   version 4.2 merged
113
114
  toto=execute(instruc)
ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
115
116
st.em_tot=em_tot

632162b9   Jean-Philippe Bernard   commented and add...
117
118
;==== Longji, go ahaead there:
IF !dustem_redshift NE 0. THEN BEGIN
1d18279c   Jean-Philippe Bernard   improved
119
120
121
	st.wav=st.wav*(1+!dustem_redshift)
	;help,st,/str
	;help,st.wav
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