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

Move most of the computation to _init_code() to make the sfhdelayed module...

Move most of the computation to _init_code() to make the sfhdelayed module consister with other modules.
parent 91ae47f6
......@@ -10,6 +10,7 @@
- The output files providing estimates of the physical properties are now generated both in the form of text and FITS files. (Médéric Boquien)
- When using the dustatt_calzleit module, choosing ẟ≠0 leads to an effective E(B-V) different from the one set by the user. Now the E(B-V) will always correspond to the one specified by the user. This means that at fixed E(B-V), A(V) depends on ẟ. (Médéric Boquien)
- The pcigale-mock tool has been merged into pcigale-plots; the mock plots can be obtained with the "mock" command.
- The sfhdelayed module is now initialised with _init_code() to be consistent with the way things are done in other modules. This should give a slight speedup under some sircumstances too. (Médéric Boquien)
### Fixed
- To estimate parameters in log, pcigale determines which variables end with the "_log" string and removed it to compute the models. However in some circumstances, it was overzealous. This has been fixed. (Médéric Boquien)
......@@ -52,40 +52,41 @@ class SFHDelayed(CreationModule):
def process(self, sed):
sed : pcigale.sed.SED object
tau_main = float(self.parameters["tau_main"])
def _init_code(self):
self.tau_main = float(self.parameters["tau_main"])
age = int(self.parameters["age"])
sfr_A = int(self.parameters["sfr_A"])
normalise = (self.parameters["normalise"].lower() == "true")
# Time grid and age. If needed, the age is rounded to the inferior Myr
time_grid = np.arange(1, age + 1)
# Main SFR
sfr = time_grid / tau_main**2 * np.exp(-time_grid / tau_main)
# Time grid and SFR
self.time_grid = np.arange(age) = self.time_grid * np.exp(-self.time_grid / self.tau_main) / \
# Compute the galaxy mass and normalise the SFH to 1 solar mass
# produced if asked to.
sfr_integrated = np.sum(sfr) * 1e6
self.sfr_integrated = np.sum( * 1e6
if normalise:
sfr /= sfr_integrated
sfr_integrated = 1. /= self.sfr_integrated
self.sfr_integrated = 1.
sfr *= sfr_A
sfr_integrated *= sfr_A *= sfr_A
self.sfr_integrated *= sfr_A
def process(self, sed):
sed : pcigale.sed.SED object
sed.add_module(, self.parameters)
# Add the sfh and the output parameters to the SED.
sed.sfh = (time_grid, sfr)
sed.add_info("sfh.integrated", sfr_integrated, True)
sed.add_info("sfh.tau_main", tau_main)
sed.sfh = (self.time_grid,
sed.add_info("sfh.integrated", self.sfr_integrated, True)
sed.add_info("sfh.tau_main", self.tau_main)
# CreationModule to be returned by get_module
Module = SFHDelayed
Supports Markdown
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