added flexibility

This commit is contained in:
Dominik Demuth
2024-11-28 14:50:26 +01:00
parent 1c8befac3f
commit d844aac0e8
16 changed files with 121 additions and 52 deletions

View File

@@ -193,3 +193,33 @@ void save_data_to_file(
}
}
}
void save_data_to_file(
const std::string& resulttype,
const std::string& motiontype,
const std::string& disttype,
const std::vector<double>& x,
const std::vector<double>& y,
std::unordered_map<std::string, double>& optional
) {
// make file name
std::ostringstream datafile_name;
datafile_name << resulttype << "_" << motiontype << "_" << disttype;
datafile_name << std::setprecision(6) << std::scientific;
for (const auto& [key, value]: optional) {
datafile_name << "_" << key << "=" << value;
}
datafile_name << ".dat";
{
// write data to file, columns are secondary axis (echo delay, evolution times)
std::string datafile = datafile_name.str();
std::ofstream filestream(datafile, std::ios::out);
// write values to file
auto size = x.size();
for (unsigned int i = 0; i < size; i++) {
filestream << x[i] << "\t" << y[i] << "\n";
}
}
}