Parses the input data and sets up the interpolators.
23 {
26
27 try {
28 std::istringstream ss(data);
29 std::string line;
30 std::map<double, std::vector<std::pair<double, double>>> acc_to_flow_pa;
31
32 while (std::getline(ss, line)) {
33 std::istringstream lineStream(line);
34 std::string value;
35 double paValue, flowRate, acceleration;
36 paValue = flowRate = acceleration = 0.f;
37
38
39 if (std::getline(lineStream, value, ',')) {
40 paValue = std::stod(value);
41 }
42
43
44 if (std::getline(lineStream, value, ',')) {
45 flowRate = std::stod(value);
46 }
47
48
49 if (std::getline(lineStream, value, ',')) {
50 acceleration = std::stod(value);
51 }
52
53
54 acc_to_flow_pa[acceleration].emplace_back(flowRate, paValue);
55 }
56
57
58 for (const auto& kv : acc_to_flow_pa) {
59 double acceleration = kv.first;
60 const auto& data = kv.second;
61
62 std::vector<double> flowRates;
63 std::vector<double> paValues;
64
65 for (const auto& pair : data) {
66 flowRates.push_back(pair.first);
67 paValues.push_back(pair.second);
68 }
69
70
71 if (flowRates.size() > 1) {
72 PchipInterpolatorHelper interpolator(flowRates, paValues);
75 }
76 }
77 } catch (const std::exception&) {
79 return -1;
80 }
82 return 0;
83}
std::vector< double > accelerations_
Store unique accelerations.
Definition AdaptivePAInterpolator.hpp:50