diff --git a/python/cclassy.pxd b/python/cclassy.pxd index 8cc9086e..945a165e 100644 --- a/python/cclassy.pxd +++ b/python/cclassy.pxd @@ -60,6 +60,12 @@ cdef extern from "class.h": double w0_fld double wa_fld double cs2_fld + short shooting_failed + int parameters_size_smg + int parameters_2_size_smg + double * parameters_smg + double * parameters_2_smg + int tuning_index_smg double Omega0_ur double Omega0_dcdmdr double Omega0_scf diff --git a/python/classy.pyx b/python/classy.pyx index 8e57a5f3..6438840b 100644 --- a/python/classy.pyx +++ b/python/classy.pyx @@ -1721,11 +1721,35 @@ cdef class Class: value = self.sp.sigma8 elif name == 'sigma8_cb': value = self.sp.sigma8_cb + elif name == 'Omega0_smg' or name == 'Omega_smg': + value = self.Omega0_smg() + elif 'parameters_smg_real' in name: + value = self.__MontePython_ask_for_array_component(name, self.ba.parameters_smg, self.ba.parameters_size_smg) + elif 'parameters_2_smg_real' in name: + value = self.__MontePython_ask_for_array_component(name, self.ba.parameters_2_smg, self.ba.parameters_2_size_smg) + elif name == 'tuning_parameter': + value = self.ba.parameters_smg[self.ba.tuning_index_smg] else: raise CosmoSevereError("%s was not recognized as a derived parameter" % name) derived[name] = value return derived + cdef __MontePython_ask_for_array_component(self, name, double * carray, carray_size): + + try: + index = int(name.split('_')[-1]) + except: + print "Index not given or not an interger: printing the whole array" + array = [] + for i in range(carray_size): + array.append(carray[i]) + return array + + if index <= carray_size: + return carray[index-1] + else: + raise CosmoSevereError("%s index is greater than array length" % name) + def nonlinear_scale(self, np.ndarray[DTYPE_t,ndim=1] z, int z_size): """ nonlinear_scale(z, z_size) diff --git a/source/background.c b/source/background.c index 465e1478..6c68e5d3 100755 --- a/source/background.c +++ b/source/background.c @@ -674,7 +674,7 @@ int background_init( /** - if shooting failed during input, catch the error here */ class_test_except(pba->shooting_failed == _TRUE_, pba->error_message, - background_free(pba), + background_free_input(pba), "Shooting failed, try optimising input_get_guess(). Error message:\n\n%s", pba->shooting_error); @@ -1781,7 +1781,7 @@ int background_solve( class_test_except((tau_end-tau_start)/tau_start < ppr->smallest_allowed_variation, pba->error_message, - gt_free(&gTable);cleanup_generic_integrator(&gi);background_free(pba);free(pvecback_integration);free(pvecback), + gt_free(&gTable);cleanup_generic_integrator(&gi);background_free_input(pba);free(pvecback_integration);free(pvecback), "integration step: relative change in time =%e < machine precision : leads either to numerical error or infinite loop",(tau_end-tau_start)/tau_start); /* -> save data in growTable */