test_tides.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
41 
42 // system includes
43 #include <string>
44 #include <vector>
45 #include <iostream>
46 #include <iomanip>
47 #include <fstream>
48 // gnsstk
49 #include "Exception.hpp"
50 #include "EphTime.hpp"
51 #include "Position.hpp"
52 // geomatics
53 #include "CommandLine.hpp"
54 #include "logstream.hpp"
55 #include "singleton.hpp"
56 #include "expandtilde.hpp"
57 #include "SolarPosition.hpp"
58 #include "SolarSystem.hpp"
59 #include "SunEarthSatGeometry.hpp"
60 #include "OceanLoadTides.hpp"
61 #include "AtmLoadTides.hpp"
62 #include "logstream.hpp"
63 
64 using namespace std;
65 using namespace gnsstk;
66 using namespace StringUtils;
67 
68 
69 
70 static const string tidesVersion("4.0 12/3/19");
71 
72 
73 
74 // data input from command line
75 class InputConfig : public Singleton<InputConfig>
76 {
77 public:
78  // input data
79  bool doSimple,doOcean,doSolid,doPole,doAtm;
80  string logfile, SSEfile, earthfile, oceanfile, atmfile;
81  string fmtGPS,fmtCAL,fmt;
82  ofstream oflog;
83  EphTime beg, end;
84  int begmjd,endmjd;
85  bool help,verbose;
86  int prec, debug, iersyear; // debug output - prints all the data
87  double dt;
88  string refPosstr;
89  vector<string> oceannames,atmnames;
90  Position posset,posotl,posatm;
94 
95  // for CommandLine::ProcessCommandLine()
96  string cmdlineUsage, cmdlineErrors, cmdlineDump;
97  vector<string> cmdlineUnrecog;
98 
99  // ctor with defaults
100  InputConfig() noexcept
101  {
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");
105  prec = 5;
106  help = verbose = false;
107  debug = -1;
108  begmjd = 55007.0;
109  endmjd = 55008.0;
110  dt = 900.0; // 15 minutes
111  refPosstr = string("-740289.9049,-5457071.7352,3207245.5544 #ARL.2012.0000");
112  iersyear = 2010;
113  // add options to make it look like three programs
114  doPole = doSolid = doOcean = doAtm = false;
115  // make default NOT to use SSE and earth
116  doSimple = true;
117  //SSEfile = string("/home/btolman/.grits/SolarSystem1960to2020.405.bin");
118  //iersyear = 2010; // or 2003
119  //SSEfile = string("/home/btolman/.grits/SolarSystem1960to2020.405.bin");
120  //earthfile = string("/home/btolman/.grits/finals2000A.data");
121  //oceanfile = string("/home/btolman/.grits/ocean.blq");
122  }
123 
124 }; // end class InputConfig
125 
126 
127 
128 // prototypes
132 int GetCommandLine(int argc, char **argv);
133 
134 
135 
136 int main(int argc, char **argv)
137 {
138  try
139  {
141  int i, iret;
142 
143  // Title and description
144  string Title =
145  "tides, a program to compute solid Earth, ocean loading and pole"
146  " tides, Ver " + tidesVersion;
147  LOG(INFO) << Title;
148 
149  // TEMP, for debugging CommandLine;
150  //LOGlevel = ConfigureLOG::Level("DEBUG");
151 
152  iret = GetCommandLine(argc, argv);
153  LOG(DEBUG) << "GetCommandLine returned " << iret;
154  //LOG(INFO) << "LOG level is " << LOGlevel;
155 
156  // return with help or errors - print to the screen - LOG is cout here
157  if (iret)
158  {
159  if (iret == 1)
160  {
161  // help, else -1 == error
162  if (!C.cmdlineUsage.empty())
163  {
164  LOG(INFO) << C.cmdlineUsage;
165  }
166  if (!C.cmdlineDump.empty())
167  {
168  LOG(INFO) << endl << C.cmdlineDump;
169  }
170  }
171  else
172  LOG(ERROR) << C.cmdlineErrors;
173  return iret;
174  }
175 
176  // open output file
177  if (!C.logfile.empty())
178  {
179  C.oflog.open(C.logfile.c_str(),ios_base::out);
180  if (!C.oflog.is_open())
181  {
182  LOG(ERROR) << "Failed to open log file " << C.logfile;
183  return -1;
184  }
185  else
186  {
187  C.oflog.exceptions(ios::failbit);
188  LOG(INFO) << "Output directed to file " << C.logfile;
189  pLOGstrm = &C.oflog; // ConfigureLOG::Stream() = &C.oflog;
190  ConfigureLOG::ReportLevels() = false;
191  ConfigureLOG::ReportTimeTags() = false;
192  // debug and verbose handled earlier in GetCommandLine
193  LOG(INFO) << Title;
194  }
195  }
196 
198  //if (pLOGstrm == &cout) C.screen = false;
199 
200  // dump configuration
201  LOG(VERBOSE) << endl << C.cmdlineDump;
202 
203 
204  // initialize
205  bool isValid(true);
206 
207  if (!C.SSEfile.empty())
208  {
209  C.doSimple = false;
210 
211  // initialize solar system
212  if (C.iersyear == 1996)
213  {
214  C.SolSys.setConvention(IERSConvention::IERS1996);
215  }
216  if (C.iersyear == 2003)
217  {
218  C.SolSys.setConvention(IERSConvention::IERS2003);
219  }
220  if (C.iersyear == 2010)
221  {
222  C.SolSys.setConvention(IERSConvention::IERS2010);
223  }
224 
225  // read solar system ephemeris file
228  LOG(INFO) << "Solar System Ephemeris is DE"
229  << C.SolSys.EphNumber() << "; timespan "
230  << C.SolSys.startTime() << " to " << C.SolSys.endTime()
231  << " with " << C.SolSys.getConvention();
232 
233  // read EarthOP file and fill store
235  C.SolSys.addFile(C.earthfile);
236 
237  // trim the EOP list, as we might be using
238  // e.g. finals2000A.data (huge); trim generously so
239  // ephemeris limits the data, not EOP
240  if (C.beg.dMJD()-10 > C.SolSys.getFirstTimeMJD() ||
241  C.end.dMJD()+10 < C.SolSys.getLastTimeMJD())
242  {
243  //LOG(VERBOSE) << "Trim EOP store based on input time limits.";
244  C.SolSys.edit(C.beg.lMJD()-10, C.end.lMJD()+10);
245  }
246 
247  // dump the EOP summary
248  if (C.verbose)
249  {
250  C.SolSys.dump(C.debug > -1 ? 1 : 0, LOGstrm);
251  }
252  }
253  else
254  {
255  LOG(INFO) << "Solar System Ephemeris is simple Solar Position";
256  }
257 
258  // doSimple and doPole inconsistent
259  if (C.doSimple && C.doPole)
260  {
261  LOG(ERROR) << "Error - pole option requires SSEfile and earthfile;"
262  << " abort.";
263  isValid = false;
264  }
265 
266  // fill ocean store
267  if (C.doOcean && (C.oceanfile.empty() || C.oceannames.size()==0))
268  {
269  // no ocean file and doOcean inconsistent
270  LOG(ERROR) << "Error - ocean option requires oceanfile and oceansite;"
271  << " abort.";
272  isValid = false;
273  }
274  else if (C.doOcean)
275  {
276  vector<string> sites(C.oceannames);
277  // add the ocean file(s) and name(s) to the store
278  try
279  {
281  }
282  catch(Exception& e)
283  {
284  LOG(ERROR) << "Error - failed to open ocean loading file: "
285  << C.oceanfile << " :\n" << e.what();
286  isValid = false;
287  }
288  catch(exception& e)
289  {
290  LOG(ERROR) << "Error - failed to open ocean loading file: "
291  << C.oceanfile << " :\n" << e.what();
292  isValid = false;
293  }
294 
295  // get the site
296  for (i=0; i<C.oceannames.size(); i++)
297  {
298  if (C.oceannames[i].empty())
299  {
300  isValid = false;
301  }
302  else
303  {
304  try
305  {
307  if (pos[0] == 0.0 && pos[1] == 0.0)
308  {
309  LOG(ERROR) << "Error - Failed to find ocean site name "
310  << C.oceannames[i];
311  isValid = false;
312  }
313  else
314  {
315  LOG(VERBOSE) << "Found ocean loading site "
316  << C.oceannames[i] << " at position "
317  << pos[0] << "N, " << pos[1] << "E";
318  }
319 
320  C.posotl.setGeodetic(pos[0],pos[1],0.0);
321 
322  }
323  catch(Exception& e)
324  {
325  LOG(ERROR) << "Error - failed to get ocean loading site: "
326  << C.oceannames[i] << " from ocean loading files"
327  << " :\n"<< e.what();
328  isValid = false;
329  }
330  catch(exception& e)
331  {
332  LOG(ERROR) << "Error - failed to get ocean loading site: "
333  << C.oceannames[i]
334  << " from ocean loading files\n" << e.what();
335  isValid = false;
336  }
337  }
338  }
339  }
340 
341  // fill atmospheric loading store
342  if (C.doAtm && (C.atmfile.empty() || C.atmnames.size()==0))
343  {
344  // no atm file and doAtm inconsistent
345  LOG(ERROR) << "Error - atm option requires atmfile and atmsite;"
346  << " abort.";
347  isValid = false;
348  }
349  else if (C.doAtm)
350  {
351  vector<string> sites(C.atmnames);
352  // add the atm file(s) and name(s) to the store
353  try
354  {
355  C.atmStore.initializeSites(sites,C.atmfile);
356  }
357  catch(Exception& e)
358  {
359  LOG(ERROR) << "Error - failed to open atm loading file: "
360  << C.atmfile << " :\n" << e.what();
361  isValid = false;
362  }
363  catch(exception& e)
364  {
365  LOG(ERROR) << "Error - failed to open atm loading file: "
366  << C.atmfile << " :\n" << e.what();
367  isValid = false;
368  }
369 
370  // get the site
371  for (i=0; i<C.atmnames.size(); i++)
372  {
373  if (C.atmnames[i].empty())
374  {
375  isValid = false;
376  }
377  else
378  {
379  try
380  {
382  if (pos[0] == 0.0 && pos[1] == 0.0)
383  {
384  LOG(ERROR) << "Error - Failed to find atm site name "
385  << C.atmnames[i];
386  isValid = false;
387  }
388  else LOG(VERBOSE) << "Found atm loading site "
389  << C.atmnames[i]
390  << " at position " << pos[0] << "N, "
391  << pos[1] << "E";
392 
393  C.posatm.setGeodetic(pos[0],pos[1],0.0);
394 
395  }
396  catch(Exception& e)
397  {
398  LOG(ERROR) << "Error - failed to get atm loading site: "
399  << C.atmnames[i] << " from atm loading files"
400  << " :\n"<< e.what();
401  isValid = false;
402  }
403  catch(exception& e)
404  {
405  LOG(ERROR) << "Error - failed to get atm loading site: "
406  << C.atmnames[i] << " from atm loading files\n"
407  << e.what();
408  isValid = false;
409  }
410  }
411  }
412  }
413 
414  // get rotation matrix XYZ->NEU for pos
415  Matrix<double> Rotate,RotOTL,RotATM;
416  Rotate = northEastUp(C.posset);
417  RotOTL = northEastUp(C.posotl);
418  RotATM = northEastUp(C.posatm);
419 
420  if (!isValid)
421  {
422  if (C.oflog.is_open())
423  {
424  C.oflog.close();
425  }
426  return iret;
427  }
428 
429  // do it
430  if (C.doSolid)
431  {
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"
434  << " SET_U_cm";
435  }
436  if (C.doOcean)
437  {
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"
440  << " OLT_U_cm site";
441  }
442  if (C.doPole)
443  {
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"
446  << " POT_U_cm";
447  }
448  if (C.doAtm)
449  {
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"
452  << " ATL_U_cm site";
453  }
454 
455  // loop over times
456  int w(C.prec+3);
457  double arad;
458  double mjd;
459  EphTime ttag;
460  Vector<double> XYZ(3),NEU(3);
461  Triple dXYZ,dNEU;
462  for (mjd=static_cast<double>(C.begmjd);
463  mjd < static_cast<double>(C.endmjd); mjd += C.dt/SEC_PER_DAY)
464  {
465  ttag.setMJD(mjd);
466  ttag.setTimeSystem(TimeSystem::UTC);
467  if (C.doSolid)
468  {
469  if (C.doSimple)
470  {
471  Position Sun(solarPosition(ttag, arad));
472  Position Moon(lunarPosition(ttag, arad));
473  dXYZ = computeSolidEarthTides(C.posset, ttag, Sun, Moon);
474  }
475  else
476  {
477  dXYZ = C.SolSys.computeSolidEarthTides(C.posset, ttag);
478  }
479  for (i=0; i<3; i++)
480  {
481  XYZ(i) = dXYZ[i];
482  }
483  NEU = Rotate * XYZ;
484 
485  LOG(INFO) << "SET " << ttag.asMJDString()
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.;
493  }
494 
495  if (C.doOcean)
496  {
497  for (size_t j=0; j<C.oceannames.size(); j++)
498  {
499  dNEU = C.oceanStore.computeDisplacement(C.oceannames[j], ttag);
500  for (i=0; i<3; i++)
501  {
502  NEU(i) = dNEU[i];
503  }
504  XYZ = transpose(RotOTL) * NEU;
505 
506  LOG(INFO) << "OLT " << ttag.asMJDString()
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.
514  << " " << C.oceannames[j];
515  }
516  }
517 
518  if (C.doPole)
519  {
520  dXYZ = C.SolSys.computePolarTides(C.posset, ttag);
521  for (i=0; i<3; i++)
522  {
523  XYZ(i) = dXYZ[i];
524  }
525  NEU = Rotate * XYZ;
526 
527  LOG(INFO) << "POT " << ttag.asMJDString()
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.;
535  }
536 
537  if (C.doAtm)
538  {
539  for (size_t j=0; j<C.atmnames.size(); j++)
540  {
541  dNEU = C.atmStore.computeDisplacement(C.atmnames[j], ttag);
542  for (i=0; i<3; i++)
543  {
544  NEU(i) = dNEU[i];
545  }
546  XYZ = transpose(RotATM) * NEU;
547 
548  LOG(INFO) << "ATL " << ttag.asMJDString()
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.
556  << " " << C.atmnames[j];
557  }
558  }
559 
560  } // end loop over times
561 
562  if (C.oflog.is_open())
563  {
564  C.oflog.close();
565  }
566 
567  return iret;
568  }
569  catch(gnsstk::Exception& e)
570  {
571  cerr << "Exception: " << e;
572  }
573  catch (...)
574  {
575  cerr << "Unknown exception. Abort." << endl;
576  }
577  return 1;
578 } // end main()
579 
580 
581 
582 int GetCommandLine(int argc, char **argv)
583 {
584  try
585  {
587  int i;
588 
589  // ---------------------------------------------------------------
590  // create list of command line options, and fill it
591  CommandLine opts;
592 
593  // build the command line == syntax page
594  opts.DefineUsageString("tides [options]");
595  string PrgmDesc =
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"
606  ;
607 
608  // opts.Add(char, opt, arg, repeat?, required?, &target, pre-descript, descript.);
609  bool req(false); // obs is not req'd b/c filenames can appear alone (Unrecog)
610  // optional args
611  string dummy(""); // dummy for --file
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"
637  " ephem]");
638  opts.Add(0, "earthfile", "fn", false, req, &C.earthfile, "",
639  "Earth orientation parameter file name [if & only if"
640  " --SSEfile]");
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");
659 
660  // options to ignore
661  //opts.Add_ignore_off("--Scan");
662  // deprecated args
663  //opts.Add_deprecated("--dummy","--thisisatest");
664  // undocumented args
665  //opts.Add(0, "progress", "", false, req, &C.progress, "", "", false);
666 
667  // ---------------------------------------------------------------
668  // declare it and parse it; write all errors to string C.cmdlineErrors
669  int iret = opts.ProcessCommandLine(argc, argv, PrgmDesc, C.cmdlineUsage,
671  if (iret == -2)
672  {
673  return -1; // bad alloc
674  }
675  if (iret == -3)
676  {
677  return -1; // invalid command line
678  }
679 
680  // ---------------------------------------------------------------
681  // do extra parsing - append errors to C.cmdlineErrors
682  string msg;
683  vector<string> fields;
684  ostringstream oss;
685 
686  // unrecognized arguments are an error
687  if (C.cmdlineUnrecog.size() > 0)
688  {
689  oss << " Error - unrecognized arguments:\n";
690  for (i=0; i<C.cmdlineUnrecog.size(); i++)
691  {
692  oss << C.cmdlineUnrecog[i] << "\n";
693  }
694  oss << " End of unrecognized arguments\n";
695  }
696 
697  // start and stop times
698  C.beg.setMJD(C.begmjd);
699  C.end.setMJD(C.endmjd);
700 
701  // reference position
702  if (!C.refPosstr.empty())
703  {
704  fields = StringUtils::split(C.refPosstr,',');
705  if (fields.size() != 3)
706  {
707  oss << "Error - invalid field in --refPos input: " << C.refPosstr
708  << endl;
709  }
710  else
711  {
712  try
713  {
714  C.posset.setECEF(StringUtils::asDouble(fields[0]),
715  StringUtils::asDouble(fields[1]),
716  StringUtils::asDouble(fields[2]));
717  }
718  catch(Exception& e)
719  {
720  oss << "Error - invalid position in --refPos input: "
721  << C.refPosstr << endl;
722  }
723  }
724  }
725 
726  if (C.iersyear != 1996 && C.iersyear != 2003 && C.iersyear != 2010)
727  {
728  oss << "Error - invalid field in --IERS input: " << C.iersyear
729  << " - use 1996, 2003 or 2010." << endl;
730  }
731 
732  // append errors onto cmdlineErrors
733  C.cmdlineErrors += oss.str();
735 
736  // ---------------------------------------------------------------
737  // dump a summary of command line configuration
738  if (C.verbose)
739  {
740  oss.str(""); // clear it
741  oss << "------ Summary of tides command line configuration --------"
742  << endl;
743  opts.DumpConfiguration(oss);
744  oss << endl << " Begin time is " << C.beg.asMJDString() << endl;
745  oss << " End time is " << C.end.asMJDString() << endl;
746  oss << " Position is "
747  << C.posset.printf("ECEF %.4x %.4y %.4z meters") << endl;
748  oss << "------ End configuration summary --------" << endl;
749  C.cmdlineDump = oss.str();
750  stripTrailing(C.cmdlineDump,'\n');
751  }
752 
753  // ---------------------------------------------------------------
754  // return
755  if (!C.cmdlineErrors.empty())
756  {
757  return -1; // errors
758  }
759  if (C.help)
760  {
761  return 1; // help
762  }
763 
764  return 0; // ok
765  }
766  catch(Exception& e)
767  {
768  GNSSTK_RETHROW(e);
769  }
770  catch(exception& e)
771  {
772  Exception E("std except: "+string(e.what())); GNSSTK_THROW(E);
773  }
774  catch(...)
775  {
776  Exception e("Unknown exception"); GNSSTK_THROW(e);
777  }
778  return -1;
779 }
780 
InputConfig::atmnames
vector< string > atmnames
Definition: test_tides.cpp:89
expandtilde.hpp
main
int main(int argc, char **argv)
Definition: test_tides.cpp:136
gnsstk::SolarSystem::endTime
CommonTime endTime() const
Definition: SolarSystem.hpp:239
AtmLoadTides.hpp
gnsstk::AtmLoadTides
Definition: AtmLoadTides.hpp:70
gnsstk::Singleton< InputConfig >::Instance
static InputConfig & Instance()
Definition: singleton.hpp:48
example6.mjd
mjd
Definition: example6.py:102
gnsstk::lunarPosition
Position lunarPosition(const CommonTime &t, double &AR)
Definition: SolarPosition.cpp:249
CommandLine.hpp
pLOGstrm
#define pLOGstrm
Definition: logstream.hpp:321
InputConfig::SolSys
SolarSystem SolSys
Definition: test_tides.cpp:91
InputConfig::InputConfig
InputConfig() noexcept
Definition: test_tides.cpp:100
InputConfig::dt
double dt
Definition: test_tides.cpp:87
gnsstk::northEastUp
Matrix< double > northEastUp(Position &pos, bool geocentric)
Same as upEastNorth(), but with rows re-ordered.
Definition: SunEarthSatGeometry.cpp:57
EphTime.hpp
InputConfig::cmdlineUsage
string cmdlineUsage
Definition: test_tides.cpp:96
gnsstk::Singleton
Definition: singleton.hpp:46
gnsstk::SolarSystem::startTime
CommonTime startTime() const
Definition: SolarSystem.hpp:228
gnsstk::SEC_PER_DAY
const long SEC_PER_DAY
Seconds per day.
Definition: TimeConstants.hpp:63
SunEarthSatGeometry.hpp
gnsstk::EphTime::setTimeSystem
void setTimeSystem(TimeSystem sys)
Definition: EphTime.hpp:141
SolarPosition.hpp
gnsstk::EOPStore::edit
void edit(int mjdmin, int mjdmax)
Definition: EOPStore.cpp:214
gnsstk::Exception::what
std::string what() const
Dump to a string.
Definition: Exception.cpp:193
InputConfig::SSEfile
string SSEfile
Definition: test_tides.cpp:80
gnsstk::SolarSystem::getConvention
IERSConvention getConvention() const
get the IERS Convention
Definition: SolarSystem.hpp:187
logstream.hpp
InputConfig::beg
EphTime beg
Definition: test_tides.cpp:83
Position.hpp
InputConfig
Definition: test_tides.cpp:75
InputConfig::debug
int debug
Definition: test_tides.cpp:86
gnsstk::CommandLine::ProcessCommandLine
int ProcessCommandLine(int argc, char **argv, std::string PrgmDesc, std::string &Usage, std::string &Errors, std::vector< std::string > &Unrec)
Definition: CommandLine.cpp:80
InputConfig::fmt
string fmt
Definition: test_tides.cpp:81
InputConfig::endmjd
int endmjd
Definition: test_tides.cpp:84
InputConfig::end
EphTime end
Definition: test_tides.cpp:83
LOGstrm
#define LOGstrm
Definition: logstream.hpp:322
gnsstk::Triple
Definition: Triple.hpp:68
gnsstk::CommandLine::DefineUsageString
void DefineUsageString(std::string str) noexcept
Define the text after 'Usage: '; default is '<prgm> [options] ...'.
Definition: CommandLine.hpp:296
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::expand_filename
void expand_filename(string &filename)
Definition: expandtilde.cpp:51
InputConfig::oceannames
vector< string > oceannames
Definition: test_tides.cpp:89
gnsstk::Position::printf
std::string printf(const char *fmt) const
Definition: Position.cpp:982
gnsstk::StringUtils::split
std::vector< std::string > split(const std::string &str, const char delimiter=' ')
Definition: StringUtils.hpp:2275
gnsstk::SolarSystemEphemeris::EphNumber
int EphNumber() const
Definition: SolarSystemEphemeris.hpp:303
gnsstk::CommandLine::Add
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
Definition: CommandLine.hpp:197
GetCommandLine
int GetCommandLine(int argc, char **argv)
Definition: test_tides.cpp:582
InputConfig::doSimple
bool doSimple
Definition: test_tides.cpp:79
gnsstk::SolarSystem::initializeWithBinaryFile
int initializeWithBinaryFile(std::string filename)
Definition: SolarSystem.hpp:197
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::StringUtils::stripTrailing
std::string & stripTrailing(std::string &s, const std::string &aString, std::string::size_type num=std::string::npos)
Definition: StringUtils.hpp:1453
gnsstk::Position::setECEF
Position & setECEF(const double X, const double Y, const double Z) noexcept
Definition: Position.cpp:601
InputConfig::oflog
ofstream oflog
Definition: test_tides.cpp:82
Title
string Title
Definition: testSSEph.cpp:86
gnsstk::EphTime::lMJD
long lMJD() const
Definition: EphTime.hpp:165
gnsstk::SolarSystem::computeSolidEarthTides
Triple computeSolidEarthTides(const Position site, const EphTime &tt)
Definition: SolarSystem.hpp:436
gnsstk::AtmLoadTides::computeDisplacement
Triple computeDisplacement(std::string site, EphTime t, double UT1mUTC=0)
Definition: AtmLoadTides.cpp:265
gnsstk::EOPStore::dump
void dump(short detail=0, std::ostream &s=std::cout) const
Definition: EOPStore.cpp:271
gnsstk::OceanLoadTides::computeDisplacement
Triple computeDisplacement(std::string site, EphTime t)
Definition: OceanLoadTides.cpp:416
InputConfig::refPosstr
string refPosstr
Definition: test_tides.cpp:88
gnsstk::transpose
SparseMatrix< T > transpose(const SparseMatrix< T > &M)
transpose
Definition: SparseMatrix.hpp:829
gnsstk::Matrix< double >
InputConfig::posotl
Position posotl
Definition: test_tides.cpp:90
debug
#define debug
Definition: Rinex3ClockHeader.cpp:51
InputConfig::logfile
string logfile
Definition: test_tides.cpp:80
InputConfig::prec
int prec
Definition: test_tides.cpp:86
gnsstk::ERROR
@ ERROR
Definition: logstream.hpp:57
gnsstk::EphTime::asMJDString
std::string asMJDString(const int prec=3) const
Definition: EphTime.hpp:270
gnsstk::EphTime
Definition: EphTime.hpp:67
gnsstk::AtmLoadTides::initializeSites
int initializeSites(std::vector< std::string > &sites, std::string filename)
Definition: AtmLoadTides.cpp:75
InputConfig::cmdlineUnrecog
vector< string > cmdlineUnrecog
Definition: test_tides.cpp:97
gnsstk::EOPStore::addFile
void addFile(const std::string &filename)
Definition: EOPStore.cpp:98
gnsstk::VERBOSE
@ VERBOSE
Definition: logstream.hpp:57
gnsstk::solarPosition
Position solarPosition(const CommonTime &t, double &AR)
Definition: SolarPosition.cpp:96
gnsstk::StringUtils::asDouble
double asDouble(const std::string &s)
Definition: StringUtils.hpp:705
gnsstk::EOPStore::getLastTimeMJD
int getLastTimeMJD()
Return last time (MJD) in the store.
Definition: EOPStore.hpp:150
gnsstk::EOPStore::getFirstTimeMJD
int getFirstTimeMJD()
Return first time (MJD) in the store.
Definition: EOPStore.hpp:147
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
InputConfig::doPole
bool doPole
Definition: test_tides.cpp:79
InputConfig::earthfile
string earthfile
Definition: test_tides.cpp:80
example4.pos
pos
Definition: example4.py:125
InputConfig::cmdlineDump
string cmdlineDump
Definition: test_tides.cpp:96
gnsstk::Vector< double >
OceanLoadTides.hpp
InputConfig::oceanStore
OceanLoadTides oceanStore
Definition: test_tides.cpp:92
InputConfig::doOcean
bool doOcean
Definition: test_tides.cpp:79
InputConfig::atmStore
AtmLoadTides atmStore
Definition: test_tides.cpp:93
InputConfig::oceanfile
string oceanfile
Definition: test_tides.cpp:80
InputConfig::iersyear
int iersyear
Definition: test_tides.cpp:86
gnsstk::OceanLoadTides
Definition: OceanLoadTides.hpp:82
LOG
#define LOG(level)
define the macro that is used to write to the log stream
Definition: logstream.hpp:315
SolarSystem.hpp
gnsstk::CommandLine::DumpConfiguration
void DumpConfiguration(std::ostream &os, std::string tag=std::string())
Definition: CommandLine.cpp:180
tidesVersion
static const string tidesVersion("4.0 12/3/19")
Exception.hpp
std
Definition: Angle.hpp:142
InputConfig::fmtGPS
string fmtGPS
Definition: test_tides.cpp:81
gnsstk::SolarSystem::computePolarTides
Triple computePolarTides(const Position site, const EphTime &tt)
Definition: SolarSystem.hpp:464
gnsstk::INFO
@ INFO
Definition: logstream.hpp:57
gnsstk::SolarSystem::setConvention
void setConvention(const IERSConvention &conv)
Definition: SolarSystem.hpp:180
gnsstk::OceanLoadTides::initializeSites
int initializeSites(std::vector< std::string > &sites, std::string filename)
Definition: OceanLoadTides.cpp:86
InputConfig::help
bool help
Definition: test_tides.cpp:85
gnsstk::Position
Definition: Position.hpp:136
gnsstk::Position::setGeodetic
Position & setGeodetic(const double lat, const double lon, const double ht, const EllipsoidModel *ell=nullptr)
Definition: Position.cpp:495
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::DEBUG
@ DEBUG
Definition: logstream.hpp:57
gnsstk::AtmLoadTides::getPosition
Triple getPosition(std::string site)
Definition: AtmLoadTides.hpp:119
gnsstk::CommandLine
list of Options
Definition: CommandLine.hpp:63
singleton.hpp
gnsstk::OceanLoadTides::getPosition
Triple getPosition(std::string site)
Definition: OceanLoadTides.hpp:153
gnsstk::computeSolidEarthTides
Triple computeSolidEarthTides(const Position &site, const EphTime &ttag, const Position &Sun, const Position &Moon, double EMRAT, double SERAT, const IERSConvention &iers)
Definition: SolidEarthTides.cpp:80
gnsstk::EphTime::dMJD
double dMJD() const
Definition: EphTime.hpp:171
InputConfig::doAtm
bool doAtm
Definition: test_tides.cpp:79
InputConfig::atmfile
string atmfile
Definition: test_tides.cpp:80
gnsstk::EphTime::setMJD
void setMJD(long double mjd)
Definition: EphTime.hpp:155
gnsstk::SolarSystem
Definition: SolarSystem.hpp:162
InputConfig::posset
Position posset
Definition: test_tides.cpp:90
InputConfig::cmdlineErrors
string cmdlineErrors
Definition: test_tides.cpp:96
InputConfig::verbose
bool verbose
Definition: test_tides.cpp:85
InputConfig::posatm
Position posatm
Definition: test_tides.cpp:90
InputConfig::doSolid
bool doSolid
Definition: test_tides.cpp:79
InputConfig::begmjd
int begmjd
Definition: test_tides.cpp:84
docstring_generator.help
help
Definition: docstring_generator.py:98


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41