RSTT  3.2.0
Regional Seismic Travel Time
All Classes Namespaces Files Functions Variables Typedefs Friends Macros
UncertaintyPDU.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government retains certain rights in this software.
6 //-
7 //- BSD Open Source License
8 //- All rights reserved.
9 //-
10 //- Redistribution and use in source and binary forms, with or without
11 //- modification, are permitted provided that the following conditions are met:
12 //-
13 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37 
38 #ifndef UncertaintyPDU_H
39 #define UncertaintyPDU_H
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <string>
44 #include <vector>
45 #include <list>
46 #include <map>
47 
48 #include "SLBMGlobals.h"
49 #include "IFStreamAscii.h"
50 #include "IFStreamBinary.h"
51 #include "UncertaintyPIU.h"
52 #include "CpuTimer.h"
53 
54 using namespace std;
55 
56 // **** _BEGIN SLBM NAMESPACE_ **************************************************
57 
58 namespace slbm {
59 
60  // **** _LOCAL INCLUDES_ *******************************************************
61 
81  {
82 
83  public:
84 
89 
95  UncertaintyPDU(int phase);
96 
102  UncertaintyPDU(const string& phase);
103 
110  UncertaintyPDU(string modelPath, int phase);
111 
112  // \brief Parameterized constructor that loads path dependent model error
119  UncertaintyPDU(string modelPath, const string& phase);
120 
125 
129  virtual ~UncertaintyPDU();
130 
135 
142  virtual bool operator == (const UncertaintyPDU& other) const;
143  virtual bool operator != (const UncertaintyPDU& other) const { return !(*this == other); } ;
144 
151  bool operator!=(const UncertaintyPDU& other) { return !(*this == other); }
152 
160  static UncertaintyPDU* getUncertainty(ifstream& input, int phase);
161 
168  static UncertaintyPDU* getUncertainty(ifstream& input, const string& phase);
169 
177  static UncertaintyPDU* getUncertainty(geotess::IFStreamAscii& input);
178 
186  static UncertaintyPDU* getUncertainty(geotess::IFStreamBinary& input);
187 
195  static UncertaintyPDU* getUncertainty(const string& modelPath, int phase);
196 
197  void readFile(ifstream& fin);
198 
199  void readFile(geotess::IFStreamAscii& fin);
200 
201  void readFile(geotess::IFStreamBinary& fin);
202 
203  void writeFile(geotess::IFStreamAscii& output);
204 
205  void writeFile(geotess::IFStreamBinary& fout);
206 
207  void writeFile(const string& directoryName);
208 
214  int getPhase() const {
215  return phaseNum;
216  }
217 
223  const string getPhaseStr() const {
224  return getPhase(phaseNum);
225  }
226 
230  const string& getLoadedFileName() const {
231  return fname;
232  }
233 
239  const string& getGridId() const {
240  return gridId;
241  }
242 
256  double getUncertainty(double distance,
257  const vector<int>& crustNodeIds, const vector<double>& crustWeights,
258  const vector<int>& headWaveNodeIds, const vector<double>& headWaveWeights,
259  const vector<vector<int> >& headWaveNodeNeighbors, const bool& calcRandomError = false,
260  bool printDebugInfo = false);
261 
265  bool isRandomErrorDefined() const {
266  return (pathUncRandomError.size() > 0);
267  }
268 
269  string toStringTable();
270 
271  string toStringFile();
272 
273  static string getPhase(const int& phaseIndex)
274  {
275  return UncertaintyPIU::getPhase(phaseIndex);
276  }
277 
278  static int getPhase(const string& phase)
279  {
280  return UncertaintyPIU::getPhase(phase);
281  }
282 
283  vector<double>& getPathUncCrustError() {
284  return pathUncCrustError;
285  }
286 
287  const vector<double>& getPathUncCrustError() const {
288  return pathUncCrustError;
289  }
290 
291  vector<vector<double> >& getPathUncRandomError() {
292  return pathUncRandomError;
293  }
294 
295  const vector<vector<double> >& getPathUncRandomError() const {
296  return pathUncRandomError;
297  }
298 
299  vector<double>& getPathUncDistanceBins() {
300  return pathUncDistanceBins;
301  }
302 
303  const vector<double>& getPathUncDistanceBins() const {
304  return pathUncDistanceBins;
305  }
306 
307  vector<vector<double> >& getPathUncModelError() {
308  return pathUncModelError;
309  }
310 
311  const vector<vector<double> >& getPathUncModelError() const {
312  return pathUncModelError;
313  }
314 
315  vector<vector<double> >& getPathUncBias() {
316  return pathUncBias;
317  }
318 
319  const vector<vector<double> >& getPathUncBias() const {
320  return pathUncBias;
321  }
322 
323  string toString();
324 
327  map<string, string> properties;
328 
329  vector<string> keys;
330 
331 
332  private:
333 
339  void readFile(const string& filename);
340 
346  string fname;
347 
351  int phaseNum;
352 
359  string gridId;
360 
365  vector<double> pathUncCrustError;
366 
371  vector<double> pathUncDistanceBins;
372 
379  vector<vector<double> > pathUncRandomError;
380 
386  vector<vector<double> > pathUncModelError;
387 
393  vector<vector<double> > pathUncBias;
394 
395  };
396 
397 } // end slbm namespace
398 
399 #endif // UncertaintyPDU_H
#define SLBM_EXP
Definition: SLBMGlobals.h:181
A UncertaintyPDU object contains the raw data to calculate a path dependent modeling error in seconds...
void readFile(geotess::IFStreamBinary &fin)
int getPhase() const
A public convenience accessor used to verify the error data for the correct model phase is loaded in ...
vector< double > & getPathUncDistanceBins()
UncertaintyPDU(int phase)
Parameterized constructor that defines an empty path path specific model error for the input phase.
double getUncertainty(double distance, const vector< int > &crustNodeIds, const vector< double > &crustWeights, const vector< int > &headWaveNodeIds, const vector< double > &headWaveWeights, const vector< vector< int > > &headWaveNodeNeighbors, const bool &calcRandomError=false, bool printDebugInfo=false)
Returns the model uncertainty as a function of angular distance (degrees), crustal grid vertex indice...
vector< double > & getPathUncCrustError()
UncertaintyPDU(const string &phase)
Parameterized constructor that that defines an empty path path specific model error for the input pha...
const vector< double > & getPathUncCrustError() const
void readFile(geotess::IFStreamAscii &fin)
static UncertaintyPDU * getUncertainty(ifstream &input, const string &phase)
const vector< vector< double > > & getPathUncBias() const
static int getPhase(const string &phase)
const vector< vector< double > > & getPathUncModelError() const
const string & getLoadedFileName() const
Returns loaded file name or "not specified".
const vector< double > & getPathUncDistanceBins() const
void writeFile(geotess::IFStreamBinary &fout)
void writeFile(const string &directoryName)
vector< vector< double > > & getPathUncRandomError()
bool operator!=(const UncertaintyPDU &other)
UncertaintyPDU & operator=(const UncertaintyPDU &u)
Assignment operator.
vector< vector< double > > & getPathUncBias()
static UncertaintyPDU * getUncertainty(ifstream &input, int phase)
vector< string > keys
UncertaintyPDU(const UncertaintyPDU &u)
Copy constructor.
virtual ~UncertaintyPDU()
Destructor.
void readFile(ifstream &fin)
UncertaintyPDU(string modelPath, int phase)
Parameterized constructor that loads path dependent model error definition from a specified file.
const vector< vector< double > > & getPathUncRandomError() const
static string getPhase(const int &phaseIndex)
UncertaintyPDU(string modelPath, const string &phase)
static UncertaintyPDU * getUncertainty(geotess::IFStreamAscii &input)
const string & getGridId() const
Returns the grid id for which this path dependent uncertainty objects data are defined.
static UncertaintyPDU * getUncertainty(geotess::IFStreamBinary &input)
map< string, string > properties
A map to store metadata like phase, gridId, nBins, nVertices, etc..
vector< vector< double > > & getPathUncModelError()
bool isRandomErrorDefined() const
Returns true if random error is defined.
void writeFile(geotess::IFStreamAscii &output)
static UncertaintyPDU * getUncertainty(const string &modelPath, int phase)
UncertaintyPDU()
Default constructor.
const string getPhaseStr() const
A public convenience accessor used to verify the error data for the correct model phase is loaded in ...