Example #1
0
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.");
}
Example #2
0
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;
   }
}
Example #3
0
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);
   
}
Example #4
0
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;   
}