Blame view

src/idl/dustem_plot_ext.pro 6.95 KB
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
1
2
3
4
PRO dustem_plot_ext,st,ps=ps,UV=UV,win=win,print_Rv=print_Rv,mergePAH=mergePAH, $
	                ylog=ylog,xlog=xlog,yr=yr,ysty=ysty,xr=xr,xsty=xsty, $
	                donotclose=donotclose,noerrbars=noerrbars,albedo=albedo,multi=multi, $
	                _extra=_extra,help=help
427f1205   Jean-Michel Glorian   version 4.2 merged
5
6
7
8

;+
; NAME:
;     dustem_plot_ext
5deeb77c   Annie Hughes   updated help
9
;
427f1205   Jean-Michel Glorian   version 4.2 merged
10
; PURPOSE:
5deeb77c   Annie Hughes   updated help
11
12
;    Plots a Dustem extinction curve
;
427f1205   Jean-Michel Glorian   version 4.2 merged
13
; CATEGORY:
5deeb77c   Annie Hughes   updated help
14
15
;    Dustem, Plotting, Low-level
;  
427f1205   Jean-Michel Glorian   version 4.2 merged
16
; CALLING SEQUENCE:
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
17
;    dustem_plot_ext,st[,/help]
5deeb77c   Annie Hughes   updated help
18
;
427f1205   Jean-Michel Glorian   version 4.2 merged
19
20
; INPUTS:
;    st        = Dustem model output structure
5deeb77c   Annie Hughes   updated help
21
;
427f1205   Jean-Michel Glorian   version 4.2 merged
22
; OPTIONAL INPUT PARAMETERS:
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
23
;    _extra    = extra parameters for the plot routine (currently not passed)
5deeb77c   Annie Hughes   updated help
24
;
427f1205   Jean-Michel Glorian   version 4.2 merged
25
26
; OUTPUTS:
;    None
5deeb77c   Annie Hughes   updated help
27
;
427f1205   Jean-Michel Glorian   version 4.2 merged
28
29
; OPTIONAL OUTPUT PARAMETERS:
;    None
5deeb77c   Annie Hughes   updated help
30
;
427f1205   Jean-Michel Glorian   version 4.2 merged
31
32
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
5deeb77c   Annie Hughes   updated help
33
;
427f1205   Jean-Michel Glorian   version 4.2 merged
34
35
; COMMON BLOCKS:
;    None
5deeb77c   Annie Hughes   updated help
36
;
427f1205   Jean-Michel Glorian   version 4.2 merged
37
38
; SIDE EFFECTS:
;    model is plotted
5deeb77c   Annie Hughes   updated help
39
;
427f1205   Jean-Michel Glorian   version 4.2 merged
40
; RESTRICTIONS:
5deeb77c   Annie Hughes   updated help
41
42
;    The DustEMWrap idl code must be installed
;
427f1205   Jean-Michel Glorian   version 4.2 merged
43
44
; PROCEDURE:
;    None
5deeb77c   Annie Hughes   updated help
45
;
427f1205   Jean-Michel Glorian   version 4.2 merged
46
47
; EXAMPLES
;    dustem_init,/wrap
5deeb77c   Annie Hughes   updated help
48
;    dir_in=getenv('DUSTEM_SOFT_DIR')
427f1205   Jean-Michel Glorian   version 4.2 merged
49
50
51
52
;    dir=getenv('DUSTEM_RES')
;    st=dustem_read_all_res(dir_in)
;    loadct,13
;    dustem_plot_ext,st,yr=[1.e-6,1.e0],/ysty,xr=[1.,400],/xsty
427f1205   Jean-Michel Glorian   version 4.2 merged
53
;
5deeb77c   Annie Hughes   updated help
54
; MODIFICATION HISTORY:
427f1205   Jean-Michel Glorian   version 4.2 merged
55
;    Written by J.-Ph. Bernard
5deeb77c   Annie Hughes   updated help
56
57
58
;    Modified by VG with flags /UV,/IR
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
427f1205   Jean-Michel Glorian   version 4.2 merged
59
60
;-

5deeb77c   Annie Hughes   updated help
61

427f1205   Jean-Michel Glorian   version 4.2 merged
62
63
64
65
66
IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plot_ext'
  goto,the_end
ENDIF

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
67
IF not keyword_set(multi) THEN multi=0
427f1205   Jean-Michel Glorian   version 4.2 merged
68
69
70

defsysv,'!dustem_data',exists=data_exists

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
71
IF keyword_set(print_Rv) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
72
73
74
75
76
77
78
79
80
81

	Vband = 0.55
	Bband = 0.44
	tauV = interpol(st.ext.ext_tot,st.ext.wav,Vband)
	tauB = interpol(st.ext.ext_tot,st.ext.wav,Bband)
	print
	print,"E(B-V) model/NH",1.086*(tauB-tauV)/1d21
	print,"Av model",1.086*tauV
	print,"Rv model = ",tauV/(tauB-tauV)
	print,"NH/Av model = ",1e21/(tauv*1.086)
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
82
83
    print
	IF data_exists THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
84
85
86
87
88
89
		tauV = interpol((*!dustem_data.ext).values,(*!dustem_data.ext).wav,Vband)
		tauB = interpol((*!dustem_data.ext).values,(*!dustem_data.ext).wav,Bband)
		print,"E(B-V) data/NH",1.086*(tauB-tauV)/1d21
		print,"Av data",1.086*tauV
		print,"Rv data = ",tauv/(tauB-tauV)
		print,"NH/Av data = ",1e21/(tauv*1.086)
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
90
91
        print
	ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
92

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
93
ENDIF ELSE IF keyword_set(albedo) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
94

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
95
96
	IF keyword_set(ps) THEN BEGIN
		previous_device=!d.name
427f1205   Jean-Michel Glorian   version 4.2 merged
97
98
   		set_plot, 'PS'
   		device, filename=ps, /color, /encapsulated
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
99
100
101
102
	ENDIF else BEGIN
		;set_plot,'X'
        IF keyword_set(win) THEN window,win
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
103
104
105
	
	Ngrains=n_tags(st.sed)-2

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
106
107
108
109
110
111
    abs_tot=st.ext.abs_grain(0)*0.
    sca_tot=st.ext.sca_grain(0)*0.
    FOR i=0L,Ngrains-1 DO BEGIN
        abs_tot=abs_tot+st.ext.abs_grain[i]
        sca_tot=sca_tot+st.ext.sca_grain[i]
    ENDFOR
427f1205   Jean-Michel Glorian   version 4.2 merged
112

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
113
    xrange=1./st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
114
115
116
117
	xr=[0,10]
	yr=[0,1]
	xtit=textoidl('1/\lambda (\mum^{-1})')
	ytit=textoidl('albedo')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
118
	;stop
cca12c00   Jean-Philippe Bernard   impreoved for ext...
119
120
	cgplot,xrange,/nodata,xtit=xtit,ytit=ytit,tit=tit,xlog=xlog,ylog=ylog,yr=yr,ys=ys,xr=xr,xsty=xsty
	cgoplot,xrange,sca_tot/(sca_tot+abs_tot)
36e8b879   Jean-Michel Glorian   update from deborah
121
	
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
122
123
124
125
126
127
128
129
130
131
132
133
ENDIF ELSE BEGIN

	IF multi NE 2 THEN BEGIN
		IF keyword_set(ps) THEN BEGIN
			previous_device=!d.name
   			set_plot, 'PS'
   			device, filename=ps, /color, /encapsulated
		ENDIF ELSE BEGIN
			;set_plot,'X'
        	IF keyword_set(win) THEN window,win
		ENDELSE
	ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
134
	
cca12c00   Jean-Philippe Bernard   impreoved for ext...
135
136
137
	;Ngrains=n_tags(st.sed)-2
	;colors=dustem_grains_colors(Ngrains,ls,ps=ps)
	Ngrains=(*!dustem_params).Ngrains
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
138
	colors=['dark',dustem_grains_colors(Ngrains,ls,/cgplot,ps=ps)]   ;dark added because first color taken for total extinction
cca12c00   Jean-Philippe Bernard   impreoved for ext...
139
140
	use_lines=replicate(0,Ngrains)

36e8b879   Jean-Michel Glorian   update from deborah
141
;	stop
427f1205   Jean-Michel Glorian   version 4.2 merged
142
	ytit=textoidl('\sigma_{ext}/N_H (cm^2/H)') 
666cba76   Jean-Philippe Bernard   cleaned the code
143
	IF NOT keyword_set(ps) THEN tit='DUSTEMWrapper extinction'
427f1205   Jean-Michel Glorian   version 4.2 merged
144
145
146
147
148
149
150
151
	
	abs_tot=st.ext.abs_grain(0)*0.
	sca_tot=st.ext.sca_grain(0)*0.
	FOR i=0L,Ngrains-1 DO BEGIN
  		abs_tot=abs_tot+st.ext.abs_grain(i)
  		sca_tot=sca_tot+st.ext.sca_grain(i)
	ENDFOR

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
152
	IF !dustem_show_plot EQ 2 OR multi EQ 2 THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
153
154
155
156
		norm = abs_tot+sca_tot
		yr=[0.,2.]
		ylog = 0
		ys = 1
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
157
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
158
		norm = abs_tot * 0. + 1.d21
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
159
160
		IF keyword_set(UV) THEN ylog = 0 ELSE ylog = 1
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
161
162
	
	;VG
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
163
	IF keyword_set(UV) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
164
		xtit=textoidl('1/\lambda (\mum^{-1})')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
165
        xrange=1./st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
166
		xlog = 0
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
167
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
168
		xtit=textoidl('\lambda (\mum)')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
169
        xrange=st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
170
		xlog = 1
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
171
172
173
174
	ENDELSE
	IF multi EQ 0 THEN cgplot,xrange,/nodata,xtit=xtit,ytit=ytit,tit=tit,xlog=xlog,ylog=ylog,yr=yr,ys=ys,xr=xr,xsty=xsty
	IF multi EQ 1 THEN cgplot,xrange,/nodata,xtit='',ytit=ytit,tit=tit,xlog=xlog,ylog=ylog,yr=yr,/ys,xr=xr,xsty=xsty,position=[0.17,0.35,0.95,0.95],xtickformat='(A1)',yticks=3,yminor=10
	IF multi EQ 2 THEN cgplot,xrange,/nodata,xtit=xtit,xlog=xlog,ylog=ylog,ys=ys,xsty=xsty,ytit='Normalized',tit='',xr=xr,yr=[0,2],position=[0.17,0.14,0.95,0.35],/noerase,yticks=2,yminor=5,xticklen=0.1
427f1205   Jean-Michel Glorian   version 4.2 merged
175
176
177
178
179
	;VG
	
	;VG
	; Plot model
	FOR i=0L,Ngrains-1 DO BEGIN
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
180
		IF i LE 1 AND keyword_set(mergePAH) THEN BEGIN
cca12c00   Jean-Philippe Bernard   impreoved for ext...
181
  			;if i eq 0 then oplot,xrange,(st.ext.abs_grain(0)+st.ext.sca_grain(0)+st.ext.abs_grain(1)+st.ext.sca_grain(1))/norm,color=colors(1),psym=psym,line=ls(1) 
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
182
183
  			IF i EQ 0 THEN cgoplot,xrange,(st.ext.abs_grain(0)+st.ext.sca_grain(0)+st.ext.abs_grain(1)+st.ext.sca_grain(1))/norm,color=colors(1),psym=psym,line=ls(1) 
		ENDIF ELSE BEGIN
cca12c00   Jean-Philippe Bernard   impreoved for ext...
184
185
  			;oplot,xrange,(st.ext.abs_grain(i)+st.ext.sca_grain(i))/norm,color=colors(i+1),psym=psym,line=ls(i+1)
  			cgoplot,xrange,(st.ext.abs_grain(i)+st.ext.sca_grain(i))/norm,color=colors(i+1),psym=psym,line=ls(i+1)
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
186
		ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
187
	ENDFOR
452c334e   Ilyes Choubani   Implementation Of...
188
189
190
191
192
193
194
	;cgoplot,xrange,(abs_tot+sca_tot)/norm,psym=psym
	
	;cgoplot,xrange,(abs_tot+sca_tot+powerlaw)/norm,psym=psym
	
	cgoplot,xrange,(st.ext.ext_tot)/norm,psym=psym
	
	
f882e687   Ilyes Choubani   improved
195
196
197
; 	; LINES OF CODE TO PLOT THE NEW ADDED PLUGINS TO THE EXTINCTION WILL HAVE TO BE ADDED HERE 
; 	
; 	cgoplot,xrange,(*(*!dustem_plugin).powerlaw)/norm,psym=psym,color='cadetblue'  
452c334e   Ilyes Choubani   Implementation Of...
198
199
200
	
	
	
427f1205   Jean-Michel Glorian   version 4.2 merged
201
	
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
202
	IF !dustem_show_plot EQ 2 or multi EQ 2 THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
203
		norm = interpol(st.ext.ext_tot,st.ext.wav,(*!dustem_data.ext).wav)
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
204
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
205
		norm = st.ext.ext_tot * 0. + 1.d21
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
206
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
207
208
	
	; Plot data
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
209
210
211
	IF data_exists THEN BEGIN
   		IF ptr_valid(!dustem_data.ext) THEN BEGIN
      			IF keyword_set(UV) THEN xdata = 1./(*!dustem_data.ext).wav else xdata = (*!dustem_data.ext).wav
cca12c00   Jean-Philippe Bernard   impreoved for ext...
212
      			;if keyword_set(noerrbars) then oplot,xdata,(*!dustem_data.ext).values/norm,psym=4 $
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
213
214
215
216
217
218
219
220
221
222
      			IF keyword_set(noerrbars) THEN BEGIN
      				cgoplot,xdata,(*!dustem_data.ext).values/norm,psym=4
      			ENDIF ELSE BEGIN
        		    ;else oploterror,xdata,(*!dustem_data.ext).values/norm,xdata*0.,(*!dustem_data.ext).sigma/norm,psym=4
        			;oploterror,xdata,(*!dustem_data.ext).values/norm,xdata*0.,(*!dustem_data.ext).sigma/norm,psym=4
        			cgoplot,xdata,(*!dustem_data.ext).values/norm,psym=4
        			yy=(*!dustem_data.ext).values/norm
        			rms=3.*(*!dustem_data.ext).sigma/norm/2.
        			cgerrplot,xdata,yy-rms,yy+rms,color='black'
        	    ENDELSE
cca12c00   Jean-Philippe Bernard   impreoved for ext...
223
        		;oploterror,xdata,(*!dustem_data.ext).values/norm,xdata*0.,(*!dustem_data.ext).sigma/norm,psym=4
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
224
225
226
227
   		ENDIF
	ENDIF

	IF keyword_set(ps) AND NOT keyword_set(donotclose) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
228
		device,/close
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
229
		set_plot,previous_device
f882e687   Ilyes Choubani   improved
230
		set_plot,'X'
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
231
	ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
232

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
233
ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
234
235
236
237

the_end:

END