Пример #1
0
void ObsArrayEvaluator::run(int argc, char *argv[])
{
   // Default difference that isolates multipath from the Y code
   string formula="P1-wl1*L1+2/(1-gamma)*(wl1*L1-wl2*L2)";
   formula = "C1Y-wl1*L1Y+2/(1-gamma)*(wl1*L1Y-wl2*L2Y)";

   // Default minimum length for a pass for use solution
   double minPassLength = 300;
   double angInterval = 15; 

   CommandOptionNoArg 
      rawOption('r', "raw","Output raw data instead of descriptive statistics"),
      numericOption('n', "numeric", "Format output for numerical packages"),
      azimuthOption('a', "azimuth", "Compute statistics binned by azimuth "
                    "instead of elevation"),
      debiasOption('z', "debias", "Remove the mean of each pass before "
                   "outputting or computing statistics.");

   CommandOptionWithAnyArg
      binOption('b', "bin", 
                "Defines a bin. Eliminates the default bins. Repeated use "
                "of this option defines additional bins. Value is min,max. "
                "Ex.: -b 10,90"),
      formulaOption('f', "function",
                    "Function to evaluate for the data. The default is the dual "
                    "frequency multipath combination " + formula + ".");

   CommandOptionWithNumberArg 
      lengthOption('l', "length", "Minimum length in seconds for an "
                   "overhead pass to be used. Default value is " + 
                   StringUtils::asString(minPassLength, 1) + " seconds."),
      angWidthOption('w', "width", "Width of angular bins to use. If used, "
                     "defines regular, nonoverlapping bins of azimuth or "
                     "elevation. Default value is " + 
                     StringUtils::asString(angInterval, 2) + " degrees.");

   lengthOption.setMaxCount(1);
   angWidthOption.setMaxCount(1);
   formulaOption.setMaxCount(1);
      
   initialize(argc, argv);

   DayTime now;

   bool numeric = numericOption.getCount()>0;
         
   ObsArray oa;

   if (formulaOption.getCount()>0)
      formula = formulaOption.getValue()[0];

   if ((verboseLevel) && (!numeric))
      output << "Formula: " << formula << endl;

   oa.debugLevel = debugLevel;

   oa.add(formula);
   oa.load(obsFiles, *ephReader.eph, rxPos);
   size_t originalLength = oa.getNumSatEpochs();
      
   if ((!numeric)&& (verboseLevel))
      output << "Editing points with loss of lock indication and pass with "
         "short lengths." << endl;
      
   valarray<bool> removePts = oa.lli;
   if (lengthOption.getCount()>0)
      minPassLength =  StringUtils::asDouble(lengthOption.getValue()[0]);
      
   set<long> allpasses = unique(oa.pass);
   for (set<long>::iterator i=allpasses.begin(); i!=allpasses.end(); i++)
      if (oa.getPassLength(*i)<minPassLength)
         removePts = removePts || (oa.pass==*i);
      
   oa.edit(removePts);
   allpasses = unique(oa.pass);
      
   size_t editedLength = oa.getNumSatEpochs();
   double pct_edited = 100.*(originalLength-editedLength)/originalLength;
   if (!numeric)
      output << "Edited " << (originalLength-editedLength)
           << " points (" << setprecision(2) << pct_edited << "%)."
           << endl;

   if (pct_edited > 50)
   {
      output << "Edited more than 50% of the data. This is bad. I quit." << endl;
      exit(-1);
   }

   if (debiasOption.getCount())
   {
      if (!numeric)
         output << "Removing mean of each pass." << endl;
      
      for (set<long>::iterator iPass=allpasses.begin();
           iPass!=allpasses.end() ; iPass++)
      {
         valarray<bool> passMask = (oa.pass==*iPass);
         valarray<double> mpVals = oa.observation[passMask];
         double mean = mpVals.sum() / mpVals.size();
         mpVals -= mean;
         oa.observation[passMask]=mpVals;
      }
   }

   allpasses = unique(oa.pass);
   if (!numeric)
      output << "Data collection interval is " << fixed << setprecision(1)
           << oa.interval << " seconds" << "." <<endl
           << "Overhead passes used: " << allpasses.size() << endl;

   if (rawOption.getCount()>0)
   {
      dumpRaw(oa, numeric);
   }
   else
   {
      bool byAzimuth = (azimuthOption.getCount()>0);
      if (angWidthOption.getCount()>0)
         angInterval =  StringUtils::asDouble(angWidthOption.getValue()[0]);
      bool regularIntervals = (byAzimuth || (angWidthOption.getCount()>0));

      SparseBinnedStats<double> sbs;
      if (binOption.getCount()==0)
      {  
         if (!byAzimuth)
         {
            if (!regularIntervals)
            {      
               sbs.addBin(0,90);
               sbs.addBin(10,30);
               sbs.addBin(20,40);
               sbs.addBin(40,90);
               sbs.addBin(10,90);
            }
            else
            {
               for (double d=0; d<90; d+=angInterval)
                  sbs.addBin(d,d+angInterval);
            }
         }
         else
         {
            for (double d=0; d<359; d+=angInterval)
               sbs.addBin(d,d+angInterval);
         }
      }
      else
      {
         for (int k=0; k<binOption.getValue().size(); k++)
         {  
            string temp = binOption.getValue()[k];
            string lowerWord = StringUtils::word(temp,0,',');
            string upperWord = StringUtils::word(temp,1,',');
            sbs.addBin(StringUtils::asDouble(lowerWord),
                       StringUtils::asDouble(upperWord));
         }            
      }
         
      for (set<long>::iterator iPass=allpasses.begin();
           iPass!=allpasses.end() ; iPass++)
      {
         valarray<bool> passMask = (oa.pass==*iPass);
         valarray<double> mpVals = oa.observation[passMask];
         valarray<double> binVals(mpVals.size());
         if (!byAzimuth)
            binVals = oa.elevation[passMask];
         else
            binVals = oa.azimuth[passMask];
            
         sbs.addData(mpVals, binVals);
      }

      writeStats(sbs, numeric, !byAzimuth);
   }
      

   DayTime then;

   if ( (verboseLevel) && (!numeric))
      output << "Processing complete in " << then - now << " seconds." << endl;
}
Пример #2
0
int main(int argc, char* argv[])
{
   try {

      ObsArray oa;

      cout << oa.add(RinexObsHeader::C1) << endl;
      cout << oa.add(RinexObsHeader::P2) << endl;
      cout << oa.add("C1-P2") << endl;
      cout << oa.add("P1-wl1*L1-1/(1-gamma)*(wl1*L1-wl2*L2)");
      
      cout << "There are " << oa.getNumObsTypes() << " obs indices." << endl;

      cout << "Reading input files." << endl;
//      oa.load("netrs027.06o.30s","netrs027.06n");
      oa.load("arl_256.06o","arl_256.06n");
      cout << "Done reading." << endl;

      cout << "Values directly using operator(size_t, size_t): " << endl;
      for (int j=0; j <oa.getNumObsTypes(); j++)
         for (int i=0; i<12; i++)
         {
            cout << "(" << i << "," << j << ")";
            cout << setprecision(12) << oa(i,j) << endl;
         }

      cout << "Getting values with a slice: " << endl;
      slice myslice(0,20,1);  
      valarray <double> copyObs = oa.observation[myslice];
      slice_array <double> obsSample = oa.observation[myslice];
      cout << "There are " << copyObs.size() << " elements in this slice." << endl;
      for (int i=0; i<20; i++)
         cout << copyObs[i] << endl;

      cout << "Operations on a slice: " << endl;
      cout << "Mean value is: " << copyObs.sum() / copyObs.size() << endl;
      //cout << "Mean value is: " << oa.observation[myslice].sum() / oa.observation[myslice].size() << endl;

      SatID thisPrn(9,SatID::systemGPS);
      valarray<bool> prnIdx = (oa.satellite==thisPrn);
      valarray<double> prnObs = oa.observation[prnIdx];
      valarray<CommonTime> prnTime = oa.epoch[prnIdx];
      cout << "Data for PRN 9:" << endl;
      for (int i=0; i<12; i++)
      {
         cout << prnTime[i].GPSfullweek() << " ";
         cout << prnTime[i].GPSsow() << " ";
         cout << prnObs[i] << endl;
      }
      
      set<CommonTime> allepochs = unique(oa.epoch);  
      cout << "Unique epochs:" << endl << allepochs << endl;
      
      set<SatID> allprns = unique(oa.satellite);
      cout << "Unique satellites: " << endl << allprns << endl;

      set<long> allpasses = unique(oa.pass);
      cout << "Unique passes: " << endl << allpasses << endl;
      
      exit(0);
   }
   catch(Exception& ex)
   {
      cerr << "Exception caught" << endl;
      cerr << ex << endl;
   }
}