Go to the documentation of this file.
104 int ProcessUserInput(
int argc,
char **argv);
109 string BuildCommandLine(
void);
115 int ExtraProcessing(
string& errors,
string& extras);
120 int OpenLogFile(
void);
124 if(pTrop)
delete pTrop;
125 if(oflog.is_open()) oflog.close();
130 void SetDefaults(
void) noexcept;
188 tropstr = string(
"Global,20,1013,50");
196 refPosstr = string(
"-740376.5046,-5457019.3545,3207315.7299");
207 int main(
int argc,
char **argv)
212 clock_t totaltime = clock();
224 + GD.
Version +
printTime(wallclkbeg,
", Run %04Y/%02m/%02d at %02H:%02M:%02S");
231 for(
bool go=
true; go; go=
false) {
251 msg = GD.
PrgmName + string(
" is terminating with code ")
257 else if(iret == -3) {
LOG(
INFO) <<
"The cmdline definition is invalid"; }
258 else if(iret == 2) { ; }
259 else if(iret == 3) {
LOG(
INFO) <<
"The user requested input validation."; }
260 else if(iret == 4) {
LOG(
INFO) <<
"The input is invalid."; }
261 else if(iret == 5) {
LOG(
INFO) <<
"The log file could not be opened."; }
263 LOG(
INFO) <<
"temp - Some other return code... " << iret;
270 totaltime = clock()-totaltime;
272 oss << GD.
PrgmName <<
" CPU timing: " << fixed << setprecision(3)
273 << double(totaltime)/double(CLOCKS_PER_SEC)
274 <<
" seconds. (Wall Clock Timing: " << (wallclkend - wallclkbeg) <<
" sec)";
276 cout << oss.str() << endl;
279 if(iret == 0)
return 0;
else return -1;
282 cerr << prgmname <<
" caught Exception:\n" << e.
what() << endl;
286 cerr <<
"Unknown error in " << prgmname <<
". Abort." << endl;
296 string PrgmDesc, cmdlineUsage, cmdlineErrors, cmdlineExtras;
297 vector<string> cmdlineUnrec;
301 opts.DefineUsageString(
PrgmName +
" [options]");
302 PrgmDesc = BuildCommandLine();
306 int iret = opts.ProcessCommandLine(argc, argv, PrgmDesc,
307 cmdlineUsage, cmdlineErrors, cmdlineUnrec);
310 if(iret == -2)
return iret;
311 if(iret == -3)
return iret;
314 if(opts.hasHelp() || trophelp) {
317 LOG(
INFO) <<
"\n Valid trop model names (cf. gnsstk/core/lib/GNSSCore):\n"
318 <<
" GCAT - GPS Code Analysis Tool" << endl
319 <<
" GG - Goad and Goodman (1974)" << endl
320 <<
" GGHeight - Goad and Goodman with height" << endl
321 <<
" Global - the Global (GMF) model" << endl
322 <<
" MOPS - RTCA Minimum Operational Performance Standards" << endl
323 <<
" NB - New Brunswick" << endl
324 <<
" Neill - Neill (Neill 1996)" << endl
325 <<
" Saas - Saastamoinen" << endl
326 <<
" Simple - a simple Black model" << endl
327 <<
" Zero - all zeros";
333 iret = ExtraProcessing(cmdlineErrors, cmdlineExtras);
334 if(iret)
return iret;
337 if(cmdlineUnrec.size() > 0) {
338 oss <<
"Warning - unrecognized arguments:";
339 for(
size_t i=0; i<cmdlineUnrec.size(); i++)
340 oss <<
" >" << cmdlineUnrec[i] <<
"<";
345 if(!cmdlineErrors.empty()) {
348 LOG(
ERROR) <<
"Errors found on command line:\n " << cmdlineErrors
349 <<
"\nEnd of command line errors.";
355 iret = OpenLogFile();
356 if(iret < 0)
return iret;
361 oss <<
"------ Summary of " <<
PrgmName <<
" command line configuration ------";
362 opts.DumpConfiguration(oss);
363 if(!cmdlineExtras.empty()) oss <<
"\n# Extra Processing\n" << cmdlineExtras;
364 oss <<
"------ End configuration summary ------";
380 string(
" Program ") +
PrgmName + string(
" defines a trop model and prints "
381 "a table of values for all elevations.\n"
382 "\n Input is on the command line, or of the same format in a file "
383 "(see --file below);\n lines in that file which begin with '#' are ignored. "
384 "Accepted options are \n shown below, followed by a description, with default "
385 "value, if any, in ().");
389 opts.noArgsRequired();
393 opts.Add(
'f',
"file",
"name",
true,
false, &dummy,
"\n# File I/O:",
394 "Name of file containing more options");
395 opts.Add(0,
"log",
"name",
false,
false, &logfile,
"",
396 "Name of output log file");
397 opts.Add(0,
"logpath",
"path",
false,
false, &logpath,
"",
398 "Path for output log file");
400 opts.Add(
't',
"trop",
"m[,T,P,H]",
false,
false, &tropstr,
"\n# Configuration",
401 "Tropospheric model and optional weather T(C),P(mb),RH(%)");
402 opts.Add(0,
"refPos",
"X,Y,Z",
false,
false, &refPosstr,
"",
403 "Receiver position (ECEF XYZ)");
404 opts.Add(0,
"doy",
"d",
false,
false, &doy,
"",
405 "Day of year = time of model");
408 opts.Add(0,
"elevmin",
"deg",
false,
false, &elevmin,
"\n# Output",
409 "Minimum elevation angle (degrees)");
410 opts.Add(0,
"elevmax",
"deg",
false,
false, &elevmax,
"",
411 "Maximum elevation angle (degrees)");
412 opts.Add(0,
"delev",
"deg",
false,
false, &delev,
"",
413 "Step in degrees of elevation for the output table");
415 opts.Add(0,
"trophelp",
"",
false,
false, &trophelp,
"\n# Help",
416 "Print a list of available trop model names and quit");
430 vector<string> fields;
431 ostringstream oss, ossx;
435 if(fields.size() != 1 && fields.size() != 4) {
436 oss <<
"Error - invalid field in --Trop input: " << tropstr << endl;
437 inputIsValid =
false;
440 tropName = fields[0];
441 if(fields.size() == 4) {
450 else if(tropName ==
string(
"Zero")) pTrop =
new ZeroTropModel();
451 else if(tropName ==
string(
"Saas")) pTrop =
new SaasTropModel();
452 else if(tropName ==
string(
"NB")) pTrop =
new NBTropModel();
453 else if(tropName ==
string(
"GG")) pTrop =
new GGTropModel();
455 else if(tropName ==
string(
"Neill")) pTrop =
new NeillTropModel();
457 else if(tropName ==
string(
"GCAT")) pTrop =
new GCATTropModel();
458 else if(tropName ==
string(
"MOPS")) pTrop =
new MOPSTropModel();
460 ossx <<
" Warning - unknown trop model: " << tropName
461 <<
"; use Global" << endl;
462 tropName = string(
"Global");
469 pTrop->setWeather(Temp,Press,Humid);
470 ossx <<
" Trop model " << pTrop->name() <<
" weather: "
471 << Temp <<
"degC, " << Press <<
"mbar, " << Humid <<
"%RH" << endl;
476 if(!refPosstr.empty()) {
478 if(fields.size() != 3) {
479 oss <<
" Error - invalid field in --refPos input: " << refPosstr << endl;
493 if(refPos.getCoordinateSystem() != Position::Unknown) {
494 pTrop->setReceiverHeight(refPos.getHeight());
495 pTrop->setReceiverLatitude(refPos.getGeodeticLatitude());
496 pTrop->setReceiverLongitude(refPos.getLongitude());
497 ossx <<
" Trop model Rx at lat " << refPos.getGeodeticLatitude()
498 <<
", long " << refPos.getLongitude()
499 <<
", ht " << refPos.getHeight();
504 oss <<
" Error - definition of reference position failed." << endl;
505 inputIsValid =
false;
510 oss <<
" Error - invalid position in --refPos : " << refPosstr << endl;
511 inputIsValid =
false;
516 ossx <<
" Error - no reference position given" << endl;
517 inputIsValid =
false;
521 pTrop->setDayOfYear(doy);
522 ossx <<
" Trop model on day of year " << doy << endl;
550 return (inputIsValid ? 0 : 4);
560 if(!logfile.empty()) {
561 oflog.open(logfile.c_str(),ios_base::out);
563 cerr <<
"Failed to open log file " << logfile << endl;
566 LOG(
INFO) <<
"Output directed to log file " << logfile;
571 ConfigureLOG::ReportLevels() =
false;
572 ConfigureLOG::ReportTimeTags() =
false;
599 << fixed << setprecision(4)
603 LOG(
INFO) <<
"drytotal = drymap*(dry zenith delay), wettotal = wetmap*(wet zenith delay)";
606 <<
" " << setw(5) <<
"elev"
607 <<
" " << setw(11) <<
"drymap"
609 <<
" " << setw(8) <<
"drytotal"
610 <<
" " << setw(8) <<
"wetmap"
612 <<
" " << setw(8) <<
"wettotal"
613 <<
" " << setw(8) <<
"total(m)";
618 <<
" " << setw(5) << elev << setprecision(4)
std::string & replaceAll(std::string &s, const std::string &oldString, const std::string &newString)
virtual double correction(double elevation) const
string logfile
name of output log file
static GlobalData & Instance()
string tropstr
string for cmdline trop model weather (T,P,RH)
virtual double dry_zenith_delay() const =0
string dummy
dummy string used for –file option
std::string what() const
Dump to a string.
string refPosstr
string for cmdline ref pos
virtual std::string name()
Return the name of the model.
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
string BuildCommandLine(void)
static const string PrgmName
program name
string logpath
path of output log file
int ExtraProcessing(string &errors, string &extras)
CommandLine opts
command line options and syntax page
std::vector< std::string > split(const std::string &str, const char delimiter=' ')
std::string & stripTrailing(std::string &s, const std::string &aString, std::string::size_type num=std::string::npos)
int main(int argc, char **argv)
Position refPos
reference position
ofstream oflog
output log file stream
bool trophelp
if true, print syntax and list of trop models
static const string Version
version string
TropModel * pTrop
tropospheric delay model (cf. *TropModel)
int doy
only time input to TropModel is DOY
~GlobalData()
destructor, clean up
double elevmax
upper limit on elevation (degrees)
virtual double wet_zenith_delay() const =0
double asDouble(const std::string &s)
double elevmin
lower limit on elevation (degrees)
#define GNSSTK_RETHROW(exc)
GlobalData() noexcept
Default and only constructor, sets defaults.
virtual double dry_mapping_function(double elevation) const =0
int ProcessUserInput(int argc, char **argv)
bool verbose
flag handled by CommandLine
bool inputIsValid
true finds no problem
void SetDefaults(void) noexcept
Define defaults for all command line input and global data.
#define LOG(level)
define the macro that is used to write to the log stream
std::string printTime(const CommonTime &t, const std::string &fmt)
double delev
step in elevation (degrees)
virtual double wet_mapping_function(double elevation) const =0
string tropName
string for cmdline trop model
string Title
ID line printed to screen/log: name, ver, run.
A simple Black model of the troposphere. temp is in Kelvin.
int debug
int handled by CommandLine
The 'zero' trop model, meaning it always returns zero.
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:42