📄 ionobias.cpp
字号:
" Prgm IonoBias will open and read several preprocessed Rinex obs files\n" " (containing obs types EL,LA,LO,SR or SS) and use the data to estimate\n" " satellite and receiver biases and to compute a simple ionospheric model\n" " using least squares and the slant TEC values.\n" " Input is on the command line, or of the same format in a file (-f<file>).\n"); // allow user to put all options in a file // could also scan for debug here vector<string> Args; for(j=1; j<argc; j++) PreProcessArgs(argv[j],Args); if(Args.size()==0) Args.push_back(string("-h")); // pass the rest argc = Args.size()+1; char **CArgs=new char*[argc]; if(!CArgs) { cerr << "Failed to allocate CArgs\n"; return -1; } CArgs[0] = argv[0]; for(j=1; j<argc; j++) { CArgs[j] = new char[Args[j-1].size()+1]; if(!CArgs[j]) { cerr << "Failed to allocate CArgs[j]\n"; return -1; } strcpy(CArgs[j],Args[j-1].c_str()); } if(debug) { cout << "List passed to parse\n"; for(i=0; i<argc; i++) cout << i << " " << CArgs[i] << endl; } Par.parseOptions(argc, CArgs); delete[] CArgs; if(dashh.getCount() > 0) { help = true; } if(Par.hasErrors()) { cerr << "\nErrors found in command line input:\n"; Par.dumpErrors(cerr); cerr << "...end of Errors\n\n"; help = true; } if(help) { Par.displayUsage(cout,false); cout << endl; } // get values found on command line vector<string> values; // f never appears because we intercept it above //if(dashf.getCount()) { cout << "Option f "; dashf.dumpValue(cout); } // open the log file first if(dashl.getCount()) { values = dashl.getValue(); if(help) cout << "Input name of output log file: " << values[0] << endl; LogFile = values[0]; } oflog.open(LogFile.c_str(),ios_base::out); if(!oflog) { cerr << "Failed to open log file " << LogFile << endl; return -1; } oflog << Title; cout << "IonoBias output directed to log file " << LogFile << endl; if(help) { Par.displayUsage(oflog,false); oflog << endl; if (Par.hasErrors()) { oflog << "\nErrors found in command line input:\n"; Par.dumpErrors(oflog); oflog << "...end of Errors\n\n"; return -1; } } // input path; do path before input file names if(dashp.getCount()) { values = dashp.getValue(); if(help) cout << "Input path name: " << values[0] << endl; InputPath = values[0]; } else InputPath = string(""); // input file names if(dashin.getCount()) { values = dashin.getValue(); if(help) cout << "Input Rinex obs file names are:\n"; string::size_type pos; string fname; for(i=0; i<values.size(); i++) { fname = values[i]; // expand filenames of the form @name or name@ // into the *contents* (one name per line) of file 'name'. pos = fname.find('@'); if(pos == string::npos || (pos != 0 && pos != fname.length()-1)) { // value is a Rinex file name if(InputPath.size() > 0) { fname = InputPath + "/" + fname; } Filenames.push_back(fname); if(help) cout << " " << fname << endl; } else { // value is a file containing Rinex file names fname.erase(pos,1); if(InputPath.size() > 0) { fname = InputPath + "/" + fname; } if(help) cout << " " << "(Open and read file names from: " << fname << ")" << endl; ifstream infile(fname.c_str()); if(!infile) { oflog << "Error: could not open file " << fname << endl; } else { while(infile >> fname) { if(fname[0] == '#') { // skip to end of line char c; while(infile.get(c)) { if(c=='\n') break; } } else { Filenames.push_back(fname); if(debug) oflog << " " << fname << endl; } } // end loop over lines in the file infile.close(); } // end opened file } // end if value is a file containing file names } // end loop over values on command line } // end dashin // ephemeris input if(dashnd.getCount()) { values = dashnd.getValue(); NavDir = values[0]; if(help) cout << "Input Nav Directory: " << NavDir << endl; } if(dashn.getCount()) { values = dashn.getValue(); NavFiles = values; if(help) { cout << "Input Nav files :"; for(i=0; i<NavFiles.size(); i++) cout << " " << NavFiles[i]; cout << endl; } } if(dashat.getCount()) { values = dashat.getValue(); if(help) cout << "Input name of AT file: " << values[0] << endl; ATFileName = values[0]; } if(dashout.getCount()) { values = dashout.getValue(); if(help) cout << "Output biases file name: " << values[0] << endl; BiasFileName = values[0]; } if(dasheb.getCount()) { values = dasheb.getValue(); BegTime.setToString(values[0], "%Y,%m,%d,%H,%M,%S"); if(help) cout << "Input BeginTime " << BegTime << endl; } if(dashee.getCount()) { values = dashee.getValue(); EndTime.setToString(values[0], "%Y,%m,%d,%H,%M,%S"); if(help) cout << "Input EndTime " << EndTime << endl; } if(dashgb.getCount()) { values = dashgb.getValue(); BegTime.setToString(values[0], "%F,%g"); if(help) cout << "Input BeginGPSTime " << BegTime << endl; } if(dashge.getCount()) { values = dashge.getValue(); EndTime.setToString(values[0], "%F,%g"); if(help) cout << "Input EndGPSTime " << EndTime << endl; } // processing if(dashde.getCount()) { DoEstimation = false; if(help) cout << "Turn OFF estimation of biases and model" << endl; } if(dashwo.getCount()) { SkipPreproc = true; if(help) cout << "Read the existing AT file (skip preprocessing)" << endl; } if(dashsb.getCount()) { ComputeSatBiases = false; if(help) cout << "Compute Rx biases only, not Rx+Sat biases" << endl; } if(dashmod.getCount()) { values = dashmod.getValue(); Model = values[0]; if(help) cout << "Model input is " << Model << endl; if(Model != string("linear") && Model != string("quadratic") && Model != string("cubic")) { cout << "Warning: --Model is invalid -- linear will be used\n"; } } if(dashMinPoints.getCount()) { values = dashMinPoints.getValue(); MinPoints = asInt(values[0]); if(help) cout << "Minimum points per satellite = " << MinPoints << endl; } if(dashMinTimeSpan.getCount()) { values = dashMinTimeSpan.getValue(); MinTimeSpan = asDouble(values[0]); if(help) cout << "Minimum time span = " << MinTimeSpan << " minutes" << endl; } if(dashMinElevation.getCount()) { values = dashMinElevation.getValue(); MinElevation = asDouble(values[0]); //if(MinElevation <= 0.0 || MinElevation >= 90.0) { //} if(help) cout << "Minimum elevation = " << MinElevation << "degrees " << endl; } if(dashMinLatitude.getCount()) { values = dashMinLatitude.getValue(); MinLatitude = asDouble(values[0]); //if(MinLatitude <= -90.0 || MinLatitude >= 90.0) { //} if(help) cout << "Minimum latitude = " << MinLatitude << " degrees" << endl; } if(dashMaxLatitude.getCount()) { values = dashMaxLatitude.getValue(); MaxLatitude = asDouble(values[0]); //if(MaxLatitude <= -90.0 || MaxLatitude >= 90.0) { //} if(help) cout << "Maximum latitude = " << MaxLatitude << " degrees" << endl; } if(dashMinLongitude.getCount()) { values = dashMinLongitude.getValue(); MinLongitude = asDouble(values[0]); while(MinLongitude < 0.0) MinLongitude+=360.0; if(help) cout << "Minimum longitude = " << MinLongitude << " degrees" << endl; } if(dashMaxLongitude.getCount()) { values = dashMaxLongitude.getValue(); MaxLongitude = asDouble(values[0]); while(MaxLongitude < 0.0) MaxLongitude+=360.0; if(help) cout << "Maximum longitude = " << MaxLongitude << " degrees" << endl; } if(dashTimeSector.getCount()) { values = dashTimeSector.getValue(); TimeSector = lowerCase(values[0]); if(help) cout << "Time sector = " << TimeSector << endl; // TD check that it is valid } if(dashTermOffset.getCount()) { values = dashTermOffset.getValue(); TermOffset = asDouble(values[0]); if(help) cout << "Terminal offset = " << TermOffset << " minutes" << endl; } if(dashIonoHt.getCount()) { values = dashIonoHt.getValue(); IonoHt = asDouble(values[0]); if(help) cout << "Ionosphere height = " << IonoHt << " km" << endl; } if(dashXsat.getCount()) { values = dashXsat.getValue(); for(i=0; i<values.size(); i++) { sat.fromString(values[i]); if(help) cout << "Input: exclude satellite " << sat << endl; ExSV.push_back(sat); } } if(dashh.getCount()) oflog << "Option h appears " << dashh.getCount() << " times\n"; if(dashv.getCount()) { verbose = true; if(help) cout << "Option v appears " << dashv.getCount() << " times\n"; } if(dashd.getCount()) { debug = true; if(help) cout << "Option d appears " << dashd.getCount() << " times\n"; } if(Rest.getCount() && help) { cout << "Remaining options:" << endl; values = Rest.getValue(); for (i=0; i<values.size(); i++) cout << values[i] << endl; } if(verbose && help) { cout << "\nTokens on command line (" << Args.size() << ") are:" << endl; for(j=0; j<Args.size(); j++) cout << Args[j] << endl; cout << endl; } if(help) cout << "Configuration summarized in log file\n"; // print configuration if(verbose || help || debug) { oflog << "Input configuration for IonoBias:\n"; if(!InputPath.empty()) oflog << " Path for input files is " << InputPath << endl; oflog << " Input Rinex obs file names are:\n"; for(i=0; i<Filenames.size(); i++) oflog << " " << Filenames[i] << endl; if(!NavDir.empty()) oflog << " Path for input nav files is " << NavDir << endl; if(NavFiles.size() > 0) { oflog << " Input Rinex nav file names are:\n"; for(i=0; i<NavFiles.size(); i++) oflog << " " << NavFiles[i] << endl; } //oflog << " Input data interval is: " << fixed << setprecision(2) //<< DataInterval << endl; if(!ATFileName.empty()) oflog << " AT file name is " << ATFileName << endl; if(BegTime > DayTime::BEGINNING_OF_TIME) oflog << " Begin time is " << BegTime.printf("%Y/%m/%d_%H:%M:%6.3f=%F/%10.3g") << endl; if(EndTime < DayTime::END_OF_TIME) oflog << " End time is " << EndTime.printf("%Y/%m/%d_%H:%M:%6.3f=%F/%10.3g") << endl; oflog << " Processing:\n"; oflog << " Use a " << Model << " ionospheric model" << endl; oflog << " Minimum points per satellite = " << MinPoints << endl; oflog << " Minimum time span = " << MinTimeSpan << " minutes" << endl; oflog << " Minimum elevation = " << MinElevation << " degrees" << endl; oflog << " Minimum latitude = " << MinLatitude << " degrees" << endl; oflog << " Maximum latitude = " << MaxLatitude << " degrees" << endl; oflog << " Minimum longitude = " << MinLongitude << " degrees" << endl; oflog << " Maximum longitude = " << MaxLongitude << " degrees" << endl; oflog << " Time sector = " << TimeSector << endl; oflog << " Terminal offset = " << TermOffset << " minutes" << endl; oflog << " Ionosphere height = " << IonoHt << " km" << endl; if(ExSV.size() > 0) { oflog << " Exclude these satellites:"; for(i=0; i<ExSV.size(); i++) oflog << " " << ExSV[i]; oflog << endl; } oflog << " Compute " << (ComputeSatBiases ? "Sat+":"") << "Rx biases" << endl; if(BiasFileName.length() > 0) oflog << " Output biases to file " << BiasFileName << endl; else oflog << " Do not output biases to a file" << endl; oflog << " Do" << (DoEstimation?"":" not do") << " the estimation problem" << endl; oflog << " " << (SkipPreproc?"Skip":"Do not skip") << " the preprocessing" << endl; if(help) oflog << " Help (-h) is set\n"; if(debug) oflog << " Debug (-d) is set\n"; oflog << "End of input configuration for IonoBias" << endl; } if(!DoEstimation && SkipPreproc) { cout << "ERROR: Estimation is turned off and so is preprocessing!\n"; cout << "ERROR: Abort: nothing to do.\n"; return -1; } if(help) return 1; return 0;}catch(Exception& e) { GPSTK_RETHROW(e); }catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }}//------------------------------------------------------------------------------------// Pull out --debug --verbose -f<f> and --file <f> and -l<f> --log <f> options.void PreProcessArgs(const char *arg, vector<string>& Args) throw(Exception){try { static bool found_cfg_file=false; static bool found_log_file=false; if(found_cfg_file || (arg[0]=='-' && arg[1]=='f')) { string filename(arg); if(!found_cfg_file) filename.erase(0,2); else found_cfg_file = false; if(debug) cout << "Found a file of options: " << filename << endl; ifstream infile(filename.c_str()); if(!infile) { cout << "Error: could not open options file " << filename << endl; return; } bool again_cfg_file=false; bool again_log_file=false; char c; string buffer,word; while(1) { getline(infile,buffer); stripTrailing(buffer,'\r'); // process the buffer before checking eof or bad b/c there can be // a line at EOF that has no CRLF... while(!buffer.empty()) { word = firstWord(buffer); if(again_cfg_file) { word = "-f" + word; again_cfg_file = false; PreProcessArgs(word.c_str(),Args); } else if(again_log_file) { word = "-l" + word; again_log_file = false; PreProcessArgs(word.c_str(),Args); } else if(word[0] == '#') { // skip to end of line buffer.clear(); } else if(word == "--file" || word == "-f") again_cfg_file = true; else if(word == "--log" || word == "-l") again_log_file = true; else if(word[0] == '"') { word = stripFirstWord(buffer,'"'); buffer = "dummy " + buffer; // to be stripped later PreProcessArgs(word.c_str(),Args); } else PreProcessArgs(word.c_str(),Args); word = stripFirstWord(buffer); // now remove it from buffer } if(infile.eof() || !infile.good()) break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -