change saving
This commit is contained in:
@@ -7,11 +7,15 @@
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
#include <iomanip>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
#include "../motions/base.h"
|
||||
#include "../times/base.h"
|
||||
|
||||
|
||||
class Motion;
|
||||
|
||||
std::pair<std::string, double> get_optional_parameter(std::vector<std::string>::const_iterator &it) {
|
||||
std::string stripped_arg;
|
||||
@@ -124,16 +128,30 @@ std::unordered_map<std::string, double> read_parameter(const std::filesystem::pa
|
||||
}
|
||||
|
||||
|
||||
std::string make_directory(
|
||||
const Motion& motion,
|
||||
const Distribution& distribution
|
||||
) {
|
||||
std::ostringstream path_name;
|
||||
path_name << motion.toString() << "/" << distribution.toString();
|
||||
|
||||
if (!std::filesystem::create_directories(path_name.str())) {
|
||||
std::cout << "Created directory " << path_name.str() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
return path_name.str();
|
||||
}
|
||||
|
||||
|
||||
void save_parameter_to_file(
|
||||
const std::string& resulttype,
|
||||
const std::string& motiontype,
|
||||
const std::string& disttype,
|
||||
std::unordered_map<std::string, double>& parameter,
|
||||
std::unordered_map<std::string, double>& optional
|
||||
const std::string& directory,
|
||||
const std::unordered_map<std::string, double>& parameter,
|
||||
const std::unordered_map<std::string, double>& optional
|
||||
) {
|
||||
|
||||
std::ostringstream parameter_filename;
|
||||
parameter_filename << resulttype << "_" << motiontype << "_" << disttype;
|
||||
parameter_filename << directory << "/" << resulttype;
|
||||
|
||||
parameter_filename << std::setprecision(6) << std::scientific;
|
||||
for (const auto& [key, value]: optional) {
|
||||
@@ -155,15 +173,15 @@ void save_parameter_to_file(
|
||||
|
||||
void save_data_to_file(
|
||||
const std::string& resulttype,
|
||||
const std::string& motiontype,
|
||||
const std::string& disttype,
|
||||
const std::string& directory,
|
||||
const std::vector<double>& x,
|
||||
const std::map<double, std::vector<double>>& y,
|
||||
std::unordered_map<std::string, double>& optional
|
||||
const std::unordered_map<std::string, double>& optional
|
||||
) {
|
||||
// make file name
|
||||
std::ostringstream datafile_name;
|
||||
datafile_name << resulttype << "_" << motiontype << "_" << disttype;
|
||||
datafile_name << directory << "/" << resulttype;
|
||||
|
||||
datafile_name << std::setprecision(6) << std::scientific;
|
||||
for (const auto& [key, value]: optional) {
|
||||
datafile_name << "_" << key << "=" << value;
|
||||
@@ -196,15 +214,15 @@ void save_data_to_file(
|
||||
|
||||
void save_data_to_file(
|
||||
const std::string& resulttype,
|
||||
const std::string& motiontype,
|
||||
const std::string& disttype,
|
||||
const std::string& directory,
|
||||
const std::vector<double>& x,
|
||||
const std::vector<double>& y,
|
||||
std::unordered_map<std::string, double>& optional
|
||||
const std::unordered_map<std::string, double>& optional
|
||||
) {
|
||||
// make file name
|
||||
std::ostringstream datafile_name;
|
||||
datafile_name << resulttype << "_" << motiontype << "_" << disttype;
|
||||
datafile_name << directory << "/" << resulttype;
|
||||
|
||||
datafile_name << std::setprecision(6) << std::scientific;
|
||||
for (const auto& [key, value]: optional) {
|
||||
datafile_name << "_" << key << "=" << value;
|
||||
|
||||
Reference in New Issue
Block a user