Go to the documentation of this file.
66 using namespace StringUtils;
79 bool doSimple,doOcean,
doSolid,doPole,doAtm;
80 string logfile,
SSEfile, earthfile, oceanfile, atmfile;
102 fmtGPS = string(
"%F,%g");
103 fmtCAL = string(
"%Y,%m,%d,%02H,%M,%f");
104 fmt = string(
"%4F %10.3g %4Y %2m %2d %2H %2M %6.3f");
106 help = verbose =
false;
111 refPosstr = string(
"-740289.9049,-5457071.7352,3207245.5544 #ARL.2012.0000");
114 doPole = doSolid = doOcean = doAtm =
false;
136 int main(
int argc,
char **argv)
145 "tides, a program to compute solid Earth, ocean loading and pole"
153 LOG(
DEBUG) <<
"GetCommandLine returned " << iret;
180 if (!C.
oflog.is_open())
187 C.
oflog.exceptions(ios::failbit);
190 ConfigureLOG::ReportLevels() =
false;
191 ConfigureLOG::ReportTimeTags() =
false;
228 LOG(
INFO) <<
"Solar System Ephemeris is DE"
255 LOG(
INFO) <<
"Solar System Ephemeris is simple Solar Position";
261 LOG(
ERROR) <<
"Error - pole option requires SSEfile and earthfile;"
270 LOG(
ERROR) <<
"Error - ocean option requires oceanfile and oceansite;"
284 LOG(
ERROR) <<
"Error - failed to open ocean loading file: "
290 LOG(
ERROR) <<
"Error - failed to open ocean loading file: "
307 if (
pos[0] == 0.0 &&
pos[1] == 0.0)
309 LOG(
ERROR) <<
"Error - Failed to find ocean site name "
317 <<
pos[0] <<
"N, " <<
pos[1] <<
"E";
325 LOG(
ERROR) <<
"Error - failed to get ocean loading site: "
326 << C.
oceannames[i] <<
" from ocean loading files"
327 <<
" :\n"<< e.
what();
332 LOG(
ERROR) <<
"Error - failed to get ocean loading site: "
334 <<
" from ocean loading files\n" << e.what();
345 LOG(
ERROR) <<
"Error - atm option requires atmfile and atmsite;"
359 LOG(
ERROR) <<
"Error - failed to open atm loading file: "
365 LOG(
ERROR) <<
"Error - failed to open atm loading file: "
366 << C.
atmfile <<
" :\n" << e.what();
382 if (
pos[0] == 0.0 &&
pos[1] == 0.0)
384 LOG(
ERROR) <<
"Error - Failed to find atm site name "
388 else LOG(
VERBOSE) <<
"Found atm loading site "
390 <<
" at position " <<
pos[0] <<
"N, "
398 LOG(
ERROR) <<
"Error - failed to get atm loading site: "
399 << C.
atmnames[i] <<
" from atm loading files"
400 <<
" :\n"<< e.
what();
405 LOG(
ERROR) <<
"Error - failed to get atm loading site: "
406 << C.
atmnames[i] <<
" from atm loading files\n"
422 if (C.
oflog.is_open())
432 LOG(
INFO) <<
"SET MJD HH:MM:SS.sss "
433 <<
"SET_X_cm SET_Y_cm SET_Z_cm SET_N_cm SET_E_cm"
438 LOG(
INFO) <<
"OLT MJD HH:MM:SS.sss "
439 <<
"OLT_X_cm OLT_Y_cm OLT_Z_cm OLT_N_cm OLT_E_cm"
444 LOG(
INFO) <<
"POT MJD HH:MM:SS.sss "
445 <<
"POT_X_cm POT_Y_cm POT_Z_cm POT_N_cm POT_E_cm"
450 LOG(
INFO) <<
"ATL MJD HH:MM:SS.sss "
451 <<
"ATL_X_cm ATL_Y_cm ATL_Z_cm ATL_N_cm ATL_E_cm"
486 << fixed << setprecision(C.
prec)
487 <<
" " << setw(w) << XYZ(0)*100.
488 <<
" " << setw(w) << XYZ(1)*100.
489 <<
" " << setw(w) << XYZ(2)*100.
490 <<
" " << setw(w) << NEU(0)*100.
491 <<
" " << setw(w) << NEU(1)*100.
492 <<
" " << setw(w) << NEU(2)*100.;
507 << fixed << setprecision(C.
prec)
508 <<
" " << setw(w) << XYZ(0)*100.
509 <<
" " << setw(w) << XYZ(1)*100.
510 <<
" " << setw(w) << XYZ(2)*100.
511 <<
" " << setw(w) << NEU(0)*100.
512 <<
" " << setw(w) << NEU(1)*100.
513 <<
" " << setw(w) << NEU(2)*100.
528 << fixed << setprecision(C.
prec)
529 <<
" " << setw(w) << XYZ(0)*100.
530 <<
" " << setw(w) << XYZ(1)*100.
531 <<
" " << setw(w) << XYZ(2)*100.
532 <<
" " << setw(w) << NEU(0)*100.
533 <<
" " << setw(w) << NEU(1)*100.
534 <<
" " << setw(w) << NEU(2)*100.;
539 for (
size_t j=0; j<C.
atmnames.size(); j++)
549 << fixed << setprecision(C.
prec)
550 <<
" " << setw(w) << XYZ(0)*100.
551 <<
" " << setw(w) << XYZ(1)*100.
552 <<
" " << setw(w) << XYZ(2)*100.
553 <<
" " << setw(w) << NEU(0)*100.
554 <<
" " << setw(w) << NEU(1)*100.
555 <<
" " << setw(w) << NEU(2)*100.
562 if (C.
oflog.is_open())
571 cerr <<
"Exception: " << e;
575 cerr <<
"Unknown exception. Abort." << endl;
596 "Prgm tides computes tides (solid earth, ocean loading, pole) for a given\n"
597 " time (UTC) and site, and dumps them to the screen.\n"
598 " NB One or more of options (solid ocean pole atm) must be provided.\n"
599 " NB ocean option requires oceanfile and oceansite.\n"
600 " NB atm option requires atmfile and atmsite.\n"
601 " NB pole requires SSEfile and earthfile.\n"
602 " NB SSEfile and earthfile are optional (unless pole); they are more accurate.\n"
603 " Input is on the command line, or of the same format in a file (see --file);\n"
604 " lines in that file which begin with '#' are ignored.\n"
605 " Options are shown below, with a description and default value, if any, in ().\n"
612 opts.
Add(0,
"solid",
"",
false, req, &C.
doSolid,
613 "# Computation: Require one or more of the following:",
614 "Output Solid Earth tide");
615 opts.
Add(0,
"ocean",
"",
false, req, &C.
doOcean,
"",
616 "Output Ocean loading [requires oceanfile and oceansite]");
617 opts.
Add(0,
"pole",
"",
false, req, &C.
doPole,
"",
618 "Output Polar tide [requires SSEfile and earthfile]");
619 opts.
Add(0,
"atm",
"",
false, req, &C.
doAtm,
"",
620 "Output Atmospheric loading [requires atmfile and atmsite]");
621 opts.
Add(
'f',
"file",
"name",
true, req, &dummy,
"# File I/O:",
622 "Name of file containing more options [#-EOL = comment]");
623 opts.
Add(
'o',
"log",
"fn",
false, req, &C.
logfile,
"",
624 "Output the summary to a file named <fn>");
625 opts.
Add(0,
"start",
"mjd",
false, req, &C.
begmjd,
"",
626 "Start processing the input data at this MJD");
627 opts.
Add(0,
"stop",
"mjd",
false, req, &C.
endmjd,
"",
628 "Stop processing the input data at this MJD");
629 opts.
Add(0,
"dt",
"sec",
false, req, &C.
dt,
"",
630 "Timestep in seconds");
631 opts.
Add(0,
"refPos",
"X,Y,Z",
false, req, &C.
refPosstr,
"",
632 "Position for SET (ECEF XYZ)");
633 opts.
Add(0,
"IERS",
"year",
false, req, &C.
iersyear,
"",
634 "Year of IERS convention: 1996, 2003 or 2010");
635 opts.
Add(0,
"SSEfile",
"fn",
false, req, &C.
SSEfile,
"",
636 "Solar System ephemeris binary file name [else use simple"
638 opts.
Add(0,
"earthfile",
"fn",
false, req, &C.
earthfile,
"",
639 "Earth orientation parameter file name [if & only if"
641 opts.
Add(0,
"oceanfile",
"fn",
true, req, &C.
oceanfile,
"",
642 "Ocean loading file name");
643 opts.
Add(0,
"oceansite",
"name",
true, req, &C.
oceannames,
"",
644 "Site name in ocean loading file");
645 opts.
Add(0,
"atmfile",
"fn",
true, req, &C.
atmfile,
"",
646 "Ocean loading file name");
647 opts.
Add(0,
"atmsite",
"name",
true, req, &C.
atmnames,
"",
648 "Site name in atmospheric loading file");
649 opts.
Add(0,
"timefmt",
"f",
false, req, &C.
fmt,
"# Output",
650 "Output format for time tag");
651 opts.
Add(
'p',
"prec",
"n",
false, req, &C.
prec,
"",
652 "Output precision for offsets");
653 opts.
Add(
'd',
"debug",
"",
false, req, &C.
debug,
"",
654 "Print debug output at level 0 [debug<n> for level n=1-7]");
655 opts.
Add(0,
"verbose",
"",
false, req, &C.
verbose,
"",
656 "print extended output information");
657 opts.
Add(
'h',
"help",
"",
false, req, &C.
help,
"",
658 "Print this syntax page and quit");
683 vector<string> fields;
689 oss <<
" Error - unrecognized arguments:\n";
694 oss <<
" End of unrecognized arguments\n";
705 if (fields.size() != 3)
707 oss <<
"Error - invalid field in --refPos input: " << C.
refPosstr
720 oss <<
"Error - invalid position in --refPos input: "
728 oss <<
"Error - invalid field in --IERS input: " << C.
iersyear
729 <<
" - use 1996, 2003 or 2010." << endl;
741 oss <<
"------ Summary of tides command line configuration --------"
746 oss <<
" Position is "
747 << C.
posset.
printf(
"ECEF %.4x %.4y %.4z meters") << endl;
748 oss <<
"------ End configuration summary --------" << endl;
int main(int argc, char **argv)
CommonTime endTime() const
static InputConfig & Instance()
Position lunarPosition(const CommonTime &t, double &AR)
Matrix< double > northEastUp(Position &pos, bool geocentric)
Same as upEastNorth(), but with rows re-ordered.
CommonTime startTime() const
const long SEC_PER_DAY
Seconds per day.
void setTimeSystem(TimeSystem sys)
void edit(int mjdmin, int mjdmax)
std::string what() const
Dump to a string.
IERSConvention getConvention() const
get the IERS Convention
int ProcessCommandLine(int argc, char **argv, std::string PrgmDesc, std::string &Usage, std::string &Errors, std::vector< std::string > &Unrec)
void DefineUsageString(std::string str) noexcept
Define the text after 'Usage: '; default is '<prgm> [options] ...'.
void expand_filename(string &filename)
std::string printf(const char *fmt) const
std::vector< std::string > split(const std::string &str, const char delimiter=' ')
void Add(char s, std::string l, std::string a, bool rep, bool req, bool *ptr, std::string predes, std::string des, bool doc=true)
add a boolean option
int GetCommandLine(int argc, char **argv)
int initializeWithBinaryFile(std::string filename)
std::string & stripTrailing(std::string &s, const std::string &aString, std::string::size_type num=std::string::npos)
Position & setECEF(const double X, const double Y, const double Z) noexcept
Triple computeSolidEarthTides(const Position site, const EphTime &tt)
Triple computeDisplacement(std::string site, EphTime t, double UT1mUTC=0)
void dump(short detail=0, std::ostream &s=std::cout) const
Triple computeDisplacement(std::string site, EphTime t)
SparseMatrix< T > transpose(const SparseMatrix< T > &M)
transpose
std::string asMJDString(const int prec=3) const
int initializeSites(std::vector< std::string > &sites, std::string filename)
void addFile(const std::string &filename)
Position solarPosition(const CommonTime &t, double &AR)
double asDouble(const std::string &s)
int getLastTimeMJD()
Return last time (MJD) in the store.
int getFirstTimeMJD()
Return first time (MJD) in the store.
#define GNSSTK_RETHROW(exc)
#define LOG(level)
define the macro that is used to write to the log stream
void DumpConfiguration(std::ostream &os, std::string tag=std::string())
static const string tidesVersion("4.0 12/3/19")
Triple computePolarTides(const Position site, const EphTime &tt)
void setConvention(const IERSConvention &conv)
int initializeSites(std::vector< std::string > &sites, std::string filename)
Position & setGeodetic(const double lat, const double lon, const double ht, const EllipsoidModel *ell=nullptr)
#define GNSSTK_THROW(exc)
Triple getPosition(std::string site)
Triple getPosition(std::string site)
Triple computeSolidEarthTides(const Position &site, const EphTime &ttag, const Position &Sun, const Position &Moon, double EMRAT, double SERAT, const IERSConvention &iers)
void setMJD(long double mjd)
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41