/** @class SolarFlux @author Brian Magill @creationdate 8/14/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 contains solar flux data for MSIS model */ #include "SolarFlux.h" #include "GetAPLU.h" #include #include #include using namespace std; //const unsigned long KP_ARRAY_SIZE = 32; SolarFlux::SolarFlux(vector kp, long apvg, float f10_7, float f_90) { GetAPLU get_aplu; assert(kp.size() == KP_ARRAY_SIZE); // There must be data for the current day and 3 previous ones APavg = apvg; flux10_7 = f10_7; flux_90 = f_90; Aplu = vector(kp.size() ); transform(kp.begin(), kp.end(), Aplu.begin(), get_aplu); hasData = true; } SolarFlux::SolarFlux(valarray kValues, long apvg, float f10_7, float f_90) { GetAPLU get_aplu; assert(kValues.size() == KP_ARRAY_SIZE); // There must be data for the current day and 3 previous ones APavg = apvg; flux10_7 = f10_7; flux_90 = f_90; vector kp; for(unsigned long i = 0; i < kValues.size(); i++) { kp.push_back(kValues[i]); } Aplu = vector(kp.size() ); transform(kp.begin(), kp.end(), Aplu.begin(), get_aplu); hasData = true; } SolarFlux::SolarFlux(valarray kValues, long apvg, float f10_7, float f_90) { GetAPLU get_aplu; assert(kValues.size() == KP_ARRAY_SIZE); // There must be data for the current day and 3 previous ones APavg = apvg; flux10_7 = f10_7; flux_90 = f_90; vector kp; for(unsigned long i = 0; i < kValues.size(); i++) { kp.push_back(kValues[i]); } Aplu = vector(kp.size() ); transform(kp.begin(), kp.end(), Aplu.begin(), get_aplu); hasData = true; } vector SolarFlux::getAP(float sec) { const float sec_per_3hr = 10800; vector ap(7); ap[0] = static_cast(APavg); // determine the 3 hour index for this event: vector::iterator ndxnow = Aplu.begin() + 24 + static_cast(sec/sec_per_3hr); // compute ap for present time. its value goes in ap(1) ap[1] = *ndxnow; // compute ap for 3 hours before current time. its value goes in ap(2) ap[2] = *(ndxnow - 1); // compute ap for 6 hours before current time. its value goes in ap(3) ap[3] = *(ndxnow - 2); // compute ap for 9 hours before current time. its value goes in ap(4) ap[4] = *(ndxnow - 3); ap[5] = accumulate(ndxnow - 11, ndxnow - 3, 0.0)/8.; // compute the average of eight 3 hr ap indicies from 36 to 59 hrs prior // to current time. its value goes in ap(6) ap[6] = accumulate(ndxnow - 19, ndxnow - 11, 0.0)/8.; return ap; }