dustem_plugin_phangs_stellar_isrf.pro 4.1 KB
FUNCTION dustem_plugin_phangs_stellar_isrf,key=key $
                                			   ,val=val $
                                			   ,scope=scope $
                                			   ,paramtag=paramtag $
                                			   ,age_values=age_values $
                                			   ,metalicity_values=metalicity_values $
                                			   ,paramdefault=paramdefault $
;                                			   ,object_distance=object_distance $
                                			   ,object_thickness=object_thickness $
                                         ,Voronoi_Npix=Voronoi_Npix $
                                			   ,help=help

;+
; NAME:
;    dustem_plugin_phangs_stellar_isrf
; PURPOSE:
;    DustEMWrap plugin to compute ISRF from stellar template emission
; CATEGORY:
;    DustEM, Distributed, Mid-Level, Plugin
; CALLING SEQUENCE:
;    ISRF=dustem_plugin_phangs_stellar_isrf([,key=][,val=][,scope=][,paramtag=][paramdefault=][,/help])
; INPUTS:
;    None
; OPTIONAL INPUT PARAMETERS:
;    key  = input parameter number
;					  First parameter: Amplitude factor for the emission
;           Second parameter: E(B-V) for extinction to stars applied to the template, as used in Phangs
;           Following 13*6 parameters are weights by which to multiply the MILES templates [Msun/pc^2]
;    val  = corresponding input parameter value
;  object_distance  = distance to the object in MPc (default = 1 Mpc)
;  object_thickness = thickness of the object in kpc (default = 1 kpc)
; OUTPUTS:
;    ISRF = stellar ISRF in omega*Inu [ergs/s/cm2/Hz] for omega = 1 sr
; OPTIONAL OUTPUT PARAMETERS:
;    scope = if set, return the scope of the plugin
;    paramdefault = default values of parameters
;    paramtag = if set, return the return plugin parameter names as strings
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
;    method                = SSP used. can be EMILES or CB19. default='EMILES'
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
; PROCEDURE:
;    This is a DustEMWrap plugin for phangs
;    It differs from dustem_plugin_emiles_stellar_continuum.pro only by the way the extinction is applied to the output spectrum
; EXAMPLES
;    dustem_init
;    vec=dustem_plugin_phangs_stellar_continuum(scope=scope)
; MODIFICATION HISTORY:
;    Written by JPB June 2023
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plugin_phangs_stellar_isrf'
  ISRF=0.
  goto,the_end
ENDIF

IF keyword_set(scope) THEN BEGIN
    scope='REPLACE_ISRF'   
    out=0
    goto,the_end
ENDIF 

;==== define parameter tags
IF keyword_set(paramtag) THEN BEGIN
	ISRF=dustem_plugin_phangs_stellar_continuum(paramtag=paramtag,paramdefault=paramdefault,voronoi_Npix=voronoi_Npix)  ;This is Inu stars MJy/sr
  ISRF=0
	GOTO,the_end
ENDIF

;use_object_distance=1. ;MPc
;use_object_thickness=1. ;Pc
;IF keyword_set(object_distance) THEN use_object_distance=object_distance
;IF keyword_set(object_thickness) THEN use_object_thickness=object_thickness

;use_omega_ratio=((use_object_thickness/2.*1.e3)/(use_object_distance*1.e6))^2
;This factor is to go from Inu_stars in MJy/sr to 4*pi*Iisrf in ergs/s/cm2/Hz 
;==== JPB: I think it should say *1.e-4, not *1.e4 and /use_omega_ratio, not *use_omega_ratio
;use_factor=4.*!pi*1.e-20*1.e7*1.e4*use_omega_ratio
;so,
;use_factor=4.*!pi*1.e-20*1.e7*1.e-4/use_omega_ratio
;but in fact we go to a distance equal to the size of the Voronoi bin, ie (indep. of omega_ration ....)
;use_factor=4.*!pi*1.e-20*1.e7*1.e-4
use_factor=1.e-20*1.e7*1.e-4    ;This is to go from MJy/sr to ergs/s/cm2/Hz/sr

;stop
Inu_stars=dustem_plugin_phangs_stellar_continuum(key=key,val=val,voronoi_Npix=voronoi_Npix)   ;This is in MJy/sr
ISRF=Inu_stars[*,0]*use_factor

;REM: Inu_stars is on lambir wavelength. For an ISRF plugins, needs to to be interpolated on isrf wavelengths
spec_wavelengths=dustem_get_wavelengths(isrf_wavelengths=isrf_wavelengths)
ISRF=interpol(ISRF,spec_wavelengths,isrf_wavelengths)

the_end:
RETURN,ISRF
  
END