当前位置: 首页>>代码示例>>C++>>正文


C++ Statistics类代码示例

本文整理汇总了C++中Statistics的典型用法代码示例。如果您正苦于以下问题:C++ Statistics类的具体用法?C++ Statistics怎么用?C++ Statistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Statistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsisMain

void IsisMain() {

  //get the number of samples to skip from the left and right ends
  // of the prefix and suffix data
  UserInterface &ui = Application::GetUserInterface();

  int imageLeft      = 0;
  int imageRight     = 0;
  int rampLeft       = 0;
  int rampRight      = 0;
  int calLeftBuffer  = 0;
  int calRightBuffer = 0;
  int calLeftDark    = 0;
  int calRightDark   = 0;
  int leftBuffer     = 0;
  int rightBuffer    = 0;
  int leftDark       = 0;
  int rightDark      = 0;

  if(ui.GetBoolean("USEOFFSETS")) {
    imageLeft      = ui.GetInteger("LEFTIMAGE");
    imageRight     = ui.GetInteger("RIGHTIMAGE");
    rampLeft       = ui.GetInteger("LEFTIMAGE");
    rampRight      = ui.GetInteger("RIGHTIMAGE");
    calLeftBuffer  = ui.GetInteger("LEFTCALBUFFER");
    calRightBuffer = ui.GetInteger("LEFTCALBUFFER");
    calLeftDark    = ui.GetInteger("LEFTCALDARK");
    calRightDark   = ui.GetInteger("RIGHTCALDARK");
    leftBuffer     = ui.GetInteger("LEFTBUFFER");
    rightBuffer    = ui.GetInteger("RIGHTBUFFER");
    leftDark       = ui.GetInteger("LEFTDARK");
    rightDark      = ui.GetInteger("RIGHTDARK");
  }


  Isis::FileName fromFile = ui.GetFileName("FROM");
  Isis::Cube inputCube;
  inputCube.open(fromFile.expanded());

  //Check to make sure we got the cube properly
  if(!inputCube.isOpen()) {
    QString msg = "Could not open FROM cube " + fromFile.expanded();
    throw IException(IException::User, msg, _FILEINFO_);
  }

  Process p;
  Cube *icube = p.SetInputCube("FROM");

  // Get statistics from the cube prefix and suffix data
  Table hifix("HiRISE Ancillary");
  icube->read(hifix);
  Statistics darkStats, bufStats, rampDarkStats;
  int tdi = icube->group("Instrument")["Tdi"];
  int binning_mode = icube->group("Instrument")["Summing"];

  //This gets us the statistics for the dark and buffer pixels
  // alongside of the image itself
  for(int rec = 2; rec < hifix.Records(); rec++) {
    vector<int> dark = hifix[rec]["DarkPixels"];
    vector<int> buf = hifix[rec]["BufferPixels"];
    if(buf.size() <= (unsigned int)(leftBuffer + rightBuffer)) {
      ThrowException(buf.size(), leftBuffer, rightBuffer, "image buffer");
    }
    if(dark.size() <= (unsigned int)(leftDark + rightDark)) {
      ThrowException(dark.size(), leftDark, rightDark, "image dark reference");
    }

    for(int i = leftDark; i < (int)dark.size() - rightDark; i++) {
      double d;
      if(dark[i] == NULL2) d = NULL8;
      else if(dark[i] == LOW_REPR_SAT2) d = LOW_REPR_SAT8;
      else if(dark[i] == LOW_INSTR_SAT2) d = LOW_INSTR_SAT8;
      else if(dark[i] == HIGH_INSTR_SAT2) d = HIGH_INSTR_SAT8;
      else if(dark[i] == HIGH_REPR_SAT2) d = HIGH_REPR_SAT8;
      else d = dark[i];
      darkStats.AddData(&d, 1);
    }


    for(int i = leftBuffer; i < (int)buf.size() - rightBuffer; i++) {
      double d;
      if(buf[i] == NULL2) d = NULL8;
      else if(buf[i] == LOW_REPR_SAT2) d = LOW_REPR_SAT8;
      else if(buf[i] == LOW_INSTR_SAT2) d = LOW_INSTR_SAT8;
      else if(buf[i] == HIGH_INSTR_SAT2) d = HIGH_INSTR_SAT8;
      else if(buf[i] == HIGH_REPR_SAT2) d = HIGH_REPR_SAT8;
      else d = buf[i];
      bufStats.AddData(&d, 1);
    }
  }

  // Get statistics from the calibration image

  //Calculate boundaries of the reverse readout lines,
  // Masked lines, and ramp lines.

  //There are always 20 reverse readout lines
  int reverseReadoutLines = 20;

  //Number of mask pixels depends on Binning mode
//.........这里部分代码省略.........
开发者ID:corburn,项目名称:ISIS,代码行数:101,代码来源:histat.cpp

示例2: LBASSERT

void ViewEqualizer::Listener::notifyLoadData(Channel* channel,
                                             const uint32_t frameNumber,
                                             const Statistics& statistics,
                                             const Viewport& /*region*/)
{
    Load& load = _getLoad(frameNumber);
    if (load == Load::NONE)
        return;

    LBASSERT(_taskIDs.find(channel) != _taskIDs.end());
    const uint32_t taskID = _taskIDs[channel];

    // gather relevant load data
    int64_t startTime = std::numeric_limits<int64_t>::max();
    int64_t endTime = 0;
    bool loadSet = false;
    int64_t transmitTime = 0;
    for (size_t i = 0; i < statistics.size() && !loadSet; ++i)
    {
        const Statistic& data = statistics[i];
        if (data.task != taskID) // data from another compound
            continue;

        switch (data.type)
        {
        case Statistic::CHANNEL_CLEAR:
        case Statistic::CHANNEL_DRAW:
        case Statistic::CHANNEL_READBACK:
            startTime = LB_MIN(startTime, data.startTime);
            endTime = LB_MAX(endTime, data.endTime);
            break;

        case Statistic::CHANNEL_ASYNC_READBACK:
        case Statistic::CHANNEL_FRAME_TRANSMIT:
            transmitTime += data.startTime - data.endTime;
            break;
        case Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN:
            transmitTime -= data.endTime - data.startTime;
            break;

        // assemble blocks on input frames, stop using subsequent data
        case Statistic::CHANNEL_ASSEMBLE:
            loadSet = true;
            break;

        default:
            break;
        }
    }

    if (startTime == std::numeric_limits<int64_t>::max())
        return;

    LBASSERTINFO(load.missing > 0, load << " for " << channel->getName() << " "
                                        << channel->getSerial());

    const int64_t time = LB_MAX(endTime - startTime, transmitTime);
    load.time += time;
    --load.missing;

    if (load.missing == 0)
    {
        const float rTime = float(load.time) / float(load.nResources);
        load.time = int64_t(rTime * sqrtf(float(load.nResources)));
    }

    LBLOG(LOG_LB1) << "Task " << taskID << ", added time " << time << " to "
                   << load << " from " << channel->getName() << " "
                   << channel->getSerial() << std::endl;
}
开发者ID:Eyescale,项目名称:Equalizer,代码行数:70,代码来源:viewEqualizer.cpp

示例3: IsisMain


//.........这里部分代码省略.........

  // Turn off Keywords
  cProcess.ForceScalingFactor(false);
  cProcess.ForceSampleBitMask(false);
  cProcess.ForceCoreNull(false);
  cProcess.ForceCoreLrs(false);
  cProcess.ForceCoreLis(false);
  cProcess.ForceCoreHrs(false);
  cProcess.ForceCoreHis(false);

  // Standard label Translation
  Pvl &pdsLabel = cProcess.StandardPdsLabel(ProcessExportPds::Image);

  // bLevel => Level 2 = True, Level 3 = False
  bool bLevel2 = cInCube->hasGroup("Instrument");

  // Translate the keywords from the original EDR PDS label that go in
  // this RDR PDS label for Level2 images only
  if(bLevel2) {
    OriginalLabel cOriginalBlob;
    cInCube->read(cOriginalBlob);
    Pvl cOrigLabel;
    PvlObject cOrigLabelObj = cOriginalBlob.ReturnLabels();
    cOrigLabelObj.setName("OriginalLabelObject");
    cOrigLabel.addObject(cOrigLabelObj);

    // Translates the ISIS labels along with the original EDR labels
    cOrigLabel.addObject(*(cInCube->label()));
    PvlTranslationManager cCubeLabel2(cOrigLabel, "$lro/translations/mrfExportOrigLabel.trn");
    cCubeLabel2.Auto(pdsLabel);


    if(cInLabel->findObject("IsisCube").findGroup("Instrument").hasKeyword("MissionName")) {
      PvlKeyword &cKeyMissionName = cInLabel->findObject("IsisCube").findGroup("Instrument").findKeyword("MissionName");
      int sFound = cKeyMissionName[0].indexOf("CHANDRAYAAN");
      if(sFound != -1) {
        cCubeLabel2 = PvlTranslationManager(cOrigLabel, "$lro/translations/mrfExportOrigLabelCH1.trn");
        cCubeLabel2.Auto(pdsLabel);
      }
      else {
        cCubeLabel2 = PvlTranslationManager(cOrigLabel, "$lro/translations/mrfExportOrigLabelLRO.trn");
        cCubeLabel2.Auto(pdsLabel);
      }
    }
  }
  else { //Level3 - add Band_Name keyword
    PvlGroup &cBandBinGrp = cInCube->group("BandBin");
    PvlKeyword cKeyBandBin = PvlKeyword("BAND_NAME");
    PvlKeyword cKeyInBandBin;
    if(cBandBinGrp.hasKeyword("OriginalBand")) {
      cKeyInBandBin = cBandBinGrp.findKeyword("OriginalBand");
    }
    else if(cBandBinGrp.hasKeyword("FilterName")) {
      cKeyInBandBin = cBandBinGrp.findKeyword("FilterName");
    }
    for(int i = 0; i < cKeyInBandBin.size(); i++) {
      cKeyBandBin += cKeyInBandBin[i];
    }
    PvlObject &cImageObject(pdsLabel.findObject("IMAGE"));
    cImageObject += cKeyBandBin;
  }

  // Get the Sources Product ID if entered for Level2 only as per example
  if(ui.WasEntered("SRC") && bLevel2) {
    QString sSrcFile = ui.GetFileName("SRC");
    QString sSrcType = ui.GetString("TYPE");
    GetSourceProductID(sSrcFile, sSrcType, pdsLabel);
  }

  // Get the User defined Labels
  if(ui.WasEntered("USERLBL")) {
    QString sUserLbl = ui.GetFileName("USERLBL");
    GetUserLabel(sUserLbl, pdsLabel, bLevel2);
  }

  // Calculate CheckSum
  Statistics *cStats =  cInCube->statistics();
  iCheckSum = (unsigned int)cStats->Sum();

  FixLabel(pdsLabel, bLevel2);

  // Add an output format template to the PDS PVL
  // Distinguish betweeen Level 2 and 3 images by calling the camera()
  // function as only non mosaic images(Level2) have a camera
  if(bLevel2) {
    pdsLabel.setFormatTemplate("$lro/translations/mrfPdsLevel2.pft");
  }
  else {
    pdsLabel.setFormatTemplate("$lro/translations/mrfPdsLevel3.pft");
  }

  int iFound = outFileName.indexOf(".lbl");
  outFileName.replace(iFound, 4, ".img");
  ofstream oCube(outFileName.toAscii().data());
  cProcess.OutputDetachedLabel();
  //cProcess.OutputLabel(oCube);
  cProcess.StartProcess(oCube);
  oCube.close();
  cProcess.EndProcess();
}
开发者ID:corburn,项目名称:ISIS,代码行数:101,代码来源:mrf2pds.cpp

示例4: setBatch

bool SioImporter::ensureStatisticsReadProperly(Progress *pProgress, std::ostream& failure)
{
   bool success = true;
   success &= setBatch();
   PlugInArgList* pInList = NULL;
   PlugInArgList* pOutList = NULL;
   isseas(getInputSpecification(pInList) != false, failure);
   isseas(getOutputSpecification(pOutList) != false, failure);
   PlugInArg* pRasterElementArg = NULL;
   isseas(pInList->getArg(Importer::ImportElementArg(), pRasterElementArg) != false, failure);

   string testFilePath = TestUtilities::getTestDataPath() + "tipjul5bands.sio";

   RasterElement* pRasterElement = NULL;
   if (success)
   {
      vector<ImportDescriptor*> descriptors = getImportDescriptors(testFilePath);
      if (descriptors.empty() == false)
      {
         ImportDescriptor* pImportDescriptor = descriptors.front();
         if (pImportDescriptor != NULL)
         {
            DataDescriptor* pDescriptor = pImportDescriptor->getDataDescriptor();
            if (pDescriptor != NULL)
            {
               Service<ModelServices> pModel;
               pRasterElement = dynamic_cast<RasterElement*>(pModel->createElement(pDescriptor));
               if (pRasterElement != NULL)
               {
                  pRasterElementArg->setActualValue(pRasterElement);
               }
            }
         }
      }
   }

   isseas(execute(pInList, pOutList) != false, failure);
   isseas(pRasterElement != NULL, failure);
   if (success)
   {
      RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor());
      isseas(pDescriptor != NULL, failure);

      const vector<DimensionDescriptor>& loadedBands = pDescriptor->getBands();
      isseas(loadedBands.size() == 5, failure);
      int iNumBandsWithStats = 0;
      for (int i = 0; i < 5; ++i)
      {
         // we don't want to do an assert yet... only when we know 4 bands have computed statistics
         Statistics* pStatistics = pRasterElement->getStatistics(loadedBands[i]);
         if (pStatistics != NULL)
         {
            if (pStatistics->areStatisticsCalculated() == true)
            {
               if (success)
               {
                  iNumBandsWithStats++;
               }
            }
         }
      }

      // success of the band computation is dependent on 4 bands with statistics
      isseas(iNumBandsWithStats == 3, failure);
   }
   if (pRasterElement != NULL)
   {
      Service<ModelServices> pModel;
      pModel->destroyElement(pRasterElement);
      pRasterElement = NULL;
   }
   Service<PlugInManagerServices> pPim;
   if (pInList)
   {
      pPim->destroyPlugInArgList(pInList);
   }

   if (pOutList)
   {
      pPim->destroyPlugInArgList(pOutList);
   }

   return success;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:84,代码来源:SioImporter.cpp

示例5: IsisMain


//.........这里部分代码省略.........
        imageValid &= (tmp.Bands() == 1);

        // Sample sizes must always match
        imageValid &= (numOutputSamples == tmp.Samples());

        // For push frame cameras, there must be valid all framelets
        if(cameraType == PushFrame) {
            imageValid &=  (tmp.Lines() % numFrameLines == 0);
        }

        // For framing cameras, we need to figure out the size...
        //    setTempFileLength is used to revert if the file
        //    is decided to be invalid
        bool setTempFileLength = false;
        if(cameraType == Framing) {
            if(tempFileLength == 0 && imageValid) {
                tempFileLength = tmp.Lines();
                numFrameLines = tempFileLength;
                setTempFileLength = true;
            }

            imageValid &= (tempFileLength == tmp.Lines());
        }

        // Statistics are necessary at this point for push frame and framing cameras
        //   because the framing camera standard deviation tolerance is based on
        //   entire images, and push frame framelet exclusion stats can not be collected
        //   during pass 2 cleanly
        if((cameraType == Framing || cameraType == PushFrame) && imageValid) {
            string prog = "Calculating Standard Deviation " + iString((int)currImage+1) + "/";
            prog += iString((int)inList.size()) + " (" + Filename(inList[currImage]).Name() + ")";

            if(cameraType == Framing) {
                Statistics *stats = tmp.Statistics(1, prog);
                imageValid &= !IsSpecial(stats->StandardDeviation());
                imageValid &= !IsSpecial(stats->Average());
                imageValid &= stats->StandardDeviation() <= maxStdev;

                vector<double> fileStats;
                fileStats.push_back(stats->Average());
                inputFrameletAverages.push_back(fileStats);

                delete stats;
            }
            else if(cameraType == PushFrame) {
                imageValid &= CheckFramelets(prog, tmp);
            }

            if(setTempFileLength && !imageValid) {
                tempFileLength = 0;
            }
        }

        // The line scan camera needs to actually count the number of lines in each image to know
        //   how many total frames there are before beginning pass 2.
        if(imageValid && (cameraType == LineScan)) {
            int lines = (tmp.Lines() / numFrameLines);

            // partial frame?
            if(tmp.Lines() % numFrameLines != 0) {
                lines ++;
            }

            tempFileLength += lines;
        }
        else if(!imageValid) {
开发者ID:novas0x2a,项目名称:isis3,代码行数:67,代码来源:makeflat.cpp

示例6: IsisMain

void IsisMain() {

  UserInterface &ui = Application::GetUserInterface();
  Cube cube;
  cube.open(ui.GetFileName("FROM"));

  // Check that it is a Mariner10 cube.
  Pvl * labels = cube.label();
  if ("Mariner_10" != (QString)labels->findKeyword("SpacecraftName", Pvl::Traverse)) {
    QString msg = "The cube [" + ui.GetFileName("FROM") + "] does not appear" +
      " to be a Mariner10 cube";
    throw IException(IException::User, msg, _FILEINFO_);
  }

  // Check that the cube actually needs reconstruction
  Chip cp(5, 5);
  cp.TackCube(25, 25);
  cp.Load(cube);
  Statistics *stats = NULL;
  stats = cp.Statistics();
  // Maximum possible number of good pixels in a 5x5
  if(stats->ValidPixels() > 8) {
    QString msg = "The cube [" + ui.GetFileName("FROM") + "] does not need" +
      " reconstruction, try mar10clean instead";
    throw IException(IException::User, msg, _FILEINFO_);
  }
  if (stats != NULL) {
    delete stats;
    stats = NULL;
  }

  // Open the input cube
  Pipeline p("mar10restore");
  p.SetInputFile("FROM");
  p.SetOutputFile("TO");
  p.KeepTemporaryFiles(!ui.GetBoolean("REMOVE"));

  // Run a standard deviation filter on the cube
  p.AddToPipeline("noisefilter", "noise1");
  p.Application("noise1").SetInputParameter("FROM", true);
  p.Application("noise1").SetOutputParameter("TO", "noise1");
  p.Application("noise1").AddConstParameter("TOLDEF", "stddev");
  p.Application("noise1").AddConstParameter("FLATTOL", "10");
  p.Application("noise1").AddConstParameter("SAMP", "5");
  p.Application("noise1").AddConstParameter("LINE", "5");
  p.Application("noise1").AddConstParameter("MINIMUM", "4");
  p.Application("noise1").AddConstParameter("TOLMIN", "2.0");
  p.Application("noise1").AddConstParameter("TOLMAX", "1.5");
  p.Application("noise1").AddConstParameter("REPLACE", "null");

  // run a standard deviation filter on the cube
  p.AddToPipeline("noisefilter", "noise2");
  p.Application("noise2").SetInputParameter("FROM", true);
  p.Application("noise2").SetOutputParameter("TO", "noise2");
  p.Application("noise2").AddConstParameter("TOLDEF", "stddev");
  p.Application("noise2").AddConstParameter("FLATTOL", "10");
  p.Application("noise2").AddConstParameter("SAMP", "11");
  p.Application("noise2").AddConstParameter("LINE", "11");
  p.Application("noise2").AddConstParameter("MINIMUM", "9");
  p.Application("noise2").AddConstParameter("TOLMIN", "100");
  p.Application("noise2").AddConstParameter("TOLMAX", "2.0");
  p.Application("noise2").AddConstParameter("REPLACE", "null");

  // Run a standard deviation filter on the cube
  p.AddToPipeline("noisefilter", "noise3");
  p.Application("noise3").SetInputParameter("FROM", true);
  p.Application("noise3").SetOutputParameter("TO", "noise3");
  p.Application("noise3").AddConstParameter("TOLDEF", "stddev");
  p.Application("noise3").AddConstParameter("FLATTOL", "10");
  p.Application("noise3").AddConstParameter("SAMP", "7");
  p.Application("noise3").AddConstParameter("LINE", "7");
  p.Application("noise3").AddConstParameter("MINIMUM", "4");
  p.Application("noise3").AddConstParameter("TOLMIN", "100");
  p.Application("noise3").AddConstParameter("TOLMAX", "1.5");
  p.Application("noise3").AddConstParameter("REPLACE", "null");

  // Run a low pass filter on the invalid data in the cube
  p.AddToPipeline("lowpass", "lowpass1");
  p.Application("lowpass1").SetInputParameter("FROM", true);
  p.Application("lowpass1").SetOutputParameter("TO", "lp1");
  p.Application("lowpass1").AddConstParameter("SAMP", "3");
  p.Application("lowpass1").AddConstParameter("LINE", "3");
  p.Application("lowpass1").AddConstParameter("MINIMUM", "2");
  p.Application("lowpass1").AddConstParameter("FILTER", "outside");
  p.Application("lowpass1").AddConstParameter("NULL", "true");
  p.Application("lowpass1").AddConstParameter("LIS", "true");
  p.Application("lowpass1").AddConstParameter("HIS", "true");
  p.Application("lowpass1").AddConstParameter("LRS", "true");

  // Run a low pass filter on the invalid data in the cube
  p.AddToPipeline("lowpass", "lowpass2");
  p.Application("lowpass2").SetInputParameter("FROM", true);
  p.Application("lowpass2").SetOutputParameter("TO", "lp2");
  p.Application("lowpass2").AddConstParameter("SAMP", "3");
  p.Application("lowpass2").AddConstParameter("LINE", "3");
  p.Application("lowpass2").AddConstParameter("MINIMUM", "2");
  p.Application("lowpass2").AddConstParameter("FILTER", "outside");
  p.Application("lowpass2").AddConstParameter("NULL", "true");
  p.Application("lowpass2").AddConstParameter("LIS", "true");
  p.Application("lowpass2").AddConstParameter("HIS", "true");
//.........这里部分代码省略.........
开发者ID:corburn,项目名称:ISIS,代码行数:101,代码来源:mar10restore.cpp

示例7: VERIFY

QWidget* ResultsExporter::getExportOptionsWidget(const PlugInArgList *pInArgList)
{
   const DataDescriptor* pDescriptor = NULL;
   if (pInArgList != NULL)
   {
      RasterElement* pElement = pInArgList->getPlugInArgValue<RasterElement>(Exporter::ExportItemArg());
      if (pElement != NULL)
      {
         pDescriptor = pElement->getDataDescriptor();
      }
   }
   if (mpOptionsWidget == NULL)
   {
      Service<DesktopServices> pDesktop;
      VERIFY(pDesktop.get() != NULL);

      mpOptionsWidget = new ResultsOptionsWidget(pDesktop->getMainWidget());
   }

   if (mpOptionsWidget != NULL)
   {
      const string& name = pDescriptor->getName();
      const string& type = pDescriptor->getType();
      DataElement* pParent = pDescriptor->getParent();

      RasterElement* pResults = dynamic_cast<RasterElement*>(mpModel->getElement(name, type, pParent));
      if (pResults != NULL)
      {
         GeocoordType geocoordType;
         PassArea passArea = MIDDLE;
         double dFirstThreshold = 0.0;
         double dSecondThreshold = 0.0;

         SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow());
         if (pWindow != NULL)
         {
            SpatialDataView* pView = pWindow->getSpatialDataView();
            if (pView != NULL)
            {
               LayerList* pLayerList = pView->getLayerList();
               if (pLayerList != NULL)
               {
                  ThresholdLayer* pThresholdLayer =
                     static_cast<ThresholdLayer*>(pLayerList->getLayer(THRESHOLD, pResults));
                  if (pThresholdLayer != NULL)
                  {
                     passArea = pThresholdLayer->getPassArea();
                     dFirstThreshold = pThresholdLayer->getFirstThreshold();
                     dSecondThreshold = pThresholdLayer->getSecondThreshold();
                  }
                  else
                  {
                     Statistics* pStatistics = pResults->getStatistics();
                     if (pStatistics != NULL)
                     {
                        dFirstThreshold = pStatistics->getMin();
                        dSecondThreshold = pStatistics->getMax();
                     }
                  }
               }

               LatLonLayer* pLatLonLayer = static_cast<LatLonLayer*>(pView->getTopMostLayer(LAT_LONG));
               if (pLatLonLayer != NULL)
               {
                  geocoordType = pLatLonLayer->getGeocoordType();
               }
            }

            if (geocoordType.isValid() == false)
            {
               bool hasGeoData = pResults->isGeoreferenced();
               if (hasGeoData == false)
               {
                  RasterElement* pParent = dynamic_cast<RasterElement*>(mpResults->getParent());
                  if (pParent != NULL)
                  {
                     hasGeoData = pParent->isGeoreferenced();
                  }
               }

               if (hasGeoData == true)
               {
                  geocoordType = Georeference::getSettingGeocoordType();
               }
            }
         }

         mpOptionsWidget->setGeocoordType(geocoordType);
         mpOptionsWidget->setPassArea(passArea);
         mpOptionsWidget->setFirstThreshold(dFirstThreshold);
         mpOptionsWidget->setSecondThreshold(dSecondThreshold);
      }
   }

   return mpOptionsWidget;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:96,代码来源:ResultsExporter.cpp

示例8: cubeViewport

  /**
   * Retrieve the statistics based on the box size
   * and point on the cube.
   *
   * @param p
   */
  void StatisticsTool::getStatistics(QPoint p) {
    MdiCubeViewport *cvp = cubeViewport();
    if(cvp == NULL) return;

    double sample, line;
    cvp->viewportToCube(p.x(), p.y(), sample, line);

    // If we are outside of the cube, do nothing
    if((sample < 0.5) || (line < 0.5) ||
        (sample > cvp->cubeSamples() + 0.5) || (line > cvp->cubeLines() + 0.5)) {
      return;
    }

    int isamp = (int)(sample + 0.5);
    int iline = (int)(line + 0.5);

    Statistics stats;
    Brick *brick = new Brick(1, 1, 1, cvp->cube()->pixelType());


    QVector<QVector<double> > pixelData(p_boxLines, QVector<double>(p_boxSamps, Null));

    double lineDiff = p_boxLines / 2.0;
    double sampDiff = p_boxSamps / 2.0;

    p_ulSamp = isamp - (int)floor(sampDiff);
    p_ulLine = iline - (int)floor(lineDiff);

    int x, y;

    y = p_ulLine;

    for(int i = 0; i < p_boxLines; i++) {
      x = p_ulSamp;
      if(y < 1 || y > cvp->cubeLines()) {
        y++;
        continue;
      }
      for(int j = 0; j < p_boxSamps; j++) {
        if(x < 1 || x > cvp->cubeSamples()) {
          x++;
          continue;
        }
        brick->SetBasePosition(x, y, cvp->grayBand());
        cvp->cube()->read(*brick);
        stats.AddData(brick->at(0));
        pixelData[i][j] = brick->at(0);

        x++;
      }
      y++;
    }

    p_visualDisplay->setPixelData(pixelData, p_ulSamp, p_ulLine);

    if (stats.ValidPixels()) {
      p_minLabel->setText(QString("Minimum: %1").arg(stats.Minimum()));
      p_maxLabel->setText(QString("Maximum: %1").arg(stats.Maximum()));
      p_avgLabel->setText(QString("Average: %1").arg(stats.Average()));
      p_stdevLabel->setText(QString("Standard Dev: %1").arg(stats.StandardDeviation(), 0, 'f', 6));
    }
    else {
      p_minLabel->setText(QString("Minimum: n/a"));
      p_maxLabel->setText(QString("Maximum: n/a"));
      p_avgLabel->setText(QString("Average: n/a"));
      p_stdevLabel->setText(QString("Standard Dev: n/a"));
    }

    p_set = true;

    resizeScrollbars();
  }
开发者ID:corburn,项目名称:ISIS,代码行数:78,代码来源:StatisticsTool.cpp

示例9: main

int
main (int argc, char *argv[])
{

    //myTableLookUp.readTable(hXOR);
    //myTableLookUp.readTable(hIFF);


    //maxMemory=0;

    if (argc != 11)
    {
        printf
            ("DSMGA ell nInitial selectionPressure pc pm maxGen maxFe repeat display rand_seed\n");
        return -1;
    }

    int ell = atoi (argv[1]);	// problem size
    int nInitial = atoi (argv[2]);	// initial population size
    int selectionPressure = atoi (argv[3]);	// selection pressure
    double pc = atof (argv[4]);	// pc
    double pm = atof (argv[5]);	// pm
    int maxGen = atoi (argv[6]);	// max generation
    int maxFe = atoi (argv[7]);	// max fe
    int repeat = atoi (argv[8]);	// how many time to repeat
    int display = atoi (argv[9]); // display each generation or not
    int rand_seed = atoi (argv[10]); 	// rand seed

    if (rand_seed != -1)  // time
        myRand.seed((unsigned long)rand_seed);

    int i;

    Statistics stGen;
    int usedGen;

    int failNum = 0;

    int maxMemoryUsage = 0;

    for (i = 0; i < repeat; i++) {

        DSMGA dsmga (ell, nInitial, selectionPressure, pc, pm, maxGen, maxFe);

        if (display == 1)
            usedGen = dsmga.doIt (true);
        else
            usedGen = dsmga.doIt (false);


        if (!dsmga.foundOptima()) {
            failNum++;
            printf ("-");
        }
        else {
            stGen.record (usedGen);
            printf ("+");
        }

        maxMemoryUsage += maxMemory;
        fflush (NULL);

    }

    cout << endl;
    cout  << "Max DSM memory usage:" << (double)maxMemoryUsage/(double)repeat << " bytes." << endl;
    cout  << "Memory usage of DSM + population: " << (double)maxMemory/(double)repeat + nInitial*ell/8 << " bytes." << endl;
    printf ("\n");
    printf ("%f  %d\n", stGen.getMean (), failNum);

    return EXIT_SUCCESS;
}
开发者ID:rbx1219,项目名称:modelBasedDSMGA,代码行数:72,代码来源:dsmgaMain.cpp

示例10: pStep

bool ResultsExporter::writeOutput(ostream &stream)
{
   mMessage = "Exporting results matrix...";
   if (mpProgress != NULL)
   {
      mpProgress->updateProgress(mMessage, 0, NORMAL);
   }

   StepResource pStep(mMessage, "app", "D890E37C-B960-4527-8AAC-D62F2DE7A541");

   RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(mpResults->getDataDescriptor());
   if (pDescriptor == NULL)
   {
      mMessage = "Could not get the results data descriptor!";
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress(mMessage, 0, ERRORS);
      }

      pStep->finalize(Message::Failure);
      return false;
   }

   VERIFY(mpResults != NULL);
   string name = mpResults->getName();

   VERIFY(mpFileDescriptor != NULL);
   const vector<DimensionDescriptor>& rows = mpFileDescriptor->getRows();
   const vector<DimensionDescriptor>& columns = mpFileDescriptor->getColumns();
   unsigned int numRows = pDescriptor->getRowCount();
   unsigned int numColumns = pDescriptor->getColumnCount();
   EncodingType eDataType = pDescriptor->getDataType();
   const vector<int>& badValues = pDescriptor->getBadValues();

   if (mbMetadata)
   {
      stream << APP_NAME << " Results Raster\n";
      stream << "Version = 4\n";
      stream << "Results Name = " << name << "\n";

      DataElement* pParent = mpResults->getParent();
      if (pParent != NULL)
      {
         stream << "Data Set Name = " << pParent->getName() << "\n";
      }

      stream << "Rows = " << numRows << "\n";
      stream << "Columns = " << numColumns << "\n";

      string dataType = StringUtilities::toDisplayString(eDataType);
      stream << "Data Type = " << dataType << "\n";

      Statistics* pStatistics = mpResults->getStatistics();
      if (pStatistics != NULL)
      {
         stream << "Min = " << pStatistics->getMin() << "\n";
         stream << "Max = " << pStatistics->getMax() << "\n";
         stream << "Average = " << pStatistics->getAverage() << "\n";
         stream << "Standard Deviation = " << pStatistics->getStandardDeviation() << "\n\n";
      }
   }

   RasterElement* pGeo = getGeoreferencedRaster();

   DataAccessor da = mpResults->getDataAccessor();
   if (!da.isValid())
   {
      mMessage = "Could not access the data in the results raster!";
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress(mMessage, 0, ERRORS);
      }

      pStep->finalize(Message::Failure);
      return false;
   }

   unsigned int activeRowNumber = 0;
   for (unsigned int r = 0; r < rows.size(); ++r)
   {
      if (mbAbort)
      {
         mMessage = "Results exporter aborted!";
         if (mpProgress != NULL)
         {
            mpProgress->updateProgress(mMessage, 0, ABORT);
         }

         pStep->finalize(Message::Abort);
         return false;
      }

      DimensionDescriptor rowDim = rows[r];
      // Skip to the next row
      for (; activeRowNumber < rowDim.getActiveNumber(); ++activeRowNumber)
      {
         da->nextRow();
      }

      unsigned int activeColumnNumber = 0;
//.........这里部分代码省略.........
开发者ID:Siddharthk,项目名称:opticks,代码行数:101,代码来源:ResultsExporter.cpp

示例11: IsisMain


//.........这里部分代码省略.........

        //  If we have both left and right images in the control point, save it
        if ( (cmLeft != 0) && (cmRight != 0) ) {
          Coordinate left = Coordinate(cmLeft->GetLine(), cmLeft->GetSample());
          Coordinate right = Coordinate(cmRight->GetLine(), cmRight->GetSample());
          SmtkPoint spnt = matcher.Create(left, right);

          // Insert the point (unregistered)
          if ( spnt.isValid() ) {
            int line = (int) cmLeft->GetLine();
            int samp = (int) cmLeft->GetSample();
            matcher.isValid(spnt);
            gstack.insert(qMakePair(line, samp), spnt);
            lastEigen = spnt.GoodnessOfFit();
          }
        }
      }

      prog.CheckStatus();
    }
  }
  else {
  // We want to create a grid of control points that is N rows by M columns.

    int rows = (lhImage.lineCount() + linc - 1)/linc;
    int cols = (lhImage.sampleCount() + sinc - 1)/sinc;

    prog.SetMaximumSteps(rows * cols);
    prog.CheckStatus();

    // First pass stack and eigen value statistics
    SmtkQStack fpass;
    fpass.reserve(rows * cols);
    Statistics temp_mev;

    // Loop through grid of points and get statistics to compute
    // initial set of points
    for (int line = linc / 2 + 1; line < nl; line += linc) {
      for (int samp = sinc / 2 + 1 ; samp < ns; samp += sinc) {
        numAttemptedInitialPoints ++;
        SmtkPoint spnt = matcher.Register(Coordinate(line,samp));
        if ( spnt.isValid() ) {
          matcher.isValid(spnt);
          fpass.insert(qMakePair(line, samp), spnt);
          temp_mev.AddData(spnt.GoodnessOfFit());
        }
        prog.CheckStatus();
      }
    }

    //  Now select a subset of fpass points as the seed points
    cout << "Number of Potential Seed Points: " << fpass.size() << "\n";
    cout << "Min / Max Eigenvalues Matched: " << temp_mev.Minimum() << ", "
         << temp_mev.Maximum() << "\n";

    // How many seed points are requested
    double nseed = ui.GetDouble("NSEED");
    int inseed;
    if (nseed >= 1.0) inseed = (int) nseed;
    else if (nseed > 0.0) inseed = (int) (nseed * (double) (fpass.size()));
    else inseed = (int) ((double) (fpass.size()) * 0.05);

    double seedsample = ui.GetDouble("SEEDSAMPLE");

    // Generate a new stack
    gstack.reserve(inseed);
开发者ID:corburn,项目名称:ISIS,代码行数:67,代码来源:smtk.cpp

示例12: sprintf

void Facility::GenerateStandartStatistics(int thread, int mask)
{
    Statistics *s;

    char buf[9];
    sprintf(buf,"%d",thread);

    if(mask&1)
    {
        s=new IntervalStatistics(true,thread);
        if(thread!=-1)
            s->SetName("w_"+name + "_" + buf);
        else
            s->SetName("w_"+name);
        s->SetNode(0);
        stats[0].push_back(s);

        s=new IntervalStatistics(false,thread);
        if(thread!=-1)
            s->SetName("w_"+name + "_" + buf);
        else
            s->SetName("w_"+name);
        s->SetNode(0);
        stats[1].push_back(s);
    }

    if(mask&2)
    {
        s=new IntervalStatistics(true,thread);
        if(thread!=-1)
            s->SetName(name + "_" + buf);
        else
            s->SetName(name);
        s->SetNode(0);
        stats[0].push_back(s);

        s=new IntervalStatistics(false,thread);
        if(thread!=-1)
            s->SetName(name + "_" + buf);
        else
            s->SetName(name);
        s->SetNode(0);
        stats[2].push_back(s);
    }
}
开发者ID:kwetril,项目名称:GpssGeneratorQt,代码行数:45,代码来源:Facility.cpp

示例13: calculateSpecificEnergy

/**
 * This calculates the coefficients for specific energy corrections
 */
void calculateSpecificEnergy(Cube *icube) {
  PvlGroup &inst = icube->label()->findGroup("Instrument", Pvl::Traverse);
  bool vis = (inst["Channel"][0] != "IR");

  double coefficient = 1.0;

  if(inst["GainMode"][0] == "HIGH") {
    coefficient /= 2;
  }

  if(vis && inst["SamplingMode"][0] == "HI-RES") {
    coefficient *= 3;
  }

  if(vis) {
    coefficient /= toDouble(inst["ExposureDuration"][1]) / 1000.0;
  }
  else {
    coefficient /= (toDouble(inst["ExposureDuration"][0]) * 1.01725) / 1000.0 - 0.004;
  }

  QString specEnergyFile = "$cassini/calibration/vims/";

  if(vis) {
    specEnergyFile += "vis_perf_v????.cub";
  }
  else {
    specEnergyFile += "ir_perf_v????.cub";
  }

  QString waveCalFile = "$cassini/calibration/vims/wavecal_v????.cub";

  FileName specEnergyFileName(specEnergyFile);
  specEnergyFileName = specEnergyFileName.highestVersion();

  FileName waveCalFileName(waveCalFile);
  waveCalFileName = waveCalFileName.highestVersion();

  Cube specEnergyCube;
  specEnergyCube.open(specEnergyFileName.expanded());

  Cube waveCalCube;
  waveCalCube.open(waveCalFileName.expanded());

  LineManager specEnergyMgr(specEnergyCube);
  LineManager waveCalMgr(waveCalCube);

  for(int i = 0; i < icube->bandCount(); i++) {
    Statistics specEnergyStats;
    Statistics waveCalStats;

    if(vis) {
      specEnergyMgr.SetLine(1, i + 1);
      waveCalMgr.SetLine(1, i + 1);
    }
    else {
      specEnergyMgr.SetLine(1, i + 1);
      // ir starts at band 97
      waveCalMgr.SetLine(1, i + 96 + 1);
    }

    specEnergyCube.read(specEnergyMgr);
    waveCalCube.read(waveCalMgr);

    specEnergyStats.AddData(specEnergyMgr.DoubleBuffer(), specEnergyMgr.size());
    waveCalStats.AddData(waveCalMgr.DoubleBuffer(), waveCalMgr.size());

    double bandCoefficient = coefficient * specEnergyStats.Average() * waveCalStats.Average();

    specificEnergyCorrections.push_back(bandCoefficient);
  }
}
开发者ID:jlaura,项目名称:isis3,代码行数:75,代码来源:vimscal.cpp

示例14: writeFlat

//function to write the stats values to flat file
void writeFlat (ofstream &os, Statistics &s){
  os << ValidateValue(s.Minimum())<<","<<
        ValidateValue(s.Maximum())<<","<<
        ValidateValue(s.Average())<<","<<
        ValidateValue(s.StandardDeviation())<<",";
}
开发者ID:assutech,项目名称:isis3,代码行数:7,代码来源:camstats.cpp

示例15: notifyLoadData

void LoadEqualizer::notifyLoadData( Channel* channel,
                                    const uint32_t frameNumber,
                                    const Statistics& statistics,
                                    const Viewport& region )
{
    LBLOG( LOG_LB2 ) << statistics.size()
                     << " samples from "<< channel->getName()
                     << " @ " << frameNumber << std::endl;
    for( std::deque< LBFrameData >::iterator i = _history.begin();
         i != _history.end(); ++i )
    {
        LBFrameData& frameData = *i;
        if( frameData.first != frameNumber )
            continue;

        // Found corresponding historical data set
        LBDatas& items = frameData.second;
        for( LBDatas::iterator j = items.begin(); j != items.end(); ++j )
        {
            Data& data = *j;
            if( data.channel != channel )
                continue;

            // Found corresponding historical data item
            const uint32_t taskID = data.taskID;
            LBASSERTINFO( taskID > 0, channel->getName( ));

            // gather relevant load data
            int64_t startTime = std::numeric_limits< int64_t >::max();
            int64_t endTime   = 0;
            bool    loadSet   = false;
            int64_t transmitTime = 0;
            for( size_t k = 0; k < statistics.size(); ++k )
            {
                const Statistic& stat = statistics[k];
                if( stat.task == data.destTaskID )
                    _updateAssembleTime( data, stat );

                // from different compound
                if( stat.task != taskID || loadSet )
                    continue;

                switch( stat.type )
                {
                case Statistic::CHANNEL_CLEAR:
                case Statistic::CHANNEL_DRAW:
                case Statistic::CHANNEL_READBACK:
                    startTime = LB_MIN( startTime, stat.startTime );
                    endTime   = LB_MAX( endTime, stat.endTime );
                    break;

                case Statistic::CHANNEL_ASYNC_READBACK:
                case Statistic::CHANNEL_FRAME_TRANSMIT:
                    transmitTime += stat.endTime - stat.startTime;
                    break;
                case Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN:
                    transmitTime -= stat.endTime - stat.startTime;
                    break;

                // assemble blocks on input frames, stop using subsequent data
                case Statistic::CHANNEL_ASSEMBLE:
                    loadSet = true;
                    break;

                default:
                    break;
                }
            }

            if( startTime == std::numeric_limits< int64_t >::max( ))
                return;

            data.vp.apply( region ); // Update ROI
            data.time = endTime - startTime;
            data.time = LB_MAX( data.time, 1 );
            data.time = LB_MAX( data.time, transmitTime );
            data.assembleTime = LB_MAX( data.assembleTime, 0 );
            LBLOG( LOG_LB2 ) << "Added time " << data.time << " (+"
                             << data.assembleTime << ") for "
                             << channel->getName() << " " << data.vp << ", "
                             << data.range << " @ " << frameNumber << std::endl;
            return;

            // Note: if the same channel is used twice as a child, the
            // load-compound association does not work.
        }
    }
}
开发者ID:BillTheBest,项目名称:Equalizer,代码行数:88,代码来源:loadEqualizer.cpp


注:本文中的Statistics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。