Blame view

src/idl/dustem_plugin_freefree.pro 3.63 KB
759a527d   Ilyes Choubani   general update
1
FUNCTION dustem_plugin_freefree,key=key,val=val,scope=scope,paramtag=paramtag,help=help
b5ccb706   Jean-Philippe Bernard   improved to fit p...
2
3
4

;+
; NAME:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
5
;    dustem_plugin_freefree
b5ccb706   Jean-Philippe Bernard   improved to fit p...
6
; PURPOSE:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
7
;    DUSTEM plugin to compute free-free emission
b5ccb706   Jean-Philippe Bernard   improved to fit p...
8
9
10
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
11
;    freefree=dustem_plugin_freefree([,key=][,val=])
b5ccb706   Jean-Philippe Bernard   improved to fit p...
12
13
14
15
16
17
18
19
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;    val  = input parameter value
; OUTPUTS:
;    freefree = free-free spectrum (on dustem wavelengths)
; OPTIONAL OUTPUT PARAMETERS:
403e9eaa   Jean-Philippe Bernard   modified to match...
20
;    scope = scope of the plugin
b5ccb706   Jean-Philippe Bernard   improved to fit p...
21
22
23
24
25
26
27
28
29
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    None
; PROCEDURE:
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
30
;    This is a dustem plugin
b5ccb706   Jean-Philippe Bernard   improved to fit p...
31
; EXAMPLES
403e9eaa   Jean-Philippe Bernard   modified to match...
32
;    dustem_init
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
33
;    vec=dustem_plugin_freefree(scope=scope)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
34
35
36
37
38
; MODIFICATION HISTORY:
;    Written by JPB 
;-

IF keyword_set(help) THEN BEGIN
cbf75ef0   Ilyes Choubani   dustem_init_plugi...
39
  doc_library,'dustem_plugin_freefree'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
40
41
42
43
44
  output=0.
  goto,the_end
ENDIF

;default values of input parameters
266ae799   Ilyes Choubani   General update
45
Tgas=10000.           ;default gas temperature
b5ccb706   Jean-Philippe Bernard   improved to fit p...
46
Amplitude=1.          ;Amplitude
266ae799   Ilyes Choubani   General update
47
48
49
smallp=0.0            ;default polarization fraction
psi=0.                ;default polarization angle
paramtag=['T_gas (K)','Amp','p','Psi (deg)']
b5ccb706   Jean-Philippe Bernard   improved to fit p...
50
51
52
IF keyword_set(key) THEN BEGIN 
  a=where(key EQ 1,count1)
  b=where(key EQ 2,count2)
266ae799   Ilyes Choubani   General update
53
54
  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...
55
56
  IF count1 NE 0 then Tgas=(val(a))(0)
  IF count2 NE 0 then Amplitude=(val(b))(0)
266ae799   Ilyes Choubani   General update
57
58
  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...
59
ENDIF
403e9eaa   Jean-Philippe Bernard   modified to match...
60
61
62
63
64
65
66
67

;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
68
Nwavs=n_elements(lambir)
b5ccb706   Jean-Philippe Bernard   improved to fit p...
69
70
71
72
73
cmic=3.e14
nu=cmic/lambir   ;Hz
mjy=1           ;output is in MJy/sr
lambir_ref=10000.

266ae799   Ilyes Choubani   General update
74

5f04fa07   Ilyes Choubani   general update
75
output=fltarr(Nwavs,5) ;newly added
266ae799   Ilyes Choubani   General update
76

b5ccb706   Jean-Philippe Bernard   improved to fit p...
77
;stop
9818c4c0   Jean-Philippe Bernard   cant remember wha...
78
;use_method='Deschenes2008'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
79
;use_method='WallsGabaud1998'
9818c4c0   Jean-Philippe Bernard   cant remember wha...
80
use_method='Dickinson2003_norm'
b5ccb706   Jean-Philippe Bernard   improved to fit p...
81
82
83
84

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
85
		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...
86
87
		fact=Amplitude/I_halpha_R
        ;=== normalize to the requested Halpha value.
266ae799   Ilyes Choubani   General update
88
		output[*,0]=output[*,0]*fact
b5ccb706   Jean-Philippe Bernard   improved to fit p...
89
90
91
	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
92
93
94
		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...
95
96
97
	END
	'Deschenes2008':BEGIN
		beta_freefree=2.+1./(10.48+1.5*alog(Tgas/8.e3)-alog(nu/1.e9))
266ae799   Ilyes Choubani   General update
98
99
100
		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...
101
102
103
104
105
106
107
108
109
110
	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
		convert_mk_mjy, lambir, Tb, I_Mjy, /RJ
		norm=interpol(I_Mjy,lambir,lambir_ref)
266ae799   Ilyes Choubani   General update
111
		output[*,0]=I_Mjy/norm*Amplitude
b5ccb706   Jean-Philippe Bernard   improved to fit p...
112
113
114
	END
ENDCASE

af5bca1f   Ilyes Choubani   general update
115
scope='ADD_SED'
266ae799   Ilyes Choubani   General update
116
117
118

;polarization this actually need to 
polar_ippsi2iqu,output[*,0],Q,U,replicate(smallp,Nwavs),replicate(psi,Nwavs)
452c334e   Ilyes Choubani   Implementation Of...
119

266ae799   Ilyes Choubani   General update
120
121
output[*,1]=Q
output[*,2]=U
5f04fa07   Ilyes Choubani   general update
122
123
output[*,3]=replicate(smallp,Nwavs)
output[*,4]=replicate(psi,Nwavs)
d66feb17   Ilyes Choubani   Fix to some routines
124
 
452c334e   Ilyes Choubani   Implementation Of...
125

b5ccb706   Jean-Philippe Bernard   improved to fit p...
126
127
128
129
the_end:
RETURN,output
  
END