Blame view

src/idl/dustem_compute_sed.pro 3.63 KB
283845da   Ilyes Choubani   Small corrections...
1
FUNCTION dustem_compute_sed,p_dim,$
cee5beec   Jean-Philippe Bernard   just changed form...
2
                            st=st,$
0b156835   Annie Hughes   improved inline d...
3
                            sed_spec=sed_spec, $
88f84272   Jean-Philippe Bernard   changed
4
                            use_previous_fortran=use_previous_fortran, $
cee5beec   Jean-Philippe Bernard   just changed form...
5
                            help=help
427f1205   Jean-Michel Glorian   version 4.2 merged
6

427f1205   Jean-Michel Glorian   version 4.2 merged
7
8
9
;+
; NAME:
;    dustem_compute_sed
f09e876c   Annie Hughes   updated doc help
10
;
427f1205   Jean-Michel Glorian   version 4.2 merged
11
; PURPOSE:
07a51917   Ilyes Choubani   updating help sec...
12
;    Computes a SED for a given Dustem model
f09e876c   Annie Hughes   updated doc help
13
;
427f1205   Jean-Michel Glorian   version 4.2 merged
14
15
; CATEGORY:
;    Dustem
f09e876c   Annie Hughes   updated doc help
16
;
427f1205   Jean-Michel Glorian   version 4.2 merged
17
; CALLING SEQUENCE:
24ae49f0   Jean-Philippe Bernard   fixed for new def...
18
;    sed=dustem_compute_sed(p_dim[,st][,sed_spec][,/help])
f09e876c   Annie Hughes   updated doc help
19
;
427f1205   Jean-Michel Glorian   version 4.2 merged
20
; INPUTS:
07a51917   Ilyes Choubani   updating help sec...
21
;    p_dim      = parameter values
f09e876c   Annie Hughes   updated doc help
22
;
427f1205   Jean-Michel Glorian   version 4.2 merged
23
; OPTIONAL INPUT PARAMETERS:
88f84272   Jean-Philippe Bernard   changed
24
;    st        = Dustem Fortran output structure
f09e876c   Annie Hughes   updated doc help
25
;
427f1205   Jean-Michel Glorian   version 4.2 merged
26
27
; OUTPUTS:
;    sed       = computed SED for filters in !dustem_data
f09e876c   Annie Hughes   updated doc help
28
;
427f1205   Jean-Michel Glorian   version 4.2 merged
29
; OPTIONAL OUTPUT PARAMETERS:
24ae49f0   Jean-Philippe Bernard   fixed for new def...
30
;    st      = dustem output structure
07a51917   Ilyes Choubani   updating help sec...
31
;    sed_spec    = dustem emission spectrum
f09e876c   Annie Hughes   updated doc help
32
;
427f1205   Jean-Michel Glorian   version 4.2 merged
33
; ACCEPTED KEY-WORDS:
88f84272   Jean-Philippe Bernard   changed
34
;    use_previous_fortran = if set, uses the output of the previous fortran run, and does not run the fortran.
427f1205   Jean-Michel Glorian   version 4.2 merged
35
;    help      = If set, print this help
f09e876c   Annie Hughes   updated doc help
36
;
427f1205   Jean-Michel Glorian   version 4.2 merged
37
38
; COMMON BLOCKS:
;    None
f09e876c   Annie Hughes   updated doc help
39
;
427f1205   Jean-Michel Glorian   version 4.2 merged
40
41
; SIDE EFFECTS:
;    None
f09e876c   Annie Hughes   updated doc help
42
;
427f1205   Jean-Michel Glorian   version 4.2 merged
43
; RESTRICTIONS:
f09e876c   Annie Hughes   updated doc help
44
45
;    The DustEMWrap IDL code must be installed
;
427f1205   Jean-Michel Glorian   version 4.2 merged
46
47
; PROCEDURE:
;    None
f09e876c   Annie Hughes   updated doc help
48
;
427f1205   Jean-Michel Glorian   version 4.2 merged
49
50
51
; EXAMPLES
;    
; MODIFICATION HISTORY:
f09e876c   Annie Hughes   updated doc help
52
;    Written by J.-Ph. Bernard 2008
84fd3e7e   Annie Hughes   comments
53
54
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
427f1205   Jean-Michel Glorian   version 4.2 merged
55
56
57
58
59
60
61
62
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_compute_sed'
  dustem_sed=0.
  goto,the_end
ENDIF

427f1205   Jean-Michel Glorian   version 4.2 merged
63
IF not keyword_set(st) THEN BEGIN
88f84272   Jean-Philippe Bernard   changed
64
   dustem_activate_plugins,p_dim/(*(*!dustem_fit).param_init_values),st=st,use_previous_fortran=use_previous_fortran
427f1205   Jean-Michel Glorian   version 4.2 merged
65
66
ENDIF

427f1205   Jean-Michel Glorian   version 4.2 merged
67
; Convert into MJy/sr/1d20
759a527d   Ilyes Choubani   general update
68
fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7 ;this is correct despite the way it is presented (1.e4/1e.7*1e.20=1.e17 which is the factor to convert from ergs to Mega Janskys)
5f04fa07   Ilyes Choubani   general update
69
SED_spec = st.sed.em_tot * fact
452c334e   Ilyes Choubani   Implementation Of...
70

3a5c5df8   Jean-Philippe Bernard   small change
71
;===== Adding plugin output to spectrum ----------------
88f84272   Jean-Philippe Bernard   changed
72
73
Nplugins=n_elements(*!dustem_plugin)
scopes=(*!dustem_plugin).scope
553fad92   Annie Hughes   updated doc help
74

3a5c5df8   Jean-Philippe Bernard   small change
75
;stop
79991f38   Jean-Philippe Bernard   fixed for whan sc...
76
IF scopes[0] NE 'NONE' THEN BEGIN
88f84272   Jean-Philippe Bernard   changed
77
78
79
80
81
  FOR i=0L,Nplugins-1 DO BEGIN
    IF total(strsplit((*!dustem_plugin)[i].scope,'+',/extract) eq 'ADD_SED') THEN BEGIN
      SED_spec+=(*(*!dustem_plugin)[i].spec)[*,0]
    ENDIF
  ENDFOR
79991f38   Jean-Philippe Bernard   fixed for whan sc...
82
ENDIF
452c334e   Ilyes Choubani   Implementation Of...
83
84
;------------------------------------------

88f84272   Jean-Philippe Bernard   changed
85
IF not isarray(SED_spec) THEN stop
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
86
    
427f1205   Jean-Michel Glorian   version 4.2 merged
87
;COMPUTE THE MODEL SED
88f84272   Jean-Philippe Bernard   changed
88
;JPB: problem there: we should be able to compute an SED even when there is no data in !dustem_data
0068116a   Ilyes Choubani   General update + ...
89
dustem_sed = (*(*!dustem_data).sed).values * 0.
427f1205   Jean-Michel Glorian   version 4.2 merged
90
91
92
93
94
95
96

IF !dustem_do_cc NE 0 AND !dustem_never_do_cc EQ 0 THEN BEGIN
  message,'DOING color correction calculations',/info
ENDIF ELSE BEGIN
  message,'SKIPPING color correction calculations: we take previous values of cc',/info
ENDELSE

07a51917   Ilyes Choubani   updating help sec...
97
ind_sed=where((*(*!dustem_data).sed).filt_names NE 'SPECTRUM' and (*(*!dustem_data).sed).wav gt 0.,count_sed)
427f1205   Jean-Michel Glorian   version 4.2 merged
98
IF count_sed NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
99
  filter_names=((*(*!dustem_data).sed).filt_names)[ind_sed]
3c479f24   Ilyes Choubani   Allowing to fix p...
100
  ssed=dustem_cc(st.sed.wav,SED_spec,filter_names,cc=cc)  
9ccf7615   Jean-Philippe Bernard   modified to fit u...
101
  dustem_sed[ind_sed]=ssed
427f1205   Jean-Michel Glorian   version 4.2 merged
102
ENDIF ELSE BEGIN
452c334e   Ilyes Choubani   Implementation Of...
103
  print,"**** WARNING **** NO FILTER defined in DATA for COLOUR CORRECTION" 
427f1205   Jean-Michel Glorian   version 4.2 merged
104
105
106
107
108
ENDELSE

;For spectrum data points, interpolate in log-log
;Linear interpolation leads to wrong values, in particular where few
;wavelengths points exist in the model (long wavelengths).
0068116a   Ilyes Choubani   General update + ...
109
ind_spec=where((*(*!dustem_data).sed).filt_names EQ 'SPECTRUM',count_spec)
427f1205   Jean-Michel Glorian   version 4.2 merged
110
IF count_spec NE 0 THEN BEGIN
0068116a   Ilyes Choubani   General update + ...
111
    dustem_sed[ind_spec]=interpol(SED_spec,st.sed.wav,(((*(*!dustem_data).sed).wav)[ind_spec]))
5f04fa07   Ilyes Choubani   general update
112
    ;dustem_sed(ind_spec)=10^interpol(alog10(spec),alog10(st.sed.wav),alog10((((*!dustem_data.sed).wav)(ind_spec))))
427f1205   Jean-Michel Glorian   version 4.2 merged
113
114
115
116
117
118
119
120
121
ENDIF
out_st=st

;clean pointers
heap_gc

the_end:

;VG : error in cc IRAS1 when no PAH 
5f04fa07   Ilyes Choubani   general update
122
123
; j=where(dustem_sed ne dustem_sed,count)
; if count gt 0 then dustem_sed[j]=0.
3ff9cac3   Ilyes Choubani   general update
124
;stop
427f1205   Jean-Michel Glorian   version 4.2 merged
125
126
127
RETURN,dustem_sed

END