dustem_plugin_mdfy_spinning_pol.pro 2.26 KB
FUNCTION dustem_plugin_mdfy_spinning_pol, key=key, val=val, scope=scope, paramtags=paramtags, help=help

;+
; NAME:
;    dustem_create_stext
; PURPOSE:
;    MODIFIES THE SPINNING DUST SED BY INTRODUCING A POLARIZATION FRACTION p AND A POLARIZATION ANGLE psi
; CATEGORY:
;    DUSTEM Wrapper
; CALLING SEQUENCE:
;    dustem_plugin_modify_spinning_sed(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 extinction stokes parameters
; 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_plugin_modify_spinning_polarization'
  goto,the_end
ENDIF


; 
; IF  ptr_valid((*!dustem_fit).CURRENT_PARAM_VALUES) THEN BEGIN
;     p_dii=(*(*!dustem_fit).CURRENT_PARAM_VALUES)    
;     
; ENDIF ELSE BEGIN
;           
;           
;           p_dii=(*(*!dustem_fit).PARAM_INIT_VALUES)
;           
;                     
;       ENDELSE  
;       
; st=dustem_run(p_dii)      


psi=0.
smallp=0. ;supposing the spinning dust is 

IF keyword_set(key) THEN BEGIN 
  
  ind1=where(key EQ 1,count1)
  ind2=where(key EQ 2,count2)
  IF count1 NE 0 THEN smallp=val[ind1[0]] ; setting smallp from pd   
  IF count2 NE 0 THEN psi=val[ind2[0]] ; setting psi from pd

ENDIF



paramtags=['p','Psi (deg)']

lambir=dustem_get_wavelengths()
Nwaves=n_elements(lambir)

fact = 1.e4*1.E20/(4.*!pi)/(3.e8/1.e-6/(lambir))*1.e20/1.e7

filee=!dustem_dat+'out/SPIN.RES'

readcol,filee,waves,em_g1,em_g2,em_g3,em_tot,format='D,D,D,D,D',delimiter=' ',silent=silent,skipline=8;comment='#'
;spawn,'rm -rf '+!dustem_dat+'out/*SPIN*'

out=fltarr(Nwaves,3)


out[*,0]=em_tot*fact

polar_ippsi2iqu,out[*,0],SpinningQ,SpinningU,replicate(smallp,Nwaves),replicate(psi,Nwaves) 

out[*,1]=SpinningQ
out[*,2]=SpinningU



scope='ADD_POLSED' ;replace this scope by ADD_POL (new scopes are : ADD_SED/ADD_POLSED/ADD_EXT/ADD_POLEXT)


return, out


;clean pointers
heap_gc
the_end:


end