Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _compute_csp(self):
self._update_params()
NSPEC = driver.get_nspec()
NTFULL = driver.get_ntfull()
driver.compute_zdep(NSPEC, NTFULL, self._zcontinuous)
self._stats = None
If true, return spectra in units of :math:`L_\odot/\AA`, otherwise
:math:`L_\odot/\mathrm{Hz}`
:returns spec:
The SSP spectrum, interpolated to zpos and tpos.
:returns mass:
The stellar mass of the SSP at tpos.
:returns lbol:
The bolometric luminosity of the returned SSP.
"""
if self.params.dirtiness == 2:
self._update_params()
NSPEC = driver.get_nspec()
spec, mass, lbol = np.zeros(NSPEC), np.zeros(1), np.zeros(1)
logt_yrs = np.log10(tpos * 1e9)
driver.interp_ssp(zpos, logt_yrs, spec, mass, lbol)
if peraa:
wavegrid = self.wavelengths
factor = 3e18 / wavegrid ** 2
spec *= factor
return spec, mass, lbol
print("Warning: redshift is different than 'zred'.")
else:
zr = redshift
self.params["tage"] = tage
if zmet is not None:
self.params["zmet"] = zmet
if self.params.dirty:
self._compute_csp()
if tage > 0.0:
NTFULL = 1
else:
NTFULL = driver.get_ntfull()
NBANDS = driver.get_nbands()
NSPEC = driver.get_nspec()
band_array = np.ones(NBANDS, dtype=bool)
if bands is not None:
user_sorted_inds = np.array([FILTERS[band.lower()].index
for band in bands])
band_array[np.array([i not in user_sorted_inds
for i in range(NBANDS)],
dtype=bool)] = False
inds = np.array(band_array, dtype=int)
mags = driver.get_mags(NSPEC, NTFULL, zr, inds)
if tage > 0.0:
if bands is not None:
return mags[0, user_sorted_inds]
else:
return mags[0, :]
def wavelengths(self):
"""The wavelength scale for the computed spectra, in :math:`\AA`
"""
if self._wavelengths is None:
NSPEC = driver.get_nspec()
self._wavelengths = driver.get_lambda(NSPEC)
return self._wavelengths
:math:`L_\odot/\mathrm{Hz}`
:returns spec:
The spectra of the SSPs, having shape (nspec, ntfull, nz).
:returns mass:
The mass of the SSPs, having shape (ntfull, nz).
:returns lbol:
The bolometric luminosity of the SSPs, having shape (ntfull, nz).
"""
if (self.params.dirtiness == 2) and update:
self._update_params()
NSPEC = driver.get_nspec()
NTFULL = driver.get_ntfull()
NZ = driver.get_nz()
spec = np.zeros([NSPEC, NTFULL, NZ], order='F')
mass = np.zeros([NTFULL, NZ], order='F')
lbol = np.zeros([NTFULL, NZ], order='F')
driver.get_ssp_spec(spec, mass, lbol)
if peraa:
wavegrid = self.wavelengths
factor = 3e18 / wavegrid ** 2
spec *= factor[:, None, None]
return spec, mass, lbol
:param mdot:
The log of the mass loss rate.
:param weight:
The IMF weight
:returns outspec:
The spectrum of the star, in :math:`L_\odot/\mathrm{Hz}`
"""
if zmet is not None:
self.params["zmet"] = zmet
if self.params.dirty:
self._update_params()
NSPEC = driver.get_nspec()
outspec = np.zeros(NSPEC)
driver.stellar_spectrum(mact, logt, lbol, logg, phase,
comp, mdot, weight, outspec)
if peraa:
wavegrid = self.wavelengths
factor = 3e18 / wavegrid ** 2
outspec *= factor
return outspec
"""
self.params["tage"] = tage
if zmet is not None:
self.params["zmet"] = zmet
if self.params.dirty:
self._compute_csp()
wavegrid = self.wavelengths
if peraa:
factor = 3e18 / wavegrid ** 2
else:
factor = np.ones_like(wavegrid)
NSPEC = driver.get_nspec()
if (tage > 0.0) or (tage == -99):
return wavegrid, driver.get_spec(NSPEC, 1)[0] * factor
NTFULL = driver.get_ntfull()
return wavegrid, driver.get_spec(NSPEC, NTFULL) * factor[None, :]