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


C++ Cube::Statistics方法代码示例

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


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

示例1: 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

示例2: IsisMain

void IsisMain() {
  //Create a process to create the input cubes
  Process p;
  //Create the input cubes, matching sample/lines
  Cube *inCube = p.SetInputCube ("FROM");
  Cube *latCube = p.SetInputCube("LATCUB", SpatialMatch);
  Cube *lonCube = p.SetInputCube("LONCUB", SpatialMatch);

  //A 1x1 brick to read in the latitude and longitude DN values from
  //the specified cubes
  Brick latBrick(1,1,1, latCube->PixelType());
  Brick lonBrick(1,1,1, lonCube->PixelType());

  UserInterface &ui = Application::GetUserInterface();

  //Set the sample and line increments
  int sinc = (int)(inCube->Samples() * 0.10);
  if(ui.WasEntered("SINC")) {
    sinc = ui.GetInteger("SINC");
  }

  int linc = (int)(inCube->Lines() * 0.10);
  if(ui.WasEntered("LINC")) {
    linc = ui.GetInteger("LINC");
  }

  //Set the degree of the polynomial to use in our functions
  int degree = ui.GetInteger("DEGREE");

  //We are using a polynomial with two variables
  PolynomialBivariate sampFunct(degree); 
  PolynomialBivariate lineFunct(degree);

  //We will be solving the function using the least squares method
  LeastSquares sampSol(sampFunct);
  LeastSquares lineSol(lineFunct);

  //Setup the variables for solving the stereographic projection
  //x = cos(latitude) * sin(longitude - lon_center)
  //y = cos(lat_center) * sin(latitude) - sin(lat_center) * cos(latitude) * cos(longitude - lon_center)

  //Get the center lat and long from the input cubes
  double lat_center = latCube->Statistics()->Average() * PI/180.0;
  double lon_center = lonCube->Statistics()->Average() * PI/180.0;


  /**
   * Loop through lines and samples projecting the latitude and longitude at those
   * points to stereographic x and y and adding these points to the LeastSquares 
   * matrix. 
   */
  for(int i = 1; i <= inCube->Lines(); i+= linc) {
    for(int j = 1; j <= inCube->Samples(); j+= sinc) {
      latBrick.SetBasePosition(j, i, 1);
      latCube->Read(latBrick);
      if(IsSpecial(latBrick.at(0))) continue;
      double lat = latBrick.at(0) * PI/180.0;
      lonBrick.SetBasePosition(j, i, 1);
      lonCube->Read(lonBrick);
      if(IsSpecial(lonBrick.at(0))) continue;
      double lon = lonBrick.at(0) * PI/180.0;

      //Project lat and lon to x and y using a stereographic projection
      double k = 2/(1 + sin(lat_center) * sin(lat) + cos(lat_center)*cos(lat)*cos(lon - lon_center));
      double x = k * cos(lat) * sin(lon - lon_center);
      double y = k * (cos(lat_center) * sin(lat)) - (sin(lat_center) * cos(lat) * cos(lon - lon_center));

      //Add x and y to the least squares matrix
      vector<double> data;
      data.push_back(x);
      data.push_back(y);
      sampSol.AddKnown(data, j);
      lineSol.AddKnown(data, i);

      //If the sample increment goes past the last sample in the line, we want to
      //always read the last sample..
      if(j != inCube->Samples() && j + sinc > inCube->Samples()) {
        j = inCube->Samples() - sinc;
      }
    }
    //If the line increment goes past the last line in the cube, we want to
    //always read the last line..
    if(i != inCube->Lines() && i + linc > inCube->Lines()) {    
      i = inCube->Lines() - linc;
    }
  }

  //Solve the least squares functions using QR Decomposition
  sampSol.Solve(LeastSquares::QRD);
  lineSol.Solve(LeastSquares::QRD);

  //If the user wants to save the residuals to a file, create a file and write
  //the column titles to it.
  TextFile oFile;
  if(ui.WasEntered("RESIDUALS")) {
    oFile.Open(ui.GetFilename("RESIDUALS"), "overwrite");
    oFile.PutLine("Sample,\tLine,\tX,\tY,\tSample Error,\tLine Error\n");
  }

  //Gather the statistics for the residuals from the least squares solutions
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:nocam2map.cpp

示例3: ComputeInputRange

//Helper function to compute input range.
void ComputeInputRange () {
  Process p;
  Cube *latCub = p.SetInputCube("LATCUB");
  Cube *lonCub = p.SetInputCube("LONCUB");

  UserInterface &ui = Application::GetUserInterface();
  Pvl userMap;
  userMap.Read(ui.GetFilename("MAP"));
  PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse);

  Statistics *latStats = latCub->Statistics();
  Statistics *lonStats = lonCub->Statistics();

  double minLat = latStats->Minimum();
  double maxLat = latStats->Maximum();

  int lonDomain = userGrp.HasKeyword("LongitudeDomain") ? (int)userGrp.FindKeyword("LongitudeDomain") : 360;
  double minLon = lonDomain == 360 ? Projection::To360Domain(lonStats->Minimum()) : Projection::To180Domain(lonStats->Minimum());
  double maxLon = lonDomain == 360 ? Projection::To360Domain(lonStats->Maximum()) : Projection::To180Domain(lonStats->Maximum());

  if(userGrp.HasKeyword("LatitudeType")) {
    bool isOcentric = ((std::string)userGrp.FindKeyword("LatitudeType")) == "Planetocentric";

    double equRadius;
    double polRadius;

    //If the user entered the equatorial and polar radii
    if(ui.WasEntered("EQURADIUS") && ui.WasEntered("POLRADIUS")) {
      equRadius = ui.GetDouble("EQURADIUS");
      polRadius = ui.GetDouble("POLRADIUS");
    }
    //Else read them from the pck
    else {
      Filename pckFile("$base/kernels/pck/pck?????.tpc");
      pckFile.HighestVersion();

      string pckFilename = pckFile.Expanded();

      furnsh_c(pckFilename.c_str());

      string target;

      //If user entered target 
      if(ui.WasEntered("TARGET")) {
        target = ui.GetString("TARGET");
      }
      //Else read the target name from the input cube
      else {
        Pvl fromFile;
        fromFile.Read(ui.GetFilename("FROM"));
        target = (string)fromFile.FindKeyword("TargetName", Pvl::Traverse);
      }

      SpiceInt code;
      SpiceBoolean found;

      bodn2c_c (target.c_str(), &code, &found);

      if (!found) {
        string msg = "Could not convert Target [" + target +
                     "] to NAIF code";
        throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_);
      }

      SpiceInt n;
      SpiceDouble radii[3];

      bodvar_c(code,"RADII",&n,radii);

      equRadius = radii[0] * 1000;
      polRadius = radii[2] * 1000;
    }

    if(isOcentric) {
      if(ui.GetString("LATTYPE") != "PLANETOCENTRIC") {
        minLat = Projection::ToPlanetocentric(minLat, (double)equRadius, (double)polRadius);
        maxLat = Projection::ToPlanetocentric(maxLat, (double)equRadius, (double)polRadius);
      }
    }
    else {
      if(ui.GetString("LATTYPE") == "PLANETOCENTRIC") {
        minLat = Projection::ToPlanetographic(minLat, (double)equRadius, (double)polRadius);
        maxLat = Projection::ToPlanetographic(maxLat, (double)equRadius, (double)polRadius);
      }
    }
  }

  if(userGrp.HasKeyword("LongitudeDirection")) {
    bool isPosEast = ((std::string)userGrp.FindKeyword("LongitudeDirection")) == "PositiveEast";

    if(isPosEast) {
      if(ui.GetString("LONDIR") != "POSITIVEEAST") {
        minLon = Projection::ToPositiveEast(minLon, lonDomain);
        maxLon = Projection::ToPositiveEast(maxLon, lonDomain);

        if(minLon > maxLon) {
          double temp = minLon;
          minLon = maxLon;
          maxLon = temp;
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:nocam2map.cpp

示例4: IsisMain


//.........这里部分代码省略.........
	cProcess.SetOutputEndian(Isis::Msb);

	// 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");			
			size_t sFound = cKeyMissionName[0].find("CHANDRAYAAN");
			if (sFound != string::npos ) {
				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->GetGroup("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) {
		std::string sSrcFile = ui.GetFilename("SRC");
		std::string sSrcType = ui.GetString("TYPE");
		GetSourceProductID(sSrcFile, sSrcType, pdsLabel);
	}	
  
	// Get the User defined Labels
	if (ui.WasEntered("USERLBL")) {
		std::string 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");
	}

	size_t iFound = outFilename.find(".lbl");
	outFilename.replace(iFound, 4, ".img");
	ofstream oCube(outFilename.c_str());
	cProcess.OutputDetatchedLabel(); 		
	//cProcess.OutputLabel(oCube);		
	cProcess.StartProcess(oCube);		
	oCube.close();
	cProcess.EndProcess();	
}
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:mrf2pds.cpp


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