bool MinSfTest::initialize(int argc, char *argv[]) throw() { if (!BasicFramework::initialize(argc, argv)) return false; if (debugLevel) { cout << "Input File: " << inputOption.getValue().front() << endl; cout << "Output File: " << outputOption.getValue().front() << endl; } return true; }
void compSatVis::generateHeader( gpstk::CommonTime currT ) { CommonTime sysTime = SystemTime(); string tform = "%02m/%02d/%02y DOY %03j, GPS Week %F, DOW %w"; fprintf(logfp,"compSatVis output file. Generated at %s\n", printTime(sysTime,"%02H:%02M on %02m/%02d/%02y").c_str() ); fprintf(logfp,"Program arguments:\n"); fprintf(logfp," Navigation file : "); vector<std::string> values = nFileNameOpt.getValue(); for (size_t i=0; i<nFileNameOpt.getCount(); ++i) fprintf(logfp,"%s ",values[i].c_str()); fprintf(logfp,"\n"); fprintf(logfp," Day of interest : %s\n",printTime(currT,tform).c_str()); fprintf(logfp," Minimum elv ang : %5.0f degrees\n",minimumElevationAngle); fprintf(logfp," Evaluation interval : %5.0f sec\n",intervalInSeconds); fprintf(logfp," Station coordinates file: %s\n",mscFileName.getValue().front().c_str()); printNavFileReferenceTime(logfp); fprintf(logfp," Start time of evaluation: %s\n",printTime(startT,tform+", %02H:%02M:%02S").c_str()); fprintf(logfp," End time of evaluation : %s\n",printTime(endT,tform+", %02H:%02M:%02S").c_str()); if (siderealDay) fprintf(logfp," Evaluation covers one sidereal day.\n"); // Print list of stations if (includeStation.getCount() || excludeStation.getCount() ) { fprintf(logfp,"\n Stations included in the analysis\n"); fprintf(logfp," Abbr XYZ(km)\n"); StaPosList::const_iterator si; for (si=stationPositions.begin();si!=stationPositions.end();++si) { string mnemonic = (string) si->first; Position coordinates(si->second); fprintf(logfp," %4s %10.3lf %10.3lf %10.3lf\n", mnemonic.c_str(), coordinates[0]/1000.0, coordinates[1]/1000.0, coordinates[2]/1000.0 ); } int nSta = stationPositions.size(); fprintf(logfp,"Number of Stations: %d\n\n", nSta); } else fprintf(logfp," All stations in coordinates file were included in the analysis."); }
void RinexHeaderDiff:: process() { FileType ft1, ft2; FFData *header1, *header2; string fn1(inputFileOption.getValue()[0]), fn2(inputFileOption.getValue()[1]); bool giveUp = false, including = false; std::vector<std::string> diffs, inclExclList; // Assume the headers are different until proved otherwise. exitCode = 1; if (inclOption.getCount()) { inclExclList = inclOption.getValue(); including = true; } else { // Make exclusion the default because if nothing is // specified, we'll be excluding nothing. inclExclList = exclOption.getValue(); } // First test for readability. Use fopen because perror. FILE *accTest; if ((accTest = fopen(fn1.c_str(), "r")) == NULL) { string errmsg = argv0 + ": " + fn1; std::perror(errmsg.c_str()); giveUp = true; } else { fclose(accTest); } if ((accTest = fopen(fn2.c_str(), "r")) == NULL) { string errmsg = argv0 + ": " + fn2; std::perror(errmsg.c_str()); giveUp = true; } else { fclose(accTest); } // don't bother further processing if we can't open the files if (giveUp) return; // get the headers and file types ft1 = identFile(fn1, header1); ft2 = identFile(fn2, header2); if (ft1 == Unknown) { cerr << argv0 << ": " << fn1 << ": Unknown file format" << endl; giveUp = true; } if (ft2 == Unknown) { giveUp = true; cerr << argv0 << ": " << fn2 << ": Unknown file format" << endl; } // don't bother further processing if files are of an unknown format if (giveUp) return; if (ft1 == ft2) { // compare headers switch (ft1) { case RinexMet: if (dynamic_cast<RinexMetHeader*>(header1)->compare( *(dynamic_cast<RinexMetHeader*>(header2)), diffs, inclExclList, including)) { // compare success exitCode = 0; } break; case RinexNav: if (dynamic_cast<Rinex3NavHeader*>(header1)->compare( *(dynamic_cast<Rinex3NavHeader*>(header2)), diffs, inclExclList, including)) { // compare success exitCode = 0; } break; case RinexObs: if (dynamic_cast<Rinex3ObsHeader*>(header1)->compare( *(dynamic_cast<Rinex3ObsHeader*>(header2)), diffs, inclExclList, including)) { // compare success exitCode = 0; } break; default: cerr << "File format currently not supported" << endl; return; } } else { cerr << argv0 << ": Can't compare files of different formats" << endl; giveUp = true; } if (giveUp) return; if (exitCode) { // found some differences cout << "Headers are different:" << endl; for (unsigned i = 0; i < diffs.size(); i++) cout << diffs[i] << endl; } }
void compSatVis::process() { // Read navigation file input if (verboseOption) { cout << "Loading navigation message data from "; int nfiles = nFileNameOpt.getCount(); vector<std::string> names = nFileNameOpt.getValue(); for (int i1=0;i1<nfiles;++i1) { if (i1>0) cout << ", "; cout << names[i1]; } cout << "." << endl; } switch(navFileType) { case FIC_EPH: VisSupport::readFICNavData(nFileNameOpt,BCAlmList,BCEphList); break; case FIC_ALM: VisSupport::readFICNavData(nFileNameOpt,BCAlmList,BCEphList); break; case RINEX_NAV: VisSupport::readRINEXNavData(nFileNameOpt,BCEphList); break; case Yuma_ALM: VisSupport::readYumaData(nFileNameOpt,YumaAlmStore); break; case SEM_ALM: VisSupport::readSEMData(nFileNameOpt,SEMAlmStore); break; case SP3: VisSupport::readPEData(nFileNameOpt,SP3EphList); break; default: cerr << "Unknown navigation file type in process()." << endl; cerr << "Fatal error. compSatVis will halt." << endl; exit(1); } // Determine day of interest if (debugLevel) cout << "Setting evaluation start time: "; startT = evalStartTime; if (!evalStartTimeSet) startT = setStartTime(); if (debugLevel) cout << printTime(startT, "%02m/%02d/%02y DOY %03j, GPS Week %F, DOW %w, %02H:%02M.") << endl; // If no end time commanded, compute for 23h 56m (GPS ground track repeat) if (debugLevel) cout << "Setting evaluation end time: "; siderealDay = true; endT = startT + ( (double) SEC_PER_DAY - 240.0); if (evalEndTimeSet) endT = evalEndTime; if ((int)(endT-startT)!=(int)(SEC_PER_DAY-240)) siderealDay = false; if (debugLevel) { cout << printTime(endT,"%02m/%02d/%02y DOY %03j, GPS Week %F, DOW %w, %02H:%02M.") << endl; cout << "Sidereal Day flag : " << siderealDay << endl; } CommonTime currT = startT; // Get coordinates for the stations stationPositions = VisSupport::getStationCoordinates( mscFileName, startT, includeStation, excludeStation ); // Generate the header generateHeader( startT ); // For each interval, calculate SV-station visibility if (debugLevel) cout << "Entering calculation loop." << endl; long lastValue = -1; while (currT <= endT) { if (debugLevel) { long sec = (long) static_cast<GPSWeekSecond>(currT).sow; long newValue = sec / 3600; if (newValue!=lastValue) { if (static_cast<CivilTime>(currT).hour==0) cout << printTime(currT,"%02m/%02d/%04Y "); cout << printTime(currT,"%02H:, "); lastValue = newValue; } } computeVisibility( currT ); currT += intervalInSeconds; epochCount++; } if (debugLevel) cout << endl << "Generating trailer." << endl; generateTrailer( ); fclose(logfp); }
bool compSatVis::initialize(int argc, char *argv[]) throw() { if (!BasicFramework::initialize(argc, argv)) return false; // Open the output file logfp = fopen( outputOpt.getValue().front().c_str(),"wt"); if (logfp==0) { cout << "Failed to open output file. Exiting." << endl; return false; } // Set up starting CommonTime, ending CommonTime, number and size of intervals vector<string> values; intervalInSeconds = 60.0; // default if (intervalOpt.getCount()>0) { values = intervalOpt.getValue(); intervalInSeconds = StringUtils::asInt( values[0] ); } navFileType = FIC_ALM; // default case if (typeOpt.getCount()!=0) { values = typeOpt.getValue(); if (values[0].compare("FEPH")==0) navFileType = FIC_EPH; else if (values[0].compare("RNAV")==0) navFileType = RINEX_NAV; else if (values[0].compare("SP3")==0) navFileType = SP3; else if (values[0].compare("FALM")==0) navFileType = FIC_ALM; else if (values[0].compare("YUMA")==0) navFileType = Yuma_ALM; else if (values[0].compare("SEM")==0) navFileType = SEM_ALM; else { cerr << "Invalid value for nav file type. Must be one of " << endl; cerr << " 'FALM', 'FEPH', 'RNAV', or 'SP3'. " << endl; cerr << "Fatal error. compSatVis will terminate." << endl; return false; } } minimumElevationAngle = 10.0; if (minElvOpt.getCount()!=0) { values = minElvOpt.getValue(); minimumElevationAngle = StringUtils::asDouble( values[0] ); } detailPrint = false; if (detailPrintOpt.getCount()!=0) detailPrint = true; minStationCount = 2; if (minStaOpt.getCount()!=0) { values = minStaOpt.getValue(); minStationCount = StringUtils::asInt( values[0] ); } // Initialize the statistics objects for (int PRNID=1;PRNID<=gpstk::MAX_PRN;++PRNID) { StaStats temp = StaStats( StringUtils::asString(PRNID), 0, minStationCount ); pair<int,StaStats> node( PRNID, temp ); staStatsList.insert( node ); DiscreteVisibleCounts dvcTemp = DiscreteVisibleCounts(); pair<int,DiscreteVisibleCounts> dvcNode(PRNID, dvcTemp); dvcList.insert(dvcNode); } statsOverAllPRNs.updateMinStations( minStationCount ); DiscreteVisibleCounts dvcTemp = DiscreteVisibleCounts(); pair<int,DiscreteVisibleCounts> dvcNode(0, dvcTemp); dvcList.insert(dvcNode); // If the user SPECIFIED a start time for the evaluation, store that // time and set the flag. evalStartTimeSet = false; evalStartTime=CommonTime::BEGINNING_OF_TIME; if (evalStartTimeOpt.getCount()!=0) { if (debugLevel) cout << "Reading start time from command line." << endl; std::vector<CommonTime> tvalues = evalStartTimeOpt.getTime(); evalStartTime = tvalues[0]; evalStartTimeSet = true; // Reinit YumaAlmStore to know the time of interest.. if (navFileType==Yuma_ALM) YumaAlmStore = YumaAlmanacStore( evalStartTime ); if (navFileType==SEM_ALM) SEMAlmStore = SEMAlmanacStore( evalStartTime ); } // If the user SPECIFIED an end time for the evaluation, store that // time and set the flag. evalEndTimeSet = false; evalEndTime=CommonTime::END_OF_TIME; if (evalEndTimeOpt.getCount()!=0) { if (debugLevel) cout << "Reading end time from command line." << endl; std::vector<CommonTime> tvalues = evalEndTimeOpt.getTime(); evalEndTime = tvalues[0]; evalEndTimeSet = true; } return true; }
void MinSfTest::process() { if (debugLevel) cout << "Setting up input file: " << inputOption.getValue().front() << endl; FileFilterFrame<FICStream, FICData> input(inputOption.getValue().front()); printf(" input.getDataCount() after init: %d\n", input.getDataCount()); if(debugLevel) cout << "Setting up output file: " << outputOption.getValue().front() << endl; fp.open( outputOption.getValue().front().c_str() ); if ( !fp.is_open() ) { printf(" Failed to open output file.\n"); exit(1); } // filter the FIC data for the requested vlock(s) std::list<long> blockList; blockList.push_back(109); input.filter(FICDataFilterBlock(blockList)); input.sort(FICDataOperatorLessThanBlock109()); input.unique(FICDataUniqueBlock109()); //some hand waving for the data conversion if(debugLevel) cout << "Reading the input data." << endl; list<FICData>& ficList = input.getData(); list<FICData>::iterator itr = ficList.begin(); DayTime earliest( DayTime::END_OF_TIME ); DayTime latest( DayTime::BEGINNING_OF_TIME ); int count = 0; int numMismatches = 0; int numMismatchEph = 0; while (itr != ficList.end()) { EngEphemeris ee(*itr); bc109.addEphemeris( ee ); DayTime ct = ee.getEpochTime(); if (ct>latest) latest = ct; if (ct<earliest) earliest = ct; // Following code simulates a situation where only words 3-10 // and the estimated time of receipt are available. DayTime timeOfReceipt = ee.getTransmitTime(); FICData& fic = *itr; long sf1min[8]; long sf2min[8]; long sf3min[8]; int wrdCnt = 8; int i; for (i=0; i<wrdCnt; ++i) sf1min[i] = fic.i[4+i]; for (i=0; i<wrdCnt; ++i) sf2min[i] = fic.i[14+i]; for (i=0; i<wrdCnt; ++i) sf3min[i] = fic.i[24+i]; EngEphemeris eeMin; short PRNID = (short) fic.i[1]; eeMin.addIncompleteSF1Thru3( sf1min, sf2min, sf3min, (long) timeOfReceipt.GPSsecond(), timeOfReceipt.GPSfullweek(), PRNID, 0 ); minRaw.addEphemeris( eeMin ); // Compare non-orbit portions of the two objects bool mismatch = false; for (int i=1; i<=3; ++i) { if (!ee.isData(i) || !eeMin.isData(i)) { mismatch = true; fp << "ERROR: not all subframes are claimed available."; } } if (ee.getIODC()!=eeMin.getIODC()) { mismatch = true; fp << "ERROR: IODCs do not match."; } if (ee.getIODE()!=eeMin.getIODE()) { mismatch = true; fp << "ERROR: IODCs do not match."; } if (ee.getFitInterval() != eeMin.getFitInterval() ) { mismatch = true; fp << "ERROR: fit intervals do not match."; } if (ee.getCodeFlags()!=eeMin.getCodeFlags() ) { mismatch = true; fp << "ERROR: code flags do not match."; } if (ee.getL2Pdata()!=eeMin.getL2Pdata() ) { mismatch = true; fp << "ERROR: L2P data flags do not match."; } if (ee.getAccuracy()!=eeMin.getAccuracy() ) { mismatch = true; fp << "ERROR: accuracy values do not match."; } if (ee.getAccFlag()!=eeMin.getAccFlag() ) { mismatch = true; fp << "ERROR: accuracy flags do not match."; } if (ee.getHealth()!=eeMin.getHealth() ) { mismatch = true; fp << "ERROR: health values do not match."; } if (ee.getFitInt()!=eeMin.getFitInt() ) { mismatch = true; fp << "ERROR: Fit interval values do not match."; } if (mismatch) { fp << " PRNID: " << PRNID << ", IODC: 0x " << hex << ee.getIODC() << dec << endl; numMismatches++; } itr++; count++; } cout << "Number of Block 109 records read: " << count << endl; if (numMismatches!=0) { printf("Errors detected. Some ephemerides did not match in both forms.\n"); printf("Number of mismatches: %d\n",numMismatches); } fp << "Number of mismatches detected: " << numMismatches << endl; if (debugLevel) cout << "done." << endl; // Generate test positions for PRN 1 and PRN 31 at // earliest epoch, latest epoch, and middle of the time span. try { double timeDuration = latest - earliest; DayTime middle( earliest ); middle += (timeDuration/2); short IODC109 = -1; short IODCMin = -1; short PRNID = 1; printf("--- PRN 1 Examples ---\n"); printf("\nEarliest time\n"); fp << "--- PRN 1 Examples ---" << endl; fp << endl << "Earliest time" << endl; testXvt( PRNID, earliest ); printf("\nMiddle time\n"); fp << endl << "Middle time" << endl; testXvt( PRNID, middle ); printf("\nLatest time\n"); fp << endl << "Latest time" << endl; testXvt( PRNID, latest ); PRNID = 31; printf("\n--- PRN 31 Examples ---\n"); printf("\nEarliest time\n"); fp << endl << "--- PRN 31 Examples ---" << endl; fp << endl << "Earliest time" << endl; testXvt( PRNID, earliest ); printf("\nMiddle time\n"); fp << endl << "Middle time" << endl; testXvt( PRNID, middle ); printf("\nLatest time\n"); fp << endl << "Latest time" << endl; testXvt( PRNID, latest ); } catch (gpstk::Exception& e) { cout << e << endl; } printf("\nBCEphemerisStore directly from existing FIC handlers.\n"); fp << endl << "BCEphemerisStore directly from existing FIC handlers." << endl; bc109.dump(1, fp); printf("BCEphemerisStore from new method.\n"); fp << endl << "BCEphemerisStore from new method." << endl; minRaw.dump(1, fp); // write the file data if (debugLevel) cout << "Conversion complete." << endl; }