Rinex3ObsFileLoader.hpp
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 
42 #ifndef GNSSTK_RINEX3_FILE_LOADER_INCLUDE
43 #define GNSSTK_RINEX3_FILE_LOADER_INCLUDE
44 
45 //------------------------------------------------------------------------------------
46 // system includes
47 #include <string>
48 #include <vector>
49 
50 // GNSSTk
51 #include "CommonTime.hpp"
52 #include "Exception.hpp"
53 #include "MostCommonValue.hpp"
54 #include "Rinex3ObsData.hpp"
55 #include "Rinex3ObsHeader.hpp"
56 #include "stl_helpers.hpp" // vectorindex
57 
58 // gnsstk-geomatics
59 #include "SatPass.hpp"
60 
61 namespace gnsstk
62 {
63 
64  //--------------------------------------------------------------------------------
86  {
87  private:
88  static const double dttol;
89 
90  // input
91  std::vector<std::string> filenames;
93  bool saveData;
94  std::string timefmt;
95  // editing
96  double dtdec;
98 
104  std::vector<std::string> inputWantedObsTypes;
105 
107  std::vector<std::string> wantedObsTypes;
108 
113  std::map<RinexSatID, std::vector<int>> SatObsCountMap;
114 
116  std::vector<int> countWantedObsTypes;
117 
118  // used internally
121  double rawdt;
122  std::vector<SatID> exSats;
123 
128  std::map<SatID, std::string> mapSatStr;
129 
130  // output
131  int nepochs;
132  double nominalDT;
134  std::vector<std::string> obstypes;
135  std::vector<Rinex3ObsHeader> headers;
136 
138  std::vector<Rinex3ObsData> datastore;
139 
141  void init()
142  {
143  saveData = false;
144  nepochsToRead = -1;
145  timefmt = std::string("%04Y/%02m/%02d %02H:%02M:%02S");
146  reset();
147  }
148 
149  public:
150  // constructors
151  // ------------------------------------------------------------
154 
159  Rinex3ObsFileLoader(std::string in_filename)
160  {
161  init();
162  filenames.clear();
163  headers.clear();
164  filenames.push_back(in_filename);
165  }
166 
171  Rinex3ObsFileLoader(std::vector<std::string> in_filenames)
172  {
173  init();
174  files(in_filenames);
175  }
176 
177  // resets ------------------------------------------------------------
179  inline void reset()
180  {
181  nepochs = 0;
182  // nominalDT: nominal timestep (rawdt or dtdec)
183  dtdec = rawdt = nominalDT = -1.0;
187 
193 
194  obstypes.clear();
195  mcv.reset();
196  datastore.clear();
197  exSats.clear();
198  headers.clear();
199  inputWantedObsTypes.clear();
200  wantedObsTypes.clear();
201  SatObsCountMap.clear();
202  }
203 
208  inline void reset(std::vector<std::string> in_filenames)
209  {
210  reset();
211  files(in_filenames);
212  }
213 
214  // configure: before loadFiles() -------------------------------------
215  // configure: files, epochs, save?, time limits, etc -----------------
216 
221  inline void files(std::vector<std::string> in_filenames)
222  {
223  filenames.clear();
224  filenames = in_filenames;
225  }
226 
234  inline bool loadObsID(std::string srot)
235  {
236  if (srot.size() != 4)
237  {
238  return false;
239  }
240 
241  // NB isValidRinexObsID() does not handle system = "*"
242  bool is3(srot.substr(0, 1) == "*");
243 
244  // valid Rinex obs ID
245  if (isValidRinexObsID(is3 ? srot.substr(1, 3) : srot))
246  {
247  if (vectorindex(inputWantedObsTypes, srot) == -1)
248  {
249  inputWantedObsTypes.push_back(srot);
250  return true;
251  }
252  }
253  return false;
254  }
255 
260  inline void nEpochsToRead(int n) { nepochsToRead = n; }
261 
266  inline void saveTheData(bool b) { saveData = b; }
267 
272  inline bool dataSaved() { return saveData; }
273 
278  inline void setStartTime(const CommonTime& tt) { startTime = tt; }
279 
284  inline void setStopTime(const CommonTime& tt) { stopTime = tt; }
285 
291  inline void setDecimation(double dt) { dtdec = dt; }
292 
298  inline void setTimeFormat(std::string fmt) { timefmt = fmt; }
299 
305  inline void excludeSat(SatID sat) { exSats.push_back(sat); }
306 
311  inline void excludeSats(std::vector<SatID> sats)
312  {
313  for (int i = 0; i < sats.size(); i++)
314  excludeSat(sats[i]);
315  }
316 
317  // access results: after loadFiles() ---------------------------------
318 
323  std::string asString();
324 
326  inline CommonTime getDataBeginTime() const { return begDataTime; }
327 
329  inline CommonTime getDataEndTime() const { return endDataTime; }
330 
335  inline std::vector<std::string> getWantedObsTypes() const
336  {
337  return wantedObsTypes;
338  }
339 
345  inline std::map<RinexSatID, std::vector<int>>
347  {
348  return SatObsCountMap;
349  }
355  inline std::vector<int> getTotalObsCounts() const
356  {
357  return countWantedObsTypes;
358  }
359 
365  inline double getDT() { return nominalDT; }
366 
372  inline Rinex3ObsHeader getFullHeader(unsigned int i) const
373  {
374  return headers[i];
375  }
376 
381  inline const int getStoreSize() const { return datastore.size(); }
382 
387  inline const std::vector<Rinex3ObsData>& getStore() const
388  {
389  return datastore;
390  }
391 
392  // Read the files ----------------------------------------------------
393 
400  int loadFiles(std::string& errmsg, std::string& msg);
401 
402  // Utilities ---------------------------------------------------------
403 
421  int
422  WriteSatPassList(const std::map<char, std::vector<std::string>>& obstypes,
423  const std::map<char, std::vector<int>>& indexLoadOT,
424  std::vector<SatPass>& SPList);
425 
430  void dumpSatObsTable(std::ostream& s) const;
431 
436  void dumpStoreEpoch(std::ostream& s,
437  const gnsstk::Rinex3ObsData& rod) const;
438 
443  void dumpStoreData(std::ostream& s) const;
444 
445  }; // end class Rinex3ObsFileLoader
446 
452  void dumpAllRinex3ObsTypes(std::ostream& s);
453 
455 
456 } // end namespace gnsstk
457 
458 #endif // GNSSTK_RINEX3_FILE_LOADER_INCLUDE
gnsstk::Rinex3ObsFileLoader::mapSatStr
std::map< SatID, std::string > mapSatStr
Definition: Rinex3ObsFileLoader.hpp:128
gnsstk::Rinex3ObsFileLoader::setTimeFormat
void setTimeFormat(std::string fmt)
Definition: Rinex3ObsFileLoader.hpp:298
gnsstk::Rinex3ObsFileLoader::getWantedObsTypes
std::vector< std::string > getWantedObsTypes() const
Definition: Rinex3ObsFileLoader.hpp:335
SatPass.hpp
gnsstk::Rinex3ObsFileLoader::startTime
CommonTime startTime
Definition: Rinex3ObsFileLoader.hpp:97
gnsstk::Rinex3ObsFileLoader::datastore
std::vector< Rinex3ObsData > datastore
vector of all input data - filled only if saveData is true.
Definition: Rinex3ObsFileLoader.hpp:138
gnsstk::Rinex3ObsFileLoader::wantedObsTypes
std::vector< std::string > wantedObsTypes
list of wanted RinexObsIDs, without any "*", which appear in header(s)
Definition: Rinex3ObsFileLoader.hpp:107
gnsstk::isValidRinexObsID
bool isValidRinexObsID(const std::string &strID)
Definition: RinexObsID.cpp:223
gnsstk::Rinex3ObsFileLoader::getTotalObsCounts
std::vector< int > getTotalObsCounts() const
Definition: Rinex3ObsFileLoader.hpp:355
gnsstk::Rinex3ObsFileLoader::dtdec
double dtdec
decimate to this time step
Definition: Rinex3ObsFileLoader.hpp:96
gnsstk::Rinex3ObsFileLoader::Rinex3ObsFileLoader
Rinex3ObsFileLoader()
empty constructor
Definition: Rinex3ObsFileLoader.hpp:153
gnsstk::Rinex3ObsFileLoader::saveData
bool saveData
if true save the data (F)
Definition: Rinex3ObsFileLoader.hpp:93
gnsstk::Rinex3ObsHeader
Definition: Rinex3ObsHeader.hpp:155
gnsstk::Rinex3ObsFileLoader
Definition: Rinex3ObsFileLoader.hpp:85
gnsstk::MostCommonValue
Definition: MostCommonValue.hpp:59
stl_helpers.hpp
MostCommonValue.hpp
gnsstk::Rinex3ObsFileLoader::dttol
static const double dttol
tolerance in comparing times
Definition: Rinex3ObsFileLoader.hpp:88
gnsstk::Rinex3ObsFileLoader::init
void init()
initialization used by the constructors
Definition: Rinex3ObsFileLoader.hpp:141
gnsstk::Rinex3ObsFileLoader::getDT
double getDT()
Definition: Rinex3ObsFileLoader.hpp:365
gnsstk::SatID
Definition: SatID.hpp:89
gnsstk::Rinex3ObsFileLoader::dumpStoreEpoch
void dumpStoreEpoch(std::ostream &s, const gnsstk::Rinex3ObsData &rod) const
Definition: Rinex3ObsFileLoader.cpp:716
gnsstk::TimeSystem::Any
@ Any
wildcard; allows comparison with any other type
gnsstk::Rinex3ObsFileLoader::filenames
std::vector< std::string > filenames
input RINEX obs file names
Definition: Rinex3ObsFileLoader.hpp:91
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
gnsstk::CommonTime::BEGINNING_OF_TIME
static const GNSSTK_EXPORT CommonTime BEGINNING_OF_TIME
earliest representable CommonTime
Definition: CommonTime.hpp:102
gnsstk::Rinex3ObsFileLoader::nepochsToRead
int nepochsToRead
number of epochs to read (default:all)
Definition: Rinex3ObsFileLoader.hpp:92
gnsstk::Rinex3ObsFileLoader::excludeSat
void excludeSat(SatID sat)
Definition: Rinex3ObsFileLoader.hpp:305
gnsstk::Rinex3ObsFileLoader::reset
void reset(std::vector< std::string > in_filenames)
Definition: Rinex3ObsFileLoader.hpp:208
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Rinex3ObsFileLoader::dumpStoreData
void dumpStoreData(std::ostream &s) const
Definition: Rinex3ObsFileLoader.cpp:750
gnsstk::CommonTime::END_OF_TIME
static const GNSSTK_EXPORT CommonTime END_OF_TIME
latest representable CommonTime
Definition: CommonTime.hpp:104
gnsstk::Rinex3ObsFileLoader::saveTheData
void saveTheData(bool b)
Definition: Rinex3ObsFileLoader.hpp:266
gnsstk::Rinex3ObsFileLoader::mcv
MostCommonValue mcv
estimator of the raw time interval
Definition: Rinex3ObsFileLoader.hpp:119
gnsstk::Rinex3ObsFileLoader::stopTime
CommonTime stopTime
edit to start and stop times
Definition: Rinex3ObsFileLoader.hpp:97
gnsstk::Rinex3ObsFileLoader::getStore
const std::vector< Rinex3ObsData > & getStore() const
Definition: Rinex3ObsFileLoader.hpp:387
gnsstk::Rinex3ObsFileLoader::getDataBeginTime
CommonTime getDataBeginTime() const
Definition: Rinex3ObsFileLoader.hpp:326
gnsstk::Rinex3ObsFileLoader::endDataTime
CommonTime endDataTime
first and last times of data
Definition: Rinex3ObsFileLoader.hpp:133
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::Rinex3ObsData
Definition: Rinex3ObsData.hpp:75
Rinex3ObsHeader.hpp
gnsstk::Rinex3ObsFileLoader::setStopTime
void setStopTime(const CommonTime &tt)
Definition: Rinex3ObsFileLoader.hpp:284
gnsstk::Rinex3ObsFileLoader::files
void files(std::vector< std::string > in_filenames)
Definition: Rinex3ObsFileLoader.hpp:221
gnsstk::Rinex3ObsFileLoader::reset
void reset()
reset - called before reading another set of files, clears all info
Definition: Rinex3ObsFileLoader.hpp:179
gnsstk::Rinex3ObsFileLoader::prevtime
CommonTime prevtime
used in reading loop for dt
Definition: Rinex3ObsFileLoader.hpp:120
gnsstk::Rinex3ObsFileLoader::countWantedObsTypes
std::vector< int > countWantedObsTypes
total counts per obs for wanted obs types (parallel to wantedObsTypes)
Definition: Rinex3ObsFileLoader.hpp:116
gnsstk::Rinex3ObsFileLoader::exSats
std::vector< SatID > exSats
exclude satellites, incl. (-1,sys)
Definition: Rinex3ObsFileLoader.hpp:122
gnsstk::Rinex3ObsFileLoader::Rinex3ObsFileLoader
Rinex3ObsFileLoader(std::vector< std::string > in_filenames)
Definition: Rinex3ObsFileLoader.hpp:171
Rinex3ObsData.hpp
gnsstk::Rinex3ObsFileLoader::dataSaved
bool dataSaved()
Definition: Rinex3ObsFileLoader.hpp:272
gnsstk::Rinex3ObsFileLoader::begDataTime
CommonTime begDataTime
Definition: Rinex3ObsFileLoader.hpp:133
gnsstk::Rinex3ObsFileLoader::setDecimation
void setDecimation(double dt)
Definition: Rinex3ObsFileLoader.hpp:291
gnsstk::Rinex3ObsFileLoader::excludeSats
void excludeSats(std::vector< SatID > sats)
Definition: Rinex3ObsFileLoader.hpp:311
gnsstk::dumpAllRinex3ObsTypes
void dumpAllRinex3ObsTypes(ostream &os)
Definition: Rinex3ObsFileLoader.cpp:764
gnsstk::Rinex3ObsFileLoader::setStartTime
void setStartTime(const CommonTime &tt)
Definition: Rinex3ObsFileLoader.hpp:278
gnsstk::Rinex3ObsFileLoader::nepochs
int nepochs
number of epochs read
Definition: Rinex3ObsFileLoader.hpp:131
gnsstk::Rinex3ObsFileLoader::SatObsCountMap
std::map< RinexSatID, std::vector< int > > SatObsCountMap
Definition: Rinex3ObsFileLoader.hpp:113
gnsstk::Rinex3ObsFileLoader::obstypes
std::vector< std::string > obstypes
RINEX obs types found in data.
Definition: Rinex3ObsFileLoader.hpp:134
gnsstk::Rinex3ObsFileLoader::rawdt
double rawdt
best est. of time interval, no decimate
Definition: Rinex3ObsFileLoader.hpp:121
gnsstk::Rinex3ObsFileLoader::nominalDT
double nominalDT
nominal timestep (rawdt or dtdec)
Definition: Rinex3ObsFileLoader.hpp:132
Exception.hpp
gnsstk::Rinex3ObsFileLoader::getFullHeader
Rinex3ObsHeader getFullHeader(unsigned int i) const
Definition: Rinex3ObsFileLoader.hpp:372
CommonTime.hpp
gnsstk::Rinex3ObsFileLoader::loadObsID
bool loadObsID(std::string srot)
Definition: Rinex3ObsFileLoader.hpp:234
gnsstk::Rinex3ObsFileLoader::loadFiles
int loadFiles(std::string &errmsg, std::string &msg)
Definition: Rinex3ObsFileLoader.cpp:75
gnsstk::Rinex3ObsFileLoader::headers
std::vector< Rinex3ObsHeader > headers
headers from reading filenames
Definition: Rinex3ObsFileLoader.hpp:135
gnsstk::Rinex3ObsFileLoader::getStoreSize
const int getStoreSize() const
Definition: Rinex3ObsFileLoader.hpp:381
gnsstk::Rinex3ObsFileLoader::dumpSatObsTable
void dumpSatObsTable(std::ostream &s) const
Definition: Rinex3ObsFileLoader.cpp:687
gnsstk::Rinex3ObsFileLoader::asString
std::string asString()
Definition: Rinex3ObsFileLoader.cpp:495
gnsstk::Rinex3ObsFileLoader::nEpochsToRead
void nEpochsToRead(int n)
Definition: Rinex3ObsFileLoader.hpp:260
gnsstk::Rinex3ObsFileLoader::timefmt
std::string timefmt
format for time tags in output
Definition: Rinex3ObsFileLoader.hpp:94
gnsstk::MostCommonValue::reset
void reset(int i=DEFAULT_DIM)
reset
Definition: MostCommonValue.hpp:76
gnsstk::Rinex3ObsFileLoader::inputWantedObsTypes
std::vector< std::string > inputWantedObsTypes
Definition: Rinex3ObsFileLoader.hpp:104
gnsstk::Rinex3ObsFileLoader::WriteSatPassList
int WriteSatPassList(const std::map< char, std::vector< std::string >> &obstypes, const std::map< char, std::vector< int >> &indexLoadOT, std::vector< SatPass > &SPList)
Definition: Rinex3ObsFileLoader.cpp:535
gnsstk::Rinex3ObsFileLoader::getDataEndTime
CommonTime getDataEndTime() const
Definition: Rinex3ObsFileLoader.hpp:329
gnsstk::Rinex3ObsFileLoader::Rinex3ObsFileLoader
Rinex3ObsFileLoader(std::string in_filename)
Definition: Rinex3ObsFileLoader.hpp:159
gnsstk::vectorindex
int vectorindex(const std::vector< T > &vec, const T &value)
Definition: stl_helpers.hpp:123
gnsstk::Rinex3ObsFileLoader::getWantedSatObsCountMap
std::map< RinexSatID, std::vector< int > > getWantedSatObsCountMap() const
Definition: Rinex3ObsFileLoader.hpp:346


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