Commit 1e9f2b0a authored by Yannick Roehlly's avatar Yannick Roehlly

Make SFH normalisation optional in sfhfromfile

In the sfhfromfile module, make the SFH normalisation to 1 solar mass
produced at the given age optional. When using pcigale to simulate SEDs,
one may not want this normalisation to happend.

Such SEDs should not be stored in the database (but SEDs made using
sfhfromfile should not anyway be stored in the database). We will have
to make the SED storing optional in the warehouse.
parent 92bc6f12
......@@ -10,6 +10,10 @@ less than the age of the Universe at observation redshift.
** TODO SED serialisation.
Code SED serialisation to store them in a database without pickling the whole
object.
** TODO Make the saving of SED to database optional
When using the sfhfromfile module, we don't want to save the SED to the
database (maybe unless we save to memory), especially when the SFH is not
normalised. Make this saving optional in the warehouse.
** DONE Enhance the management of array parameters.
CLOSED: [2013-09-17 mar. 22:14]
When a parameter is an array (like the filters for which the attenuation is
......
......@@ -38,6 +38,11 @@ class Module(common.SEDCreationModule):
"integer",
"Age [Myr] where each SFH will be looked at.",
None
)),
("normalise", (
"boolean",
"Normalise the SFH to one solar mass produced at the given age.",
"True"
))
])
......@@ -62,13 +67,15 @@ class Module(common.SEDCreationModule):
sfr = table[sfr_column_name]
age = int(self.parameters['age'])
normalise = (self.parameters["normalise"].lower() == "true")
# We cut the SFH to the desired age.
sfr = sfr[time_grid <= age]
time_grid = time_grid[time_grid <= age]
# The we normalise it to 1 solar mass produced.
sfr = sfr / np.trapz(sfr * 1.e6, time_grid)
# Normalise the SFH to 1 solar mass produced if asked to.
if normalise:
sfr = sfr / np.trapz(sfr * 1.e6, time_grid)
sed.add_module(self.name, self.parameters)
sed.sfh = (time_grid, sfr)
......
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