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

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 @@ ...@@ -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) - 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) - 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 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 ### 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) - 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): ...@@ -52,40 +52,41 @@ class SFHDelayed(CreationModule):
)) ))
]) ])
def process(self, sed): def _init_code(self):
""" self.tau_main = float(self.parameters["tau_main"])
Parameters
----------
sed : pcigale.sed.SED object
"""
tau_main = float(self.parameters["tau_main"])
age = int(self.parameters["age"]) age = int(self.parameters["age"])
sfr_A = int(self.parameters["sfr_A"]) sfr_A = int(self.parameters["sfr_A"])
normalise = (self.parameters["normalise"].lower() == "true") normalise = (self.parameters["normalise"].lower() == "true")
# Time grid and age. If needed, the age is rounded to the inferior Myr # Time grid and SFR
time_grid = np.arange(1, age + 1) self.time_grid = np.arange(age)
self.sfr = self.time_grid * np.exp(-self.time_grid / self.tau_main) / \
# Main SFR self.tau_main**2
sfr = time_grid / tau_main**2 * np.exp(-time_grid / tau_main)
# Compute the galaxy mass and normalise the SFH to 1 solar mass # Compute the galaxy mass and normalise the SFH to 1 solar mass
# produced if asked to. # produced if asked to.
sfr_integrated = np.sum(sfr) * 1e6 self.sfr_integrated = np.sum(self.sfr) * 1e6
if normalise: if normalise:
sfr /= sfr_integrated self.sfr /= self.sfr_integrated
sfr_integrated = 1. self.sfr_integrated = 1.
else: else:
sfr *= sfr_A self.sfr *= sfr_A
sfr_integrated *= sfr_A self.sfr_integrated *= sfr_A
def process(self, sed):
"""
Parameters
----------
sed : pcigale.sed.SED object
"""
sed.add_module(self.name, self.parameters) sed.add_module(self.name, self.parameters)
# Add the sfh and the output parameters to the SED. # Add the sfh and the output parameters to the SED.
sed.sfh = (time_grid, sfr) sed.sfh = (self.time_grid, self.sfr)
sed.add_info("sfh.integrated", sfr_integrated, True) sed.add_info("sfh.integrated", self.sfr_integrated, True)
sed.add_info("sfh.tau_main", tau_main) sed.add_info("sfh.tau_main", self.tau_main)
# CreationModule to be returned by get_module # CreationModule to be returned by get_module
Module = SFHDelayed Module = SFHDelayed
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