Commit dfe7d37f authored by Médéric Boquien's avatar Médéric Boquien

Fix the interpretation of booleans when using a parameters file, which bypasses type checks.

parent b487455e
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
- Internally the luminosity distance was erroneously stored in Mpc rather than in m for non-zero redshifts. This has now been standardised to m. (Médéric Boquien) - Internally the luminosity distance was erroneously stored in Mpc rather than in m for non-zero redshifts. This has now been standardised to m. (Médéric Boquien)
- As the best-fit properties are computed at the exact observed redshift, correct the scaling factor as it is computed at the grid redshift. This corrects for slight offsets on the best-fit properties when the input redshift has more decimals than the grid redshift. (Médéric Boquien) - As the best-fit properties are computed at the exact observed redshift, correct the scaling factor as it is computed at the grid redshift. This corrects for slight offsets on the best-fit properties when the input redshift has more decimals than the grid redshift. (Médéric Boquien)
- Fix the pip install by making pcigale.managers discoverable. (Yannick Roehlly) - Fix the pip install by making pcigale.managers discoverable. (Yannick Roehlly)
- When using a parameters file, Boolean values were not correctly interpreted. (Médéric Boquien, reported by Eric Martínez, INAOE)
### Optimised ### Optimised
- Slight speedup of the computation of the likelihood from the χ² (Médéric Boquien) - Slight speedup of the computation of the likelihood from the χ² (Médéric Boquien)
......
...@@ -64,7 +64,10 @@ class MBB(SedModule): ...@@ -64,7 +64,10 @@ class MBB(SedModule):
self.epsilon = float(self.parameters["epsilon_mbb"]) self.epsilon = float(self.parameters["epsilon_mbb"])
self.T = float(self.parameters["t_mbb"]) self.T = float(self.parameters["t_mbb"])
self.beta = float(self.parameters["beta_mbb"]) self.beta = float(self.parameters["beta_mbb"])
self.energy_balance = bool(self.parameters["energy_balance"]) if type(self.parameters["energy_balance"]) is str:
self.energy_balance = self.parameters["energy_balance"].lower() == 'true'
else:
self.energy_balance = bool(self.parameters["energy_balance"])
if self.epsilon < 0.: if self.epsilon < 0.:
raise Exception("Error, epsilon_mbb must be ≥ 0.") raise Exception("Error, epsilon_mbb must be ≥ 0.")
......
...@@ -95,7 +95,10 @@ class NebularEmission(SedModule): ...@@ -95,7 +95,10 @@ class NebularEmission(SedModule):
self.fesc = float(self.parameters['f_esc']) self.fesc = float(self.parameters['f_esc'])
self.fdust = float(self.parameters['f_dust']) self.fdust = float(self.parameters['f_dust'])
self.lines_width = float(self.parameters['lines_width']) self.lines_width = float(self.parameters['lines_width'])
self.emission = bool(self.parameters["emission"]) if type(self.parameters["emission"]) is str:
self.emission = self.parameters["emission"].lower() == 'true'
else:
self.emission = bool(self.parameters["emission"])
if self.fesc < 0. or self.fesc > 1: if self.fesc < 0. or self.fesc > 1:
raise Exception("Escape fraction must be between 0 and 1") raise Exception("Escape fraction must be between 0 and 1")
......
...@@ -73,7 +73,10 @@ class Sfh2Exp(SedModule): ...@@ -73,7 +73,10 @@ class Sfh2Exp(SedModule):
self.burst_age = int(self.parameters["burst_age"]) self.burst_age = int(self.parameters["burst_age"])
age = int(self.parameters["age"]) age = int(self.parameters["age"])
sfr_0 = float(self.parameters["sfr_0"]) sfr_0 = float(self.parameters["sfr_0"])
normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
# Time grid and age. If needed, the age is rounded to the inferior Myr # Time grid and age. If needed, the age is rounded to the inferior Myr
time_grid = np.arange(age) time_grid = np.arange(age)
......
...@@ -63,7 +63,10 @@ class SfhBuat08(SedModule): ...@@ -63,7 +63,10 @@ class SfhBuat08(SedModule):
def _init_code(self): def _init_code(self):
self.velocity = float(self.parameters["velocity"]) self.velocity = float(self.parameters["velocity"])
self.age = int(self.parameters["age"]) self.age = int(self.parameters["age"])
normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
# Time grid and age. If needed, the age is rounded to the inferior Myr # Time grid and age. If needed, the age is rounded to the inferior Myr
time_grid = np.arange(self.age) time_grid = np.arange(self.age)
......
...@@ -52,7 +52,10 @@ class SfhQuenchSmooth(SedModule): ...@@ -52,7 +52,10 @@ class SfhQuenchSmooth(SedModule):
def _init_code(self): def _init_code(self):
self.quenching_age = int(self.parameters["quenching_time"]) self.quenching_age = int(self.parameters["quenching_time"])
self.quenching_factor = float(self.parameters["quenching_factor"]) self.quenching_factor = float(self.parameters["quenching_factor"])
self.normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
def process(self, sed): def process(self, sed):
""" """
......
...@@ -52,7 +52,10 @@ class SfhQuenchTrunk(SedModule): ...@@ -52,7 +52,10 @@ class SfhQuenchTrunk(SedModule):
def _init_code(self): def _init_code(self):
self.quenching_age = int(self.parameters["quenching_age"]) self.quenching_age = int(self.parameters["quenching_age"])
self.quenching_factor = float(self.parameters["quenching_factor"]) self.quenching_factor = float(self.parameters["quenching_factor"])
self.normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
def process(self, sed): def process(self, sed):
""" """
......
...@@ -81,7 +81,10 @@ class SFHDelayed(SedModule): ...@@ -81,7 +81,10 @@ class SFHDelayed(SedModule):
self.age_burst = int(self.parameters["age_burst"]) self.age_burst = int(self.parameters["age_burst"])
self.f_burst = float(self.parameters["f_burst"]) self.f_burst = float(self.parameters["f_burst"])
sfr_A = float(self.parameters["sfr_A"]) sfr_A = float(self.parameters["sfr_A"])
normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
# Time grid for each component # Time grid for each component
t = np.arange(self.age_main) t = np.arange(self.age_main)
......
...@@ -76,7 +76,10 @@ class SFHDelayedBQ(SedModule): ...@@ -76,7 +76,10 @@ class SFHDelayedBQ(SedModule):
self.age_bq = int(self.parameters["age_bq"]) self.age_bq = int(self.parameters["age_bq"])
self.r_sfr = float(self.parameters["r_sfr"]) self.r_sfr = float(self.parameters["r_sfr"])
sfr_A = float(self.parameters["sfr_A"]) sfr_A = float(self.parameters["sfr_A"])
normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
# Delayed SFH # Delayed SFH
t = np.arange(self.age_main) t = np.arange(self.age_main)
......
...@@ -59,9 +59,12 @@ class SfhFromFile(SedModule): ...@@ -59,9 +59,12 @@ class SfhFromFile(SedModule):
def _init_code(self): def _init_code(self):
filename = self.parameters['filename'] filename = self.parameters['filename']
normalise = bool(self.parameters["normalise"])
age = int(self.parameters['age']) age = int(self.parameters['age'])
self.sfr_column_number = int(self.parameters['sfr_column']) self.sfr_column_number = int(self.parameters['sfr_column'])
if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
table = read_table(filename) table = read_table(filename)
self.sfr = table.columns[self.sfr_column_number].data.astype(np.float) self.sfr = table.columns[self.sfr_column_number].data.astype(np.float)
......
...@@ -73,7 +73,10 @@ class SfhPeriodic(SedModule): ...@@ -73,7 +73,10 @@ class SfhPeriodic(SedModule):
self.tau_bursts = float(self.parameters["tau_bursts"]) self.tau_bursts = float(self.parameters["tau_bursts"])
age = int(self.parameters["age"]) age = int(self.parameters["age"])
sfr_A = float(self.parameters["sfr_A"]) sfr_A = float(self.parameters["sfr_A"])
normalise = bool(self.parameters["normalise"]) if type(self.parameters["normalise"]) is str:
normalise = self.parameters["normalise"].lower() == 'true'
else:
normalise = bool(self.parameters["normalise"])
time_grid = np.arange(0, age) time_grid = np.arange(0, age)
self.sfr = np.zeros_like(time_grid, dtype=np.float) self.sfr = np.zeros_like(time_grid, dtype=np.float)
......
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