Calibrator  0.1
Command line tool for 14C calibration
cal_date_list.cpp
Go to the documentation of this file.
1 #include "../include/cal_date_list.h"
2 
3 CalDateList::CalDateList(vector<CalDate> dates):
4  _dates(dates)
5  {}
7  _dates()
8  {}
9 
10 vector<CalDate> CalDateList::get_dates(){
11  vector<CalDate> return_value(_dates);
12  return return_value;
13 };
14 
16  _dates.push_back(date);
17 }
18 
20  json return_value;
21  int i = 0;
22  for (auto& element : _dates) {
23  json this_date;
24  string this_name = element.get_name();
25  return_value[this_name] = element.to_json();
26  i++;
27  }
28  return return_value;
29 }
30 
32  std::stringstream ss;
33  ss << "name,bp,probability\n";
34  for (auto& element : _dates) {
35  ss << element.to_csv();
36  }
37  std::string return_value = ss.str();
38  return return_value;
39 }
40 
42  vector<double> probs;
43  vector<int> full_bp;
44  vector<double> new_probs;
45 
46  for(auto it = _dates.begin(); it != _dates.end(); ++it) {
47  CalDate element = *it;
48  if (it == _dates.begin()) {
49  full_bp = element.get_full_bp();
50  probs = element.get_full_probabilities();
51  } else {
52  vector<double> new_probs = element.get_full_probabilities();
53  std::transform ( probs.begin(),
54  probs.end(),
55  new_probs.begin(),
56  new_probs.begin(),
57  std::plus<double>());
58  }
59  if (it == _dates.end()) full_bp = element.get_full_bp();
60  }
61  CalDate sum_date = CalDate("sum", probs, full_bp, 0, 0, full_bp, probs);
62  _dates.push_back(sum_date);
63 }
vector< CalDate > get_dates()
string to_csv()
nlohmann::json json
Definition: cal_date.h:29
vector< CalDate > _dates
Definition: cal_date_list.h:34
void push_back(CalDate date)
vector< double > get_full_probabilities()
Definition: cal_date.cpp:60
Represents a calibrated date.
Definition: cal_date.h:33
vector< int > get_full_bp()
Definition: cal_date.cpp:56