Commit a59a38bf authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Computing the luminosity each time we integrate in a filter (for instance) is...

Computing the luminosity each time we integrate in a filter (for instance) is not efficient. As the luminosity is in effect modified in only one place (add_contribution), let's just compute it manually each we add a component. This yields a ~10% improvement.
parent 08ee2b85
......@@ -62,6 +62,7 @@ class SED(object):
self.modules = []
self.wavelength_grid = None
self.contribution_names = []
self.luminosity = None
self.luminosities = None = OrderedDict()
self.mass_proportional_info = []
......@@ -114,17 +115,6 @@ class SED(object):
def luminosities(self, value):
self._luminosities = value
def luminosity(self):
"""Total luminosity of the SED
Return the total luminosity density vector, i.e. the sum of all the
contributions in W/nm.
if self._luminosities is None:
return None
return self._luminosities.sum(0)
def fnu(self):
......@@ -221,8 +211,9 @@ class SED(object):
# If the SED luminosity table is empty, then there is nothing to
# compute.
if self.luminosities is None:
if self.luminosity is None:
self.wavelength_grid = np.copy(results_wavelengths)
self.luminosity = np.copy(results_lumin)
self.luminosities = np.copy(results_lumin)
# If the added luminosity contribution changes the SED wavelength
......@@ -249,9 +240,11 @@ class SED(object):
self.wavelength_grid = new_wavelength_grid
self.luminosities = np.vstack((new_luminosities, interp_lumin))
self.luminosity = self.luminosities.sum(0)
self.luminosities = np.vstack((self.luminosities,
self.luminosity += results_lumin
def get_lumin_contribution(self, name):
"""Get the luminosity vector of a given contribution
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment