dustem_plugin_phangs_stellar_isrf.pro 3.74 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 $
                                			   ,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 4*pi*Inu [ergs/s/cm2/Hz]
; 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 

;use_method='EMILES'
;use_method='CB19'

;age_values=[0.03, 0.05, 0.08, 0.15, 0.25, 0.40, 0.60, 1.0, 1.75, 3.0, 5.0, 8.5, 13.5]
;metalicity_values=[-1.48630, -0.961400, -0.351200, +0.0600000, +0.255900, +0.397100]
;Nage=n_elements(age_values)
;Nmetalicity=n_elements(metalicity_values)
;Nparam=Nage*Nmetalicity+2    ;+2 is for Amplitude and E(B-V)

;==== define parameter tags
IF keyword_set(paramtag) THEN BEGIN
	ISRF=dustem_plugin_phangs_stellar_continuum(paramtag=paramtag,paramdefault=paramdefault)
  ISRF=0
	GOTO,the_end
ENDIF

use_object_distance=1. ;MPc
use_object_thickness=1. ;kPc
use_omega_ratio=((use_object_thickness/2.)/(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 
use_factor=4.*!pi*1.e-20*1.e7*1.e4*use_omega_ratio

;stop
Inu_stars=dustem_plugin_phangs_stellar_continuum(key=key,val=val)
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