Beispiel #1
0
//=============================================================================
// Test for getXvt.
// Tests the getXvt method in SP3EphemerisStore by comparing known
// results with the method's output for various time stamps in an
// SP3 file; also ensures nonexistent SatIDs throw an exception
//=============================================================================
   int getXvtTest (void)
   {
      TUDEF( "SP3EphemerisStore", "getXvt" );

      try
      {
         SP3EphemerisStore store;
         store.loadFile(inputSP3Data);

         stringstream outputStream1;
         stringstream outputStream15;
         stringstream outputStream31;

         const short PRN0 = 0; // Nonexistent in SP3 file
         const short PRN1 = 1;
         const short PRN15 = 15;
         const short PRN31 = 31;
         const short PRN32 = 32; // Nonexistent in SP3 file

         SatID sid0(PRN0,SatID::systemGPS);
         SatID sid1(PRN1,SatID::systemGPS);
         SatID sid15(PRN15,SatID::systemGPS);
         SatID sid31(PRN31,SatID::systemGPS);
         SatID sid32(PRN32,SatID::systemGPS);

         CivilTime eTime_civ(1997,4,6,6,15,0); // Time stamp of one epoch
         CommonTime eTime = eTime_civ.convertToCommonTime();
         CivilTime bTime_civ(1997,4,6,0,0,0); // Time stamp of first epoch
         CommonTime bTime = bTime_civ.convertToCommonTime();

         try
         {
               // Verify that an InvalidRequest exception is thrown when SatID is not in the data
            try
            {
               store.getXvt(sid0,bTime);
               TUFAIL("No exception thrown when getXvt looks for an invalid"
                      " SatID");
            }
            catch (InvalidRequest& e)
            {
               TUPASS("Expected exception thrown when getXvt looks for an invalid"
                      " SatID");
            }
            catch (...)
            {
               TUFAIL("Unexpected exception thrown when getXvt looks for an"
                      " invalid SatID");
            }

               // Verify that an InvalidRequest exception is thrown when SatID is not in the data
            try
            {
               store.getXvt(sid32,bTime);
               TUFAIL("No exception thrown when getXvt looks for an invalid"
                      " SatID");
            }
            catch (InvalidRequest& e)
            {
               TUPASS("Expected exception thrown when getXvt looks for an invalid"
                      " SatID");
            }
            catch (...)
            {
               TUFAIL("Unexpected exception thrown when getXvt looks for an"
                      " invalid SatID");
            }

               // Verify that no exception is thrown for SatID in the data set
            try
            {
               store.getXvt(sid1,eTime);
               TUPASS("No exception thrown when getXvt looks for a valid SatID");
            }
            catch (...)
            {
               TUFAIL("Exception thrown when getXvt looks for a valid SatID");
            }

            outputStream1 << store.getXvt(sid1,eTime);
            outputStream15 << store.getXvt(sid15,eTime);
            outputStream31 << store.getXvt(sid31,eTime);
         }

         catch (Exception& e)
         {
            cout << e;
         }

            //--------------------------------------------------------------------
            // Were the values set to expectation using the explicit constructor?
            //--------------------------------------------------------------------
         TUASSERTE(std::string, inputComparisonOutput1, outputStream1.str());
         TUASSERTE(std::string, inputComparisonOutput15, outputStream15.str());
         TUASSERTE(std::string, inputComparisonOutput31, outputStream31.str());
      }
      catch (...)
      {
         TUFAIL("Unexpected exception");
      }

      return testFramework.countFails();
   }
Beispiel #2
0
void compSatVis::computeVisibility( gpstk::CommonTime currT )
{
   gpstk::Position SVpos[gpstk::MAX_PRN+1];
   bool SVAvail[gpstk::MAX_PRN+1];
   Xvt SVxvt;
   
      // Compute SV positions for this epoch
   int PRNID;
   for (PRNID=1;PRNID<=gpstk::MAX_PRN;++PRNID)
   {
      SVAvail[PRNID] = false;
      try
      {
         SatID satid(PRNID,SatID::systemGPS);
         switch(navFileType)
         {
            case FIC_EPH:
            case RINEX_NAV:
               SVxvt = BCEphList.getXvt( satid, currT );
               break;
            
            case FIC_ALM:
               SVxvt = BCAlmList.getXvt( satid, currT );
               break;
            
            case Yuma_ALM:
               SVxvt = YumaAlmStore.getXvt( satid, currT );
               break;
 
            case SEM_ALM:
               SVxvt = SEMAlmStore.getXvt( satid, currT );
               break;
            
            case SP3:
               SVxvt = SP3EphList.getXvt( satid, currT );
               break;
               
            default:
               cerr << "Unknown navigation file type in computeVisibility()." << endl;
               cerr << "Fatal error. compSatVis will halt." << endl;
               exit(1);
         }
         SVpos[PRNID] = SVxvt.x; 
         SVAvail[PRNID] = true;
      }
      catch(InvalidRequest& e)
      { 
         continue;
      }
   }
   
      // If first time through, print the detail hearder if required.
   if (detailPrint && currT==startT)
   {
      fprintf(logfp," Number of Stations visible to each SV by epoch\n");
      fprintf(logfp,"  PRN, ");
      for (int pi=1;pi<=gpstk::MAX_PRN;++pi)
      {
         if (SVAvail[pi]) fprintf(logfp," %4d,",pi);
      }
      fprintf(logfp,"   Max,   Min\n");
   }
   
   if (detailPrint) fprintf(logfp,"%s, ",printTime(currT,"%02H:%02M").c_str());

      // Now count number of Stations visible to each SV
   int maxNum = 0;
   int minNum = stationPositions.size() + 1; 
   StaPosList::const_iterator splCI;
   DiscreteVisibleCounts& dvc0 = dvcList.find(0)->second;
   
   for (PRNID=1;PRNID<=gpstk::MAX_PRN;++PRNID)
   {
      if (!SVAvail[PRNID]) continue;
      int numVis = 0;
      for (splCI =stationPositions.begin();
           splCI!=stationPositions.end();
           ++splCI)
      {
         Position staPos = splCI->second;
         double elv = staPos.elvAngle( SVpos[PRNID] );
         if (elv>=minimumElevationAngle) numVis++;
      }
      if (detailPrint) fprintf(logfp,"   %2d,",numVis);
      if (numVis>maxNum) maxNum = numVis;
      if (numVis<minNum) minNum = numVis;
      
      StaStatsList::iterator sslI = staStatsList.find( PRNID );
      if (sslI==staStatsList.end())
      {
         cerr << "Missing statistics object for satellite " << PRNID << endl;
         cerr << "Fatal error.  compSatVis will termination." << endl;
      }
      StaStats& ss = sslI->second;
      ss.addEpochInfo( numVis, epochCount );
      statsOverAllPRNs.addEpochInfo( numVis, epochCount );
      DiscreteVisibleCounts& dvc = dvcList.find(PRNID)->second;
      dvc.addCount(numVis);
      dvc0.addCount(numVis);
   }
   if (detailPrint) fprintf(logfp,"    %2d,    %2d\n",maxNum,minNum);
}
Beispiel #3
0
int main(int argc, char *argv[])
{
   if (argc<2) {
      cout << "Usage: petest <SP3-format files ...>\n";
      return -1;
   }

   try
   {

      bool firstEpochFound=true;
      DayTime firstTime;
      DayTime lastTime;
      SatID firstSat;
         
      int i,ip,it,nf=0,np=0,nt=0;
      SP3EphemerisStore EphList;
      for(i=1; i<argc; i++) {
         SP3Header header;
         SP3Data data;
         
         // you can't open, close, and reopen a file w/o abort on second open...
         SP3Stream pefile;
         pefile.exceptions(ifstream::failbit);
         cout << "Reading SP3 file " << argv[i] << "." << endl;
         pefile.open(argv[i],ios::in);

         pefile >> header;
         data.version = header.version;
         
         //cout << "Dump header:\n";
         //header.dump(cout);
         //cout << endl;

         ip = it = 0;
         DayTime t(DayTime::BEGINNING_OF_TIME);

         while(pefile >> data) {
            if (firstEpochFound)
            {  
               firstSat = data.sat;
               firstTime = data.time;
               lastTime = firstTime;
               
               firstEpochFound=false;
            }

            if (data.time > lastTime) lastTime = data.time;
            
            if(data.time > t) {
               //cout << "Epoch " << data.time << endl;
               t = data.time;
               it++; nt++;
            }
            //data.dump(cout);
            ip++; np++;
         }
         cout << "\nDone with file " << argv[i] << ": read "
              << ip << " P/V records and " << it << " epochs." << endl;
         pefile.close();
         nf++;

         // add to store
         EphList.loadFile(string(argv[i]));
      }
      
      cout << "\nDone with " << nf << " files: read "
           << np << " P/V records and " << nt << " epochs." << endl;

      //EphList.dump(2);

      unsigned long ref;
      // choose a time tag within the data....
      DayTime tt = firstTime + (lastTime-firstTime)/2.;
      SatID tsat = firstSat;
      Xvt PVT;
      for(i=0; i<300; i++) {
         tt += 30.0;
         PVT = EphList.getXvt(tsat,tt);

         if (true) 
            cout << "LI " << tt << " P " << fixed
                 << setw(13) << setprecision(6) << PVT.x[0] << " "
                 << setw(13) << setprecision(6) << PVT.x[1] << " "
                 << setw(13) << setprecision(6) << PVT.x[2] << " "
                 << setw(13) << setprecision(6) << PVT.dtime
                 << " V "
                 << setw(13) << setprecision(6) << PVT.v[0] << " "
                 << setw(13) << setprecision(6) << PVT.v[1] << " "
                 << setw(13) << setprecision(6) << PVT.v[2] << " "
                 << setw(13) << setprecision(6) << PVT.ddtime
                 << endl;
      }
      
   }
   catch (Exception& e)
   {
      cout << e;
      exit(-1);
   }
   catch (...)
   {
      cout << "Caught an unknown exception" << endl;
      exit(-1);
   }

   return 0;
}