Blame view

src/idl/dustem_plugin_modify_dust_polarization.pro 1.89 KB
ba82c5cf   Ilyes Choubani   improved with mod...
1
Function dustem_plugin_modify_dust_polarization, key=key, val=val, scope=scope,help=help
4750086c   Ilyes Choubani   nouvelle philosph...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

;+
; NAME:
;    dustem_create_stokes
; PURPOSE:
;    Produces stokes emission parameters for the dust and synchrotron components
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
;    dustem_create_stokes(st,key=key,val=val)
; INPUTS:
;    st (st = dustem_run(p_dim))
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;    val  = input parameter value
; OUTPUTS:
;    out = array containing the stokes emission parameters associated to the dust/synchrotron component or a concatenated version for both
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The dustem fortran code must be installed
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    This is a dustem plugin
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_create_stokes'
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
36
  out=0.
4750086c   Ilyes Choubani   nouvelle philosph...
37
38
  goto,the_end
ENDIF
e7938fa3   Ilyes Choubani   Corrected02: Impl...
39

e7938fa3   Ilyes Choubani   Corrected02: Impl...
40

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
41

607060e5   Ilyes Choubani   test version
42
IF not KEYWORD_SET(st) THEN BEGIN
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
43
IF  ptr_valid((*!dustem_fit).CURRENT_PARAM_VALUES) THEN BEGIN
607060e5   Ilyes Choubani   test version
44
    p_di=(*(*!dustem_fit).CURRENT_PARAM_VALUES)
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
45
46
    
ENDIF ELSE BEGIN
607060e5   Ilyes Choubani   test version
47
          p_di=(*(*!dustem_fit).PARAM_INIT_VALUES)    
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
48
      ENDELSE 
607060e5   Ilyes Choubani   test version
49
50
51
52
          
st=dustem_run(p_di)      
ENDIF

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
53

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
54
psi=0.
ba82c5cf   Ilyes Choubani   improved with mod...
55
smallp=1.
e7938fa3   Ilyes Choubani   Corrected02: Impl...
56
IF keyword_set(key) THEN BEGIN 
ba82c5cf   Ilyes Choubani   improved with mod...
57
58
59
60
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
  IF count1 NE 0 THEN smallp=val[ind1[0]] ; setting psi from pd
  IF count2 NE 0 THEN psi=val[ind2[0]] ; setting psi from pd   
e7938fa3   Ilyes Choubani   Corrected02: Impl...
61
62
ENDIF

e7938fa3   Ilyes Choubani   Corrected02: Impl...
63

607060e5   Ilyes Choubani   test version
64
65
66
67
68
fact = 1.e4*1.E20/(4.*!pi)/(3.e8/1.e-6/((st.polsed).wav))*1.e20/1.e7
P=((st.polsed).em_tot)*fact
I=((st.sed).em_tot)*fact


4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
69
70
71

Nwaves=(size(I))[1]

ba82c5cf   Ilyes Choubani   improved with mod...
72
frac=P/I*smallp
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
73
74
75
76
77
78
tes=where(finite(frac) eq 0)
frac(tes)=0.


polar_ippsi2iqu,I,Q,U,frac,replicate(psi,Nwaves) 

ba82c5cf   Ilyes Choubani   improved with mod...
79
out=fltarr(Nwaves,3)
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
80

ba82c5cf   Ilyes Choubani   improved with mod...
81
82
83
out[*,0]=I
out[*,1]=Q
out[*,2]=U
4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
84

607060e5   Ilyes Choubani   test version
85
86
scope='REPLACE_QSED+REPLACE_USED'

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
87
88
return, out

4750086c   Ilyes Choubani   nouvelle philosph...
89
the_end:
e7938fa3   Ilyes Choubani   Corrected02: Impl...
90

4fd64cbb   Ilyes Choubani   dustem_fit_sed_po...
91

e7938fa3   Ilyes Choubani   Corrected02: Impl...
92
end