Blame view

src/idl/dustem_plugin_freefree.pro 4.15 KB
8dbb9ca6   Annie Hughes   fix bug with free...
1
2
3
4
5
6
FUNCTION dustem_plugin_freefree,key=key $
                                ,val=val $
                                ,scope=scope $
                                ,paramtag=paramtag $
                                ,paramdefault=paramdefault $
                                ,help=help
b5ccb706   Jean-Philippe Bernard   improved to fit p...
7
8
9

;+
; NAME:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
10
;    dustem_plugin_freefree
8dbb9ca6   Annie Hughes   fix bug with free...
11
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
12
; PURPOSE:
ad00126f   Annie Hughes   tidied comments
13
;    DustEMWrap plugin to compute free-free emission
8dbb9ca6   Annie Hughes   fix bug with free...
14
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
15
; CATEGORY:
ad00126f   Annie Hughes   tidied comments
16
;    DustEM, Distributed, Mid-Level, Plugin
8dbb9ca6   Annie Hughes   fix bug with free...
17
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
18
; CALLING SEQUENCE:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
19
;    freefree=dustem_plugin_freefree([,key=][,val=])
8dbb9ca6   Annie Hughes   fix bug with free...
20
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
21
22
; INPUTS:
;    None
8dbb9ca6   Annie Hughes   fix bug with free...
23
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
24
25
26
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;    val  = input parameter value
8dbb9ca6   Annie Hughes   fix bug with free...
27
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
28
29
; OUTPUTS:
;    freefree = free-free spectrum (on dustem wavelengths)
8dbb9ca6   Annie Hughes   fix bug with free...
30
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
31
; OPTIONAL OUTPUT PARAMETERS:
403e9eaa   Jean-Philippe Bernard   modified to match...
32
;    scope = scope of the plugin
616ed857   Annie Hughes   added paramdefaul...
33
34
;    paramdefault = default values of parameters
;    paramtag = plugin parameter names as strings
8dbb9ca6   Annie Hughes   fix bug with free...
35
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
36
37
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
8dbb9ca6   Annie Hughes   fix bug with free...
38
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
39
40
; COMMON BLOCKS:
;    None
8dbb9ca6   Annie Hughes   fix bug with free...
41
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
42
43
; SIDE EFFECTS:
;    None
8dbb9ca6   Annie Hughes   fix bug with free...
44
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
45
; RESTRICTIONS:
ad00126f   Annie Hughes   tidied comments
46
;    The DustEMWrap IDL code must be installed
8dbb9ca6   Annie Hughes   fix bug with free...
47
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
48
; PROCEDURE:
ad00126f   Annie Hughes   tidied comments
49
;    This is a DustEMWrap plugin
8dbb9ca6   Annie Hughes   fix bug with free...
50
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
51
; EXAMPLES
403e9eaa   Jean-Philippe Bernard   modified to match...
52
;    dustem_init
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
53
;    vec=dustem_plugin_freefree(scope=scope)
8dbb9ca6   Annie Hughes   fix bug with free...
54
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
55
; MODIFICATION HISTORY:
ad00126f   Annie Hughes   tidied comments
56
57
58
;    Written by JPB 2022 
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
b5ccb706   Jean-Philippe Bernard   improved to fit p...
59
60
61
;-

IF keyword_set(help) THEN BEGIN
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
62
  doc_library,'dustem_plugin_freefree'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
63
64
65
66
67
  output=0.
  goto,the_end
ENDIF

;default values of input parameters
266ae799   Ilyes Choubani   General update
68
Tgas=10000.           ;default gas temperature
b5ccb706   Jean-Philippe Bernard   improved to fit p...
69
Amplitude=1.          ;Amplitude
266ae799   Ilyes Choubani   General update
70
71
smallp=0.0            ;default polarization fraction
psi=0.                ;default polarization angle
616ed857   Annie Hughes   added paramdefaul...
72
scope='ADD_SED'
b1818a4d   Jean-Philippe Bernard   updated names and...
73
paramtag=[textoidl('T_{gas}')+' [K]','Amp','p','Psi [deg]']
616ed857   Annie Hughes   added paramdefaul...
74
paramdefault=[Tgas,Amplitude,smallp,psi]
b5ccb706   Jean-Philippe Bernard   improved to fit p...
75
76
77
IF keyword_set(key) THEN BEGIN 
  a=where(key EQ 1,count1)
  b=where(key EQ 2,count2)
266ae799   Ilyes Choubani   General update
78
79
  c=where(key EQ 3,count3) ;default polarization fraction -newly added
  d=where(key EQ 4,count4) ;default polarization angle -newly added
b5ccb706   Jean-Philippe Bernard   improved to fit p...
80
81
  IF count1 NE 0 then Tgas=(val(a))(0)
  IF count2 NE 0 then Amplitude=(val(b))(0)
266ae799   Ilyes Choubani   General update
82
83
  IF count3 NE 0 then smallp=val[c[0]]   ;-newly added
  IF count4 NE 0 then psi=val[d[0]]    ;-newly added
b5ccb706   Jean-Philippe Bernard   improved to fit p...
84
ENDIF
403e9eaa   Jean-Philippe Bernard   modified to match...
85
86
87
88
89
90
91
92

;IF !dustem_which EQ 'DESERT' THEN BEGIN
;  lambir=((*!dustem_params).gemissiv.lambir)
;ENDIF ELSE BEGIN
;  lambir=((*!dustem_params).lambda.lambda)
;ENDELSE
;replaced by the following to ease the life of plugins writters
lambir=dustem_get_wavelengths()
266ae799   Ilyes Choubani   General update
93
Nwavs=n_elements(lambir)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
94
95
96
97
98
cmic=3.e14
nu=cmic/lambir   ;Hz
mjy=1           ;output is in MJy/sr
lambir_ref=10000.

266ae799   Ilyes Choubani   General update
99

07372e26   Ilyes Choubani   Corrected huge pl...
100
output=fltarr(Nwavs,3) ;newly added
266ae799   Ilyes Choubani   General update
101

b5ccb706   Jean-Philippe Bernard   improved to fit p...
102
;stop
9818c4c0   Jean-Philippe Bernard   cant remember wha...
103
;use_method='Deschenes2008'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
104
;use_method='WallsGabaud1998'
9818c4c0   Jean-Philippe Bernard   cant remember wha...
105
use_method='Dickinson2003_norm'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
106
107
108
109

CASE use_method OF
    'WallsGabaud1998':BEGIN
		em=1.   ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway
266ae799   Ilyes Choubani   General update
110
		output[*,0]=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
111
112
		fact=Amplitude/I_halpha_R
        ;=== normalize to the requested Halpha value.
266ae799   Ilyes Choubani   General update
113
		output[*,0]=output[*,0]*fact
b5ccb706   Jean-Philippe Bernard   improved to fit p...
114
115
116
	END
    'WallsGabaud1998_scaled':BEGIN
		em=1.   ;This is a stupid value for the Emission measure. Result will be rescaled based on I_halpha_R anyway
266ae799   Ilyes Choubani   General update
117
118
119
		output[*,0]=intensity_free_free(nu,Tgas,em,I_halpha_R=I_halpha_R,nHe=nHe,ergs=ergs,mjy=mjy)
		norm=interpol(output[*,0],lambir,lambir_ref)
		output[*,0]=output[*,0]/norm*Amplitude
b5ccb706   Jean-Philippe Bernard   improved to fit p...
120
121
122
	END
	'Deschenes2008':BEGIN
		beta_freefree=2.+1./(10.48+1.5*alog(Tgas/8.e3)-alog(nu/1.e9))
266ae799   Ilyes Choubani   General update
123
124
125
		output[*,0]=nu^(-1.*beta_freefree)
		norm=interpol(output[*,0],lambir,lambir_ref)
		output[*,0]=output[*,0]/norm*Amplitude
b5ccb706   Jean-Philippe Bernard   improved to fit p...
126
127
128
129
130
131
132
133
	END
	'Dickinson2003_norm':BEGIN
		;stop
		em=1.
		T4=Tgas/1.e4
		nu_ghz=nu/1.e9
		a=0.366*(nu_ghz/1.e9)^(-0.15)*(alog(4.995*1e-2*(nu_ghz)^(-1.))+1.5*alog(Tgas))
		Tb=8.369e3*a*(nu_ghz)^(-2.)*T4^0.667*10^(0.029*T4)*(1.+0.08)  ;in mK for 1 Rayleigh
8dbb9ca6   Annie Hughes   fix bug with free...
134
		psm_convert_mk2mjy, lambir, Tb, I_Mjy, /RJ
b5ccb706   Jean-Philippe Bernard   improved to fit p...
135
		norm=interpol(I_Mjy,lambir,lambir_ref)
266ae799   Ilyes Choubani   General update
136
		output[*,0]=I_Mjy/norm*Amplitude
b5ccb706   Jean-Philippe Bernard   improved to fit p...
137
138
139
	END
ENDCASE

266ae799   Ilyes Choubani   General update
140
polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
452c334e   Ilyes Choubani   Implementation Of...
141

266ae799   Ilyes Choubani   General update
142
143
output[*,1]=Q
output[*,2]=U
07372e26   Ilyes Choubani   Corrected huge pl...
144
145
;output[*,3]=replicate(smallp,Nwavs)
;output[*,4]=replicate(psi,Nwavs)
d66feb17   Ilyes Choubani   Fix to some routines
146
 
452c334e   Ilyes Choubani   Implementation Of...
147

b5ccb706   Jean-Philippe Bernard   improved to fit p...
148
149
150
151
the_end:
RETURN,output
  
END