//---------------------------------------------------------------------------// #include #include #include "../lib/raweat.hpp" //---------------------------------------------------------------------------// int main(int argc, char* argv[]) { std::cout<<"number of CLI-arguments: "<= 3 ); // get list of names/paths of raw-files from CLI argument std::vector rawfiles; for (int i = 1; i < argc-1; i++ ) rawfiles.push_back(std::string(argv[i])); // collect arrays of data (without time!), first, last time + timestep, channel names + units std::vector> alldata; std::vector> timedata; std::vector> channelinfo; // process all .raw files provided std::cout<<"\n"< channtime = {toff,toff+(n-1)*dt,dt}; timedata.push_back(channtime); std::cout< channinfo = {eatraw.get_name(),eatraw.get_unit(),eatraw.get_temp_unit()}; channelinfo.push_back(channinfo); } std::cout<<"\n"; // obtain number of channels int num_chann = (int)alldata.size(); // usually, all channels should roughly have the same start/end time for ( int ch = 1; ch < num_chann; ch++ ) { assert( fabs(timedata[ch][0]-timedata[0][0]) < 10*timedata[ch][2] ); assert( fabs(timedata[ch][1]-timedata[0][1]) < 10*timedata[ch][2] ); } // make sure all files feature same time unit for ( int ch = 1; ch < num_chann; ch++ ) { assert( channelinfo[ch][2] == channelinfo[0][2] && "time unit apparently differs in some channels!" ); } // open .csv-file for dumping all data std::ofstream fout(argv[argc-1]); // define output properties int width = 30; int doubleprec = 9; // insert header with column names std::string colA = std::string("Time [") + channelinfo[0][2] + std::string("]"); fout< channidx(num_chann,0); unsigned long int tidx = 0; // while data in any channel left bool sometimeleft = true; while ( sometimeleft && tidx < 2500 ) { // find this round's "earliest" time w.r.t. to all channels double firsttime = 1.0e10; for ( int ch = 0; ch < num_chann; ch++ ) { // get time to process in this channel double chtimenow = timedata[ch][0] + channidx[ch] * timedata[ch][2]; if ( chtimenow <= firsttime and channidx[ch] < alldata[ch].size() ) { firsttime = chtimenow; } } // print time step fout<