Calibrator  0.1
Command line tool for 14C calibration
cal_curve.cpp
Go to the documentation of this file.
1 #include "../include/cal_curve.h"
2 
3 CalCurve::CalCurve(vector<int> cal_bp, vector<int> c14_bp, vector<int> error):
4  cal_bp_(cal_bp),
5  c14_bp_(c14_bp),
6  error_(error)
7  {}
8 CalCurve::CalCurve() : cal_bp_(), c14_bp_(), error_()
9  {}
10 
12  return cal_bp_.size();
13 }
14 
15 int CalCurve::import(string file) {
16 
17  int head_length = 10;
18 
19  cal_bp_.clear();
20  c14_bp_.clear();
21  error_.clear();
22  ifstream in(file.c_str());
23  if (!in.is_open()) return 1;
24 
25  vector< string > vec;
26  string line;
27  int counter = 0;
28  while (getline(in, line)) {
29  if (counter > head_length) {
30  std::stringstream iss(line);
31  std::string val;
32  std::getline(iss, val, ',');
33  if ( !iss.good() )
34  break;
35  cal_bp_.push_back(atoi(val.c_str()));
36  std::getline(iss, val, ',');
37  if ( !iss.good() )
38  break;
39  c14_bp_.push_back(atoi(val.c_str()));
40  std::getline(iss, val, ',');
41  if ( !iss.good() )
42  break;
43  error_.push_back(atoi(val.c_str()));
44  }
45  counter++;
46  }
47  return EXIT_SUCCESS;
48 }
49 
51  int my_max = *std::max_element(cal_bp_.begin(), cal_bp_.end());
52  return my_max;
53 }
54 
56  int my_min = *std::min_element(cal_bp_.begin(), cal_bp_.end());
57  return my_min;
58 }
59 
60 vector<int> CalCurve::get_error() {
61  return error_;
62 }
63 
64 vector<int> CalCurve::get_bp() {
65  return cal_bp_;
66 }
67 
68 vector<int> CalCurve::get_c14_bp() {
69  return c14_bp_;
70 }
int rows()
Definition: cal_curve.cpp:11
vector< int > get_error()
Definition: cal_curve.cpp:60
vector< int > get_bp()
Definition: cal_curve.cpp:64
int min_bp_cal_curve()
Definition: cal_curve.cpp:55
int import(string file)
Definition: cal_curve.cpp:15
CalCurve()
Definition: cal_curve.cpp:8
int max_bp_cal_curve()
Definition: cal_curve.cpp:50
vector< int > get_c14_bp()
Definition: cal_curve.cpp:68