Rinex3ObsStream_example_2.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 
44 #include "Rinex3ObsBase.hpp"
45 #include "Rinex3ObsData.hpp"
46 #include "Rinex3ObsHeader.hpp"
47 #include "Rinex3ObsStream.hpp"
48 #include "CivilTime.hpp"
49 #include "GNSSconstants.hpp"
50 #include <iostream>
51 
52 
53 using namespace std;
54 using namespace gnsstk;
55 
56 
57  // ISO C++ forbids declaration of `main' with no type
58 int main(int argc, char *argv[])
59 {
60 
61  int myprn;
62 
63  if( argc<2 )
64  {
65  cout << "Required argument is a RINEX obs file." << endl;
66  exit(-1);
67  }
68 
69  cout << "Name your PRN of interest (by number: 1 through 32): ";
70  cin >> myprn;
71 
72  double gamma = (L1_FREQ_GPS / L2_FREQ_GPS)*(L1_FREQ_GPS / L2_FREQ_GPS);
73 
74  try
75  {
76 
77  cout << "Reading " << argv[1] << "." << endl;
78 
79  // Declare RINEX observation file streams and data objects
80  // -------------------------------------------------------
81  Rinex3ObsStream roffs(argv[1]);
82 
83  // It is necessary to set the failbit in order to throw exceptions
84  roffs.exceptions(ios::failbit);
85  Rinex3ObsHeader roh;
86  Rinex3ObsData roe;
87  RinexDatum dataobj;
88 
89  // Read the RINEX header (don't skip this step)
90  // --------------------------------------------
91  roffs >> roh;
92 
93  // Print RINEX header to terminal screen
94  // -------------------------------------
95  roh.dump(cout);
96 
97  // The following lines fetch the corresponding indexes for some
98  // observation types we are interested in
99  int indexP1( roh.getObsIndex( "P1" ) );
100  int indexP2( roh.getObsIndex( "P2" ) );
101 
102  // Loop through epochs and process data for each.
103  // ----------------------------------------------
104  while( roffs >> roe )
105  {
106 
107  // Let's use the CivilTime class to print time
108  CivilTime civtime( roe.time );
109 
110  cout << civtime << " ";
111 
112  // Make a GNSSTK SatID object for your PRN so you can search it
113  // -----------------------------------------------------------
114  SatID prn( myprn, SatelliteSystem::GPS );
115 
116  // Check to see if your PRN is in view at this epoch (ie.
117  // search for the PRN).
118  // -----------------------------------------------------------
119  Rinex3ObsData::DataMap::iterator pointer = roe.obs.find(prn);
120  if( pointer == roe.obs.end() )
121  {
122  cout << "PRN " << myprn << " not in view " << endl;
123  }
124  else
125  {
126  // Get P1, P2 and L1 observations
127  // Here there are three equivalent ways to get the RinexDatum
128  // from the RinexObsData object
129 
130  // The first one is a fast but DANGEROUS method, because there
131  // is a chance of unawarely change the contents of "roe.obs".
132  // -----------------------------------------------------------
133  dataobj = roe.obs[prn][indexP1];
134  double P1 = dataobj.data;
135 
136  // The second method is secure but a little slower.
137  // This should be your preferred method
138  // -----------------------------------------------------------
139  dataobj = roe.getObs(prn, indexP2);
140  double P2 = dataobj.data;
141 
142  // The third method is also secure but it is the slowest.
143  // On the other hand it has the advantage that it doesn't need
144  // a prior call to method 'Rinex3ObsHeader::getObsIndex()'
145  // -----------------------------------------------------------
146  dataobj = roe.getObs(prn, "L1", roh);
147  double L1 = dataobj.data;
148 
149  // Compute multipath
150  // -----------------
151  double mu = P1 -L1*(C_MPS/L1_FREQ_GPS) -2*(P1 -P2)/(1-gamma);
152 
153  // The following line makes sure that you get a proper output
154  // format. The line above with "roh.dump" sets this, but just
155  // in case...
156  cout << fixed << setw(7) << setprecision(3);
157 
158  cout << " PRN " << myprn
159  << " biased multipath " << mu << endl;
160 
161  } // End of 'if( pointer == roe.obs.end() )'
162 
163  } // End of 'while (roffs >> roe)'
164 
165  cout << "Read " << roffs.recordNumber << " epochs. Cheers." << endl;
166 
167  exit(0);
168 
169  } // End of 'try' block
170  catch(FFStreamError& e)
171  {
172  cout << e;
173  exit(1);
174  }
175  catch(Exception& e)
176  {
177  cout << e;
178  exit(1);
179  }
180  catch (...)
181  {
182  cout << "unknown error. I don't feel so well..." << endl;
183  exit(1);
184  }
185 
186  exit(0);
187 
188 } // End of 'main()'
gnsstk::RinexDatum
Storage for single RINEX OBS data measurements.
Definition: RinexDatum.hpp:55
main
int main(int argc, char *argv[])
Definition: Rinex3ObsStream_example_2.cpp:58
L1
gnsstk::Matrix< double > L1
Definition: Matrix_LUDecomp_T.cpp:46
gnsstk::Rinex3ObsHeader
Definition: Rinex3ObsHeader.hpp:155
gnsstk::Rinex3ObsData::obs
DataMap obs
the map of observations
Definition: Rinex3ObsData.hpp:114
gnsstk::L1_FREQ_GPS
const double L1_FREQ_GPS
GPS L1 carrier frequency in Hz.
Definition: DeprecatedConsts.hpp:51
gnsstk::SatID
Definition: SatID.hpp:89
gnsstk::Rinex3ObsHeader::dump
virtual void dump(std::ostream &s) const
Definition: Rinex3ObsHeader.hpp:568
gnsstk::RinexDatum::data
double data
The actual data point.
Definition: RinexDatum.hpp:76
GNSSconstants.hpp
gnsstk::Rinex3ObsData::getObs
virtual RinexDatum getObs(const RinexSatID &svID, size_t index) const
Definition: Rinex3ObsData.cpp:224
example4.indexP1
indexP1
Definition: example4.py:25
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::FFStream::recordNumber
unsigned int recordNumber
keeps track of the number of records read
Definition: FFStream.hpp:176
P1
gnsstk::Matrix< double > P1
Definition: Matrix_LUDecomp_T.cpp:49
example4.indexP2
indexP2
Definition: example4.py:26
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::L2_FREQ_GPS
const double L2_FREQ_GPS
GPS L2 carrier frequency in Hz.
Definition: DeprecatedConsts.hpp:53
gnsstk::Rinex3ObsData::time
CommonTime time
Time corresponding to the observations.
Definition: Rinex3ObsData.hpp:91
P2
gnsstk::Matrix< double > P2
Definition: Matrix_LUDecomp_T.cpp:49
gnsstk::C_MPS
const double C_MPS
m/s, speed of light; this value defined by GPS but applies to GAL and GLO.
Definition: GNSSconstants.hpp:74
gnsstk::Rinex3ObsData
Definition: Rinex3ObsData.hpp:75
Rinex3ObsHeader.hpp
CivilTime.hpp
Rinex3ObsData.hpp
gnsstk::Rinex3ObsStream
Definition: Rinex3ObsStream.hpp:65
gnsstk::CivilTime
Definition: CivilTime.hpp:55
Rinex3ObsStream.hpp
std
Definition: Angle.hpp:142
Rinex3ObsBase.hpp
example3.mu
int mu
Definition: example3.py:36


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