BioDynaMo  v1.05.120-25dc9790
time_series.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
16 #include <TBufferJSON.h>
17 #include <iostream>
18 #include "core/analysis/reduce.h"
19 #include "core/scheduler.h"
20 #include "core/simulation.h"
21 #include "core/util/io.h"
22 #include "core/util/log.h"
23 
24 namespace bdm {
25 namespace experimental {
26 
27 // -----------------------------------------------------------------------------
29  const std::vector<real_t>& old_x_values,
30  std::vector<real_t>& new_x_values) const {
31  new_x_values.resize(old_x_values.size());
32  for (size_t i = 0; i < old_x_values.size(); i++) {
33  new_x_values[i] = x_slope_ * old_x_values[i] + x_intercept_;
34  }
35 };
36 
37 // -----------------------------------------------------------------------------
39  const std::vector<real_t>& old_y_values,
40  std::vector<real_t>& new_y_values) const {
41  new_y_values.resize(old_y_values.size());
42  for (size_t i = 0; i < old_y_values.size(); i++) {
43  new_y_values[i] = y_slope_ * old_y_values[i] + y_intercept_;
44  }
45 };
46 
47 // -----------------------------------------------------------------------------
49  const std::vector<real_t>& old_y_error_low,
50  std::vector<real_t>& new_y_error_low) const {
51  new_y_error_low.resize(old_y_error_low.size());
52  for (size_t i = 0; i < old_y_error_low.size(); i++) {
53  new_y_error_low[i] =
54  y_error_low_slope_ * old_y_error_low[i] + y_error_low_intercept_;
55  }
56 };
57 
58 // -----------------------------------------------------------------------------
60  const std::vector<real_t>& old_y_error_high,
61  std::vector<real_t>& new_y_error_high) const {
62  new_y_error_high.resize(old_y_error_high.size());
63  for (size_t i = 0; i < old_y_error_high.size(); i++) {
64  new_y_error_high[i] =
65  y_error_high_slope_ * old_y_error_high[i] + y_error_high_intercept_;
66  }
67 };
68 
69 // -----------------------------------------------------------------------------
70 // Setters
73  x_intercept_ = intercept;
74 }
77  y_intercept_ = intercept;
78 }
80  y_error_low_slope_ = slope;
81 }
83  y_error_low_intercept_ = intercept;
84 }
86  y_error_high_slope_ = slope;
87 }
89  y_error_high_intercept_ = intercept;
90 }
91 
92 // -----------------------------------------------------------------------------
93 TimeSeries::Data::Data() = default;
94 
95 // -----------------------------------------------------------------------------
97  real_t (*xcollector)(Simulation*))
98  : ycollector(ycollector), xcollector(xcollector) {}
99 
100 // -----------------------------------------------------------------------------
102  real_t (*xcollector)(Simulation*))
103  : y_reducer_collector(y_reducer_collector), xcollector(xcollector) {}
104 
105 // -----------------------------------------------------------------------------
107  : ycollector(other.ycollector),
108  xcollector(other.xcollector),
109  x_values(other.x_values),
110  y_values(other.y_values),
111  y_error_low(other.y_error_low),
112  y_error_high(other.y_error_high) {
113  if (other.y_reducer_collector) {
115  }
116 }
117 
118 // -----------------------------------------------------------------------------
120  if (this == &other) {
121  return *this;
122  }
123  if (other.y_reducer_collector) {
124  y_reducer_collector = other.y_reducer_collector->NewCopy();
125  }
126  ycollector = other.ycollector;
127  xcollector = other.xcollector;
128  x_values = other.x_values;
129  y_values = other.y_values;
130  y_error_low = other.y_error_low;
131  y_error_high = other.y_error_high;
132  return *this;
133 }
134 
135 // -----------------------------------------------------------------------------
137  if (y_reducer_collector) {
138  delete y_reducer_collector;
139  }
140 }
141 
142 // -----------------------------------------------------------------------------
144  // verify that all TimeSeries contain the same entries
145  if (ts1.data_.size() != ts2.data_.size()) {
146  Log::Warning("TimeSeries::ComputeError",
147  "The time series objects that should be merged do not "
148  "contain the same entries. Operation aborted.");
149  return std::numeric_limits<real_t>::infinity();
150  }
151  for (auto& p : ts1.data_) {
152  if (ts2.data_.find(p.first) == ts2.data_.end()) {
153  Log::Warning("TimeSeries::ComputeError",
154  "The time series objects that should be merged do not "
155  "contain the same entries. Operation aborted");
156  return std::numeric_limits<real_t>::infinity();
157  }
158  }
159 
160  for (auto& pair : ts1.data_) {
161  auto& key = pair.first;
162  // check that all time series objects have the same x values
163  auto& xref = ts1.data_.at(key).x_values;
164  auto& xcurrent = ts2.data_.at(key).x_values;
165  if (xref.size() != xcurrent.size()) {
166  Log::Warning("TimeSeries::ComputeError",
167  "The time series objects for entry (", key,
168  ") have different x_values. Operation aborted.");
169  return std::numeric_limits<real_t>::infinity();
170  } else {
171  for (uint64_t j = 0; j < xref.size(); ++j) {
172  if (std::abs(xref[j] - xcurrent[j]) > 1e-5) {
173  Log::Warning("TimeSeries::ComputeError",
174  "The time series objects for entry (", key,
175  ") have different x_values. Operation aborted.");
176  return std::numeric_limits<real_t>::infinity();
177  }
178  }
179  }
180  }
181 
182  real_t error = 0.0;
183  for (auto& pair : ts1.data_) {
184  auto& key = pair.first;
185  auto& yref = ts1.data_.at(key).y_values;
186  auto& ycurrent = ts2.data_.at(key).y_values;
187  error += Math::MSE(yref, ycurrent);
188  }
189  return error;
190 }
191 
192 // -----------------------------------------------------------------------------
193 void TimeSeries::Load(const std::string& full_filepath, TimeSeries** restored) {
194  GetPersistentObject(full_filepath.c_str(), "TimeSeries", *restored);
195 }
196 
197 // -----------------------------------------------------------------------------
199  TimeSeries* merged, const std::vector<TimeSeries>& time_series,
200  const std::function<void(const std::vector<real_t>&, real_t*, real_t*,
201  real_t*)>& merger) {
202  if (!merged) {
203  Log::Warning("TimeSeries::Merge",
204  "Parameter 'merged' is a nullptr. Operation aborted.");
205  return;
206  }
207 
208  // check that merged is empty
209  if (merged->data_.size() != 0) {
210  Log::Warning("TimeSeries::Merge",
211  "Parameter 'merged' is not empty. Operation aborted.");
212  return;
213  }
214 
215  if (time_series.size() == 0) {
216  Log::Warning("TimeSeries::Merge",
217  "The given time series vector is empty. Operation aborted.");
218  return;
219  } else if (time_series.size() == 1) {
220  *merged = time_series[0];
221  return;
222  }
223 
224  // verify that all TimeSeries contain the same entries
225  auto& ref = time_series[0];
226  for (uint64_t i = 1; i < time_series.size(); ++i) {
227  auto& current = time_series[i];
228  if (ref.data_.size() != current.data_.size()) {
229  Log::Warning("TimeSeries::Merge",
230  "The time series objects that should be merged do not "
231  "contain the same entries. Operation aborted.");
232  return;
233  }
234  for (auto& p : ref.data_) {
235  if (current.data_.find(p.first) == current.data_.end()) {
236  Log::Warning("TimeSeries::Merge",
237  "The time series objects that should be merged do not "
238  "contain the same entries. Operation aborted");
239  return;
240  }
241  }
242  }
243 
244  for (auto& pair : ref.data_) {
245  auto& key = pair.first;
246  // check that all time series objects have the same x values
247  auto& xref = ref.data_.at(key).x_values;
248  for (uint64_t i = 1; i < time_series.size(); ++i) {
249  auto& xcurrent = time_series[i].data_.at(key).x_values;
250  if (xref.size() != xcurrent.size()) {
251  Log::Warning("TimeSeries::Merge", "The time series objects for entry (",
252  key, ") have different x_values. Operation aborted.");
253  return;
254  } else {
255  for (uint64_t j = 0; j < xref.size(); ++j) {
256  if (std::abs(xref[j] - xcurrent[j]) > 1e-5) {
257  Log::Warning("TimeSeries::Merge",
258  "The time series objects for entry (", key,
259  ") have different x_values. Operation aborted.");
260  return;
261  }
262  }
263  }
264  }
265 
266  // merge
267  // initialize
268  merged->data_.emplace(key, Data());
269  auto& mdata = merged->data_[key];
270  mdata.x_values.resize(xref.size());
271  mdata.y_values.resize(xref.size());
272  mdata.y_error_low.resize(xref.size());
273  mdata.y_error_high.resize(xref.size());
274 
275 #pragma omp parallel for
276  for (uint64_t i = 0; i < xref.size(); ++i) {
277  mdata.x_values[i] = xref[i];
278  std::vector<real_t> all_y_values(time_series.size());
279  for (uint64_t j = 0; j < time_series.size(); ++j) {
280  all_y_values[j] = time_series[j].data_.at(key).y_values[i];
281  merger(all_y_values, &mdata.y_values[i], &mdata.y_error_low[i],
282  &mdata.y_error_high[i]);
283  }
284  }
285  }
286 }
287 
288 // -----------------------------------------------------------------------------
289 TimeSeries::TimeSeries() = default;
290 
291 // -----------------------------------------------------------------------------
292 TimeSeries::TimeSeries(const TimeSeries& other) : data_(other.data_) {}
293 
294 // -----------------------------------------------------------------------------
296  : data_(std::move(other.data_)) {}
297 
298 // -----------------------------------------------------------------------------
300  data_ = std::move(other.data_);
301  return *this;
302 }
303 
304 // -----------------------------------------------------------------------------
306  data_ = other.data_;
307  return *this;
308 }
309 
310 // -----------------------------------------------------------------------------
311 void TimeSeries::AddCollector(const std::string& id,
312  real_t (*ycollector)(Simulation*),
313  real_t (*xcollector)(Simulation*)) {
314  auto it = data_.find(id);
315  if (it != data_.end()) {
316  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
317  ") exists already. Operation aborted.");
318  }
319  data_.emplace(id, Data(ycollector, xcollector));
320 }
321 
322 // -----------------------------------------------------------------------------
323 void TimeSeries::AddCollector(const std::string& id,
324  Reducer<real_t>* y_reducer_collector,
325  real_t (*xcollector)(Simulation*)) {
326  auto it = data_.find(id);
327  if (it != data_.end()) {
328  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
329  ") exists already. Operation aborted.");
330  }
331  data_.emplace(id, Data(y_reducer_collector, xcollector));
332 }
333 
334 // -----------------------------------------------------------------------------
335 void TimeSeries::AddTransformedData(const std::string& old_id,
336  const std::string& transformed_id,
337  const DataTransformer& transformer) {
338  // Get previous data
339  auto previous_data = data_.find(old_id);
340  if (previous_data == data_.end()) {
341  Log::Warning("TimeSeries::AddTransformed", "TimeSeries with id (", old_id,
342  ") does not exist. Operation aborted.");
343  return;
344  }
345  // Check if transformed data already exists
346  auto transformed_data = data_.find(transformed_id);
347  if (transformed_data != data_.end()) {
348  Log::Warning("TimeSeries::AddTransformed", "TimeSeries with id (",
349  transformed_id, ") exists already. Operation aborted.");
350  return;
351  }
352 
353  // Copy data to new object
354  Data data;
355 
356  // Transform data
357  const auto& previous = previous_data->second;
358  transformer.TransformXValues(previous.x_values, data.x_values);
359  transformer.TransformYValues(previous.y_values, data.y_values);
360  transformer.TransformYErrorLow(previous.y_error_low, data.y_error_low);
361  transformer.TransformYErrorHigh(previous.y_error_high, data.y_error_high);
362 
363  // Add data to map
364  data_.emplace(transformed_id, data);
365 }
366 
367 // -----------------------------------------------------------------------------
369  if (!data_.empty()) {
370  auto* sim = Simulation::GetActive();
371  auto* scheduler = sim->GetScheduler();
372  auto* param = sim->GetParam();
373 
374  // First all reducers
375  std::vector<std::pair<Reducer<real_t>*, const std::string>> reducers;
376  for (auto& entry : data_) {
377  auto& result_data = entry.second;
378  if (result_data.y_reducer_collector == nullptr) {
379  continue;
380  }
381  result_data.y_reducer_collector->Reset();
382  reducers.push_back(
383  std::make_pair(result_data.y_reducer_collector, entry.first));
384  if (result_data.xcollector == nullptr) {
385  result_data.x_values.push_back(scheduler->GetSimulatedSteps() *
386  param->simulation_time_step);
387  } else {
388  result_data.x_values.push_back(result_data.xcollector(sim));
389  }
390  }
391 
392  // execute reducers
393  auto execute_reducers = L2F([&](Agent* agent) {
394  for (auto& el : reducers) {
395  (*el.first)(agent);
396  }
397  });
398  sim->GetResourceManager()->ForEachAgentParallel(execute_reducers);
399  for (auto& el : reducers) {
400  data_[el.second].y_values.push_back(el.first->GetResult());
401  }
402 
403  // Second all function collectors
404  // Thus function collectors can use the results of the reducers.
405  for (auto& entry : data_) {
406  auto& result_data = entry.second;
407  if (result_data.ycollector == nullptr) {
408  continue;
409  }
410  result_data.y_values.push_back(result_data.ycollector(sim));
411  if (result_data.xcollector == nullptr) {
412  result_data.x_values.push_back(scheduler->GetSimulatedSteps() *
413  param->simulation_time_step);
414  } else {
415  result_data.x_values.push_back(result_data.xcollector(sim));
416  }
417  }
418  }
419 }
420 
421 // -----------------------------------------------------------------------------
422 void TimeSeries::Add(const TimeSeries& ts, const std::string& suffix) {
423  if (this == &ts) {
424  Log::Warning(
425  "TimeSeries::Add",
426  "Adding a TimeSeries to itself is not supported. Operation aborted.");
427  return;
428  }
429  for (auto& p : ts.data_) {
430  // verify that entry doesn't exist yet
431  auto id = Concat(p.first, "-", suffix);
432  if (data_.find(id) != data_.end()) {
433  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
434  ") exists already. Consider changing the suffix parameter "
435  "to make it unique. Operation aborted.");
436  return;
437  }
438 
439  data_.emplace(id, p.second);
440  }
441 }
442 
443 // -----------------------------------------------------------------------------
444 void TimeSeries::Add(const std::string& id, const std::vector<real_t>& x_values,
445  const std::vector<real_t>& y_values) {
446  if (data_.find(id) != data_.end()) {
447  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
448  ") exists already. Consider changing the suffix parameter to "
449  "make it unique. Operation aborted.");
450  return;
451  }
452 
453  Data data;
454  data.x_values = x_values;
455  data.y_values = y_values;
456  data_.emplace(id, data);
457 }
458 
459 // -----------------------------------------------------------------------------
460 void TimeSeries::Add(const std::string& id, const std::vector<real_t>& x_values,
461  const std::vector<real_t>& y_values,
462  const std::vector<real_t>& y_error_low,
463  const std::vector<real_t>& y_error_high) {
464  if (data_.find(id) != data_.end()) {
465  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
466  ") exists already. Consider changing the suffix parameter to "
467  "make it unique. Operation aborted.");
468  return;
469  }
470 
471  Data data;
472  data.x_values = x_values;
473  data.y_values = y_values;
474  data.y_error_low = y_error_low;
475  data.y_error_high = y_error_high;
476  data_.emplace(id, data);
477 }
478 
479 // -----------------------------------------------------------------------------
480 void TimeSeries::Add(const std::string& id, const std::vector<real_t>& x_values,
481  const std::vector<real_t>& y_values,
482  const std::vector<real_t>& y_error) {
483  if (data_.find(id) != data_.end()) {
484  Log::Warning("TimeSeries::Add", "TimeSeries with id (", id,
485  ") exists already. Consider changing the suffix parameter to "
486  "make it unique. Operation aborted.");
487  return;
488  }
489  Data data;
490  data.x_values = x_values;
491  data.y_values = y_values;
492  data.y_error_low = y_error;
493  data.y_error_high = y_error;
494  data_.emplace(id, data);
495 }
496 
497 // -----------------------------------------------------------------------------
498 bool TimeSeries::Contains(const std::string& id) const {
499  return data_.find(id) != data_.end();
500 }
501 
502 // -----------------------------------------------------------------------------
503 uint64_t TimeSeries::Size() const { return data_.size(); }
504 
505 // -----------------------------------------------------------------------------
506 const std::vector<real_t>& TimeSeries::GetXValues(const std::string& id) const {
507  return data_.at(id).x_values;
508 }
509 
510 // -----------------------------------------------------------------------------
511 const std::vector<real_t>& TimeSeries::GetYValues(const std::string& id) const {
512  return data_.at(id).y_values;
513 }
514 
515 // -----------------------------------------------------------------------------
516 const std::vector<real_t>& TimeSeries::GetYErrorLow(
517  const std::string& id) const {
518  return data_.at(id).y_error_low;
519 }
520 
521 // -----------------------------------------------------------------------------
522 const std::vector<real_t>& TimeSeries::GetYErrorHigh(
523  const std::string& id) const {
524  return data_.at(id).y_error_high;
525 }
526 
527 // -----------------------------------------------------------------------------
529  for (auto& p : data_) {
530  std::cout << p.first << std::endl;
531  }
532 }
533 
534 // -----------------------------------------------------------------------------
535 void TimeSeries::Save(const std::string& full_filepath) const {
536  WritePersistentObject(full_filepath.c_str(), "TimeSeries", *this, "recreate");
537 }
538 
539 // -----------------------------------------------------------------------------
540 void TimeSeries::SaveJson(const std::string& full_filepath) const {
541  TBufferJSON::ExportToFile(full_filepath.c_str(), this, Class());
542 }
543 
544 } // namespace experimental
545 } // namespace bdm
bdm::experimental::LinearTransformer::SetYIntercept
void SetYIntercept(real_t intercept)
Definition: time_series.cc:76
bdm::experimental::TimeSeries::ComputeError
static real_t ComputeError(const TimeSeries &ts1, const TimeSeries &ts2)
Computes the mean squared error between ts1 and ts2
Definition: time_series.cc:143
bdm::experimental::TimeSeries::operator=
TimeSeries & operator=(TimeSeries &&other) noexcept
Definition: time_series.cc:299
bdm::experimental::LinearTransformer::SetYErrorLowIntercept
void SetYErrorLowIntercept(real_t intercept)
Definition: time_series.cc:82
bdm::experimental::TimeSeries::GetYErrorHigh
const std::vector< real_t > & GetYErrorHigh(const std::string &id) const
Definition: time_series.cc:522
bdm::experimental::DataTransformer::TransformXValues
virtual void TransformXValues(const std::vector< real_t > &old_x_values, std::vector< real_t > &new_x_values) const =0
bdm::experimental::LinearTransformer::SetYErrorHighIntercept
void SetYErrorHighIntercept(real_t intercept)
Definition: time_series.cc:88
bdm
Definition: agent.cc:39
bdm::Math::MSE
static real_t MSE(const std::vector< real_t > &v1, const std::vector< real_t > &v2)
Returns the mean squared error between two vectors.
Definition: math.h:122
bdm::experimental::TimeSeries::TimeSeries
TimeSeries()
bdm::experimental::TimeSeries::Data::y_error_high
std::vector< real_t > y_error_high
Definition: time_series.h:141
reduce.h
bdm::experimental::LinearTransformer::SetXIntercept
void SetXIntercept(real_t intercept)
Definition: time_series.cc:72
bdm::experimental::TimeSeries::Data
Definition: time_series.h:125
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::experimental::LinearTransformer::SetYSlope
void SetYSlope(real_t slope)
Definition: time_series.cc:75
bdm::experimental::TimeSeries::Data::xcollector
real_t(* xcollector)(Simulation *)
Definition: time_series.h:137
bdm::experimental::DataTransformer::TransformYErrorHigh
virtual void TransformYErrorHigh(const std::vector< real_t > &old_y_error_high, std::vector< real_t > &new_y_error_high) const =0
bdm::experimental::TimeSeries::Save
void Save(const std::string &full_filepath) const
Saves a root file to disk.
Definition: time_series.cc:535
bdm::experimental::LinearTransformer::x_intercept_
real_t x_intercept_
Definition: time_series.h:109
scheduler.h
bdm::experimental::DataTransformer::TransformYValues
virtual void TransformYValues(const std::vector< real_t > &old_y_values, std::vector< real_t > &new_y_values) const =0
bdm::experimental::TimeSeries::GetYErrorLow
const std::vector< real_t > & GetYErrorLow(const std::string &id) const
Definition: time_series.cc:516
bdm::GetPersistentObject
bool GetPersistentObject(const char *root_file, const char *obj_name, T *&empty_obj)
Gets the persistent object from the specified ROOT file.
Definition: io.h:101
bdm::L2F
LambdaFunctor< decltype(&TLambda::operator())> L2F(const TLambda &l)
Definition: functor.h:110
bdm::Agent
Contains code required by all agents.
Definition: agent.h:79
bdm::experimental::TimeSeries::Update
void Update()
Adds a new data point to all time series with a collector.
Definition: time_series.cc:368
bdm::experimental::TimeSeries::AddTransformedData
void AddTransformedData(const std::string &old_id, const std::string &transformed_id, const DataTransformer &transformer)
Definition: time_series.cc:335
bdm::experimental::LinearTransformer::y_error_high_intercept_
real_t y_error_high_intercept_
Definition: time_series.h:115
bdm::experimental::LinearTransformer::SetXSlope
void SetXSlope(real_t slope)
Definition: time_series.cc:71
bdm::experimental::LinearTransformer::y_slope_
real_t y_slope_
Definition: time_series.h:110
bdm::experimental::LinearTransformer::TransformYErrorLow
void TransformYErrorLow(const std::vector< real_t > &old_y_error_low, std::vector< real_t > &new_y_error_low) const final
Transforms the y-error-low according to the linear transformation.
Definition: time_series.cc:48
bdm::Log::Warning
static void Warning(const std::string &location, const Args &... parts)
Prints warning message.
Definition: log.h:67
bdm::experimental::LinearTransformer::TransformYValues
void TransformYValues(const std::vector< real_t > &old_y_values, std::vector< real_t > &new_y_values) const final
Transforms the y-values according to the linear transformation.
Definition: time_series.cc:38
time_series.h
bdm::experimental::TimeSeries::Data::y_values
std::vector< real_t > y_values
Definition: time_series.h:139
bdm::experimental::TimeSeries::data_
std::unordered_map< std::string, Data > data_
Definition: time_series.h:297
bdm::experimental::Reducer< real_t >
bdm::experimental::LinearTransformer::y_error_low_intercept_
real_t y_error_low_intercept_
Definition: time_series.h:113
bdm::experimental::TimeSeries::ListEntries
void ListEntries() const
Print all time series entry names to stdout.
Definition: time_series.cc:528
bdm::experimental::TimeSeries::Data::operator=
Data & operator=(const Data &other)
Definition: time_series.cc:119
bdm::experimental::LinearTransformer::TransformXValues
void TransformXValues(const std::vector< real_t > &old_x_values, std::vector< real_t > &new_x_values) const final
Transforms the x-values according to the linear transformation.
Definition: time_series.cc:28
bdm::experimental::LinearTransformer::TransformYErrorHigh
void TransformYErrorHigh(const std::vector< real_t > &old_y_error_high, std::vector< real_t > &new_y_error_high) const final
Transforms the y-error-high according to the linear transformation.
Definition: time_series.cc:59
bdm::experimental::TimeSeries::Data::x_values
std::vector< real_t > x_values
Definition: time_series.h:138
bdm::Concat
std::string Concat(const Args &... parts)
Concatenates all arguments into a string. Equivalent to streaming all arguments into a stringstream a...
Definition: string.h:70
bdm::experimental::TimeSeries::Data::~Data
~Data()
Definition: time_series.cc:136
bdm::experimental::TimeSeries::GetYValues
const std::vector< real_t > & GetYValues(const std::string &id) const
Definition: time_series.cc:511
bdm::experimental::LinearTransformer::y_error_low_slope_
real_t y_error_low_slope_
Definition: time_series.h:112
bdm::experimental::TimeSeries::Data::Data
Data()
bdm::experimental::LinearTransformer::y_intercept_
real_t y_intercept_
Definition: time_series.h:111
bdm::experimental::LinearTransformer::y_error_high_slope_
real_t y_error_high_slope_
Definition: time_series.h:114
bdm::experimental::TimeSeries
Definition: time_series.h:123
bdm::experimental::Reducer::NewCopy
virtual Reducer * NewCopy() const =0
log.h
bdm::experimental::LinearTransformer::SetYErrorHighSlope
void SetYErrorHighSlope(real_t slope)
Definition: time_series.cc:85
bdm::experimental::TimeSeries::GetXValues
const std::vector< real_t > & GetXValues(const std::string &id) const
Definition: time_series.cc:506
bdm::WritePersistentObject
void WritePersistentObject(const char *root_file, const char *obj_name, const T &pst_object, const char *mode="new")
Writes a persistent object to the specified ROOT file.
Definition: io.h:130
bdm::experimental::TimeSeries::Data::y_reducer_collector
Reducer< real_t > * y_reducer_collector
Definition: time_series.h:135
bdm::experimental::LinearTransformer::x_slope_
real_t x_slope_
Definition: time_series.h:108
bdm::experimental::TimeSeries::Merge
static void Merge(TimeSeries *merged, const std::vector< TimeSeries > &time_series, const std::function< void(const std::vector< real_t > &, real_t *, real_t *, real_t *)> &merger)
Definition: time_series.cc:198
io.h
bdm::experimental::TimeSeries::Add
void Add(const std::string &id, const std::vector< real_t > &x_values, const std::vector< real_t > &y_values)
Definition: time_series.cc:444
bdm::experimental::LinearTransformer::SetYErrorLowSlope
void SetYErrorLowSlope(real_t slope)
Definition: time_series.cc:79
simulation.h
bdm::experimental::TimeSeries::AddCollector
void AddCollector(const std::string &id, real_t(*ycollector)(Simulation *), real_t(*xcollector)(Simulation *)=nullptr)
Definition: time_series.cc:311
bdm::experimental::TimeSeries::Data::y_error_low
std::vector< real_t > y_error_low
Definition: time_series.h:140
bdm::experimental::DataTransformer::TransformYErrorLow
virtual void TransformYErrorLow(const std::vector< real_t > &old_y_error_low, std::vector< real_t > &new_y_error_low) const =0
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition: simulation.cc:68
bdm::experimental::DataTransformer
Definition: time_series.h:39
bdm::experimental::TimeSeries::Contains
bool Contains(const std::string &id) const
Returns whether a times series with given id exists in this object.
Definition: time_series.cc:498
bdm::experimental::TimeSeries::SaveJson
void SaveJson(const std::string &full_filepath) const
Saves a json representation to disk.
Definition: time_series.cc:540
bdm::Simulation
Definition: simulation.h:50
bdm::experimental::TimeSeries::Size
uint64_t Size() const
Definition: time_series.cc:503
bdm::experimental::TimeSeries::Load
static void Load(const std::string &full_filepath, TimeSeries **restored)
Definition: time_series.cc:193
bdm::experimental::TimeSeries::Data::ycollector
real_t(* ycollector)(Simulation *)
Definition: time_series.h:136