/** @class CorrectDetectorTime.cpp @author Brian Magill @datecreated 4/12/2006 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief Applies a time correction to a detector signal Applies a time correction to a time offset to a signal and then interpolates the signal back to the original time. */ //---------------------------------------------------------------------- // #include #include //#include "SOFIE_Exception.h" #include "CorrectDetectorTime.h" #include "ValInterp.h" using namespace std; CorrectDetectorTime& CorrectDetectorTime::operator = (CorrectDetectorTime const& rhs ) { if (&rhs == this) return *this; offset = rhs.offset; filter_shift = rhs.filter_shift; return *this; } // void CorrectDetectorTime::correct_signal(vector > inSignals, // valarray time, vector offset, // vector > &outSignals) void CorrectDetectorTime::correct_signal(std::vector > const &inSignals, std::valarray const &time, std::vector > &outSignals) const { const unsigned long MIN_SIG_SIZE = 3; unsigned long i; valarray offset_time(time.size() ); valarray out_sig(time.size() ); outSignals.clear(); if(inSignals.size() != offset.size()) { throw runtime_error("number of time offsets differs from number of signals"); } for(i = 0; i < inSignals.size(); i++) { if(inSignals[i].size() != time.size()) throw runtime_error("signal array size differs from time's"); if(inSignals[i].size() < MIN_SIG_SIZE) throw runtime_error("too few data points in signal"); offset_time = time + offset[i] - filter_shift; out_sig = VInterpol(inSignals[i], offset_time, time); outSignals.push_back(out_sig); } }