ProSpectSED | R Documentation |
ProSpectSED
computes a fully attenuated and re-emitted SED model incompassing star light (for a number of different star formation history models), dust and AGN. ProSpectSEDlike
is an interface for computing likelihoods, and by extension is the workhorse code that allows model fitting using a number of techniques.
ProSpectSED(SFH = SFHfunc, z = 0.1, tau_birth = 1, tau_screen = 0.3,
tau_AGN = 1, pow_birth = -0.7, pow_screen = -0.7, pow_AGN = -0.7,
alpha_SF_birth = 1, alpha_SF_screen = 3, alpha_SF_AGN = 0,
AGNlum = 0, sparse = 5, speclib = NULL, Dale = NULL, AGN = NULL,
filtout = NULL, filters = "all", Dale_M2L_func = NULL, returnall = TRUE,
H0 = 67.8, OmegaM = 0.308, OmegaL = 1 - OmegaM, waveout = seq(2,
9.35, by = 0.01), ref, unimax = 1.38e+10, agemax = NULL,
LumDist_Mpc = NULL, addradio_SF = FALSE, addradio_AGN = FALSE,
Te_SF = 10000, ff_frac_SF = 0.1, ff_power_SF = -0.1, sy_power_SF = -0.8,
Te_AGN = 10000, ff_frac_AGN = 0.1, ff_power_AGN = -0.1,
sy_power_AGN = -0.8, AGNct = 60, AGNal = 4, AGNbe = -0.5,
AGNta = 1, AGNrm = 60, AGNan = 30, Eb = 0, L0 = 2175.8, LFWHM = 470,
IGMabsorb = 0, ...)
ProSpectSEDlike(parm = c(8,9,10,10,0,-0.5,0.2), Data)
SFH |
Function; the star formation history to use. Must be one of |
z |
Numeric scalar; cosmological redshift of the source. If the provided z = 0 then the returned fluxes will be absolute, i.e. absolute magnitudes if outtype='mag'. If z <= 0 then only luminosities are computed if filtout=NULL. If filters are provided via filtout then the Photom output returns Absolute AB magnitudes for convenience. |
tau_birth |
Numeric scalar; dust tau of birth clouds. Associated with sub 10 Myr star formation. See |
tau_screen |
Numeric scalar; dust tau of the dust screen. See |
tau_AGN |
Numeric scalar; dust tau of the AGN. See |
pow_birth |
Numeric scalar; power to further raise the dust attenuation of birth clouds. See |
pow_screen |
Numeric scalar; power to further raise the dust attenuation of the dust screen. See |
pow_AGN |
Numeric scalar; power to further raise the dust attenuation of the AGN torus. See |
alpha_SF_birth |
Numeric scalar; alpha slope of the birth cloud dust. Lower values mean hotter dust. See |
alpha_SF_screen |
Numeric scalar; alpha slope of the screen dust. Lower values mean hotter dust. See |
alpha_SF_AGN |
Numeric scalar; alpha slope of the AGN torus dust. Lower values mean hotter dust. See |
AGNlum |
Numeric scalar; AGN bolometric luminosity in erg/s. |
sparse |
Numeric scalar; amount of sparse sampling of the spectra to make. |
speclib |
Object; optional. Pass in the spectral library directly. Must be one of |
Dale |
Object or scalar logical; optional. Pass in the Dale dust library |
AGN |
Object; optional. Pass in the AGN template to use. Must be one of |
filtout |
Object; required. Pass in the photometric filters directly (either matrices of functions). If |
filters |
Character vector; names of filters to use. See |
Dale_M2L_func |
Function; if dust masses and luminosities are desired then the user should supply a function to convert alpha_SF to mass-to-light, e.g. |
returnall |
Logical; if true then returns all the various sub SEDs. See Details. If FALSE then code just returns photom_out (photometry in Jansky). |
H0 |
Numeric scalar; Hubble constant as defined at z=0 (default is H0=67.8 (km/s)/Mpc). |
OmegaM |
Numeric scalar; Omega Matter today (default is 0.308). |
OmegaL |
Numeric scalar; Omega Lambda today (default is for a flat Universe with OmegaL = 1 - OmegaM = 0.692). |
waveout |
Numeric vector; desired output log10 wavelength grid to use in Ang. Default covers typical range of galaxy SED data at a resolution good enough for broad band photometry. Spectroscopic work requires the resolution to be increase by a factor ~10. If emission=TRUE (to be passed down to |
ref |
The name of a reference cosmology to use, one of 137 / 737 / Planck / Planck13 / Planck15 / Planck18 / WMAP / WMAP9 / WMAP7 / WMAP5 / WMAP3 / WMAP1 / Millennium / GiggleZ. Planck = Planck18 and WMAP = WMAP9. The usage is case insensitive, so wmap9 is an allowed input. This overrides any other settings for H0, OmegaM and OmegaL. If OmegaR is missing from the reference set then it is inherited from the function input (0 by default). See |
unimax |
Numeric scalar; maximum allowed age of any stellar population relative to z=0 (i.e. today) in years. Any star formation that is older than this will be set to 0. Overridden by agemax if that is provided. |
agemax |
Numeric scalar; maximum allowed age of any stellar population relative to the redshift of the observed galaxy in years. Any star formation that is older than this will be set to 0. Overridden by unimax if provided. It is computational a bit faster to provide this since we do not need to compute a lookup time from the redshift. |
LumDist_Mpc |
Numeric scalar; Luminosity distance computed in units of cm. Default is NULL. The luminosity distance can be supplied for repeated computations when the redshift of the object is constant. This should be supplied using the "correct" cosmology (as near as possible), i.e. using H0 ~ 70 km/s/Mpc (not 100). |
addradio_SF |
Logical scalar; should free-free and synchrotron radio continuum linked to star-formation be computed and appended to the spectrum? If TRUE, emission range is controlled by waveout. Uses the |
Te_SF |
Numeric scalar; effective HII nebular plasma temperature in Kelvin used in |
ff_frac_SF |
Numeric scalar; free-free HII nebular plasma thermal radio emission contribution fraction at 1.4 GHz used in |
ff_power_SF |
Numeric scalar; power-law slope of the free-free nebular plasma thermal radio emission associated with star-formation used in |
sy_power_SF |
Numeric scalar; power-law slope of the synchrotron radio emission associated with star-formation used in |
addradio_AGN |
Logical; should separate free-free and synchrotron radio continuum associated with an AGN be added? Uses the |
Te_AGN |
Numeric scalar; effective HII nebular plasma temperature in Kelvin used in |
ff_frac_AGN |
Numeric scalar; free-free HII nebular plasma thermal radio emission contribution fraction at 1.4 GHz used in |
ff_power_AGN |
Numeric scalar; power-law slope of the free-free nebular plasma thermal radio emission associated with an AGN used in |
sy_power_AGN |
Numeric scalar; power-law slope of the synchrotron radio emission associated with an AGN used in |
AGNct |
Numeric scalar; opening angle of torus in degrees. |
AGNal |
Numeric scalar; gamma dust parameter. |
AGNbe |
Numeric scalar; Beta dust parameter. |
AGNta |
Numeric scalar; optical depth tau. |
AGNrm |
Numeric scalar; outer to inner torus radius ratio. |
AGNan |
Numeric scalar; angle of observation in degrees, where 0 is edge on with torus, and 90 is polar aligned. |
parm |
Numeric vector; arguments to be passed to |
Data |
Object; data object containing everything else needs. See Details. |
Eb |
Numeric scalar; Additional attenuation at the 2175.8 Ang dust bump. The default of 0 means this has no effect, MW is near 3.3, and typical galaxies are around Eb=1. |
L0 |
Numeric scalar; location of the 2175.8 Ang dust bump in Angstroms (probably do not adjust this). |
LFWHM |
Numeric scalar; width of the 2175.8 Ang dust bump in Angstroms (probably do not adjust this). |
IGMabsorb |
Numeric scalar; absorbing fraction for the intervening IGM. This should be thought of as absorption due to material between the galaxy of interest an the observer. This suppressing fraction is applied to wavelength in the Lyman regime (911.8 - 1215.7 Angstrom). Based on Songaila (2004) a resonable approximation for this is given by IGMabsorb = pnorm(z, mean=3.8, sd=1.2), meaning it is almost 0 (complete transmission) at low redshift and almost 1 (complete absorption) by redshift 8. |
... |
All further arguments are passed directly into SFH, so by this mechanism you can set function specific arguments that control the star formation history etc. |
This function allows full modelling of quite sophisticated star formation histories, dust attenuation and re-emission, as well as correctly attenuated AGN. It is useful directly, but it is also the workhorse function for the ProSpectSEDlike
function, that allows us to compute likelihoods against target data and fit models in a generic manner.
Some more info on the required Data list inputs:
Data.frame, required; 4 columns: filter [band name], cenwave [central wave, Ang], flux [Jy], fluxerr [Jy].
Function, required; the star formation history function to use. Must be one of SFHfunc
or SFHburst
.
List, optional; named arguments and values that are passed directly into ProSpectSED
. Arguments that are not matched in ProSpectSED
are passed directly onto SFH, so by this mechanism you can set function specific arguments that control the star formation history, i.e. this allows you to set values to non default even when not fitting these parameters. You almost certainly want to at least specify Data$arglist$z (the object redshift) since this almost always differ from the fiducial default of z=0.1.
List, optional but recommended; pass in the spectral library directly. Must be one of BC03lr
, BC03hr
, EMILES
.
List, optional but recommended; pass in the Dale dust library directly (should be one of Dale_NormTot, Dale_NormSFR otherwise will run, but not work correctly). If set to FALSE then there will be no FIR re-emission.
Data.frame, optional; pass in the AGN template to use. Must be one of AGN_UnOb
or AGN_UnOb_Sparse
.
List; required. Pass in the photometric filters directly. If filters
is a vector of filter names, this can be achieved efficiently with a command like: filtout=foreach(i = filters)%do%getfilt(i) or filtout=foreach(i = filters)%do%approxfun(getfilt(i)), where the latter will be faster (see getfilt
).
Character scalar, required; one of 'optim', 'LD' or 'check'. See Value for full information on what is output in each case. If missing it is set to 'optim'.
Character scalar, required; specifies the type of likelihood. One of 'norm' (Normal), 'st' (Student-T) or 'chisq' (Chi-Square). If not one of these then all useful output is returned in a list. If missing it is set to 'st'.
Character vector, required; correctly named and position matched parameters for fitting. Must match length of parm in ProSpectSEDlike
, and elements should correctly describe the respective values.
Logical vector, optional; match length of parm in ProSpectSEDlike
, and elements should say which values should be raised to the power 10 when fitting. This is useful since scale parameters are better fit in log space, so Data$logged=TRUE for those elements. If missing assumes all parameters are to be fit in linear space.
Function, optional; a prior function that takes in the parm vector and returns a log-likelihood to be added to LL to form LP. If not provided then it is ignored internally. The user can expect the vector parm to have elements specified by Data$parm.names for ease.
List, optional; has elements lo and hi which if provided must be the same length as parm in ProSpectSEDlike
. These specify the lower and upper limits in the same linear/log space as parm, i.e. set lo to -1 if you do not want to logged unit to go below 0.1.
Function, optional; a constraints function that takes in theparm vector and modifies it as required, updating with the new parm which is passed out. Using this you can control physical relationships between certain parameters if required. Data$intervals is passed after this, and always over-ride the constraints if there is a conflict. The user can expect the vector parm to have elements specified by Data$parm.names for ease.
Character vector, optional; "LP" (log posterior), "masstot" (total stellar mass formed), "massrem" (total stellar mass remaining) and "SFRburst" (stars formed in the most recent 1e8 years). For dust can contain "dustmass.birth", "dustmass.screen", "dustmass.AGN", "dustmass.total" (dust masses in birth cloud, screen, AGN and total), "dustlum.birth", "dustlum.screen", "dustlum.AGN", "dustlum.total" (dust luminosities in birth cloud, screen, AGN and total). You can also monitor fluxes via "flux.XXX", where XXX specifies the name of the band as given in Data$flux$filter. Only named monitored variables are returned, in the order specified.
Logical, optional; should the automatic wavelength grid be evenly log spaced? If TRUE it will be evenly log spaced, if FALSE it will be evenly linearly spaced. Passed into specReBin
. Say you have a wavelength 10 and 20, a linear bin would be at 15 and a log bin would be at 14.1.
Logical, otional; should rough interpolation be used to rebin the spectrum (default is TRUE) or should full be pixel integration be done (FALSE). Passed into specReBin
.
Logical, optional; should verbose messages be shown. If missing it is set to TRUE.
For ProSpectSED
:
If returnall=FALSE then we get a vector containing the Photom output, which is usually the photometry in Jansky (special case when z <= 0, where this is instead the Absolute AB magnitudes for convenience).
If returnall=TRUE, then we get a list containing:
Photom |
Vector; photometry in Jansky. If z <= 0 and filters are provided via filtout then the Photom output returns Absolute AB magnitudes for convenience (i.e. source is placed at a distance of 10 pc). |
FinalFlux |
Two column data.frame; Wavelength in Ang (wave), Flux density in Jansky (flux) |
FinalLum |
Two column data.frame; Wavelength in Ang (wave), Total SED luminosity in Lsol / Ang (lum) |
StarsAtten |
Two column data.frame; Wavelength in Ang (wave), Attenuated stellar SED luminosity in Lsol / Ang (lum) |
StarsUnAtten |
Two column data.frame; Wavelength in Ang (wave), Unattenuated stellar SED luminosity in Lsol / Ang (lum) |
DustEmit |
Two column data.frame; Wavelength in Ang (wave), Re-emitted stellar dust SED luminosity in Lsol / Ang (lum) |
AGN |
Two column data.frame; Wavelength in Ang (wave), Attenuated and re-emitted AGN SED luminosity in Lsol / Ang (lum) |
Stars |
List; the full output of the relevant SFH function used. See |
dustmass |
Numeric vector; contains dust mass for the birth cloud, screen, AGN and total in Msol (requires Dale_M2L_func) |
dustlum |
Numeric vector; contains dust luminosities for the birth cloud, screen, AGN and total in Lsol (requires Dale_M2L_func) |
call |
The original function call. |
z |
Numeric scalar; the input redshift. |
filtout |
List; the filtout list used. |
filters |
List; the filters list used. |
cosmo |
List; the input 'H0', 'OmegaM' and 'OmegaL'. |
For ProSpectSEDlike
:
Output depends on the flag for Data$fit, where it can be one of 'optim' (or 'CMA'), 'LD' (or 'LA'), or 'check'.
The 'optim' output returns just the log-posterior value (LP).
The 'LD' output returns the full structure required for LaplacesDemon
and LaplaceApproximation
and should be set as such when using those optimisers.
The 'check' output return all the outputs for LaplacesDemon
and LaplaceApproximation
but additionally the full output of ProSpectSED
with returnall=TRUE set as list item 'SEDout', and the input Data object as list item 'Data'.
In the last case of Data$fit='check' it will be returned with class 'ProSpectSEDlike', which allows you to create a quick diagnostic plot via the plot
method.
Aaron Robotham
Robotham et al, 2020, MNRAS, 495, 905
Songaila, 2004, AJ, 127, 2598
SFH
, magABcalc
, dustmass
, optim
data('BC03lr')
data('Dale_NormTot')
data('AGN_UnOb_Sparse')
data('Dale_M2L_func')
filters=c('FUV_GALEX', 'NUV_GALEX', 'u_SDSS', 'g_SDSS', 'r_SDSS', 'i_SDSS', 'Z_VISTA',
'Y_VISTA', 'J_VISTA', 'H_VISTA', 'K_VISTA', 'W1_WISE' , 'W2_WISE', 'W3_WISE', 'W4_WISE',
'P100_Herschel', 'P160_Herschel', 'S250_Herschel' , 'S350_Herschel', 'S500_Herschel')
filtout={}
for(i in filters){filtout=c(filtout,list(approxfun(getfilt(i))))}
#for(i in filters){filtout=c(filtout,list(getfilt(i)))} #This works too, but slower!
#Try playing around with the below to see what impact different AGN, dust etc have:
testSED=ProSpectSED(AGNlum=1e43, tau_birth=1, tau_screen=0.3, tau_AGN=2,
alpha_SF_birth=1, alpha_SF_screen=3, alpha_SF_AGN=0, speclib=BC03lr, Dale=Dale_NormTot,
AGN=AGN_UnOb_Sparse, filtout=filtout, Dale_M2L_func=Dale_M2L_func, returnall=TRUE)
plot(testSED$FinalLum, log='xy', xlim=c(1e2,1e7), ylim=c(1e2,1e7),
xlab='Wavelength (Ang)', ylab='Lum (Lsol/Ang)', type='l', lwd=5)
lines(testSED$StarsUnAtten, col='blue', lty=2)
lines(testSED$StarsAtten, col='green')
lines(testSED$DustEmit, col='brown')
lines(testSED$AGN, col='purple')
legend('topright',
legend=c('Total Lum', 'Star Un-Atten', 'Stars Atten', 'Dust Emit', 'AGN'),
col=c('black', 'blue', 'darkgreen', 'brown', 'purple'),
lty=c(1,2,1,1,1),
lwd=c(5,1,1,1,1)
)
# or easier:
plot(testSED)
#An example of a more physical SFH and ZH:
testSED2 = ProSpectSED(massfunc = massfunc_snorm, Z=Zfunc_massmap_box)
plot(testSED2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.