本文整理汇总了C++中Process::SetInputCube方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::SetInputCube方法的具体用法?C++ Process::SetInputCube怎么用?C++ Process::SetInputCube使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::SetInputCube方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsisMain
void IsisMain() {
// Set the input image, get the camera model
Process p;
Cube *icube = p.SetInputCube("FROM");
Camera *cam = icube->camera();
// Get the ra/dec range and resolution
double minRa, maxRa, minDec, maxDec;
cam->RaDecRange(minRa, maxRa, minDec, maxDec);
double res = cam->RaDecResolution();
// Get the center ra/dec
cam->SetImage(icube->sampleCount() / 2.0, icube->lineCount() / 2.0);
double centerRa = cam->RightAscension();
double centerDec = cam->Declination();
// Compute the rotation
cam->SetRightAscensionDeclination(centerRa, centerDec + 2.0 * res);
double x = cam->Sample() - icube->sampleCount() / 2.0;
double y = cam->Line() - icube->lineCount() / 2.0;
double rot = atan2(-y, x) * 180.0 / Isis::PI;
rot = 90.0 - rot;
if(rot < 0.0) rot += 360.0;
// Setup and log results
PvlGroup results("Range");
results += PvlKeyword("MinimumRightAscension", toString(minRa), "degrees");
results += PvlKeyword("MaximumRightAscension", toString(maxRa), "degrees");
results += PvlKeyword("MinimumDeclination", toString(minDec), "degrees");
results += PvlKeyword("MaximumDeclination", toString(maxDec), "degrees");
results += PvlKeyword("MinimumRightAscension", Projection::ToHMS(minRa), "hms");
results += PvlKeyword("MaximumRightAscension", Projection::ToHMS(maxRa), "hms");
results += PvlKeyword("MinimumDeclination", Projection::ToDMS(minDec), "dms");
results += PvlKeyword("MaximumDeclination", Projection::ToDMS(maxDec), "dms");
results += PvlKeyword("Resolution", toString(res), "degrees/pixel");
Application::Log(results);
// Setup and log orientation
PvlGroup orient("Orientation");
orient += PvlKeyword("CenterSample", toString(icube->sampleCount() / 2.0));
orient += PvlKeyword("CenterLine", toString(icube->lineCount() / 2.0));
orient += PvlKeyword("CenterRightAscension", toString(centerRa), "degrees");
orient += PvlKeyword("CenterDeclination", toString(centerDec), "degrees");
orient += PvlKeyword("CelestialNorthClockAngle", toString(rot), "degrees");
orient += PvlKeyword("Resolution", toString(res), "degrees/pixel");
Application::Log(orient);
// Write the output file if requested
UserInterface ui = Application::GetUserInterface();
if(ui.WasEntered("TO")) {
Pvl temp;
temp.addGroup(results);
temp.addGroup(orient);
temp.write(ui.GetFileName("TO", "txt"));
}
p.EndProcess();
}
示例2: ComputePixRes
//Helper function to get camera resolution.
void ComputePixRes () {
Process p;
UserInterface &ui = Application::GetUserInterface();
Cube *latCube = p.SetInputCube("LATCUB");
Cube *lonCube = p.SetInputCube("LONCUB");
Brick latBrick(1,1,1,latCube->PixelType());
Brick lonBrick(1,1,1,lonCube->PixelType());
latBrick.SetBasePosition(1,1,1);
latCube->Read(latBrick);
lonBrick.SetBasePosition(1,1,1);
lonCube->Read(lonBrick);
double a = latBrick.at(0) * PI/180.0;
double c = lonBrick.at(0) * PI/180.0;
latBrick.SetBasePosition(latCube->Samples(),latCube->Lines(),1);
latCube->Read(latBrick);
lonBrick.SetBasePosition(lonCube->Samples(),lonCube->Lines(),1);
lonCube->Read(lonBrick);
double b = latBrick.at(0) * PI/180.0;
double d = lonBrick.at(0) * PI/180.0;
double angle = acos(cos(a) * cos(b) * cos(c - d) + sin(a) * sin(b));
angle *= 180/PI;
double pixels = sqrt(pow(latCube->Samples() -1.0, 2.0) + pow(latCube->Lines() -1.0, 2.0));
p.EndProcess();
ui.Clear("RESOLUTION");
ui.PutDouble("RESOLUTION", pixels/angle);
ui.Clear("PIXRES");
ui.PutAsString("PIXRES","PPD");
}
示例3: IsisMain
void IsisMain() {
// Open the input cube
Process p;
UserInterface &ui = Application::GetUserInterface();
CubeAttributeInput cai;
Cube *icube = p.SetInputCube(ui.GetFilename("FROM"), cai, ReadWrite);
// Make sure at least one CK & SPK quality was selected
if (!ui.GetBoolean("CKPREDICTED") && !ui.GetBoolean("CKRECON") && !ui.GetBoolean("CKSMITHED") && !ui.GetBoolean("CKNADIR")) {
string msg = "At least one CK quality must be selected";
throw iException::Message(iException::User,msg,_FILEINFO_);
}
if (!ui.GetBoolean("SPKPREDICTED") && !ui.GetBoolean("SPKRECON") && !ui.GetBoolean("SPKSMITHED")) {
string msg = "At least one SPK quality must be selected";
throw iException::Message(iException::User,msg,_FILEINFO_);
}
// Make sure it is not projected
Projection *proj = NULL;
try {
proj = icube->Projection();
} catch (iException &e) {
proj = NULL;
e.Clear();
}
if (proj != NULL) {
string msg = "Can not initialize SPICE for a map projected cube";
throw iException::Message(iException::User,msg,_FILEINFO_);
}
Pvl lab = *icube->Label();
// if cube has existing polygon delete it
if (icube->Label()->HasObject("Polygon")) {
icube->Label()->DeleteObject("Polygon");
}
// Set up for getting the mission name
// Get the directory where the system missions translation table is.
string transFile = p.MissionData("base", "translations/MissionName2DataDir.trn");
// Get the mission translation manager ready
PvlTranslationManager missionXlater (lab, transFile);
// Get the mission name so we can search the correct DB's for kernels
string mission = missionXlater.Translate ("MissionName");
// Get system base kernels
unsigned int allowed = 0;
unsigned int allowedCK = 0;
unsigned int allowedSPK = 0;
if (ui.GetBoolean("CKPREDICTED")) allowedCK |= spiceInit::kernelTypeEnum("PREDICTED");
if (ui.GetBoolean("CKRECON")) allowedCK |= spiceInit::kernelTypeEnum("RECONSTRUCTED");
if (ui.GetBoolean("CKSMITHED")) allowedCK |= spiceInit::kernelTypeEnum("SMITHED");
if (ui.GetBoolean("CKNADIR")) allowedCK |= spiceInit::kernelTypeEnum("NADIR");
if (ui.GetBoolean("SPKPREDICTED")) allowedSPK |= spiceInit::kernelTypeEnum("PREDICTED");
if (ui.GetBoolean("SPKRECON")) allowedSPK |= spiceInit::kernelTypeEnum("RECONSTRUCTED");
if (ui.GetBoolean("SPKSMITHED")) allowedSPK |= spiceInit::kernelTypeEnum("SMITHED");
KernelDb baseKernels (allowed);
KernelDb ckKernels (allowedCK);
KernelDb spkKernels (allowedSPK);
baseKernels.LoadSystemDb(mission);
ckKernels.LoadSystemDb(mission);
spkKernels.LoadSystemDb(mission);
Kernel lk, pck, targetSpk, fk, ik, sclk, spk, iak, dem, exk;
std::priority_queue< Kernel > ck;
lk = baseKernels.LeapSecond(lab);
pck = baseKernels.TargetAttitudeShape(lab);
targetSpk = baseKernels.TargetPosition(lab);
ik = baseKernels.Instrument(lab);
sclk = baseKernels.SpacecraftClock(lab);
iak = baseKernels.InstrumentAddendum(lab);
fk = ckKernels.Frame(lab);
ck = ckKernels.SpacecraftPointing(lab);
spk = spkKernels.SpacecraftPosition(lab);
if (ui.GetBoolean("CKNADIR")) {
// Only add nadir if no spacecraft pointing found
std::vector<std::string> kernels;
kernels.push_back("Nadir");
ck.push(Kernel((spiceInit::kernelTypes)0, kernels));
}
// Get user defined kernels and override ones already found
GetUserEnteredKernel("LS", lk);
GetUserEnteredKernel("PCK", pck);
GetUserEnteredKernel("TSPK", targetSpk);
GetUserEnteredKernel("FK", fk);
GetUserEnteredKernel("IK", ik);
GetUserEnteredKernel("SCLK", sclk);
GetUserEnteredKernel("SPK", spk);
GetUserEnteredKernel("IAK", iak);
GetUserEnteredKernel("EXTRA", exk);
// Get shape kernel
if (ui.GetString ("SHAPE") == "USER") {
GetUserEnteredKernel("MODEL", dem);
//.........这里部分代码省略.........
示例4: IsisMain
//.........这里部分代码省略.........
(poly.validLineDim() * 2) - 3.0) /
ui.GetInteger("NUMVERTICES")));
if (sinc < 1.0 || linc < 1.0)
sinc = linc = 1.0;
}
else if (incType.UpCase() == "LINCSINC"){
sinc = ui.GetInteger("SINC");
linc = ui.GetInteger("LINC");
}
else {
string msg = "Invalid INCTYPE option[" + incType + "]";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
bool precision = ui.GetBoolean("INCREASEPRECISION");
try {
poly.Create(cube, sinc, linc, 1, 1, 0, 0, 1, precision);
}
catch (IException &e) {
QString msg = "Cannot generate polygon for [" + ui.GetFileName("FROM") + "]";
throw IException(e, IException::User, msg, _FILEINFO_);
}
if(ui.GetBoolean("TESTXY")) {
Pvl cubeLab(ui.GetFileName("FROM"));
PvlGroup inst = cubeLab.findGroup("Instrument", Pvl::Traverse);
QString target = inst["TargetName"];
PvlGroup radii = Projection::TargetRadii(target);
Pvl map(ui.GetFileName("MAP"));
PvlGroup &mapping = map.findGroup("MAPPING");
if(!mapping.hasKeyword("TargetName"))
mapping += Isis::PvlKeyword("TargetName", target);
if(!mapping.hasKeyword("EquatorialRadius"))
mapping += Isis::PvlKeyword("EquatorialRadius", (QString)radii["EquatorialRadius"]);
if(!mapping.hasKeyword("PolarRadius"))
mapping += Isis::PvlKeyword("PolarRadius", (QString)radii["PolarRadius"]);
if(!mapping.hasKeyword("LatitudeType"))
mapping += Isis::PvlKeyword("LatitudeType", "Planetocentric");
if(!mapping.hasKeyword("LongitudeDirection"))
mapping += Isis::PvlKeyword("LongitudeDirection", "PositiveEast");
if(!mapping.hasKeyword("LongitudeDomain"))
mapping += Isis::PvlKeyword("LongitudeDomain", "360");
if(!mapping.hasKeyword("CenterLatitude"))
mapping += Isis::PvlKeyword("CenterLatitude", "0");
if(!mapping.hasKeyword("CenterLongitude"))
mapping += Isis::PvlKeyword("CenterLongitude", "0");
sinc = poly.getSinc();
linc = poly.getLinc();
bool polygonGenerated = false;
while (!polygonGenerated) {
Projection *proj = NULL;
geos::geom::MultiPolygon *xyPoly = NULL;
try {
proj = ProjectionFactory::Create(map, true);
xyPoly = PolygonTools::LatLonToXY(*poly.Polys(), proj);
polygonGenerated = true;
}
catch (IException &e) {
if (precision && sinc > 1 && linc > 1) {
sinc = sinc * 2 / 3;
linc = linc * 2 / 3;
poly.Create(cube, sinc, linc);
}
else {
delete proj;
delete xyPoly;
e.print(); // This should be a NAIF error
QString msg = "Cannot calculate XY for [";
msg += ui.GetFileName("FROM") + "]";
throw IException(e, IException::User, msg, _FILEINFO_);
}
}
delete proj;
delete xyPoly;
}
}
cube.deleteBlob("Polygon", sn);
cube.write(poly);
if(precision) {
PvlGroup results("Results");
results.addKeyword(PvlKeyword("SINC", toString(sinc)));
results.addKeyword(PvlKeyword("LINC", toString(linc)));
Application::Log(results);
}
Process p;
p.SetInputCube("FROM");
p.WriteHistory(cube);
cube.close();
prog.CheckStatus();
}
示例5: 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
//.........这里部分代码省略.........
示例6: IsisMain
void IsisMain() {
Process p;
Cube *icube = p.SetInputCube("FROM");
Camera *cam = icube->camera();
UserInterface &ui = Application::GetUserInterface();
QString from = ui.GetFileName("FROM");
int sinc = ui.GetInteger("SINC");
int linc = ui.GetInteger("LINC");
CameraStatistics camStats(cam, sinc, linc, from);
// Send the Output to the log area
Pvl statsPvl = camStats.toPvl();
for (int i = 0; i < statsPvl.groups(); i++) {
Application::Log(statsPvl.group(i));
}
if(ui.WasEntered("TO")) {
QString outfile = FileName(ui.GetFileName("TO")).expanded();
bool exists = FileName(outfile).fileExists();
bool append = ui.GetBoolean("APPEND");
// If the user chose a format of PVL, then write to the output file ("TO")
if(ui.GetString("FORMAT") == "PVL") {
(append) ? statsPvl.append(outfile) : statsPvl.write(outfile);
}
else {
// Create a flatfile of the data with columhn headings the flatfile is
// comma-delimited and can be imported in to spreadsheets
ofstream os;
bool writeHeader = true;
if(append) {
os.open(outfile.toAscii().data(), ios::app);
if(exists) {
writeHeader = false;
}
}
else {
os.open(outfile.toAscii().data(), ios::out);
}
// if new file or append and no file exists then write header
if(writeHeader) {
os << "Filename," <<
"LatitudeMinimum," <<
"LatitudeMaximum," <<
"LatitudeAverage," <<
"LatitudeStandardDeviation," <<
"LongitudeMinimum," <<
"LongitudeMaximum," <<
"LongitudeAverage," <<
"LongitudeStandardDeviation," <<
"SampleResolutionMinimum," <<
"SampleResolutionMaximum," <<
"SampleResolutionAverage," <<
"SampleResolutionStandardDeviation," <<
"LineResolutionMinimum," <<
"LineResolutionMaximum," <<
"LineResolutionAverage," <<
"LineResolutionStandardDeviation," <<
"ResolutionMinimum," <<
"ResolutionMaximum," <<
"ResolutionAverage," <<
"ResolutionStandardDeviation," <<
"AspectRatioMinimum," <<
"AspectRatioMaximum," <<
"AspectRatioAverage," <<
"AspectRatioStandardDeviation," <<
"PhaseMinimum," <<
"PhaseMaximum," <<
"PhaseAverage," <<
"PhaseStandardDeviation," <<
"EmissionMinimum," <<
"EmissionMaximum," <<
"EmissionAverage," <<
"EmissionStandardDeviation," <<
"IncidenceMinimum," <<
"IncidenceMaximum," <<
"IncidenceAverage," <<
"IncidenceStandardDeviation," <<
"LocalSolarTimeMinimum," <<
"LocalSolarTimeMaximum," <<
"LocalSolarTimeAverage," <<
"LocalSolarTimeStandardDeviation," <<
"LocalRadiusMaximum," <<
"LocalRadiusMaximum," <<
"LocalRadiusAverage," <<
"LocalRadiusStandardDeviation," <<
"NorthAzimuthMinimum," <<
"NorthAzimuthMaximum," <<
"NorthAzimuthAverage," <<
"NorthAzimuthStandardDeviation," << endl;
}
os << FileName(from).expanded() << ",";
//call the function to write out the values for each group
writeFlat(os, camStats.getLatStat());
writeFlat(os, camStats.getLonStat());
writeFlat(os, camStats.getSampleResStat());
writeFlat(os, camStats.getLineResStat());
//.........这里部分代码省略.........
示例7: IsisMain
void IsisMain() {
// Use a regular Process
Process p;
// Get user parameters and error check
UserInterface &ui = Application::GetUserInterface();
QString from = ui.GetFileName("FROM");
QString to = FileName(ui.GetFileName("TO")).expanded();
//TO DO: UNCOMMENT THIS LINE ONCE HRSC IS WORKING IN SS
// double HRSCNadirCenterTime = ui.GetDouble("HRSC_NADIRCENTERTIME");
// Open input cube and Make sure this is a lev1 image (ie, not map projected)
Cube cube;
cube.open(from);
if (cube.isProjected()) {
QString msg = "Input images is a map projected cube ... not a level 1 image";
throw IException(IException::User, msg, _FILEINFO_);
}
// Initialize the camera
Cube *input = p.SetInputCube("FROM");
Pvl *cubeHeader = input->label();
Camera *cam = input->camera();
CameraDetectorMap *detectorMap = cam->DetectorMap();
CameraFocalPlaneMap *focalMap = cam->FocalPlaneMap();
CameraDistortionMap *distortionMap = cam->DistortionMap();
CameraGroundMap *groundMap = cam->GroundMap();
// Make sure the image contains the InstrumentPointing (aka CK) blob/table
PvlGroup test = cube.label()->findGroup("Kernels", Pvl::Traverse);
QString InstrumentPointing = (QString) test["InstrumentPointing"];
if (InstrumentPointing != "Table") {
QString msg = "Input image does not contain needed SPICE blobs...run spiceinit with attach=yes.";
throw IException(IException::User, msg, _FILEINFO_);
}
// Open output line scanner keyword file
ofstream toStrm;
toStrm.open(to.toAscii().data(), ios::trunc);
if (toStrm.bad()) {
QString msg = "Unable to open output TO file";
throw IException(IException::User, msg, _FILEINFO_);
}
// Get required keywords from instrument and band groups
PvlGroup inst = cube.label()->findGroup("Instrument", Pvl::Traverse);
QString instrumentId = (QString) inst["InstrumentId"];
bool isMocNA = false;
//TO DO: UNCOMMENT THIS LINES ONCE MOC IS WORKING IN SS
// bool isMocWARed = false;
bool isHiRise = false;
bool isCTX = false;
bool isLroNACL = false;
bool isLroNACR = false;
bool isHRSC = false;
//TO DO: UNCOMMENT THESE LINE ONCE MOC IS WORKING IN SS
// if (instrumentId == "MOC") {
// PvlGroup band = cube.label()->findGroup("BandBin", Pvl::Traverse);
// QString filter = (QString) band["FilterName"];
//
// if (strcmp(filter.toAscii().data(), "BROAD_BAND") == 0)
// isMocNA = true;
// else if (strcmp(filter.toAscii().data(), "RED") == 0)
// isMocWARed = true;
// else if (strcmp(filter.toAscii().data(), "BLUE") == 0) {
// QString msg = "MOC WA Blue filter images not supported for Socet Set mapping";
// throw IException(IException::User, msg, _FILEINFO_);
// }
// }
// else if (instrumentId == "IdealCamera") {
//TO DO: DELETE THIS LINE ONCE MOC IS WORKING IN SS
if (instrumentId == "IdealCamera") {
PvlGroup orig = cube.label()->findGroup("OriginalInstrument", Pvl::Traverse);
QString origInstrumentId = (QString) orig["InstrumentId"];
if (origInstrumentId == "HIRISE") {
isHiRise = true;
}
else {
QString msg = "Unsupported instrument: " + origInstrumentId;
throw IException(IException::User, msg, _FILEINFO_);
}
}
else if (instrumentId == "HIRISE") {
isHiRise = true;
}
else if (instrumentId == "CTX") {
isCTX = true;
}
else if (instrumentId == "NACL") {
isLroNACL = true;
}
else if (instrumentId == "NACR") {
isLroNACR = true;
}
//TO DO: UNCOMMENT THIS LINE ONCE HRSC IS WORKING IN SS
// else if (instrumentId == "HRSC") isHRSC = true;
else {
//.........这里部分代码省略.........
示例8: IsisMain
//.........这里部分代码省略.........
double ssamp = sample + (i * space);
double sline = line + (j * space);
Coordinate pnt = Coordinate(sline, ssamp);
SmtkPoint gpnt = matcher.Clone(spnt, pnt);
if ( gpnt.isValid() ) {
SmtkQPair growpt((int) sline, (int) ssamp);
// double check we don't have a finalized result at this position
SmtkQStackIter temp = bmf.find(growpt);
if(temp == bmf.end()) {
gstack.insert(growpt, gpnt);
}
}
}
}
}
}
}
// Remove the current point from the grow stack (hole)
gstack.erase(cstack);
}
/////////////////////////////////////////////////////////////////////////
// All done with creating points. Perform output options.
/////////////////////////////////////////////////////////////////////////
// If a TO parameter was specified, create DEM with errors
if (ui.WasEntered("TO")) {
// Create the output DEM
cout << "\nCreating output DEM from " << bmf.size() << " points.\n";
Process p;
Cube *icube = p.SetInputCube("FROM");
Cube *ocube = p.SetOutputCube("TO", icube->sampleCount(),
icube->lineCount(), 3);
p.ClearInputCubes();
int boxsize = ui.GetInteger("BOXSIZE");
double plotdist = ui.GetDouble("PLOTDIST");
TileManager dem(*ocube), eigen(*ocube), stErr(*ocube);
dem.SetTile(1, 1); // DEM Data/elevation
stErr.SetTile(1, 2); // Error in stereo computation
eigen.SetTile(1, 3); // Eigenvalue of the solution
int nBTiles(eigen.Tiles()/3); // Total tiles / 3 bands
prog.SetText("Creating DEM");
prog.SetMaximumSteps(nBTiles);
prog.CheckStatus();
Statistics stAng;
while ( !eigen.end() ) { // Must use the last band for this!!
PointPlot tm = for_each(bmf.begin(), bmf.end(), PointPlot(dem, plotdist));
tm.FillPoints(*lhCamera, *rhCamera, boxsize, dem, stErr, eigen, &stAng);
ocube->write(dem);
ocube->write(stErr);
ocube->write(eigen);
dem.next();
stErr.next();
eigen.next();
prog.CheckStatus();
示例9: IsisMain
void IsisMain() {
QString projName;
Process pHist;
Cube *icube = pHist.SetInputCube("FROM");
// Check to see if the input cube looks like a HiRISE RDR
if (icube->bandCount() > 3) {
QString msg = "Input file [" +
Application::GetUserInterface().GetFileName("FROM") +
"] does not appear to be a HiRISE RDR product. Number of " +
"bands is greater than 3";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
// Setup to get a histogram for each band
g_min = new double[icube->bandCount()];
g_max = new double[icube->bandCount()];
UserInterface &ui = Application::GetUserInterface();
// Determine if the data is to be converted to JPEG2000
IString enctype = ui.GetString("ENCODING_TYPE");
enctype.DownCase();
for (int band = 1; band <= icube->bandCount(); ++band) {
if (ui.GetString("TYPE").compare("AUTOMATIC") == 0) {
// Set up a histogram for this band. This call sets the input range
// by making an initial stats pass to find the data min and max
Histogram hist(*icube, band, pHist.Progress());
// Loop and accumulate histogram
pHist.Progress()->SetText("Gathering Histogram");
pHist.Progress()->SetMaximumSteps(icube->lineCount());
pHist.Progress()->CheckStatus();
LineManager line(*icube);
for (int i = 1; i <= icube->lineCount(); i++) {
line.SetLine(i, band);
icube->read(line);
hist.AddData(line.DoubleBuffer(), line.size());
pHist.Progress()->CheckStatus();
}
// get the requested cumulative percentages
g_min[band-1] = ui.GetDouble("MINPER") == 0.0 ? hist.Minimum() : hist.Percent(ui.GetDouble("MINPER"));
g_max[band-1] = ui.GetDouble("MAXPER") == 100.0 ? hist.Maximum() : hist.Percent(ui.GetDouble("MAXPER"));
}
else {
g_min[band-1] = ui.GetDouble("MIN");
g_max[band-1] = ui.GetDouble("MAX");
}
}
// Find the minimum min and maximum max for all bands
double minmin = g_min[0];
double maxmax = g_max[0];
for (int band = 1; band < icube->bandCount(); ++band) {
if (g_min[band] < minmin) minmin = g_min[band];
if (g_max[band] > maxmax) maxmax = g_max[band];
}
pHist.EndProcess();
// Set up for writing the data to a PDS formatted file
ProcessExportPds p;
Cube *icube2 = p.SetInputCube("FROM");
if (enctype.Equal("jp2")) {
g_jp2buf = new char* [icube2->bandCount()];
FileName lblFile(ui.GetFileName("TO"));
QString lblFileName = lblFile.path() + "/" + lblFile.baseName() + ".lbl";
p.SetDetached(lblFileName);
p.setFormat(ProcessExport::JP2);
}
// Set the output pixel type and the special pixel values
int nbits = ui.GetInteger("BITS");
if (nbits == 8) {
if (enctype.Equal("jp2")) {
for (int i = 0; i < icube2->bandCount(); i++) {
g_jp2buf[i] = new char[icube2->sampleCount()];
}
}
g_oType = Isis::UnsignedByte;
p.SetOutputType(g_oType);
p.SetOutputRange(VALID_MIN1, VALID_MAX1);
p.SetOutputNull(NULL1);
p.SetOutputLis(LOW_INSTR_SAT1);
p.SetOutputLrs(LOW_REPR_SAT1);
p.SetOutputHis(HIGH_INSTR_SAT1);
p.SetOutputHrs(HIGH_REPR_SAT1);
}
else if (nbits == 16) {
if (enctype.Equal("jp2")) {
for (int i = 0; i < icube2->bandCount(); i++) {
g_jp2buf[i] = new char[icube2->sampleCount()*2];
}
}
//.........这里部分代码省略.........
示例10: IsisMain
void IsisMain(){
Process p;
// Reset all the stats objects because they are global
latStat.Reset();
lonStat.Reset();
resStat.Reset();
sampleResStat.Reset();
lineResStat.Reset();
aspectRatioStat.Reset();
phaseStat.Reset();
emissionStat.Reset();
incidenceStat.Reset();
localSolarTimeStat.Reset();
localRaduisStat.Reset();
northAzimuthStat.Reset();
UserInterface &ui = Application::GetUserInterface();
Cube *icube = p.SetInputCube("FROM");
Camera *cam = icube->Camera();
// Cube cube;
// cube.Open(ui.GetFilename("FROM"));
// Camera *cam = cube.Camera();
int eband = cam->Bands();
// if the camera is band independent that only run one band
if (cam->IsBandIndependent()) eband = 1;
int linc = ui.GetInteger("LINC");
int sinc = ui.GetInteger("SINC");
int pTotal = eband * ((cam->Lines()-2) / linc + 2) ;
Progress progress;
progress.SetMaximumSteps(pTotal);
progress.CheckStatus();
for (int band=1; band<=eband; band++) {
cam->SetBand(band);
for (int line=1; line<(int)cam->Lines(); line=line+linc) {
for (int sample=1; sample< cam->Samples(); sample=sample+sinc) {
buildStats(cam, sample, line);
}
//set the sample value to the last sample and run buildstats
int sample = cam->Samples();
buildStats(cam, sample, line);
progress.CheckStatus();
}
//set the line value to the last line and run on all samples(sample + sinc)
int line = cam->Lines();
for (int sample=1; sample< cam->Samples(); sample=sample+sinc) {
buildStats(cam, sample, line);
}
//set last sample and run with last line
int sample = cam->Samples();
buildStats(cam, sample, line);
progress.CheckStatus();
}
//Set up the Pvl groups and get min, max, avg, and sd for each statstics object
PvlGroup pUser("User Parameters");
pUser += PvlKeyword("Filename",ui.GetFilename("FROM"));
pUser += PvlKeyword("Linc",ui.GetInteger("LINC"));
pUser += PvlKeyword("Sinc",ui.GetInteger("SINC"));
PvlGroup pLat("Latitude");
pLat += ValidateKey("LatitudeMinimum",latStat.Minimum());
pLat += ValidateKey("LatitudeMaximum",latStat.Maximum());
pLat += ValidateKey("LatitudeAverage",latStat.Average());
pLat += ValidateKey("LatitudeStandardDeviation",latStat.StandardDeviation());
PvlGroup pLon("Longitude");
pLon += ValidateKey("LongitudeMinimum",lonStat.Minimum());
pLon += ValidateKey("LongitudeMaximum",lonStat.Maximum());
pLon += ValidateKey("LongitudeAverage",lonStat.Average());
pLon += ValidateKey("LongitudeStandardDeviation",lonStat.StandardDeviation());
PvlGroup pSampleRes("SampleResolution");
pSampleRes += ValidateKey("SampleResolutionMinimum",sampleResStat.Minimum(),
"meters/pixel");
pSampleRes += ValidateKey("SampleResolutionMaximum",sampleResStat.Maximum(),
"meters/pixel");
pSampleRes += ValidateKey("SampleResolutionAverage",sampleResStat.Average(),
"meters/pixel");
pSampleRes += ValidateKey("SampleResolutionStandardDeviation",
sampleResStat.StandardDeviation(),"meters/pixel");
PvlGroup pLineRes("LineResolution");
pLineRes += ValidateKey("LineResolutionMinimum",lineResStat.Minimum(),
"meters/pixel");
pLineRes += ValidateKey("LineResolutionMaximum",lineResStat.Maximum(),
"meters/pixel");
pLineRes += ValidateKey("LineResolutionAverage",lineResStat.Average(),
"meters/pixel");
pLineRes += ValidateKey("LineResolutionStandardDeviation",
lineResStat.StandardDeviation(),"meters/pixel");
PvlGroup pResolution("Resolution");
pResolution += ValidateKey("ResolutionMinimum",resStat.Minimum(),
//.........这里部分代码省略.........
示例11: 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;
//.........这里部分代码省略.........
示例12: 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
//.........这里部分代码省略.........
示例13: IsisMain
void IsisMain() {
const QString caminfo_program = "caminfo";
UserInterface &ui = Application::GetUserInterface();
QList< QPair<QString, QString> > *general = NULL, *camstats = NULL, *statistics = NULL;
BandGeometry *bandGeom = NULL;
// Get input filename
FileName in = ui.GetFileName("FROM");
// Get the format
QString sFormat = ui.GetAsString("FORMAT");
// if true then run spiceinit, xml default is FALSE
// spiceinit will use system kernels
if(ui.GetBoolean("SPICE")) {
QString parameters = "FROM=" + in.expanded();
ProgramLauncher::RunIsisProgram("spiceinit", parameters);
}
Process p;
Cube *incube = p.SetInputCube("FROM");
// General data gathering
general = new QList< QPair<QString, QString> >;
general->append(MakePair("Program", caminfo_program));
general->append(MakePair("IsisVersion", Application::Version()));
general->append(MakePair("RunDate", iTime::CurrentGMT()));
general->append(MakePair("IsisId", SerialNumber::Compose(*incube)));
general->append(MakePair("From", in.baseName() + ".cub"));
general->append(MakePair("Lines", toString(incube->lineCount())));
general->append(MakePair("Samples", toString(incube->sampleCount())));
general->append(MakePair("Bands", toString(incube->bandCount())));
// Run camstats on the entire image (all bands)
// another camstats will be run for each band and output
// for each band.
if(ui.GetBoolean("CAMSTATS")) {
camstats = new QList< QPair<QString, QString> >;
QString filename = ui.GetAsString("FROM");
int sinc = ui.GetInteger("SINC");
int linc = ui.GetInteger("LINC");
CameraStatistics stats(filename, sinc, linc);
Pvl camPvl = stats.toPvl();
PvlGroup cg = camPvl.findGroup("Latitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLatitude", cg["latitudeminimum"][0]));
camstats->append(MakePair("MaximumLatitude", cg["latitudemaximum"][0]));
cg = camPvl.findGroup("Longitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLongitude", cg["longitudeminimum"][0]));
camstats->append(MakePair("MaximumLongitude", cg["longitudemaximum"][0]));
cg = camPvl.findGroup("Resolution", Pvl::Traverse);
camstats->append(MakePair("MinimumResolution", cg["resolutionminimum"][0]));
camstats->append(MakePair("MaximumResolution", cg["resolutionmaximum"][0]));
cg = camPvl.findGroup("PhaseAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumPhase", cg["phaseminimum"][0]));
camstats->append(MakePair("MaximumPhase", cg["phasemaximum"][0]));
cg = camPvl.findGroup("EmissionAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumEmission", cg["emissionminimum"][0]));
camstats->append(MakePair("MaximumEmission", cg["emissionmaximum"][0]));
cg = camPvl.findGroup("IncidenceAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumIncidence", cg["incidenceminimum"][0]));
camstats->append(MakePair("MaximumIncidence", cg["incidencemaximum"][0]));
cg = camPvl.findGroup("LocalSolarTime", Pvl::Traverse);
camstats->append(MakePair("LocalTimeMinimum", cg["localsolartimeMinimum"][0]));
camstats->append(MakePair("LocalTimeMaximum", cg["localsolartimeMaximum"][0]));
}
// Compute statistics for entire cube
if(ui.GetBoolean("STATISTICS")) {
statistics = new QList< QPair<QString, QString> >;
LineManager iline(*incube);
Statistics stats;
Progress progress;
progress.SetText("Statistics...");
progress.SetMaximumSteps(incube->lineCount()*incube->bandCount());
progress.CheckStatus();
iline.SetLine(1);
for(; !iline.end() ; iline.next()) {
incube->read(iline);
stats.AddData(iline.DoubleBuffer(), iline.size());
progress.CheckStatus();
}
// Compute stats of entire cube
double nPixels = stats.TotalPixels();
double nullpercent = (stats.NullPixels() / (nPixels)) * 100;
double hispercent = (stats.HisPixels() / (nPixels)) * 100;
double hrspercent = (stats.HrsPixels() / (nPixels)) * 100;
double lispercent = (stats.LisPixels() / (nPixels)) * 100;
double lrspercent = (stats.LrsPixels() / (nPixels)) * 100;
//.........这里部分代码省略.........
示例14: IsisMain
void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
Process p;
// Get the histogram
Cube *icube = p.SetInputCube("FROM");
double validMin = Isis::ValidMinimum;
double validMax = Isis::ValidMaximum;
if(ui.WasEntered("VALIDMIN")) {
validMin = ui.GetDouble("VALIDMIN");
}
if(ui.WasEntered("VALIDMAX")) {
validMax = ui.GetDouble("VALIDMAX");
}
// Set a global Pvl for storing results
Pvl mainpvl;
// Get the number of bands to process
int bandcount = icube->bandCount();
for (int i = 1; i <= bandcount; i++) {
Histogram *stats = icube->histogram(i, validMin, validMax);
// Construct a label with the results
PvlGroup results("Results");
results += PvlKeyword("From", icube->fileName());
results += PvlKeyword("Band", toString(icube->physicalBand(i)));
if(stats->ValidPixels() != 0) {
results += PvlKeyword("Average", toString(stats->Average()));
results += PvlKeyword("StandardDeviation", toString(stats->StandardDeviation()));
results += PvlKeyword("Variance", toString(stats->Variance()));
// These statistics only worked on a histogram
results += PvlKeyword("Median", toString(stats->Median()));
results += PvlKeyword("Mode", toString(stats->Mode()));
results += PvlKeyword("Skew", toString(stats->Skew()));
results += PvlKeyword("Minimum", toString(stats->Minimum()));
results += PvlKeyword("Maximum", toString(stats->Maximum()));
results += PvlKeyword("Sum", toString(stats->Sum()));
}
results += PvlKeyword("TotalPixels", toString(stats->TotalPixels()));
results += PvlKeyword("ValidPixels", toString(stats->ValidPixels()));
results += PvlKeyword("OverValidMaximumPixels", toString(stats->OverRangePixels()));
results += PvlKeyword("UnderValidMinimumPixels", toString(stats->UnderRangePixels()));
results += PvlKeyword("NullPixels", toString(stats->NullPixels()));
results += PvlKeyword("LisPixels", toString(stats->LisPixels()));
results += PvlKeyword("LrsPixels", toString(stats->LrsPixels()));
results += PvlKeyword("HisPixels", toString(stats->HisPixels()));
results += PvlKeyword("HrsPixels", toString(stats->HrsPixels()));
mainpvl.addGroup(results);
delete stats;
// Write the results to the log
Application::Log(results);
}
// Write the results to the output file if the user specified one
if(ui.WasEntered("TO")) {
QString outFile = FileName(ui.GetFileName("TO")).expanded();
bool exists = FileName(outFile).fileExists();
bool append = ui.GetBoolean("APPEND");
ofstream os;
bool writeHeader = false;
//write the results in the requested format.
if(ui.GetString("FORMAT") == "PVL") {
if(append) {
mainpvl.append(outFile);
}
else {
mainpvl.write(outFile);
}
}
else {
//if the format was not PVL, write out a flat file.
if(append) {
os.open(outFile.toAscii().data(), ios::app);
if(!exists) {
writeHeader = true;
}
}
else {
os.open(outFile.toAscii().data(), ios::out);
writeHeader = true;
}
if(writeHeader) {
for(int i = 0; i < mainpvl.group(0).keywords(); i++) {
os << mainpvl.group(0)[i].name();
if( i < mainpvl.group(0).keywords() - 1 ) {
os << ",";
}
}
os << endl;
}
//.........这里部分代码省略.........
示例15: IsisMain
void IsisMain() {
// Use a regular Process
Process p;
UserInterface &ui = Application::GetUserInterface();
QString from = ui.GetFileName("FROM");
QString to = FileName(ui.GetFileName("TO")).expanded();
QString socetProject = ui.GetString("SS_PROJECT");
QString socetImageLocation = ui.GetString("SS_IMG_LOC");
QString socetInputDataPath = ui.GetString("SS_INPUT_PATH");
QString socetCameraCalibrationPath = ui.GetString("SS_CAM_CALIB_PATH");
// Open input cube and make sure this is a lev1 image (ie, not map projected)
Cube cube;
cube.open(from);
if (cube.isProjected()) {
QString msg = QString("You can only create a SOCET Set Framing Camera or FrameOffAxis settings "
"file for level 1 images. The input image [%1] is a map projected, level "
"2, cube.").arg(from);
throw IException(IException::User, msg, _FILEINFO_);
}
// Initialize the camera
Cube *input = p.SetInputCube("FROM");
Camera *cam = input->camera();
CameraDetectorMap *detectorMap = cam->DetectorMap();
CameraFocalPlaneMap *focalMap = cam->FocalPlaneMap();
// Make sure the image contains the SPICE blobs/tables
PvlGroup test = cube.label()->findGroup("Kernels", Pvl::Traverse);
QString instrumentPointing = (QString) test["InstrumentPointing"];
if (instrumentPointing != "Table") {
QString msg = QString("Input image [%1] does not contain needed SPICE blobs. Please run "
"spiceinit on the image with attach=yes.").arg(from);
throw IException(IException::User, msg, _FILEINFO_);
}
// Set the image at the boresight pixel to get the ephemeris time and SPICE data at that image
// location
double detectorSampleOrigin = focalMap->DetectorSampleOrigin();
double detectorLineOrigin = focalMap->DetectorSampleOrigin();
cam->SetImage(detectorSampleOrigin, detectorLineOrigin);
double et = cam->time().Et();
Spice spice(*input);
spice.setTime(et);
// Get required keywords from instrument and band groups
PvlGroup inst = cube.label()->findGroup("Instrument", Pvl::Traverse);
QString instrumentId = (QString) inst["InstrumentId"];
QString spacecraftName = (QString) inst["SpacecraftName"];
// Compensate for noproj altering cube labels
if (instrumentId == "IdealCamera") {
PvlGroup orig = cube.label()->findGroup("OriginalInstrument", Pvl::Traverse);
instrumentId = (QString) orig["InstrumentId"];
spacecraftName = (QString) orig["SpacecraftName"];
}
// Get sensor position and orientation (opk) angles
double ographicCamPos[3] = {0.0, 0.0, 0.0};
double omegaPhiKappa[3] = {0.0, 0.0, 0.0};
double isisFocalPlane2SocetPlateTranspose[3][3] =
{{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
getCamPosOPK(spice, spacecraftName, et, cam, ographicCamPos,
omegaPhiKappa,isisFocalPlane2SocetPlateTranspose);
// Determine the SOCET Set camera calibration file
QString socetCamFile = socetCameraCalibrationPath;
if (spacecraftName == "VIKING_ORBITER_1") {
if (instrumentId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
socetCamFile += "VIK1A.cam";
}
else {
socetCamFile += "VIK1B.cam";
}
}
else if (spacecraftName == "VIKING_ORBITER_2") {
if (instrumentId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
socetCamFile += "VIK2A.cam";
}
else {
socetCamFile += "VIK2B.cam";
}
}
//----------------------------------------.-------------
//TO DO: Uncomment these lines when MEX SRC is supported
//----------------------------------------.-------------
// // Mars Express
// else if (spacecraftName == "MARS_EXPRESS") {
// socetCamFile += "SRC.cam";
// }
//-----------------------------------------------------
//TO DO: Uncomment these lines when Themis is supported
//-----------------------------------------------------
// // THEMIS VIS images (MARS Odyssey)
//.........这里部分代码省略.........