//---------------------------------------------------------------------------// // // @file rawmerge.hpp // @author Mario Fink // @date Aug 2020 // @brief unify multiple channels and time series from .raw in single table // //---------------------------------------------------------------------------// #ifndef RAW_MERGER #define RAW_MERGER #include "raweat.hpp" //---------------------------------------------------------------------------// class raw_merger : public raw_eater { private: // number of channels int num_channels_; // (merged) channel data related to SINGLE time series std::vector> channels_; std::vector timeseries_; // temporal unit and channel meta data std::string temp_unit_; std::vector channel_names_; public: // constructor raw_merger(std::string rawfile): raw_eater(rawfile) { // add first initial channel this->add_channel(rawfile); } raw_merger(): raw_eater() { } // destructor ~raw_merger() { } // add a single channel and its associated time series bool add_channel(std::string rawfile) { // set raw file and perform conversion this->set_file(rawfile); // add first/initial time series (and channel data) if ( timeseries_.size() == 0 && channels_.size() == 0 ) { std::cout<<"adding first channel\n"; // insert timeseries and its unit timeseries_ = this->get_time(); temp_unit_ = this->get_temp_unit(); // insert channel data and its meta data channels_.push_back(this->get_data()); channel_names_.push_back(this->get_name() + std::string(" [") + this->get_unit() + std::string("]")); return true; } else { // TODO check consistency of time series, time unit, channels.... return false; } } // print all data to file void write_table(std::string filename, char delimiter = ',', int precision = 6, int width = 25) { // if at least one channel including its time series is present if ( timeseries_.size() > 0 && channels_.size() > 0 ) { // open file std::ofstream fout(filename.c_str()); if ( fout.good() ) { // define temporal column header std::string colTime = std::string("Time [") + temp_unit_ + std::string("]"); // write header if ( delimiter != ' ' ) { fout<channel_names_ ) fout<channel_names_ ) fout<timeseries_ ) { if ( delimiter != ' ' ) { fout< chn: this->channels_ ) { fout< chn: this->channels_ ) { fout<