From b38c6ebfdc89cbb8e1b1d7fa7c57e73ca6d122d7 Mon Sep 17 00:00:00 2001 From: dgegen Date: Tue, 24 Mar 2026 01:16:09 +0100 Subject: [PATCH 1/2] fix(RVFWHMmodel): use std::fixed in save_setup to preserve prior precision Without std::fixed, the default stream formatting uses 6 significant figures, which truncates large BJD-scale values (e.g. Tcprior bounds ~2458520.644 and ~2458520.656 both round to 2.45852e+06). This caused load_results to fail with "Uniform distribution must have lower < upper limits". Also removes the narrow precision(15)/precision(6) workaround around M0_epoch, which was a symptom of the same root cause. --- src/kima/RVFWHMmodel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/kima/RVFWHMmodel.cpp b/src/kima/RVFWHMmodel.cpp index 59368c7..c2e79f8 100644 --- a/src/kima/RVFWHMmodel.cpp +++ b/src/kima/RVFWHMmodel.cpp @@ -1130,7 +1130,7 @@ string RVFWHMmodel::description() const void RVFWHMmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; fout << "; " << timestamp() << endl << endl; @@ -1171,9 +1171,7 @@ void RVFWHMmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; From f0d530222035163c16e2c4b644b1c368f9cc909e Mon Sep 17 00:00:00 2001 From: dgegen Date: Tue, 24 Mar 2026 01:49:31 +0100 Subject: [PATCH 2/2] fix(models): set precision to 15 in save_setup for consistent output across all models Add `std::fixed` and `fout.precision(15)` globally in `save_setup` for all models that were missing it (BINARIESmodel, ETVmodel, GAIAmodel, GPmodel, OutlierRVmodel, RVFWHMRHKmodel, RVGAIAmodel, SPLEAFmodel, TRANSITmodel) and add `fout.precision(15)` to models that already had `std::fixed` but lacked explicit precision (ApodizedRVmodel, RVFWHMmodel, RVHGPMmodel, RVmodel). Also removes the narrow `precision(15)`/`precision(6)` workarounds around `M0_epoch` that were present in several files, as these are now superseded by the global setting. --- src/kima/ApodizedRVmodel.cpp | 1 + src/kima/BINARIESmodel.cpp | 5 ++--- src/kima/ETVmodel.cpp | 5 ++--- src/kima/GAIAmodel.cpp | 5 ++--- src/kima/GPmodel.cpp | 5 ++--- src/kima/OutlierRVmodel.cpp | 5 ++--- src/kima/RVFWHMRHKmodel.cpp | 5 ++--- src/kima/RVFWHMmodel.cpp | 1 + src/kima/RVGAIAmodel.cpp | 5 ++--- src/kima/RVHGPMmodel.cpp | 1 + src/kima/RVmodel.cpp | 1 + src/kima/SPLEAFmodel.cpp | 2 +- src/kima/TRANSITmodel.cpp | 5 ++--- 13 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/kima/ApodizedRVmodel.cpp b/src/kima/ApodizedRVmodel.cpp index 7c8601e..adc7133 100644 --- a/src/kima/ApodizedRVmodel.cpp +++ b/src/kima/ApodizedRVmodel.cpp @@ -947,6 +947,7 @@ string ApodizedRVmodel::description() const void ApodizedRVmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; diff --git a/src/kima/BINARIESmodel.cpp b/src/kima/BINARIESmodel.cpp index b24301b..5829780 100644 --- a/src/kima/BINARIESmodel.cpp +++ b/src/kima/BINARIESmodel.cpp @@ -1050,7 +1050,8 @@ string BINARIESmodel::description() const */ void BINARIESmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -1085,9 +1086,7 @@ void BINARIESmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/ETVmodel.cpp b/src/kima/ETVmodel.cpp index 9056e09..289d92f 100644 --- a/src/kima/ETVmodel.cpp +++ b/src/kima/ETVmodel.cpp @@ -422,7 +422,8 @@ string ETVmodel::description() const void ETVmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -445,8 +446,6 @@ void ETVmodel::save_setup() { fout << "skip: " << data._skip << endl; - fout.precision(12); - fout << endl; fout << "[priors.general]" << endl; diff --git a/src/kima/GAIAmodel.cpp b/src/kima/GAIAmodel.cpp index 31785a6..bd9bafd 100644 --- a/src/kima/GAIAmodel.cpp +++ b/src/kima/GAIAmodel.cpp @@ -653,7 +653,8 @@ string GAIAmodel::description() const */ void GAIAmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -680,9 +681,7 @@ void GAIAmodel::save_setup() { // fout << f << ","; // fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/GPmodel.cpp b/src/kima/GPmodel.cpp index e5bc0e8..cc2ca56 100644 --- a/src/kima/GPmodel.cpp +++ b/src/kima/GPmodel.cpp @@ -1104,7 +1104,8 @@ string GPmodel::description() const */ void GPmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -1145,9 +1146,7 @@ void GPmodel::save_setup() { fout << n << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/OutlierRVmodel.cpp b/src/kima/OutlierRVmodel.cpp index 2fd9065..a742938 100644 --- a/src/kima/OutlierRVmodel.cpp +++ b/src/kima/OutlierRVmodel.cpp @@ -670,7 +670,8 @@ string OutlierRVmodel::description() const */ void OutlierRVmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -702,9 +703,7 @@ void OutlierRVmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/RVFWHMRHKmodel.cpp b/src/kima/RVFWHMRHKmodel.cpp index 43c2f67..75d377b 100644 --- a/src/kima/RVFWHMRHKmodel.cpp +++ b/src/kima/RVFWHMRHKmodel.cpp @@ -1324,7 +1324,8 @@ string RVFWHMRHKmodel::description() const void RVFWHMRHKmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl; @@ -1364,9 +1365,7 @@ void RVFWHMRHKmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/RVFWHMmodel.cpp b/src/kima/RVFWHMmodel.cpp index c2e79f8..c6ba653 100644 --- a/src/kima/RVFWHMmodel.cpp +++ b/src/kima/RVFWHMmodel.cpp @@ -1131,6 +1131,7 @@ string RVFWHMmodel::description() const void RVFWHMmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; diff --git a/src/kima/RVGAIAmodel.cpp b/src/kima/RVGAIAmodel.cpp index 32f0a5c..38546ec 100644 --- a/src/kima/RVGAIAmodel.cpp +++ b/src/kima/RVGAIAmodel.cpp @@ -1041,7 +1041,8 @@ string RVGAIAmodel::description() const */ void RVGAIAmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -1081,9 +1082,7 @@ void RVGAIAmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << GAIA_data.M0_epoch << endl; - fout.precision(6); fout << endl; diff --git a/src/kima/RVHGPMmodel.cpp b/src/kima/RVHGPMmodel.cpp index 76a71c3..092a2c0 100644 --- a/src/kima/RVHGPMmodel.cpp +++ b/src/kima/RVHGPMmodel.cpp @@ -1033,6 +1033,7 @@ string RVHGPMmodel::description() const void RVHGPMmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; diff --git a/src/kima/RVmodel.cpp b/src/kima/RVmodel.cpp index ae0367f..efe80dd 100644 --- a/src/kima/RVmodel.cpp +++ b/src/kima/RVmodel.cpp @@ -956,6 +956,7 @@ string RVmodel::description() const void RVmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; diff --git a/src/kima/SPLEAFmodel.cpp b/src/kima/SPLEAFmodel.cpp index 63aceca..dddc39e 100644 --- a/src/kima/SPLEAFmodel.cpp +++ b/src/kima/SPLEAFmodel.cpp @@ -1147,7 +1147,7 @@ string SPLEAFmodel::description() const */ void SPLEAFmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; fout.precision(15); fout << "; " << timestamp() << endl << endl; diff --git a/src/kima/TRANSITmodel.cpp b/src/kima/TRANSITmodel.cpp index 1a02393..013dc1a 100644 --- a/src/kima/TRANSITmodel.cpp +++ b/src/kima/TRANSITmodel.cpp @@ -472,7 +472,8 @@ string TRANSITmodel::description() const */ void TRANSITmodel::save_setup() { std::fstream fout("kima_model_setup.txt", std::ios::out); - fout << std::boolalpha; + fout << std::boolalpha << std::fixed; + fout.precision(15); fout << "; " << timestamp() << endl << endl; @@ -502,9 +503,7 @@ void TRANSITmodel::save_setup() { fout << f << ","; fout << endl; - fout.precision(15); fout << "M0_epoch: " << data.M0_epoch << endl; - fout.precision(6); fout << endl;