📄 discfix.cpp
字号:
n = SPIndexList[in]; // current iterator index if(first || SPList[in].time(n) < WriteEpoch) { WriteEpoch = SPList[in].time(n); first = false; } } if(first) break; // quit if reached the target if(WriteEpoch >= targetTime) break; // prepare the RINEX obs data roe.epochFlag = 0; roe.time = WriteEpoch; roe.clockOffset = 0.0; // TD save from input? roe.numSvs = 0; // will be incremented below roe.obs.clear(); // output all data at this WriteEpoch for(in=0; in<SPList.size(); in++) { if(SPList[in].status != 98) continue; sat = SPList[in].getSat(); n = SPIndexList[in]; // current iterator index if(fabs(SPList[in].time(n) - WriteEpoch) < 0.00001) { // get the data for this epoch spd = SPList[in].getData(SPIndexList[in]); str = asString(spd.indicators); // P1P2L1L2*ls AaBbCcDd str = rightJustify(str,8,'0'); if(spd.flag > 0) { // data is good // add sat to RinexObs RinexObsData::RinexObsTypeMap rotm; roe.obs[sat] = rotm; roe.numSvs++; // build the RINEX data object RinexObsData::RinexDatum rd; rd.lli = asInt(asString<char>(str[0])); rd.ssi = asInt(asString<char>(str[1])); rd.data = spd.P1; if(UsingCA) roe.obs[sat][RinexObsHeader::C1] = rd; else roe.obs[sat][RinexObsHeader::P1] = rd; rd.lli = asInt(asString<char>(str[2])); rd.ssi = asInt(asString<char>(str[3])); rd.data = spd.P2; roe.obs[sat][RinexObsHeader::P2] = rd; //rd.lli = asInt(asString<char>(str[4])); // TD ought to set the low bit rd.lli = (spd.flag & SatPass::LL1)!=0 ? 1 : 0; rd.ssi = asInt(asString<char>(str[5])); rd.data = spd.L1; roe.obs[sat][RinexObsHeader::L1] = rd; //rd.lli = asInt(asString<char>(str[6])); rd.lli = (spd.flag & SatPass::LL2)!=0 ? 1 : 0; rd.ssi = asInt(asString<char>(str[7])); rd.data = spd.L2; roe.obs[sat][RinexObsHeader::L2] = rd; config.oflog << "Out " << WriteEpoch.printf(config.format) << " " << roe.time.printf(config.format) << " " << sat << " " << spd.flag << " " << setw(3) << spd.ndt // count << fixed << setprecision(3) << " " << setw(13) << spd.P1 << " " << setw(13) << spd.P2 << " " << setw(13) << spd.L1 << " " << setw(13) << spd.L2 << endl; } // go to next point SPIndexList[in]++; // end of data? if(SPIndexList[in] >= SPList[in].size()) SPList[in].status = 99; // status == 99 means 'written out' } } // actually write to RINEX if(roe.numSvs > 0) { config.SVonly.setfill(' '); // just for the hell of it orfstr << roe; config.SVonly.setfill('0'); } } while(1); // end while loop over all epochs up to targetTime } 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); }}//------------------------------------------------------------------------------------void PrintSPList(ostream& os, string msg, const vector<SatPass>& v, bool printTime){ int i,j,gap; GSatID sat; map<GSatID,int> lastSP; map<GSatID,int>::const_iterator kt; os << "#" << leftJustify(msg,4) << " gap tot sat ok s start time end time dt\n"; for(i=0; i<v.size(); i++) { os << msg; sat = v[i].getSat(); kt = lastSP.find(sat); if(kt == lastSP.end()) gap = 0; else { j = kt->second; gap = int((v[i].getFirstTime() - v[j].getLastTime()) / v[i].getDT() + 0.5); lastSP.erase(sat); } lastSP[sat] = i; os << " " << setw(4) << gap; os << " " << v[i]; // sat,length,ngood,firstTime,lastTime if(printTime) os << " at " << CurrEpoch.printf(config.format);//"%04Y/%02m/%02d %02H:%02M:%6.3f" os << endl; }}//------------------------------------------------------------------------------------#include "CommandOption.hpp"#include "CommandOptionParser.hpp"int GetCommandLine(int argc, char **argv) throw(Exception){ try { bool help=false,DChelp=false,DChelpall=false; int i,j; // defaults config.verbose = false; config.ith = 0.0; config.begTime = DayTime(DayTime::BEGINNING_OF_TIME); config.endTime = DayTime(DayTime::END_OF_TIME); config.MaxGap = 600.0; //config.MinPts = 10; config.LogFile = string("df.log"); config.OutFile = string("df.out"); config.format = string("%4F %10.3g"); config.UseCA = false; // meaning use P1 unless its absent, then C1 // true would mean use C1 only config.dt = -1.0; config.HDPrgm = PrgmName + string(" v.") + PrgmVers.substr(0,4); config.HDRunby = string("ARL:UT/SGL/GPSTk"); config.smoothPR = false; config.smoothPH = false; config.smooth = false; //config.CAOut = false; //config.DopOut = false; for(i=0; i<9; i++) config.ndt[i]=-1; config.Directory = string("."); // ------------------------------------------------- // required options RequiredOption dashi(CommandOption::hasArgument, CommandOption::stdType, 0,"inputfile", " --inputfile <file> Input (RINEX obs) file - more than one may be given"); RequiredOption dashDT(CommandOption::hasArgument, CommandOption::stdType, 0,"dt"," --dt <dt> Time spacing (sec) of the data. " "[NB this defines DT\n in the GDC, hence " + PrgmName + " ignores --DCDT=<dt> ]"); dashDT.setMaxCount(1); // optional options // this only so it will show up in help page... CommandOption dashf(CommandOption::hasArgument, CommandOption::stdType, 'f',""," [-f|--file] <file> file containing more options"); CommandOption dashd(CommandOption::hasArgument, CommandOption::stdType, 0,"inputdir"," --inputdir <dir> Directory of input file(s)"); dashd.setMaxCount(1); // time CommandOption dashbt(CommandOption::hasArgument, CommandOption::stdType, 0,"beginTime", "# Time limits:" " args are of the form GPSweek,sow OR YYYY,MM,DD,HH,Min,Sec\n" " --beginTime <arg> Start time of processing (BOF)"); dashbt.setMaxCount(1); CommandOption dashet(CommandOption::hasArgument, CommandOption::stdType, 0,"endTime", " --endTime <arg> End time of processing (EOF)"); dashet.setMaxCount(1); CommandOption dashith(CommandOption::hasArgument, CommandOption::stdType, 0,"decimate","# Data configuration\n" " --decimate <dt> Decimate data to time interval (sec) dt"); dashith.setMaxCount(1); CommandOptionNoArg dashCA(0,"forceCA", " --forceCA " "Use C/A code range, NOT P code (default: only if P absent)"); dashCA.setMaxCount(1); CommandOption dashGap(CommandOption::hasArgument, CommandOption::stdType, 0,"gap"," --gap <t> Minimum data gap (sec) separating " "satellite passes (" + asString(int(config.MaxGap)) + ")"); dashGap.setMaxCount(1); //CommandOption dashPts(CommandOption::hasArgument, CommandOption::stdType, //0,"Points"," --Points <n> Minimum number of points needed to " //"process a pass"); //dashPts.setMaxCount(1); CommandOption dashSV(CommandOption::hasArgument, CommandOption::stdType, 0,"onlySat"," --onlySat <sat> Process only satellite <sat> " "(a GPS SatID, e.g. G21)"); dashSV.setMaxCount(1); CommandOption dashXsat(CommandOption::hasArgument, CommandOption::stdType, 0,"exSat"," --exSat <sat> Exclude satellite(s) [e.g. --exSat G22]"); CommandOptionNoArg dashSmoothPR(0,"smoothPR", "# Smoothing: [NB smoothed " "pseudorange and debiased phase are not identical.]\n" " --smoothPR Smooth pseudorange and output in place of raw pseudorange"); dashSmoothPR.setMaxCount(1); CommandOptionNoArg dashSmoothPH(0,"smoothPH", " --smoothPH Debias phase and output in place of raw phase"); dashSmoothPH.setMaxCount(1); // last smooth option - tack on a 'vapor-option' CommandOptionNoArg dashSmooth(0,"smooth", " --smooth Same as (--smoothPR AND --smoothPH)\n" "# Discontinuity Corrector (DC) configuration:\n" " --DClabel=value Set Discontinuity Corrector parameter 'label' to 'value'\n" " [e.g. --DCWLSigma=1.5 or --DCDebug:7 " "or --DCMinPts,6]\n" " --DChelp Print a list of GDC parameters and their defaults, then quit" ); dashSmooth.setMaxCount(1); CommandOption dashLog(CommandOption::hasArgument, CommandOption::stdType, 0,"logOut","# Output:\n --logOut <file> Output log file name (" + config.LogFile + ")"); //dashLog.setMaxCount(1); CommandOption dashOut(CommandOption::hasArgument, CommandOption::stdType, 0,"cmdOut"," --cmdOut <file> Output file name (for editing commands) (" + config.OutFile + ")"); dashOut.setMaxCount(1); CommandOption dashFormat(CommandOption::hasArgument, CommandOption::stdType, 0,"format"," --format \"<format>\" Output time format (cf. gpstk::" "DayTime) (" + config.format + ")"); dashFormat.setMaxCount(1); CommandOption dashRfile(CommandOption::hasArgument, CommandOption::stdType, 0,"RinexFile","# RINEX output:\n" " --RinexFile <file> RINEX (obs) file name for output of corrected data"); //dashRfile.setMaxCount(1); CommandOption dashRrun(CommandOption::hasArgument, CommandOption::stdType, 0,"RunBy"," --RunBy <string> RINEX header 'RUN BY' string for output"); dashRrun.setMaxCount(1); CommandOption dashRobs(CommandOption::hasArgument, CommandOption::stdType, 0,"Observer"," --Observer <string> RINEX header 'OBSERVER' string for output"); dashRobs.setMaxCount(1); CommandOption dashRag(CommandOption::hasArgument, CommandOption::stdType, 0,"Agency"," --Agency <string> RINEX header 'AGENCY' string for output"); dashRag.setMaxCount(1); CommandOption dashRmark(CommandOption::hasArgument, CommandOption::stdType, 0,"Marker"," --Marker <string> RINEX header 'MARKER' string for output"); dashRmark.setMaxCount(1); CommandOption dashRnumb(CommandOption::hasArgument, CommandOption::stdType, 0,"Number"," --Number <string> RINEX header 'NUMBER' string for output"); dashRnumb.setMaxCount(1); // TD? pass-through 'other' data found in input RINEX file - requires buffering? //CommandOptionNoArg dashCAOut(0,"CAOut", // " --CAOut Output C/A code in RINEX"); //dashCAOut.setMaxCount(1); //CommandOptionNoArg dashDOut(0,"DOut", // " --DOut Output Doppler in RINEX"); //dashDOut.setMaxCount(1); CommandOptionNoArg dashh('h', "help", "# Help:\n" " [-h|--help] print this syntax page and quit." "\n --DChelp Print a list of GDC parameters and " "their defaults, and quit"); dashh.setMaxCount(1); CommandOptionNoArg dashVerb(0,"verbose", " --verbose print extended output to the log file"); dashVerb.setMaxCount(1); // ... other options CommandOptionRest Rest(""); CommandOptionParser Par("Prgm " + PrgmName + " reads a RINEX observation data file containing GPS dual-frequency\n" " pseudorange and carrier phase measurements, divides the data into 'satellite\n" " passes', and finds and fixes discontinuities in the phases for each pass.\n" " Output is a list of editing commands for use with program RinexEdit.\n" " " + PrgmName + " will (optionally) write the corrected pseudorange and phase data\n" " to a new RINEX observation file. Other options will also smooth the\n" " pseudorange and/or debias the corrected phase.\n" " "+PrgmName+" calls the GPSTk Discontinuity Corrector (GDC vers " + GDConfig.Version() + ").\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")); // strip out the DCcmds vector<string> DCcmds; vector<string>::iterator it=Args.begin(); while(it != Args.end()) { if(it->substr(0,4) == string("--DC")) { if(*it == "--DChelp") DChelp=true; else if(*it == "--DChelpall" || *it == "--DCall") DChelp=DChelpall=true; else DCcmds.push_back(*it); it = Args.erase(it); } else it++; } // pass the rest argc = Args.size()+1; char **CArgs=new char*[argc]; if(!CArgs) { cout << "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]) { cout << "Failed to allocate CArgs[j]\n"; return -1; } strcpy(CArgs[j],Args[j-1].c_str()); } Par.parseOptions(argc, CArgs); delete[] CArgs; // ------------------------------------------------- if(dashh.getCount() > 0) help = true; if(Par.hasErrors()) { if(!help && !DChelp) { cout << "\nErrors found in command line input:\n"; Par.dumpErrors(cout); cout << "...end of Errors. For help run with option --help\n\n"; } help = true; } // ------------------------------------------------- // get values found on command line string msg; vector<string> field; vector<string> values;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -