LibCorr3D 2.2
All Classes Namespaces Files Functions
LibCorr3DModel.h
Go to the documentation of this file.
1//- ****************************************************************************
2//-
3//- Copyright 2009 Sandia Corporation. Under the terms of Contract
4//- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5//- 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//- * Redistributions of source code must retain the above copyright notice,
14//- this list of conditions and the following disclaimer.
15//- * Redistributions in binary form must reproduce the above copyright
16//- notice, this list of conditions and the following disclaimer in the
17//- documentation and/or other materials provided with the distribution.
18//- * Neither the name of Sandia National Laboratories nor the names of its
19//- contributors may be used to endorse or promote products derived from
20//- this software without specific prior written permission.
21//-
22//- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23//- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24//- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25//- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26//- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27//- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28//- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29//- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30//- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31//- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32//- POSSIBILITY OF SUCH DAMAGE.
33//-
34//- ****************************************************************************
35
36#ifndef LIBCORR3DMODEL_OBJECT_H
37#define LIBCORR3DMODEL_OBJECT_H
38
39// **** _SYSTEM INCLUDES_ ******************************************************
40
41#include <iostream>
42#include <string>
43#include <fstream>
44#include <vector>
45#include <map>
46
47// use standard library objects
48using namespace std;
49
50// **** _LOCAL INCLUDES_ *******************************************************
51
52#include "CPPUtils.h"
53#include "GeoTessUtils.h"
54#include "GeoTessException.h"
55#include "GeoTessModel.h"
56
57// **** _BEGIN GEOTESS NAMESPACE_ **********************************************
58
59namespace geotess
60{
61
62// **** _FORWARD REFERENCES_ ***************************************************
63
64class GeoTessPosition;
65class GeoTessGrid;
66class GeoTessMetaData;
67class IFStreamBinary;
68class GeoTessInterpolatorType;
69
70// **** _CLASS DEFINITION_ *****************************************************
71
84class GEOTESS_EXP_IMP LibCorr3DModel: public GeoTessModel
85{
86private:
87
88 // assigned by LibCorr3D
89 int handle;
90
94 string sta;
95
99 double staOnTime;
100
104 double staOffTime;
105
109 double staLat;
110
114 double staLon;
115
119 double staDepth;
120
121 string staName;
122
123 string staType;
124
128 string staRefsta;
129
130 double staDnorth;
131
132 double staDeast;
133
137 double staPosition[3];
138
139 string phase;
140 string supportedPhases;
141 string parameters;
142 string comments;
143 string baseModel;
144 string baseModelVersion;
145
146 int formatVersion;
147
152 vector<float> bmUncDist;
153 vector<float> bmUncValu;
154
161 void loadExtraData(IFStreamBinary& input);
162
166 void loadModelBinaryLibCorr2D(IFStreamBinary& input,
167 const string& inputDirectory, const string& relGridFilePath);
168
177 virtual void loadModelBinary(IFStreamBinary& input,
178 const string& inputDirectory, const string& relGridFilePath);
179
180 virtual void writeModelBinary(IFStreamBinary& output, const string& gridFileName);
181
186 virtual void loadModelAscii(IFStreamAscii& input, const string& inputDirectory,
187 const string& relGridFilePath);
188
189 virtual void writeModelAscii(IFStreamAscii& output, const string& gridFileName);
190
191public:
192
204 LibCorr3DModel(const string& filename, const string& relGridFilePath = "",
205 int handle=-1);
206
221 LibCorr3DModel(const string& filename, const string& relGridFilePath,
222 vector<int>& attributeFilter,
223 int handle);
224
229
233 bool operator ==(const GeoTessModel& m) const;
234
238 bool operator != (const GeoTessModel& other) const { return !(*this == other); } ;
239
243 virtual string class_name() { return "LibCorr3DModel"; };
244
245 virtual string toString();
246
259 virtual LONG_INT getMemory()
260 {
261 LONG_INT memory = (LONG_INT)(sizeof(LibCorr3DModel)-sizeof(GeoTessModel));
262
263 memory += GeoTessModel::getMemory();
264
265 memory += (LONG_INT) (sta.length() + staRefsta.length() + phase.length() + parameters.length()
266 + comments.length() + baseModel.length() + baseModelVersion.length()
267 + supportedPhases.length() + staName.length() + staType.length());
268
269 memory += (LONG_INT)(7 * sizeof(double));
270
271 memory += (LONG_INT)(2 * sizeof(int));
272
273 memory += (LONG_INT)((bmUncDist.capacity() + bmUncValu.capacity()) * sizeof(float));
274
275 return memory;
276 }
277
278
285 int getHandle() const
286 {
287 return handle;
288 }
289
297 {
298 return bmUncDist.size() == 0;
299 }
300
308 double interpolate2DModelUncertainty(const double* pos);
309
314 const string& getFileName() const
315 {
316 return metaData->getInputModelFile();
317 }
318
333 void setStationInfo(const string& name,
334 const double& ontime, const double& offtime,
335 const double& lat, const double& lon, const double& depth,
336 const string& staname, const string& statype,
337 const string& refsta,
338 const double& dnorth, const double& deast
339 )
340 {
341 sta = name;
342 staOnTime = ontime;
343 staOffTime = offtime;
344 staLat = lat;
345 staLon = lon;
346 staDepth = depth;
347 staName = staname;
348 staType = statype;
349 staRefsta = refsta;
350 staDnorth = dnorth;
351 staDeast = deast;
352 GeoTessUtils::getVectorDegrees(staLat, staLon, staPosition);
353 }
354
358 const string& getStationName() const { return sta; }
359
363 double getStationStartTime() const { return staOnTime; }
364
368 double getStationEndTime() const { return staOffTime; }
369
373 double getStationLatitude() const { return staLat; }
374
378 double getStationLongitude() const { return staLon; }
379
383 double getStationDepth() const { return staDepth; }
384
388 double getStationElevation() const { return -staDepth; }
389
393 const double* getStationPosition() const { return staPosition; }
394
398 const string& getStaName() const { return staName; }
399
403 const string& getStaType() const { return staType; }
404
408 const string& getRefsta() const { return staRefsta; }
409
413 double getDnorth() const { return staDnorth; }
414
418 double getDeasts() const { return staDeast; }
419
424 const string& getPhase() const { return phase; }
425
426 void setPhase(const string& ph) { phase = ph; }
427
431 const string& getSupportedPhaseList() const { return supportedPhases; }
432
436 void setSupportedPhaseList(const string& ph) { supportedPhases = ph; }
437
441 const string& getParameters() const { return parameters; }
442
443 void setParameters(const string& par) { parameters = par; }
444
448 const string& getComments() const { return comments; }
449
450 void setComments(const string& com) { comments = com; }
451
455 const string& getBaseModel() const { return baseModel; }
456
457 void setBaseModel(const string& bm) { baseModel = bm; }
458
462 const string& getBaseModelVersion() const { return baseModelVersion; }
463
464 void setBaseModelVersion(const string& bmv) { baseModelVersion = bmv; }
465
466 string getVmodel() const {
467 map<string, string>::const_iterator it = metaData->getProperties().find("vmodel");
468 if (it == metaData->getProperties().end())
469 return "libcorr3d";
470 return it->second;
471 }
472
473};
474// end class LibCorr3DModel
475
476}// end namespace geotess
477
478#endif // LIBCORR3DMODEL_OBJECT_H
Definition: LibCorr3D.h:62
This is a LibCorr3D extension of the GeoTessModel for use by LibCorr3D.
Definition: LibCorr3DModel.h:85
double getDnorth() const
Definition: LibCorr3DModel.h:413
const string & getStaType() const
Definition: LibCorr3DModel.h:403
double getStationElevation() const
Definition: LibCorr3DModel.h:388
const string & getStaName() const
Definition: LibCorr3DModel.h:398
const string & getComments() const
Definition: LibCorr3DModel.h:448
const string & getBaseModelVersion() const
Definition: LibCorr3DModel.h:462
virtual ~LibCorr3DModel()
Destructor.
virtual LONG_INT getMemory()
Return the amount of memory currently occupied by this LibCorr3DModel object NOT INCLUDING THE GRIDS.
Definition: LibCorr3DModel.h:259
double interpolate2DModelUncertainty(const double *pos)
Calculates the old 2D model uncertainty if this model was loaded as such.
double getStationLatitude() const
Definition: LibCorr3DModel.h:373
void setStationInfo(const string &name, const double &ontime, const double &offtime, const double &lat, const double &lon, const double &depth, const string &staname, const string &statype, const string &refsta, const double &dnorth, const double &deast)
Set station information.
Definition: LibCorr3DModel.h:333
bool is3DModel()
Returns true if this model is a LibCorr3D model derived off of GeoTessModel.
Definition: LibCorr3DModel.h:296
LibCorr3DModel(const string &filename, const string &relGridFilePath="", int handle=-1)
Standard constructor.
virtual string class_name()
Returns the class name.
Definition: LibCorr3DModel.h:243
LibCorr3DModel(const string &filename, const string &relGridFilePath, vector< int > &attributeFilter, int handle)
Standard constructor.
const string & getSupportedPhaseList() const
Definition: LibCorr3DModel.h:431
double getStationDepth() const
Definition: LibCorr3DModel.h:383
string getVmodel() const
Definition: LibCorr3DModel.h:466
const double * getStationPosition() const
Definition: LibCorr3DModel.h:393
void setBaseModelVersion(const string &bmv)
Definition: LibCorr3DModel.h:464
double getStationEndTime() const
Definition: LibCorr3DModel.h:368
double getDeasts() const
Definition: LibCorr3DModel.h:418
void setComments(const string &com)
Definition: LibCorr3DModel.h:450
void setPhase(const string &ph)
Definition: LibCorr3DModel.h:426
const string & getStationName() const
Definition: LibCorr3DModel.h:358
void setParameters(const string &par)
Definition: LibCorr3DModel.h:443
const string & getPhase() const
Definition: LibCorr3DModel.h:424
void setBaseModel(const string &bm)
Definition: LibCorr3DModel.h:457
double getStationLongitude() const
Definition: LibCorr3DModel.h:378
virtual string toString()
void setSupportedPhaseList(const string &ph)
Set the list of supported phases, formatted like this: Pg, Pn, P.
Definition: LibCorr3DModel.h:436
const string & getFileName() const
Return the file name string associated with this model.
Definition: LibCorr3DModel.h:314
const string & getRefsta() const
Definition: LibCorr3DModel.h:408
const string & getParameters() const
Definition: LibCorr3DModel.h:441
const string & getBaseModel() const
Definition: LibCorr3DModel.h:455
int getHandle() const
Return the handle associated with this model.
Definition: LibCorr3DModel.h:285
double getStationStartTime() const
Definition: LibCorr3DModel.h:363