/** @file PointingDriftScaling.cpp @author Brian Magill @creation date 6/9/2008 $Date:$ $Revision:$ @copyright (©) Copyright 2008 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 Calculates the factor for normalling the solar source model */ #include "PointingDriftScaling.h" #include #include #include //#include "SOFIE_namespace.h" using namespace std; double PointingDriftScaling::operator()(valarray const & model) const { string strErr; unsigned long timeIndex; unsigned long indx; bool foundIndex = false; double result = 0.0; assert(model.size() == time.size()); if (sunsetMode) { for(indx = 0; indx < time.size(); indx++) if (calEnd <= time[indx]) { timeIndex = indx; foundIndex = true; break; } if (!timeIndex) throw runtime_error("PointingDriftScaling: Could not find time range for averaging"); if (timeIndex + sampleSize > time.size()) throw runtime_error("PointingDriftScaling: averaging sample exceeds upper time boundary"); for(indx = timeIndex; indx < timeIndex + sampleSize; indx++) result += model[indx]; result = result/sampleSize; } else { for(indx = 0; indx < time.size(); indx++) { if (calStart < time[indx]) { foundIndex = true; break; } timeIndex = indx; } if (!timeIndex) throw runtime_error("PointingDriftScaling: Could not find time range for averaging"); if (timeIndex - sampleSize <= 0) throw runtime_error("PointingDriftScaling: averaging sample exceeds upper time boundary"); for(indx = timeIndex - sampleSize + 1; indx <= timeIndex ; indx++) result += model[indx]; result = result/sampleSize; } return result; }