/** @class CheckSigInf.cpp @author Brian Magill @creation date 11/15/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 Check signals for nonfinite values */ #include #include #include #include "GATS_Utilities.hpp" #include "CheckSigInf.h" #include "SOFIE_namespace.h" using namespace std; using namespace GATS_Utilities; CheckSigInf const & CheckSigInf::operator = (CheckSigInf const &rhs) { if(&rhs == this) return *this; exceptionalErr = rhs.exceptionalErr; return *this; }; MultiSignal CheckSigInf::operator() (MultiSignal const &inSignal) const { // enum {strong, weak, diff}; valarray timeArray; // valarray signalArray; ChannelSignals channel; valarray signal; string errStr = ""; bool badData = false; string auditMsg = processName + string(" processing performed"); inSignal.getTime(timeArray); if (!isfinite(timeArray.sum()) ) { badData = true; errStr = string("nan or inf found in time array \n"); } for(int indx = 0; indx < static_cast(inSignal.numberOfSignals()); indx++) { channel = inSignal.getChannel(indx); if (!isfinite(channel.getSignal(SOFIE::Strong).sum()) ) { badData = true; errStr = errStr + string("nan or inf found in strong detector signal for gas id # ") + ConvertToString(channel.getID()) + "\n"; } if (!isfinite(channel.getSignal(SOFIE::Weak).sum()) ) { badData = true; errStr = errStr + string("nan or inf found in weak detector signal for gas id # ") + ConvertToString(channel.getID()) + "\n"; } if (!isfinite(channel.getSignal(SOFIE::Diff).sum()) ) { badData = true; errStr = errStr + string("nan or inf found in difference signal for gas id # ") + ConvertToString(channel.getID()) + "\n"; } } if(badData) { errorHandler(errStr); } MultiSignal outSignal = inSignal; outSignal.auditAdd(auditMsg); return outSignal; }; void CheckSigInf::errorHandler(string msg) const { cerr << "CheckSigInf error: " << msg << endl; if (exceptionalErr) throw overflow_error(msg); }