diff --git a/snsim/astrobj.py b/snsim/astrobj.py index 87190ca..9ecaa0b 100644 --- a/snsim/astrobj.py +++ b/snsim/astrobj.py @@ -302,6 +302,27 @@ def _set_model_par(self, model): model.set_source_peakmag(self._sim_par['mb'], 'bessellb', 'ab') self._sim_par['x0'] = model.get('x0') + + elif self._relation.lower() == 'salttrip_BS20': + # TODO : COMPLETE BS20 using dev_damiano + self._obj_attrs.extend(['alpha', 'beta', 'RV', 'Edust', 'x0', 'x1', 'c']) + self._sim_par['mb'] = self.SALTTripp( + M0, + self._sim_par['alpha'], + self._sim_par['beta'], + self._sim_par['RV'], + self._sim_par['Edust'] + self._sim_par['x1'], + self._sim_par['c']) + self.mu + + # Compute the x0 parameter + model.set( + x1=self._sim_par['x1'], + c=self._sim_par['c']) + + model.set_source_peakmag(self._sim_par['mb'], 'bessellb', 'ab') + self._sim_par['x0'] = model.get('x0') + else: # TODO - BC : Find a way to use lambda function for relation raise ValueError('Relation not available') @@ -309,8 +330,11 @@ def _set_model_par(self, model): @staticmethod def SALTTripp(M0, alpha, beta, x1, c): - return M0 + alpha * x1 - beta * c + return M0 - alpha * x1 + beta * c + @staticmethod + def SALTTrippBS20(M0, alpha, beta, RV, Edust, x1, c): + return M0 - alpha * x1 + beta * c + (RV + 1) * Edust class TimeSeries(AstrObj): """TimeSeries class. diff --git a/snsim/tests/test_astrobj.py b/snsim/tests/test_astrobj.py index a74e030..c21e39c 100644 --- a/snsim/tests/test_astrobj.py +++ b/snsim/tests/test_astrobj.py @@ -51,8 +51,8 @@ def setup_class(self): def test_tripp(self): mb = self.SNIa_Tripp.sim_par['M0'] + self.SNIa_Tripp.mu - mb += self.SNIa_Tripp.sim_par['alpha'] * self.SNIa_Tripp.sim_par['x1'] - mb += -self.SNIa_Tripp.sim_par['beta'] * self.SNIa_Tripp.sim_par['c'] + mb -= self.SNIa_Tripp.sim_par['alpha'] * self.SNIa_Tripp.sim_par['x1'] + mb += self.SNIa_Tripp.sim_par['beta'] * self.SNIa_Tripp.sim_par['c'] assert(self.SNIa_Tripp.mb == mb) def test_genflux(self): diff --git a/snsim/tests/test_geout.py b/snsim/tests/test_geout.py index ae88de6..d60330b 100644 --- a/snsim/tests/test_geout.py +++ b/snsim/tests/test_geout.py @@ -12,15 +12,5 @@ def test_compute_area(): area = geo_ut._compute_area(polygon) assert_almost_equal(area, 4 * np.pi) - -def test_compute_polygon(): - - # Regular polygon - corners = np.array([[[np.pi - 0.02, 0.02]], [[np.pi + 0.02, 0.02]] , - [[np.pi + 0.02, -0.02]], [[np.pi - 0.02, -0.02]]]) - - polygon = geo_ut._compute_polygon(corners) - - ra = np.random.uniform(0, 2 * np.pi, 10 - + \ No newline at end of file