Blame view

src/idl/dustem_plugin_modify_dust_pol.pro 3.38 KB
e6ef3674   Ilyes Choubani   removed st keywor...
1
FUNCTION dustem_plugin_modify_dust_pol, key=key, val=val, scope=scope, paramtag=paramtag, help=help
6cde48ea   Ilyes Choubani   missing procedure
2
3
4
5

;+
; NAME:
;    dustem_plugin_modify_dust_pol
6a523633   Annie Hughes   unknown
6
;  
6cde48ea   Ilyes Choubani   missing procedure
7
; PURPOSE:
a84e0595   Jean-Philippe Bernard   modified plugin s...
8
9
10
11
12
;    Replaces the emission in polarization (Stokes Q,U) with a fixed polarization angle and fraction
;    Q,U to be replaced are computed from the total intensity as:
;    Q=I*val[0]*p*cos(2*val[1])
;    U=I*val[0]*p*sin(2*val[1])
;    where I is the total intensity in the model and p is the polarization fraction in the model 
6cde48ea   Ilyes Choubani   missing procedure
13
; CATEGORY:
6a523633   Annie Hughes   unknown
14
15
;    DustEMWrap, Plugin, Mid-level, Distributed
;
6cde48ea   Ilyes Choubani   missing procedure
16
; CALLING SEQUENCE:
a84e0595   Jean-Philippe Bernard   modified plugin s...
17
;    a=dustem_plugin_modify_dust_pol([key=][val=][,scope=][,paramtag=][,paramdefault=][,/help])
6a523633   Annie Hughes   unknown
18
;
6cde48ea   Ilyes Choubani   missing procedure
19
; INPUTS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
20
;    st = dustem structure
6a523633   Annie Hughes   unknown
21
;
6cde48ea   Ilyes Choubani   missing procedure
22
; OPTIONAL INPUT PARAMETERS:
a84e0595   Jean-Philippe Bernard   modified plugin s...
23
24
25
;    key  = input parameter numbers
;           first  = multiplication factor for the polarization fraction
;           second = polarization angle [deg], default=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
26
;    val  = input parameter values
6cde48ea   Ilyes Choubani   missing procedure
27
; OUTPUTS:
a84e0595   Jean-Philippe Bernard   modified plugin s...
28
;    out  = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
6a523633   Annie Hughes   unknown
29
;
6cde48ea   Ilyes Choubani   missing procedure
30
; OPTIONAL OUTPUT PARAMETERS:
eab2e158   Jean-Philippe Bernard   did some (sometim...
31
32
;    scope = if set, returns only the scope of the pluggin
;    paramtag = if set, returns only the parameter tags
6cde48ea   Ilyes Choubani   missing procedure
33
34
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
6cde48ea   Ilyes Choubani   missing procedure
35
36
; COMMON BLOCKS:
;    None
6a523633   Annie Hughes   unknown
37
;
6cde48ea   Ilyes Choubani   missing procedure
38
39
; SIDE EFFECTS:
;    None
6a523633   Annie Hughes   unknown
40
;
6cde48ea   Ilyes Choubani   missing procedure
41
42
43
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
6a523633   Annie Hughes   unknown
44
45
46
47
48
;
; MODIFICATION HISTORY:
;    Written by IC 2022
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
6cde48ea   Ilyes Choubani   missing procedure
49
50
51
;-

IF keyword_set(help) THEN BEGIN
eab2e158   Jean-Philippe Bernard   did some (sometim...
52
  doc_library,'dustem_plugin_modify_dust_pol'
6cde48ea   Ilyes Choubani   missing procedure
53
  out=0.
eab2e158   Jean-Philippe Bernard   did some (sometim...
54
  GOTO,the_end
6cde48ea   Ilyes Choubani   missing procedure
55
ENDIF
1fcff162   Ilyes Choubani   removed stop from...
56
       
5f04fa07   Ilyes Choubani   general update
57
IF keyword_set(scope) THEN BEGIN
a84e0595   Jean-Philippe Bernard   modified plugin s...
58
59
    ;scope='REPLACE_POLSED'
    scope='REPLACE_SED'
91e991b5   Ilyes Choubani   Applying correcti...
60
    out=0
01612ee4   Ilyes Choubani   General update: I...
61
    GOTO, the_end
5f04fa07   Ilyes Choubani   general update
62
63
64
ENDIF 

IF keyword_set(paramtag) THEN BEGIN
a84e0595   Jean-Philippe Bernard   modified plugin s...
65
    paramtag=['p',textoidl('\psi')+' [deg]']
5f04fa07   Ilyes Choubani   general update
66
    out=0.
01612ee4   Ilyes Choubani   General update: I...
67
    GOTO, the_end
5f04fa07   Ilyes Choubani   general update
68
69
ENDIF 

01612ee4   Ilyes Choubani   General update: I...
70
;Retrieving this sytem variable  (dustem output)  
a84e0595   Jean-Philippe Bernard   modified plugin s...
71
72
IF ~isa(!dustem_current) then begin
    out=0
91e991b5   Ilyes Choubani   Applying correcti...
73
    goto, the_end 
a84e0595   Jean-Philippe Bernard   modified plugin s...
74
75
76
ENDIF ELSE BEGIN
    st=(*!dustem_current)
ENDELSE
01612ee4   Ilyes Choubani   General update: I...
77

eab2e158   Jean-Philippe Bernard   did some (sometim...
78
;below are the default values for the plugin parameters
2fe314fa   Annie Hughes   cosmetic change t...
79
smallp_fact=1.     ;This is the default dust polarization factor
d571675e   Jean-Philippe Bernard   went back to a mu...
80
psi=0.             ;This is the default polarization angle
5f04fa07   Ilyes Choubani   general update
81

6cde48ea   Ilyes Choubani   missing procedure
82
83
84
IF keyword_set(key) THEN BEGIN 
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
d571675e   Jean-Philippe Bernard   went back to a mu...
85
  IF count1 NE 0 THEN smallp_fact=val[ind1[0]] ; setting smallp from pd - this is another polarization fraction (constant) that is applied to the total dust emission
a84e0595   Jean-Philippe Bernard   modified plugin s...
86
87
  IF count2 NE 0 THEN psi=val[ind2[0]]
  !dustem_psi = psi ; setting psi from pd.  !dustem_psi here helps for the plotting.   
6cde48ea   Ilyes Choubani   missing procedure
88
89
ENDIF

6cde48ea   Ilyes Choubani   missing procedure
90
fact = 1.e4*(*!dustem_HCD)/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7
a84e0595   Jean-Philippe Bernard   modified plugin s...
91
92
P=((st.polsed).em_tot)*fact   ; This is the polarized emission P currently in the model
I=((st.sed).em_tot)*fact      ; This is the total intensity emission I currently in the model
5f04fa07   Ilyes Choubani   general update
93
    
6cde48ea   Ilyes Choubani   missing procedure
94
95
Nwaves=(size(I))[1]

19961cc2   Ilyes Choubani   fixing NaN values...
96
97
98
;0/0 division in frac
;since we divide by I we only need to avoid its null indices 

6a523633   Annie Hughes   unknown
99
frac_model=P*0.
19961cc2   Ilyes Choubani   fixing NaN values...
100
indI = where(I ne 0, countI)
a84e0595   Jean-Philippe Bernard   modified plugin s...
101
if countI ne 0 then frac_model[indI] = P[indI]/I[indI] ;This is the polarization fraction currently in the model
19961cc2   Ilyes Choubani   fixing NaN values...
102

d571675e   Jean-Philippe Bernard   went back to a mu...
103
frac_used=frac_model*smallp_fact
6cde48ea   Ilyes Choubani   missing procedure
104

eab2e158   Jean-Philippe Bernard   did some (sometim...
105
psi_used = replicate(psi,Nwaves)
5f04fa07   Ilyes Choubani   general update
106

eab2e158   Jean-Philippe Bernard   did some (sometim...
107
polar_ippsi2iqu,I,Q,U,frac_used,psi_used
6cde48ea   Ilyes Choubani   missing procedure
108

a84e0595   Jean-Philippe Bernard   modified plugin s...
109
out=fltarr(Nwaves,3)
6cde48ea   Ilyes Choubani   missing procedure
110
111
112
113

out[*,0]=I
out[*,1]=Q
out[*,2]=U
6cde48ea   Ilyes Choubani   missing procedure
114

eab2e158   Jean-Philippe Bernard   did some (sometim...
115
RETURN, out
6cde48ea   Ilyes Choubani   missing procedure
116
117

the_end:
91e991b5   Ilyes Choubani   Applying correcti...
118

6cde48ea   Ilyes Choubani   missing procedure
119

eab2e158   Jean-Philippe Bernard   did some (sometim...
120
END
6cde48ea   Ilyes Choubani   missing procedure