Blame view

src/idl/dustem_plugin_freefree.pro 3.97 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
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
a84e0595   Jean-Philippe Bernard   modified plugin s...
26
27
28
29
;         1 : Tgas [K]
;         2 : free-free Amplitude []
;         3 : polarization fraction [%] (default=0)
;         4 : polarization angle [deg]
b5ccb706   Jean-Philippe Bernard   improved to fit p...
30
;    val  = input parameter value
b5ccb706   Jean-Philippe Bernard   improved to fit p...
31
32
; OUTPUTS:
;    freefree = free-free spectrum (on dustem wavelengths)
8dbb9ca6   Annie Hughes   fix bug with free...
33
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
34
; OPTIONAL OUTPUT PARAMETERS:
403e9eaa   Jean-Philippe Bernard   modified to match...
35
;    scope = scope of the plugin
616ed857   Annie Hughes   added paramdefaul...
36
37
;    paramdefault = default values of parameters
;    paramtag = plugin parameter names as strings
8dbb9ca6   Annie Hughes   fix bug with free...
38
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
39
40
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
8dbb9ca6   Annie Hughes   fix bug with free...
41
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
42
43
; COMMON BLOCKS:
;    None
8dbb9ca6   Annie Hughes   fix bug with free...
44
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
45
46
; SIDE EFFECTS:
;    None
8dbb9ca6   Annie Hughes   fix bug with free...
47
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
48
; RESTRICTIONS:
ad00126f   Annie Hughes   tidied comments
49
;    The DustEMWrap IDL code must be installed
8dbb9ca6   Annie Hughes   fix bug with free...
50
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
51
; PROCEDURE:
ad00126f   Annie Hughes   tidied comments
52
;    This is a DustEMWrap plugin
8dbb9ca6   Annie Hughes   fix bug with free...
53
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
54
; EXAMPLES
403e9eaa   Jean-Philippe Bernard   modified to match...
55
;    dustem_init
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
56
;    vec=dustem_plugin_freefree(scope=scope)
8dbb9ca6   Annie Hughes   fix bug with free...
57
;
b5ccb706   Jean-Philippe Bernard   improved to fit p...
58
; MODIFICATION HISTORY:
ad00126f   Annie Hughes   tidied comments
59
60
61
;    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...
62
63
64
;-

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

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

403e9eaa   Jean-Philippe Bernard   modified to match...
89
lambir=dustem_get_wavelengths()
266ae799   Ilyes Choubani   General update
90
Nwavs=n_elements(lambir)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
91
92
93
cmic=3.e14
nu=cmic/lambir   ;Hz
mjy=1           ;output is in MJy/sr
a84e0595   Jean-Philippe Bernard   modified plugin s...
94
lambir_ref=10000.  ;in mic (this is 1cm)
266ae799   Ilyes Choubani   General update
95

a84e0595   Jean-Philippe Bernard   modified plugin s...
96
output=fltarr(Nwavs,3)
266ae799   Ilyes Choubani   General update
97

9818c4c0   Jean-Philippe Bernard   cant remember wha...
98
;use_method='Deschenes2008'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
99
;use_method='WallsGabaud1998'
9818c4c0   Jean-Philippe Bernard   cant remember wha...
100
use_method='Dickinson2003_norm'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
101
102
103
104

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
105
		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...
106
107
		fact=Amplitude/I_halpha_R
        ;=== normalize to the requested Halpha value.
266ae799   Ilyes Choubani   General update
108
		output[*,0]=output[*,0]*fact
b5ccb706   Jean-Philippe Bernard   improved to fit p...
109
110
111
	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
112
113
114
		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...
115
116
117
	END
	'Deschenes2008':BEGIN
		beta_freefree=2.+1./(10.48+1.5*alog(Tgas/8.e3)-alog(nu/1.e9))
266ae799   Ilyes Choubani   General update
118
119
120
		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...
121
122
123
124
125
126
127
128
	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...
129
		psm_convert_mk2mjy, lambir, Tb, I_Mjy, /RJ
b5ccb706   Jean-Philippe Bernard   improved to fit p...
130
		norm=interpol(I_Mjy,lambir,lambir_ref)
266ae799   Ilyes Choubani   General update
131
		output[*,0]=I_Mjy/norm*Amplitude
b5ccb706   Jean-Philippe Bernard   improved to fit p...
132
133
134
	END
ENDCASE

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

266ae799   Ilyes Choubani   General update
137
output[*,1]=Q
a84e0595   Jean-Philippe Bernard   modified plugin s...
138
output[*,2]=U 
452c334e   Ilyes Choubani   Implementation Of...
139

b5ccb706   Jean-Philippe Bernard   improved to fit p...
140
141
142
143
the_end:
RETURN,output
  
END