Blame view

src/idl/dustem_plot_ext.pro 6.96 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
9
10
11
12
13

;+
; NAME:
;     dustem_plot_ext
; PURPOSE:
;    Plots a Dustem extinction
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
14
;    dustem_plot_ext,st[,/help]
427f1205   Jean-Michel Glorian   version 4.2 merged
15
16
17
; INPUTS:
;    st        = Dustem model output structure
; OPTIONAL INPUT PARAMETERS:
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
18
;    _extra    = extra parameters for the plot routine (currently not passed)
427f1205   Jean-Michel Glorian   version 4.2 merged
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    model is plotted
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    dustem_init,/wrap
;    dir_in=getenv('DUSTEM_SOFT_DIR')+'/src/dustem3.8_web/'
;    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
; MODIFICATION HISTORY:
;
;    Modified by VG with flags /UV,/IR
;
;    Written by J.-Ph. Bernard
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plot_ext'
  goto,the_end
ENDIF

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
54
IF not keyword_set(multi) THEN multi=0
427f1205   Jean-Michel Glorian   version 4.2 merged
55
56
57

defsysv,'!dustem_data',exists=data_exists

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
58
IF keyword_set(print_Rv) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
59
60
61
62
63
64
65
66
67
68

	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...
69
70
    print
	IF data_exists THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
71
72
73
74
75
76
		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...
77
78
        print
	ENDIF
427f1205   Jean-Michel Glorian   version 4.2 merged
79

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

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
82
83
	IF keyword_set(ps) THEN BEGIN
		previous_device=!d.name
427f1205   Jean-Michel Glorian   version 4.2 merged
84
85
   		set_plot, 'PS'
   		device, filename=ps, /color, /encapsulated
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
86
87
88
89
	ENDIF else BEGIN
		;set_plot,'X'
        IF keyword_set(win) THEN window,win
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
90
91
92
	
	Ngrains=n_tags(st.sed)-2

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
93
94
95
96
97
98
    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
99

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
100
    xrange=1./st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
101
102
103
104
	xr=[0,10]
	yr=[0,1]
	xtit=textoidl('1/\lambda (\mum^{-1})')
	ytit=textoidl('albedo')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
105
	;stop
cca12c00   Jean-Philippe Bernard   impreoved for ext...
106
107
	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
108
	
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
109
110
111
112
113
114
115
116
117
118
119
120
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
121
	
cca12c00   Jean-Philippe Bernard   impreoved for ext...
122
123
124
	;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...
125
	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...
126
127
	use_lines=replicate(0,Ngrains)

36e8b879   Jean-Michel Glorian   update from deborah
128
;	stop
427f1205   Jean-Michel Glorian   version 4.2 merged
129
	ytit=textoidl('\sigma_{ext}/N_H (cm^2/H)') 
666cba76   Jean-Philippe Bernard   cleaned the code
130
	IF NOT keyword_set(ps) THEN tit='DUSTEMWrapper extinction'
427f1205   Jean-Michel Glorian   version 4.2 merged
131
132
133
134
135
136
137
138
	
	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...
139
	IF !dustem_show_plot EQ 2 OR multi EQ 2 THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
140
141
142
143
		norm = abs_tot+sca_tot
		yr=[0.,2.]
		ylog = 0
		ys = 1
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
144
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
145
		norm = abs_tot * 0. + 1.d21
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
146
147
		IF keyword_set(UV) THEN ylog = 0 ELSE ylog = 1
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
148
149
	
	;VG
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
150
	IF keyword_set(UV) THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
151
		xtit=textoidl('1/\lambda (\mum^{-1})')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
152
        xrange=1./st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
153
		xlog = 0
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
154
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
155
		xtit=textoidl('\lambda (\mum)')
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
156
        xrange=st.ext.wav
427f1205   Jean-Michel Glorian   version 4.2 merged
157
		xlog = 1
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
158
159
160
161
	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
162
163
164
165
166
	;VG
	
	;VG
	; Plot model
	FOR i=0L,Ngrains-1 DO BEGIN
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
167
		IF i LE 1 AND keyword_set(mergePAH) THEN BEGIN
cca12c00   Jean-Philippe Bernard   impreoved for ext...
168
  			;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...
169
170
  			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...
171
172
  			;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...
173
		ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
174
	ENDFOR
452c334e   Ilyes Choubani   Implementation Of...
175
176
177
178
179
180
181
	;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
182
183
184
; 	; 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...
185
186
187
	
	
	
427f1205   Jean-Michel Glorian   version 4.2 merged
188
	
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
189
	IF !dustem_show_plot EQ 2 or multi EQ 2 THEN BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
190
		norm = interpol(st.ext.ext_tot,st.ext.wav,(*!dustem_data.ext).wav)
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
191
	ENDIF ELSE BEGIN
427f1205   Jean-Michel Glorian   version 4.2 merged
192
		norm = st.ext.ext_tot * 0. + 1.d21
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
193
	ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
194
195
	
	; Plot data
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
196
197
198
	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...
199
      			;if keyword_set(noerrbars) then oplot,xdata,(*!dustem_data.ext).values/norm,psym=4 $
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
200
201
202
203
204
205
206
207
208
209
      			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...
210
        		;oploterror,xdata,(*!dustem_data.ext).values/norm,xdata*0.,(*!dustem_data.ext).sigma/norm,psym=4
37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
211
212
213
214
   		ENDIF
	ENDIF

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

37b5d8a7   Jean-Philippe Bernard   fixed to adapt gr...
220
ENDELSE
427f1205   Jean-Michel Glorian   version 4.2 merged
221
222
223
224

the_end:

END