EphComp.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: EphComp.cpp 1895 2009-05-12 19:34:29Z afarris $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //  
00021 //  Copyright 2009, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 // EphComp.cpp compare BC and SP3 ephemerides
00026 //
00027 #include <iostream>
00028 #include <iomanip>
00029 #include <string>
00030 #include <map>
00031 
00032 #include "DayTime.hpp"
00033 
00034 #include "RinexEphemerisStore.hpp"
00035 #include "SP3EphemerisStore.hpp"
00036 
00037 #include "CommandOption.hpp"
00038 #include "CommandOptionParser.hpp"
00039 
00044 using namespace std;
00045 
00046 int main(int argc, char *argv[])
00047 {
00048    try
00049    {
00050       gpstk::CommandOptionNoArg
00051          helpOption('h', "help", "Print help usage");
00052       gpstk::CommandOptionWithNumberArg
00053          prnOption('s', "prn", "Which SV to compare");
00054       gpstk::CommandOptionWithAnyArg
00055          sp3Files('p', "precise", "SP3 file",true),
00056          bceFiles('b', "broadcast", "RINEX nav file",true);
00057 
00058       string appDesc("Computes diferences between broadcast and precise ephemerides.");
00059       gpstk::CommandOptionParser cop(appDesc);
00060       cop.parseOptions(argc, argv);
00061 
00062       if (helpOption.getCount() || cop.hasErrors())
00063       {
00064          if (cop.hasErrors())
00065             cop.dumpErrors(cout);
00066          cop.displayUsage(cout);
00067          exit(0);
00068       }
00069 
00070       // load all the SP3 ephemerides files
00071       gpstk::SP3EphemerisStore SP3EphList;
00072       SP3EphList.loadFiles(sp3Files.getValue());
00073 
00074       // load the BC ephemerides
00075       gpstk::RinexEphemerisStore BCEphList;
00076       BCEphList.loadFiles(bceFiles.getValue());
00077          
00078       int prn=13;
00079       if (prnOption.getCount())
00080          prn = gpstk::StringUtils::asInt((prnOption.getValue())[0]);
00081 
00082       // choose a time range within the data....
00083       gpstk::DayTime te(BCEphList.getFinalTime());
00084       gpstk::DayTime t(BCEphList.getInitialTime());
00085       //BCEphList.SearchNear();
00086       gpstk::Xvt SP3PVT,BCPVT;
00087       while (t < te)
00088       {
00089          t += 15.0;
00090          try
00091          {
00092             // get the SP3 & BCE PVT
00093             SP3PVT = SP3EphList.getPrnXvt(prn,t);
00094             BCPVT = BCEphList.getPrnXvt(prn,t);
00095             cout << fixed << t
00096                  << " " << setw(2) << prn
00097                  << setprecision(6)
00098                  << " " << setw(13) << BCPVT.x[0]-SP3PVT.x[0]
00099                  << " " << setw(13) << BCPVT.x[1]-SP3PVT.x[1]
00100                  << " " << setw(13) << BCPVT.x[2]-SP3PVT.x[2]
00101                  << scientific
00102                  << " " << setw(13) << BCPVT.dtime-SP3PVT.dtime
00103                  << fixed
00104                  << " " << setw(13) << BCPVT.v[0]-SP3PVT.v[0]
00105                  << " " << setw(13) << BCPVT.v[1]-SP3PVT.v[1]
00106                  << " " << setw(13) << BCPVT.v[2]-SP3PVT.v[2]
00107                  << scientific
00108                  << " " << setw(13) << BCPVT.ddtime-SP3PVT.ddtime
00109                  << endl;
00110          }
00111          catch (gpstk::EphemerisStore::NoEphemerisFound& e)
00112          {
00113             cerr << t << " " << e << endl;
00114             continue;
00115          }
00116 
00117       }
00118    }
00119    catch (gpstk::Exception& e)
00120    {
00121       cout << e;
00122       exit(-1);
00123    }
00124    catch (...)
00125    {
00126       cout << "Caught an unknown exception" << endl;
00127       exit(-1);
00128    }
00129 
00130    return 0;
00131 }

Generated on Wed Feb 8 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1