/** @class EffPointingCutoff.cpp @author Greg Paxton @creation date 9/18/2009 $Date:$ $Revision:$ @copyright (©) Copyright 2009 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 Determines the Pointing Correction Cutoff index */ #include #include "EffPointingCutoff.h" #include using namespace std; void EffPointingCutoff::operator()(valarray const &time, valarray const &lockdown, double & value, long & index) { long i = 0; double dx = 0.0; double a = 0.0; index = 0; if (cutoffTime < time.min() || cutoffTime > time.max()) { std::cout << "EffPointingCutoff: time min is " << time.min() << " time max is " << time.max() << " cutoffTime is " << cutoffTime << std::endl; throw runtime_error("\nEffPointingCutoff:: cutoff time out of range"); } if (mode) { for(i = 0; i < (long)(time.size()); i++) { if (time[i] >= cutoffTime) { index = i; } } if (index == (long)(time.size() - 1)) { value = lockdown[index]; std::cerr << "\nEffPointingCutoff: Cutoff time is equal to the end of the time array\n" << std::endl; return; } } else { for(i = 0; i < (long)(time.size()); i++) //for(i = time.size() - 1; i >= 0 ; i--) { if (time[i] <= cutoffTime) { index = i; } } if (index == (long)(time.size() - 1)) { value = lockdown[index]; std::cerr << "\nEffPointingCutoff: Cutoff time is equal to the end of the time array\n" << std::endl; return; } } // Interpolate the lockdown position from the time grid at the cutoff time. dx = time[index+1] - time[index]; if (dx == 0.0) { value = (lockdown[index] + lockdown[index+1])/2; } else { a = (cutoffTime - time[index]) / dx; value = lockdown[index] + a * (lockdown[index+1] - lockdown[index]); } }