88 lines
2.4 KiB
C++
88 lines
2.4 KiB
C++
#include <iostream>
|
|
#include "temperature_drift.h"
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <vector>
|
|
|
|
int main() {
|
|
temperature_drift algorithm;
|
|
|
|
algorithm.set_config(
|
|
{
|
|
{"TEMPERATURE_DRIFT_AMPLITUDE", 0.01},
|
|
{"TEMPERATURE_DRIFT_AMPLITUDE_BASE", 10}
|
|
}
|
|
);
|
|
std::vector <std::vector<double>> user_arr;
|
|
std::ifstream fp("C:/data/user_data.csv");
|
|
std::string line;
|
|
getline(fp,line);
|
|
while (getline(fp,line)){
|
|
std::vector <double> data_line;
|
|
std::string number;
|
|
std::istringstream readstr(line);
|
|
for(int j = 0;j < 2814;j++){
|
|
getline(readstr,number,',');
|
|
data_line.push_back(atof(number.c_str()));
|
|
}
|
|
user_arr.push_back(data_line);
|
|
}
|
|
std::ofstream outfile;
|
|
outfile.open("C:/data/user_data7.csv", std::ios::out);
|
|
outfile<<"origin"<<','<<"temperature_drift"<<std::endl;
|
|
for (int i = 0; i <2814; ++i) {
|
|
user_arr[i][1]=algorithm.eval(user_arr[i][0]);
|
|
std::cout << i << "\t" << user_arr[i][1] << std::endl;
|
|
outfile<<user_arr[i][0]<<','<<user_arr[i][1]<<std::endl;
|
|
}
|
|
outfile.close();
|
|
|
|
return 0;
|
|
}
|
|
// std::vector<int> x(100);
|
|
// std::generate(x.begin(), x.end(), []() {
|
|
// static int i = 0;
|
|
// return i++;
|
|
// });
|
|
// std::vector<double> virtual_data(100, 100.0);
|
|
// std::vector<double> temperature_drift_data;
|
|
// sciplot::Plot plot;
|
|
//
|
|
// for (auto iter: virtual_data) {
|
|
// temperature_drift_data.push_back(algorithm.eval(iter));
|
|
// }
|
|
//
|
|
// plot.drawCurve(x, virtual_data).label("org");
|
|
// plot.drawCurve(x, temperature_drift_data).label("td");
|
|
// plot.show();
|
|
//
|
|
// return 0;
|
|
//}
|
|
|
|
//#include <sciplot/sciplot.hpp>
|
|
//using namespace sciplot;
|
|
//
|
|
//int main(int argc, char** argv)
|
|
//{
|
|
// // Create values for your x-axis
|
|
// Vec x = linspace(0.0, 5.0, 100);
|
|
//
|
|
// // Create a Plot object
|
|
// Plot plot;
|
|
//
|
|
// // Set color palette
|
|
// plot.palette("set2");
|
|
//
|
|
// // Draw a sine graph putting x on the x-axis and sin(x) on the y-axis
|
|
// plot.drawCurve(x, std::sin(x)).label("sin(x)").lineWidth(4);
|
|
//
|
|
// // Draw a cosine graph putting x on the x-axis and cos(x) on the y-axis
|
|
// plot.drawCurve(x, std::cos(x)).label("cos(x)").lineWidth(4);
|
|
//
|
|
// // Show the plot in a pop-up window
|
|
// plot.show();
|
|
//
|
|
// // Save the plot to a PDF file
|
|
// plot.save("plot.pdf");
|
|
//}
|