// //----------------------------------------------------------------------- /// @copyright /// (c) 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. /// //----------------------------------------------------------------------- /// /// @file Level0Profiles.cpp /// /// @author John Burton /// /// @date Thu Jan 17 14:08:25 2008 /// //----------------------------------------------------------------------- // //----------------------------------------------------------------------- // Include Files: //----------------------------------------------------------------------- // #include #include "ChainSawFilter.h" #include "Level0Profiles.h" #include "SunSensorRegion.h" #include "GATS_Utilities.hpp" #include "Interpolate.h" // //----------------------------------------------------------------------- // Defines and Macros: //----------------------------------------------------------------------- // // //----------------------------------------------------------------------- // Global Variables: //----------------------------------------------------------------------- // static const double FIXED2FLOAT = 32.0; // //----------------------------------------------------------------------- // Class Methods: //----------------------------------------------------------------------- // EventVarVect Level0Profiles::convertSums2Double(EventVarVect intSums) { EventVar tmp; EventVarVect doubleSums; int i,n,len; for(n=0;n intSums; EventVar SunSensorTimeStamp_; L0.getEventVar("L0_SolarTrackerTimes", TrackTimeStamp_); L0.getEventVar("L0_SolarImageTimes", PixelTimeStamp_); L0.getEventVar("L0_SolarTrackXLow", Track_Low_X_); L0.getEventVar("L0_SolarTrackXHigh", Track_High_X_); L0.getEventVar("L0_SolarTrackYLow", Track_Low_Y_); L0.getEventVar("L0_SolarTrackYHigh", Track_High_Y_); L0.getEventVar("L0_SolarTrackerStatus", Track_Status_); L0.getEventVar("L0_SolarImages", SumsData_); eventNumber_ = L0.getEventNumber(); srssflag_ = L0.getSRSSFlag(); // L1.getEventVar("L1_DetectorTimes", SunSensorTimeStamp_); // EventVar CorrectedTimeStamp(TrackTimeStamp_); // CorrectedTimeStamp[0] = CorrectedTimeStamp[0] * 0.999998505; // for(int i=0; i good = ((Track_Status_ >= 0xA000) && (Track_High_X_ > 0.0) && (Track_Low_X_ >= 0.0) && (Track_High_Y_ > 0.0) && (Track_Low_Y_ >= 0.0) && (SumsData_[6] > 0)); //std::cout << SumsData_.size() << std::endl; //std::cout << good.size() << std::endl; //exit(23); good = good && good.cshift(1)&& good.cshift(2); //for(unsigned jj = 0; jj < 90; ++jj) // std::cout << good[jj] << std::endl; TrackTimeStamp_ = TrackTimeStamp_[good]; PixelTimeStamp_ = PixelTimeStamp_[good]; Track_Low_X_ = Track_Low_X_[good]; Track_High_X_ = Track_High_X_[good]; Track_Low_Y_ = Track_Low_Y_[good]; Track_High_Y_ = Track_High_Y_[good]; Track_Status_ = Track_Status_[good]; ROI_Low_X_ = Track_Low_X_; ROI_High_X_ = Track_High_X_; ROI_Low_Y_ = Track_Low_Y_; ROI_High_Y_ = Track_High_Y_; for(int i=0; i evv; evv.addEventVar(Track_Low_X_); evv.addEventVar(Track_High_X_); evv.addEventVar(Track_Low_Y_); evv.addEventVar(Track_High_Y_); evv.Plot("Raw Tracking Data","After Select"); evv.clear(); } DSumsData_ = convertSums2Double(SumsData_); } void Level0Profiles::correctTimeStamp(void) { int i; double delta, tmp, tts, pts; double increment = 0.05; double correction_factor = 0.999998505; EventVar TTS(TrackTimeStamp_.size()); EventVar PTS(PixelTimeStamp_.size()); // std::string fname = "./OutputFiles/TimeStamp.dat"; // std::ofstream outfile; // outfile.open(fname.c_str(),std::ofstream::out); TTS[0] = TrackTimeStamp_[0] * correction_factor; PTS[0] = PixelTimeStamp_[0] * correction_factor; tts = TTS[0]; pts = PTS[0]; for(i=1; i low_x_roi_x(len); EventVar high_x_roi_x(len); EventVar center_roi_x(len); EventVar low_y_roi_y(len); EventVar high_y_roi_y(len); EventVarVect evv; for(int i=0; i evv; std::string lox_name = "Threshold_lox"; std::string hix_name = "Threshold_hix"; std::string loy_name = "Threshold_loy"; std::string hiy_name = "Threshold_hiy"; double lox_threshold = 0.000015; double hix_threshold = 0.000015; double loy_threshold = 0.0002; double hiy_threshold = 0.0002; if(CF_.ValidEntry(Section_,lox_name)) lox_threshold = CF_.GetReal(Section_,lox_name); if(CF_.ValidEntry(Section_,hix_name)) hix_threshold = CF_.GetReal(Section_,hix_name); if(CF_.ValidEntry(Section_,loy_name)) loy_threshold = CF_.GetReal(Section_,loy_name); if(CF_.ValidEntry(Section_,hiy_name)) hiy_threshold = CF_.GetReal(Section_,hiy_name); evv.addEventVar(Track_Low_X_); std::cerr << "doChainSawFilter::Track_Low_X\n"; Track_Low_X_ = applyChainSawFilter(Track_Low_X_,lox_threshold); evv.addEventVar(Track_Low_X_); if(CF_.GetFlag(Section_,"PlotTrackingData")) evv.Plot("Low_X_Track_","Level0Profiles::doChainSawFilter"); evv.clear(); // std::cerr << "doChainSawFilter::Track_High_X\n"; evv.addEventVar(Track_High_X_); Track_High_X_ = applyChainSawFilter(Track_High_X_,hix_threshold); evv.addEventVar(Track_High_X_); if(CF_.GetFlag(Section_,"PlotTrackingData")) evv.Plot("High_X_Track_","Level0Profiles::doChainSawFilter"); evv.clear(); // std::cerr << "doChainSawFilter::Track_Low_Y\n"; Track_Low_Y_ = applyChainSawFilter(Track_Low_Y_,loy_threshold); // std::cerr << "doChainSawFilter::Track_High_Y\n"; Track_High_Y_ = applyChainSawFilter(Track_High_Y_,hiy_threshold); // Track_Low_X_.Plot("Track_Low_X_","After Chainsaw Filter"); if(CF_.GetFlag(Section_,"PlotTrackingData")) { EventVarVect evv; evv.addEventVar(Track_Low_X_); evv.addEventVar(Track_High_X_); evv.addEventVar(Track_Low_Y_); evv.addEventVar(Track_High_Y_); evv.Plot("Filtered Tracking Data","Level0Profiles::doChainSawFilter"); evv.clear(); } } EventVarVect Level0Profiles::timeAlignSumsData(EventVarVect &sums, EventVarVect &locs, double &shft) { int nelem = sums.size(); int nlen = sums[0].size(); int minrow = 1023; int maxrow = 0; int tmp,i,j; std::string str; std::map rows; std::map revs; EventVarVect unsums; EventVarVect outsums; EventVarVect tmpsums; EventVar evtmp(nlen); EventVar ts; evtmp.setValueZero(); for(i=0;i tmp) ? tmp : minrow; tmp = locs[i].max(); maxrow = (maxrow < tmp) ? tmp : maxrow; } minrow = minrow - 1; maxrow = maxrow + 1; j = 0; for(i=0;i<1024;i++) unsums.addEventVar(evtmp); for(i=0; i0) count++; if(count>500) tmpsums.addEventVar(unsums[i]); } int ext = 1; for(i=0; i tmploc(sums[0].size()); for(i=0; i low_x_sums; EventVarVect high_x_sums; EventVarVect low_y_sums; EventVarVect high_y_sums; EventVarVect center_sums; EventVarVect low_x_loc; EventVarVect high_x_loc; EventVarVect low_y_loc; EventVarVect high_y_loc; EventVarVect center_loc; EventVarVect evv; EventVar itmp; // double hix_ts = 0.02232; // double lox_ts = 0.02072; // double hix_ts = 0.0015605; // double lox_ts = -0.00175509; double hix_ts = 0.00115636; double lox_ts = 1.3407e-08; double hiy_ts = 0.0; double loy_ts = 0.0; double ctr_ts = 0.0166074; if(CF_.ValidEntry(Section_,hix_name)) hix_ts= CF_.GetReal(Section_,hix_name); if(CF_.ValidEntry(Section_,lox_name)) lox_ts= CF_.GetReal(Section_,lox_name); if(CF_.ValidEntry(Section_,hiy_name)) hiy_ts= CF_.GetReal(Section_,hiy_name); if(CF_.ValidEntry(Section_,loy_name)) loy_ts= CF_.GetReal(Section_,loy_name); if(CF_.ValidEntry(Section_,ctr_name)) ctr_ts= CF_.GetReal(Section_,ctr_name); for(int i=0; i low_x_sums; EventVarVect high_x_sums; EventVarVect low_y_sums; EventVarVect high_y_sums; EventVarVect center_sums; EventVarVect low_x_loc; EventVarVect high_x_loc; EventVarVect low_y_loc; EventVarVect high_y_loc; EventVarVect center_loc; EventVar itmp; double hix_ts = 0.00115636; double lox_ts = 1.3407e-08; double ctr_ts = 0.0166074;; // double hix_ts = par[0]; // double lox_ts = par[1]; // double ctr_ts = par[3]; double hiy_ts = par[0]; double loy_ts = par[1]; // double hiy_ts = par[2]; // double loy_ts = par[3]; // double ctr_ts = par[4]; // double hix_ts = par[4]; // double lox_ts = par[5]; // double hiy_ts = par[6]; // double loy_ts = par[7]; // double ctr_ts = par[8]; for(int i=0; i tvect; EventVar hix_ts, lox_ts, hiy_ts, loy_ts; hix_ts = PixelTimeStamp_ - 0.05260; lox_ts = PixelTimeStamp_ - 0.05100; hiy_ts = PixelTimeStamp_ - 0.07825; loy_ts = PixelTimeStamp_ - 0.06825; Track_Low_X_ = Track_Low_X_.VInterpol(lox_ts, PixelTimeStamp_); Track_High_X_ = Track_High_X_.VInterpol(hix_ts, PixelTimeStamp_); Track_Low_Y_ = Track_Low_Y_.VInterpol(loy_ts, PixelTimeStamp_); Track_High_Y_ = Track_High_Y_.VInterpol(hiy_ts, PixelTimeStamp_); } void Level0Profiles::alignTrackingData2TimeGrid(double *par) { EventVarVect tvect; EventVar hix_ts, lox_ts, hiy_ts, loy_ts; hix_ts = PixelTimeStamp_ - 0.05260; lox_ts = PixelTimeStamp_ - 0.05100; hiy_ts = PixelTimeStamp_ - par[2]; loy_ts = PixelTimeStamp_ - par[3]; Track_Low_X_ = Track_Low_X_.VInterpol(lox_ts, PixelTimeStamp_); Track_High_X_ = Track_High_X_.VInterpol(hix_ts, PixelTimeStamp_); Track_Low_Y_ = Track_Low_Y_.VInterpol(loy_ts, PixelTimeStamp_); Track_High_Y_ = Track_High_Y_.VInterpol(hiy_ts, PixelTimeStamp_); ROI_Low_Y_ = Track_Low_Y_; ROI_High_Y_ = Track_High_Y_; } EventVar Level0Profiles::getSumsData(int i) { int j; int len = SumsData_.size(); EventVar tmp(len); for(j=0;j Level0Profiles::getDSumsData(int i) { int j; int len = DSumsData_.size(); EventVar tmp(len); for(j=0;j