RSTT 3.2.1 Regional Seismic Travel Time

Loading...
Searching...
No Matches
SlbmInterface.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 SlbmInterface_H
39#define SlbmInterface_H
40
41// **** _SYSTEM INCLUDES_ ******************************************************
42#include <map>
43#include <cmath>
44
45 using namespace std;
46
47// **** _LOCAL INCLUDES_ *******************************************************
48
49#include "GreatCircle.h"
50#include "GreatCircleFactory.h"
51#include "GridGeoTess.h"
52#include "UncertaintyPIU.h"
53#include "UncertaintyPDU.h"
54#include "SLBMException.h"
55
56// **** _BEGIN SLBM NAMESPACE_ **************************************************
57
58 namespace slbm {
59
76 class SLBM_EXP SlbmInterface
77{
78
79 public:
80
88 SlbmInterface();
89
99 SlbmInterface(const double& earthRadius);
100
104 // SlbmInterface(const SlbmInterface &other);
105
109 // SlbmInterface *clone() { return new SlbmInterface(*this); }
110
115 virtual ~SlbmInterface();
116
122 bool isEqual(SlbmInterface *other);
123
124 bool operator == (SlbmInterface &other) { return isEqual(&other); };
125 bool operator != (SlbmInterface &other) { return !(*this == other); };
126
132 static bool modelsEqual(const string modelPath1, const string modelPath2);
133
138 string getVersion() { return SlbmVersion; };
139
151 void loadVelocityModel(const string& modelPath);
152
197 void saveVelocityModel(const string& modelFileName, const int& format=4);
198
200
217 void loadVelocityModelBinary(const string& modelPath)
218 { loadVelocityModel(modelPath); };
219
236 void specifyOutputDirectory(const string& directoryName);
237
247 void saveVelocityModelBinary();
248
257 void loadVelocityModelBinary(util::DataBuffer& buffer);
258
264 void saveVelocityModelBinary(util::DataBuffer& buffer);
265
267
273 int getBufferSize() const;
274
282 void setInterpolatorType(const string& interpolatorType);
283
289 string getInterpolatorType();
290
306 void createGreatCircle(const string& phase,
307 const double& sourceLat,
308 const double& sourceLon,
309 const double& sourceDepth,
310 const double& receiverLat,
311 const double& receiverLon,
312 const double& receiverDepth);
313
329 void createGreatCircle(const int& phase,
330 const double& sourceLat,
331 const double& sourceLon,
332 const double& sourceDepth,
333 const double& receiverLat,
334 const double& receiverLon,
335 const double& receiverDepth);
336
356 void clear();
357
363 bool isValid() { return valid; };
364
368 string getPhase() { return sphase; };
369
375 void getDistance(double& distance) { distance = getDistance(); };
376
381 double getDistance();
382
390 void getSourceDistance(double& dist);
391 double getSourceDistance() { double x; getSourceDistance(x); return x; };
392
400 void getReceiverDistance(double& dist);
401 double getReceiverDistance() { double x; getReceiverDistance(x); return x; };
402
414 void getHeadwaveDistance(double& dist);
415 double getHeadwaveDistance() { double x; getHeadwaveDistance(x); return x; };
416
429 void getHeadwaveDistanceKm(double& dist);
430 double getHeadwaveDistanceKm() { double x; getHeadwaveDistanceKm(x); return x; };
431
440 void getTravelTime(double& travelTime);
441 double getTravelTime() { double x; getTravelTime(x); return x; };
442
457 void getTravelTimeComponents(double& tTotal, double& tSource, double& tReceiver,
458 double& tHeadwave, double& tGradient);
459
465 void getSlowness(double& slowness);
466 double getSlowness() { double x; getSlowness(x); return x; };
467
473 void get_dtt_ddist(double& slowness) { getSlowness(slowness); };
474 double get_dtt_ddist() { double x; getSlowness(x); return x; };
475
482 void get_dtt_dlat(double& dtt_dlat);
483 double get_dtt_dlat() { double x; get_dtt_dlat(x); return x; };
484
491 void get_dtt_dlon(double& dtt_dlon);
492 double get_dtt_dlon() { double x; get_dtt_dlon(x); return x; };
493
500 void get_dtt_ddepth(double& dtt_ddepth);
501 double get_dtt_ddepth() { double x; get_dtt_ddepth(x); return x; };
502
509 //void get_dtt_dlat_fast(double& dtt_dlat);
510
517 //void get_dtt_dlon_fast(double& dtt_dlon);
518
519// //! \brief Retrieve the derivative of horizontal slowness wrt to source-receiver distance,
520// //! in seconds/radian^2.
521// //!
522// //! Retrieve the derivative of horizontal slowness wrt to source-receiver distance,
523// //! in seconds/radian^2.
524// void get_dsh_ddist(double& dsh_ddist);
525// double get_dsh_ddist() { double x; get_dsh_ddist(x); return x; };
526//
527// //! \brief Retrieve the derivative of horizontal slowness wrt to source latitude,
528// //! in seconds/radian^2.
529// //!
530// //! Retrieve the derivative of horizontal slowness wrt to source latitude,
531// //! in seconds/radian^2.
532// //! @param dsh_dlat the derivative of horizontal slowness wrt to source latitude.
533// void get_dsh_dlat(double& dsh_dlat);
534//
535// //! \brief Retrieve the derivative of horizontal slowness wrt to source longitude,
536// //! in seconds/radian^2.
537// //!
538// //! Retrieve the derivative of horizontal slowness wrt to source longitude,
539// //! in seconds/radian^2.
540// //! @param dsh_dlon the derivative of horizontal slowness wrt to source longitude.
541// void get_dsh_dlon(double& dsh_dlon);
542//
543// //! \brief Retrieve the derivative of horizontal slowness wrt to source depth,
544// //! in seconds/radian-km.
545// //!
546// //! Retrieve the derivative of horizontal slowness wrt to source depth,
547// //! in seconds/radian-km.
548// //! @param dsh_ddepth the derivative of horizontal slowness wrt to source depth.
549// void get_dsh_ddepth(double& dsh_ddepth);
550// double get_dsh_ddepth() { double x; get_dsh_ddepth(x); return x; }
551
589 void getWeights(int nodeId[], double weight[], int& nWeights);
590
629 void getActiveNodeWeights(int nodeId[], double weight[], int& nWeights);
630
664 void getWeights(vector<int>& nodeId, vector<double>& weight);
665
698 void getActiveNodeWeights(vector<int>& nodeId, vector<double>& weight);
699
713 void getWeightsSource(int nodeids[], double weights[], int& nWeights);
714 void getWeightsSource(vector<int> &nodeids, vector<double> &weights);
715
729 void getActiveNodeWeightsSource(int nodeids[], double weights[], int& nWeights);
730 void getActiveNodeWeightsSource(vector<int> &nodeids, vector<double> &weights);
731
742 void getWeightsReceiver(int nodeids[], double weights[], int& nWeights);
743 void getWeightsReceiver(vector<int> &nodeids, vector<double> &weights);
744
755 void getActiveNodeWeightsReceiver(int nodeids[], double weights[], int& nWeights);
756 void getActiveNodeWeightsReceiver(vector<int> &nodeids, vector<double> &weights);
757
779 string toString(const int& verbosity);
780
784 void getNGridNodes(int& n);
785
789 int getNGridNodes();
790
800 void getNHeadWavePoints(int& nHeadWavePoints);
801 int getNHeadWavePoints() { int x; getNHeadWavePoints(x); return x; };
802
822 void getGridData(
823 const int& nodeId,
824 double& latitude,
825 double& longitude,
826 double depth[NLAYERS],
827 double pvelocity[NLAYERS],
828 double svelocity[NLAYERS],
829 double gradient[2]);
830
850 void getActiveNodeData(
851 const int& nodeId,
852 double& latitude,
853 double& longitude,
854 double depth[NLAYERS],
855 double pvelocity[NLAYERS],
856 double svelocity[NLAYERS],
857 double gradient[2]);
858
874 void setGridData(
875 const int& nodeId,
876 double depths[NLAYERS],
877 double pvelocity[NLAYERS],
878 double svelocity[NLAYERS],
879 double gradient[2]);
880
896 void setActiveNodeData(
897 const int& nodeId,
898 double depths[NLAYERS],
899 double pvelocity[NLAYERS],
900 double svelocity[NLAYERS],
901 double gradient[2]);
902
939 void getGreatCircleData(
940 string& phase,
941 double& actual_path_increment,
942 double sourceDepth[NLAYERS],
943 double sourceVelocity[NLAYERS],
944 double receiverDepth[NLAYERS],
945 double receiverVelocity[NLAYERS],
946 int& npoints,
947 double headWaveVelocity[],
948 double gradient[]
949 );
950 void getGreatCircleData(
951 string &phase,
952 double &actual_path_increment,
953 vector<double> &sourceDepth,
954 vector<double> &sourceVelocity,
955 vector<double> &receiverDepth,
956 vector<double> &receiverVelocity,
957 int &npoints,
958 vector<double> &headWaveVelocity,
959 vector<double> &gradient
960 );
961
975 void getGreatCircleLocations(double lat[], double lon[], double depth[], int& npoints);
976 void getGreatCircleLocations(vector<double> &lat, vector<double> &lon, vector<double> &depth);
977
1005 void getGreatCircleNodeInfo(
1006 int** neighbors,
1007 double** coefficients,
1008 const int& maxpoints,
1009 const int& maxnodes,
1010 int& npoints,
1011 int* nnodes
1012 );
1013 void getGreatCircleNodeInfo(vector<vector<int> >& neighbors, vector<vector<double> >& coefficients);
1014
1038 void getInterpolatedPoint(
1039 const double& lat,
1040 const double& lon,
1041 int* nodeIds,
1042 double* coefficients,
1043 int& nWeights,
1044 double depth[NLAYERS],
1045 double pvelocity[NLAYERS],
1046 double svelocity[NLAYERS],
1047 double& pgradient,
1048 double& sgradient
1049 );
1050
1073 void getInterpolatedPoint(
1074 const double &lat,
1075 const double &lon,
1076 vector<int> &nodeId,
1077 vector<double> &coefficients,
1078 vector<double> &depth,
1079 vector<double> &pvelocity,
1080 vector<double> &svelocity,
1081 double &pgradient,
1082 double &sgradient
1083 );
1084
1110 void getInterpolatedTransect(
1111 double lat[],
1112 double lon[],
1113 const int& nLatLon,
1114 int** neighbors,
1115 double** coefficients,
1116 int* nNeighbors,
1117 double depth[][NLAYERS],
1118 double pvelocity[][NLAYERS],
1119 double svelocity[][NLAYERS],
1120 double pgradient[NLAYERS],
1121 double sgradient[NLAYERS],
1122 int& nInvalid
1123 );
1124
1144 void getInterpolatedTransect(
1145 vector<double> lat,
1146 vector<double> lon,
1147 vector<vector<int> > &nodeId,
1148 vector<vector<double> > &coefficients,
1149 vector<vector<double> > &depth,
1150 vector<vector<double> > &pvelocity,
1151 vector<vector<double> > &svelocity,
1152 vector<double> &pgradient,
1153 vector<double> &sgradient,
1154 int& nInvalid
1155 );
1156
1169 void initializeActiveNodes(const double& latmin, const double& lonmin,
1170 const double& latmax, const double& lonmax);
1171
1188 void initializeActiveNodes(const string& polygonFileName);
1189
1202 void initializeActiveNodes(GeoTessPolygon* polygon);
1203
1225 void initializeActiveNodes(double* lat, double* lon, const int& npoints, const bool& inDegrees=true);
1226
1246 void initializeActiveNodes(const vector<double> lat, const vector<double> lon, const bool& inDegrees=true);
1247
1263 void initializeActiveNodes(vector<double*>& unitVectors);
1264
1268 int getNActiveNodes();
1269
1272 void clearActiveNodes();
1273
1279 int getGridNodeId(int activeNodeId);
1280
1286 int getActiveNodeId(int gridNodeId);
1287
1296 void getNodeHitCount(const int& nodeId, int& hitCount);
1297 int getNodeHitCount(const int &nodeId) { int x; getNodeHitCount(nodeId, x); return x; };
1298
1299
1305 void clearNodeHitCount();
1306
1314 void getNodeNeighbors(const int& nid, int neighbors[], int& nNeighbors);
1315
1323 void getActiveNodeNeighbors(const int& nid, int neighbors[], int& nNeighbors);
1324
1329 void getNodeNeighbors(const int& nid, vector<int>& neighbors);
1330
1335 void getActiveNodeNeighbors(const int& nid, vector<int>& neighbors);
1336
1344 void getNodeNeighborInfo(const int& nid, int neighbors[], double distance[],
1345 double azimuth[], int& nNeighbors);
1346 void getNodeNeighborInfo(const int nid,
1347 vector<int> &neighbors, vector<double> &distance, vector<double> &azimuth);
1348
1356 void getActiveNodeNeighborInfo(const int& nid, int neighbors[], double distance[],
1357 double azimuth[], int& nNeighbors);
1358
1366 void getActiveNodeNeighborInfo(const int& nid,
1367 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth);
1368
1372 void getNodeSeparation(const int& node1, const int& node2, double& distance);
1373
1377 void getNodeAzimuth(const int& node1, const int& node2, double& azimuth);
1378
1387 GreatCircle* getGreatCircleObject();
1388
1393 Grid* getGridObject() { return grid; };
1394
1399 GeoTessModelSLBM* getModelObject() { return grid->getModel(); }
1400
1409 void getTravelTimeUncertainty( const int& phase, const double& distance, double& uncert );
1410
1419 void getTravelTimeUncertainty(double& travelTimeUncertainty, bool calcRandomError = false);
1420
1427 void getTravelTimeUncertainty1D(double& travelTimeUncertainty);
1428
1437 void getSlownessUncertainty( const int& phase, const double& distance, double& uncert );
1438
1445 void getSlownessUncertainty(double& slownessUncertainty);
1446
1447 string getUncertaintyTable(const int& phase, const int& attribute);
1448
1449 string getUncertaintyFileFormat(const int& phase, const int& attribute);
1450
1472 void getZhaoParameters(double& Vm, double& Gm, double& H, double& C, double& Cm, int& udSign);
1473
1490 void getPgLgComponents(double& tTotal, double& tTaup, double& tHeadwave,
1491 double& pTaup, double& pHeadwave, double& trTaup, double& trHeadwave);
1492
1501 void static setCHMax(const double& chMax);
1502
1511 void static getCHMax(double& chMax);
1512 double static getCHMax() { double x; getCHMax(x); return x; }
1513
1523 void getAverageMantleVelocity(const int& type, double& velocity);
1524 double getAverageMantleVelocity(const int &type);
1525
1537 void setAverageMantleVelocity(const int& type, const double& velocity);
1538
1542 void getTessId(string& tessId);
1543 string getTessId() { string s; getTessId(s); return s; };
1544
1550 void getFractionActive(double& fractionActive);
1551 double getFractionActive() { double x; getFractionActive(x); return x; }
1552
1560 void static setMaxDistance(const double& maxDistance);
1561
1567 void static getMaxDistance(double& maxDistance);
1568 double static getMaxDistance() { double x; getMaxDistance(x); return x; }
1569
1577 void static setMaxDepth(const double& maxDepth);
1578
1582 void static getMaxDepth(double& maxDepth);
1583 double static getMaxDepth() { double x; getMaxDepth(x); return x; }
1584
1591 string getClassCount();
1592
1597 const string& getModelPath() const;
1598
1614 void getDistAz(const double& aLat, const double& aLon,
1615 const double& bLat, const double& bLon,
1616 double& distance, double& azimuth, const double& naValue);
1617
1630 void movePoint(const double& aLat, const double& aLon,
1631 const double& distance, const double& azimuth,
1632 double& bLat, double& bLon);
1633
1642 void getPiercePointSource(double& lat, double& lon, double& depth);
1643
1652 void getPiercePointReceiver(double& lat, double& lon, double& depth);
1653
1670 void getGreatCirclePoints(
1671 const double& aLat,
1672 const double& aLon,
1673 const double& bLat,
1674 const double& bLon,
1675 const int& npoints,
1676 double latitude[],
1677 double longitude[]);
1678 void getGreatCirclePoints(
1679 const double& aLat,
1680 const double& aLon,
1681 const double& bLat,
1682 const double& bLon,
1683 const int& npoints,
1684 vector<double> &latitude,
1685 vector<double> &longitude);
1686
1701 void getGreatCirclePointsOnCenters(
1702 const double& aLat,
1703 const double& aLon,
1704 const double& bLat,
1705 const double& bLon,
1706 const int& npoints,
1707 double latitude[],
1708 double longitude[]);
1709 void getGreatCirclePointsOnCenters(
1710 const double& aLat,
1711 const double& aLon,
1712 const double& bLat,
1713 const double& bLon,
1714 const int& npoints,
1715 vector<double> &latitude,
1716 vector<double> &longitude);
1717
1723 void setDelDistance(const double& del_distance);
1724
1730 void getDelDistance(double& del_distance);
1731 double getDelDistance() { double x; getDelDistance(x); return x; };
1732
1738 void setDelDepth(const double& del_depth);
1739
1744 void getDelDepth(double& del_depth);
1745 double getDelDepth() { double x; getDelDepth(x); return x; };
1746
1750 void getRayParameter(double& ray_parameter);
1751 double getRayParameter() { double x; getRayParameter(x); return x; };
1752
1756 void getTurningRadius(double& turning_radius);
1757 double getTurningRadius() { double x; getTurningRadius(x); return x; };
1758
1772 void setPathIncrement(const double& pathIncrement);
1773
1786 void getPathIncrement(double& pathIncrement);
1787
1800 double getPathIncrement();
1801
1802 string getModelString() { return grid->toString(); }
1803
1806 int getPhaseInt() { return iphase; }
1807 string getPhaseString() { return sphase; }
1808
1811 double getSrcLat() { return srcLat; }
1812
1815 double getSrcLon() { return srcLon; }
1816
1819 double getSrcDep() { return srcDep; }
1820
1823 double getRcvLat() { return rcvLat; }
1824
1827 double getRcvLon() { return rcvLon; }
1828
1831 double getRcvDep() { return rcvDep; }
1832
1833 /*
1834 void DEBUG()
1835 {
1836 // check SlbmInterface memory
1837 DEBUG_MSG(__FILE__, __FUNCTION__, this, "");
1838 cout << "SlbmInterface.grid = " << grid << endl;
1839 cout << "SlbmInterface.greatCircle = " << greatCircle << endl;
1840 cout << "SlbmInterface.valid = " << &valid << endl;
1841 cout << "SlbmInterface.CH_MAX = " << &CH_MAX << endl;
1842 cout << "SlbmInterface.srcLat = " << &srcLat << endl;
1843 cout << "SlbmInterface.srcLon = " << &srcLon << endl;
1844 cout << "SlbmInterface.srcDep = " << &srcDep << endl;
1845 cout << "SlbmInterface.rcvLat = " << &rcvLat << endl;
1846 cout << "SlbmInterface.rcvLon = " << &rcvLon << endl;
1847 cout << "SlbmInterface.rcvDep = " << &rcvDep << endl;
1848 cout << endl;
1849
1850 // check grid memory
1851 cout << "grid.modelPath = " << grid->getModelPath() << endl;
1852 cout << "grid.profiles = " << &(grid->getProfiles()) << endl;
1853 cout << "grid.getNActiveNodes() = " << grid->getNActiveNodes() << endl;
1854 cout << "grid.model = " << grid->getModel() << endl;
1855 cout << "grid.position = " << grid->getPosition() << endl;
1856 cout << "grid.polygon = " << grid->getPolygon() << endl;
1857 cout << "grid.sources = " << grid->getSources() << endl;
1858 cout << "grid.receivers = " << grid->getReceivers() << endl;
1859 cout << "grid.getNCrustalProfiles() = " << grid->getNCrustalProfiles() << endl;
1860 cout << "grid.piu = " << &(grid->getUncertaintyPIU()) << endl;
1861 cout << "grid.pdu = " << &(grid->getUncertaintyPDU()) << endl;
1862 cout << "grid.outputDirectory = " << &(grid->getOutputDirectory()) << endl;
1863 cout << endl;
1864
1865 // check piu memory
1866 auto *piu = &grid->getUncertaintyPIU();
1867 for (int i=0; i<piu->size(); i++)
1868 {
1869 cout << "piu["<<i<<"] = " << &(*piu)[i] << endl;
1870 for (int j=0; j<(*piu)[i].size(); j++)
1871 cout << "piu["<<i<<"]["<<j<<"] = " << (*piu)[i][j] << endl;
1872 }
1873 cout << endl;
1874
1875 // check pdu memory
1876 auto *pdu = &grid->getUncertaintyPDU();
1877 for (int i=0; i<pdu->size(); i++)
1878 cout << "pdu["<<i<<"] = " << &(*pdu)[i] << endl;
1879 cout << endl;
1880
1881 // check model memory
1882 GeoTessModelSLBM *model = grid->getModel();
1883 cout << "model.fileFormatVer = " << model->getFileFormatVersion() << endl;
1884 cout << "model.averageMantleVelocity = [" << model->getAverageMantleVelocity(0) << "," << model->getAverageMantleVelocity(1) << "]" << endl;
1885 cout << "model.piu = " << &(model->getPIU()) << endl;
1886 cout << "model.pdu = " << &(model->getPDU()) << endl;
1887 cout << "model.grid = " << &(model->getGrid()) << endl;
1888 cout << "model.reuseGridMap = " << model->getReuseGridMapSize() << endl;
1889 cout << "model.profiles = " << model->getProfiles() << endl;
1890 cout << "model.metaData = " << &(model->getMetaData()) << endl;
1891 cout << "model.pointMap = " << model->getPointMap() << endl;
1892 cout << endl;
1893
1894 }
1895 */
1896
1897 protected:
1898
1902 Grid* grid;
1903
1907 GreatCircle* greatCircle;
1908
1912 static double CH_MAX;
1913
1919 bool valid;
1920
1923 void clearGreatCircles();
1924
1925
1926 private:
1927
1928 // copies of the source and receiver locations that were
1929 // passed to createGreatCircle the last time it was called.
1930 // Used to compute distance in instances when createGreateCircle
1931 // fails. Units are radians.
1932 string sphase;
1933 int iphase;
1934 double srcLat, srcLon, srcDep, rcvLat, rcvLon, rcvDep;
1935};
1936
1937//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1938//
1939// INLINE FUNCTIONS
1940//
1941//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1942
1943 inline void SlbmInterface::createGreatCircle(
1944 const string& p,
1945 const double& sourceLat,
1946 const double& sourceLon,
1947 const double& sourceDepth,
1948 const double& receiverLat,
1949 const double& receiverLon,
1950 const double& receiverDepth)
1951{
1952 int ip = (p=="Pn" ? Pn : (p=="Sn" ? Sn : (p=="Pg" ? Pg : (p=="Lg" ? Lg : -1))));
1953 iphase = ip;
1954 if (ip == -1)
1955 {
1956 ostringstream os;
1957 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1958 os << endl << "ERROR in SlbmInterface::createGreatCircle" << endl
1959 << p << " is not a recognized phase. Must be one of Pn, Sn, Pg, Lg" << endl
1960 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
1961 throw SLBMException(os.str(),112);
1962 }
1963
1964 createGreatCircle(
1965 ip,
1966 sourceLat,
1967 sourceLon,
1968 sourceDepth,
1969 receiverLat,
1970 receiverLon,
1971 receiverDepth
1972 );
1973}
1974
1975 inline GreatCircle* SlbmInterface::getGreatCircleObject()
1976{
1977 return greatCircle;
1978}
1979
1980 inline void SlbmInterface::get_dtt_dlat(double& value)
1981{
1982 if (!isValid())
1983 {
1984 value = NA_VALUE;
1985 ostringstream os;
1986 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1987 os << endl << "ERROR in SlbmInterface::get_dtt_dlat" << endl
1988 << "GreatCircle is invalid." << endl
1989 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
1990 throw SLBMException(os.str(),113);
1991 }
1992 greatCircle->get_dtt_dlat(value);
1993}
1994
1995 inline void SlbmInterface::get_dtt_dlon(double& value)
1996{
1997 if (!isValid())
1998 {
1999 value = NA_VALUE;
2000 ostringstream os;
2001 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2002 os << endl << "ERROR in SlbmInterface::get_dtt_dlon" << endl
2003 << "GreatCircle is invalid." << endl
2004 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2005 throw SLBMException(os.str(),113);
2006 }
2007 greatCircle->get_dtt_dlon(value);
2008}
2009
2010 inline void SlbmInterface::get_dtt_ddepth(double& value)
2011{
2012 if (!isValid())
2013 {
2014 value = NA_VALUE;
2015 ostringstream os;
2016 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2017 os << endl << "ERROR in SlbmInterface::get_dtt_ddepth" << endl
2018 << "GreatCircle is invalid." << endl
2019 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2020 throw SLBMException(os.str(),113);
2021 }
2022 greatCircle->get_dtt_ddepth(value);
2023}
2024
2025//inline void SlbmInterface::get_dtt_dlat_fast(double& value)
2026//{
2027// if (!isValid())
2028// {
2029// value = NA_VALUE;
2030// ostringstream os;
2031// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2032// os << endl << "ERROR in SlbmInterface::get_dtt_dlat" << endl
2033// << "GreatCircle is invalid." << endl
2034// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2035// throw SLBMException(os.str(),113);
2036// }
2037// greatCircle->get_dtt_dlat_fast(value);
2038//}
2039//
2040//inline void SlbmInterface::get_dtt_dlon_fast(double& value)
2041//{
2042// if (!isValid())
2043// {
2044// value = NA_VALUE;
2045// ostringstream os;
2046// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2047// os << endl << "ERROR in SlbmInterface::get_dtt_dlon" << endl
2048// << "GreatCircle is invalid." << endl
2049// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2050// throw SLBMException(os.str(),113);
2051// }
2052// greatCircle->get_dtt_dlon_fast(value);
2053//}
2054//
2055//inline void SlbmInterface::get_dsh_ddist(double& value)
2056//{
2057// if (!isValid())
2058// {
2059// value = NA_VALUE;
2060// ostringstream os;
2061// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2062// os << endl << "ERROR in SlbmInterface::get_dsh_ddist" << endl
2063// << "GreatCircle is invalid." << endl
2064// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2065// throw SLBMException(os.str(),113);
2066// }
2067// greatCircle->get_dsh_ddist(value);
2068//}
2069//
2070//inline void SlbmInterface::get_dsh_dlat(double& value)
2071//{
2072// if (!isValid())
2073// {
2074// value = NA_VALUE;
2075// ostringstream os;
2076// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2077// os << endl << "ERROR in SlbmInterface::get_dsh_dlat" << endl
2078// << "GreatCircle is invalid." << endl
2079// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2080// throw SLBMException(os.str(),113);
2081// }
2082// greatCircle->get_dsh_dlat(value);
2083//}
2084//
2085//inline void SlbmInterface::get_dsh_dlon(double& value)
2086//{
2087// if (!isValid())
2088// {
2089// value = NA_VALUE;
2090// ostringstream os;
2091// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2092// os << endl << "ERROR in SlbmInterface::get_dsh_dlon" << endl
2093// << "GreatCircle is invalid." << endl
2094// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2095// throw SLBMException(os.str(),113);
2096// }
2097// greatCircle->get_dsh_dlon(value);
2098//}
2099//
2100//inline void SlbmInterface::get_dsh_ddepth(double& value)
2101//{
2102// if (!isValid())
2103// {
2104// value = NA_VALUE;
2105// ostringstream os;
2106// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2107// os << endl << "ERROR in SlbmInterface::get_dsh_ddepth" << endl
2108// << "GreatCircle is invalid." << endl
2109// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2110// throw SLBMException(os.str(),113);
2111// }
2112// greatCircle->get_dsh_ddepth(value);
2113//}
2114
2115 inline void SlbmInterface::getSlowness(double& value)
2116{
2117 if (!isValid())
2118 {
2119 value = NA_VALUE;
2120 ostringstream os;
2121 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2122 os << endl << "ERROR in SlbmInterface::getSlowness" << endl
2123 << "GreatCircle is invalid." << endl
2124 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2125 throw SLBMException(os.str(),113);
2126 }
2127 greatCircle->get_dtt_ddist(value);
2128}
2129
2130 inline double SlbmInterface::getDistance()
2131{
2132 if (greatCircle == NULL)
2133 {
2134 Location s(srcLat, srcLon, 0.);
2135 Location r(rcvLat, rcvLon, 0.);
2136 return s.distance(r);
2137 }
2138 else
2139 return greatCircle->getDistance();
2140}
2141
2142 inline void SlbmInterface::getSourceDistance(double& distance)
2143{
2144 if (!isValid())
2145 {
2146 distance = NA_VALUE;
2147 ostringstream os;
2148 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2149 os << endl << "ERROR in SlbmInterface::getSourceDistance" << endl
2150 << "GreatCircle is invalid." << endl
2151 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2152 throw SLBMException(os.str(),113);
2153 }
2154 distance = greatCircle->getSourceDistance();
2155}
2156
2157 inline void SlbmInterface::getReceiverDistance(double& distance)
2158{
2159 if (!isValid())
2160 {
2161 distance = NA_VALUE;
2162 ostringstream os;
2163 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2164 os << endl << "ERROR in SlbmInterface::getReceiverDistance" << endl
2165 << "GreatCircle is invalid." << endl
2166 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2167 throw SLBMException(os.str(),113);
2168 }
2169 distance = greatCircle->getReceiverDistance();
2170}
2171
2172 inline void SlbmInterface::getHeadwaveDistance(double& distance)
2173{
2174 if (!isValid())
2175 {
2176 distance = NA_VALUE;
2177 ostringstream os;
2178 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2179 os << endl << "ERROR in SlbmInterface::getHeadwaveDistance" << endl
2180 << "GreatCircle is invalid." << endl
2181 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2182 throw SLBMException(os.str(),113);
2183 }
2184 distance = greatCircle->getHeadwaveDistance();
2185}
2186
2187 inline void SlbmInterface::getHeadwaveDistanceKm(double& distance)
2188{
2189 if (!isValid())
2190 {
2191 distance = NA_VALUE;
2192 ostringstream os;
2193 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2194 os << endl << "ERROR in SlbmInterface::getHeadwaveDistanceKm" << endl
2195 << "GreatCircle is invalid." << endl
2196 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2197 throw SLBMException(os.str(),113);
2198 }
2199 distance = greatCircle->getHeadwaveDistanceKm();
2200}
2201
2202 inline void SlbmInterface::getTravelTime(double& tTotal)
2203{
2204 if (!isValid())
2205 {
2206 tTotal = NA_VALUE;
2207 ostringstream os;
2208 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2209 os << endl << "ERROR in SlbmInterface::getTravelTime" << endl
2210 << "GreatCircle is invalid." << endl
2211 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2212 throw SLBMException(os.str(),113);
2213 }
2214 tTotal=greatCircle->getTravelTime();
2215}
2216
2217 inline void SlbmInterface::getTravelTimeComponents(
2218 double& tTotal, double& tSource, double& tReceiver,
2219 double& tHeadwave, double& tGradient)
2220{
2221 if (!isValid())
2222 {
2223 tTotal = NA_VALUE;
2224 tSource = NA_VALUE;
2225 tReceiver = NA_VALUE;
2226 tHeadwave = NA_VALUE;
2227 tGradient = NA_VALUE;
2228 ostringstream os;
2229 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2230 os << endl << "ERROR in SlbmInterface::getTravelTimeComponents" << endl
2231 << "GreatCircle is invalid." << endl
2232 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2233 throw SLBMException(os.str(),113);
2234 }
2235 greatCircle->getTravelTime(tTotal, tSource, tReceiver,
2236 tHeadwave, tGradient);
2237}
2238
2239 inline void SlbmInterface::getWeights(int nodeId[], double weight[], int& nWeights)
2240{
2241 if (!isValid())
2242 {
2243 nWeights=-1;
2244 ostringstream os;
2245 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2246 os << endl << "ERROR in SlbmInterface::getWeights" << endl
2247 << "GreatCircle is invalid." << endl
2248 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2249 throw SLBMException(os.str(),113);
2250 }
2251 greatCircle->getWeights(nodeId, weight, nWeights);
2252}
2253
2254 inline void SlbmInterface::getActiveNodeWeights(int nodeId[], double weight[], int& nWeights)
2255{
2256 getWeights(nodeId, weight, nWeights);
2257 for (int i=0; i<nWeights; ++i)
2258 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
2259}
2260
2261 inline void SlbmInterface::getWeights(vector<int>& nodeId, vector<double>& weight)
2262{
2263 if (!isValid())
2264 {
2265 nodeId.clear();
2266 weight.clear();
2267 ostringstream os;
2268 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2269 os << endl << "ERROR in SlbmInterface::getWeights" << endl
2270 << "GreatCircle is invalid." << endl
2271 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2272 throw SLBMException(os.str(),113);
2273 }
2274 greatCircle->getWeights(nodeId, weight);
2275}
2276
2277 inline void SlbmInterface::getActiveNodeWeights(vector<int>& nodeId, vector<double>& weight)
2278{
2279 getWeights(nodeId, weight);
2280 for (int i=0; i<(int)nodeId.size(); ++i)
2281 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
2282}
2283
2284 inline void SlbmInterface::getWeightsSource(int nodeids[], double weights[], int& nWeights)
2285{
2286 if (!isValid())
2287 {
2288 ostringstream os;
2289 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2290 os << endl << "ERROR in SlbmInterface::getWeightsSource" << endl
2291 << "GreatCircle is invalid." << endl
2292 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2293 throw SLBMException(os.str(),113);
2294 }
2295 greatCircle->getSourceProfile()->getWeights(nodeids, weights, nWeights);
2296}
2297
2298 inline void SlbmInterface::getWeightsSource(vector<int> &nodeids, vector<double> &weights)
2299{
2300 // get the number of weights
2301 int nWeights = greatCircle->getSourceProfile()->getNCoefficients();
2302
2303 // resize arrays to proper size
2304 nodeids.resize(nWeights);
2305 weights.resize(nWeights);
2306
2307 // call getWeightsSource (v.data() sends a pointer similar to a c++ array)
2308 getWeightsSource(nodeids.data(), weights.data(), nWeights);
2309}
2310
2311 inline void SlbmInterface::getActiveNodeWeightsSource(int nodeids[], double weights[], int& nWeights)
2312{
2313 getWeightsSource(nodeids, weights, nWeights);
2314 for (int i=0; i<nWeights; ++i)
2315 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2316}
2317
2318 inline void SlbmInterface::getActiveNodeWeightsSource(vector<int> &nodeids, vector<double> &weights)
2319{
2320 // get the number of weights
2321 int nWeights = greatCircle->getSourceProfile()->getNCoefficients();
2322
2323 // resize arrays to proper size
2324 nodeids.resize(nWeights);
2325 weights.resize(nWeights);
2326
2327 // call getActiveNodeWeightsSource (v.data() sends a pointer similar to a c++ array)
2328 getActiveNodeWeightsSource(nodeids.data(), weights.data(), nWeights);
2329}
2330
2331 inline void SlbmInterface::getWeightsReceiver(int nodeids[], double weights[], int& nWeights)
2332{
2333 if (!isValid())
2334 {
2335 ostringstream os;
2336 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2337 os << endl << "ERROR in SlbmInterface::getWeightsReceiver" << endl
2338 << "GreatCircle is invalid." << endl
2339 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2340 throw SLBMException(os.str(),113);
2341 }
2342 greatCircle->getReceiverProfile()->getWeights(nodeids, weights, nWeights);
2343}
2344
2345 inline void SlbmInterface::getWeightsReceiver(vector<int> &nodeids, vector<double> &weights)
2346{
2347 // get the number of weights
2348 int nWeights = greatCircle->getReceiverProfile()->getNCoefficients();
2349
2350 // resize arrays to proper size
2351 nodeids.resize(nWeights);
2352 weights.resize(nWeights);
2353
2354 // call getActiveNodeWeightsSource (v.data() sends a pointer similar to a c++ array)
2355 getWeightsReceiver(nodeids.data(), weights.data(), nWeights);
2356}
2357
2358 inline void SlbmInterface::getActiveNodeWeightsReceiver(int nodeids[], double weights[], int& nWeights)
2359{
2360 getWeightsReceiver(nodeids, weights, nWeights);
2361 for (int i=0; i<nWeights; ++i)
2362 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2363}
2364
2365 inline void SlbmInterface::getActiveNodeWeightsReceiver(vector<int> &nodeids, vector<double> &weights)
2366{
2367 // get the number of weights
2368 int nWeights = greatCircle->getReceiverProfile()->getNCoefficients();
2369
2370 // resize arrays to proper size
2371 nodeids.resize(nWeights);
2372 weights.resize(nWeights);
2373
2374 // call getActiveNodeWeightsSource (v.data() sends a pointer similar to a c++ array)
2375 getActiveNodeWeightsReceiver(nodeids.data(), weights.data(), nWeights);
2376}
2377
2378 inline string SlbmInterface::toString(const int& verbosity)
2379{
2380 if (!isValid())
2381 {
2382 ostringstream os;
2383 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2384 os << endl << "ERROR in SlbmInterface::toString" << endl
2385 << "GreatCircle is invalid." << endl
2386 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2387 throw SLBMException(os.str(),113);
2388 }
2389
2390 ostringstream os;
2391 if (verbosity > 0)
2392 {
2393 os << endl
2394 << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
2395 << "Great Circle " << endl << endl
2396 << greatCircle->toString(verbosity);
2397
2398 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint)
2399 << setprecision(4);
2400 double slowness;
2401 getSlowness(slowness);
2402 os << endl << "Horizontal slowness = "
2403 << slowness << " sec/radian"
2404 << endl << endl;
2405 }
2406
2407 return os.str();
2408}
2409
2410 inline void SlbmInterface::getGreatCircleData(
2411 string& phase,
2412 double& actual_path_increment,
2413 double sourceDepth[NLAYERS],
2414 double sourceVelocity[NLAYERS],
2415 double receiverDepth[NLAYERS],
2416 double receiverVelocity[NLAYERS],
2417 int& npoints,
2418 double headWaveVelocity[],
2419 double gradient[]
2420 )
2421{
2422 if (!isValid())
2423 {
2424 phase = "";
2425 actual_path_increment = NA_VALUE;
2426 ostringstream os;
2427 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2428 os << endl << "ERROR in SlbmInterface::getGreatCircleData" << endl
2429 << "GreatCircle is invalid." << endl
2430 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2431 throw SLBMException(os.str(),113);
2432 }
2433
2434 int p;
2435 greatCircle->getData(p, actual_path_increment,
2436 sourceDepth, sourceVelocity, receiverDepth, receiverVelocity,
2437 npoints, headWaveVelocity, gradient);
2438 phase = (p==Pn ? "Pn" : (p==Sn ? "Sn" : (p==Pg ? "Pg" : (p==Lg ? "Lg"
2439 : "unknown phase"))));
2440}
2441
2442 inline void SlbmInterface::getGreatCircleData(
2443 string &phase,
2444 double &actual_path_increment,
2445 vector<double> &sourceDepth,
2446 vector<double> &sourceVelocity,
2447 vector<double> &receiverDepth,
2448 vector<double> &receiverVelocity,
2449 int &npoints,
2450 vector<double> &headWaveVelocity,
2451 vector<double> &gradient
2452 )
2453{
2454 if (!isValid())
2455 {
2456 phase = "";
2457 actual_path_increment = NA_VALUE;
2458 ostringstream os;
2459 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2460 os << endl << "ERROR in SlbmInterface::getGreatCircleData" << endl
2461 << "GreatCircle is invalid." << endl
2462 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2463 throw SLBMException(os.str(),113);
2464 }
2465
2466 // figure out how many points there are
2467 getNHeadWavePoints(npoints);
2468
2469 // make some room in memory
2470 sourceDepth.resize(NLAYERS);
2471 sourceVelocity.resize(NLAYERS);
2472 receiverDepth.resize(NLAYERS);
2473 receiverVelocity.resize(NLAYERS);
2474 headWaveVelocity.resize(npoints);
2475 gradient.resize(npoints);
2476
2477 int p;
2478 greatCircle->getData(p, actual_path_increment,
2479 sourceDepth.data(), sourceVelocity.data(), receiverDepth.data(),
2480 receiverVelocity.data(), npoints, headWaveVelocity.data(), gradient.data());
2481 phase = (p==Pn ? "Pn" : (p==Sn ? "Sn" : (p==Pg ? "Pg" : (p==Lg ? "Lg"
2482 : "unknown phase"))));
2483}
2484
2485 inline void SlbmInterface::getGreatCircleNodeInfo(
2486 int** neighbors,
2487 double** coefficients,
2488 const int& maxpoints,
2489 const int& maxnodes,
2490 int& npoints,
2491 int* nnodes
2492 )
2493{
2494 if (!isValid())
2495 {
2496 ostringstream os;
2497 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2498 os << endl << "ERROR in SlbmInterface::getGreatCircleNodeInfo" << endl
2499 << "GreatCircle is invalid." << endl
2500 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2501 throw SLBMException(os.str(),113);
2502 }
2503
2504 greatCircle->getNodeInfo(neighbors, coefficients, maxpoints, maxnodes, npoints, nnodes);
2505}
2506 inline void SlbmInterface::getGreatCircleNodeInfo(
2507 vector<vector<int> >& neighbors, vector<vector<double> >& coefficients)
2508 {
2509 if (!isValid())
2510 {
2511 ostringstream os;
2512 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2513 os << endl << "ERROR in SlbmInterface::getGreatCircleNodeInfo" << endl
2514 << "GreatCircle is invalid." << endl
2515 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2516 throw SLBMException(os.str(),113);
2517 }
2518
2519 greatCircle->getNodeInfo(neighbors, coefficients);
2520 }
2521
2522 inline void SlbmInterface::getGreatCircleLocations(
2523 double lat[],
2524 double lon[],
2525 double depth[],
2526 int& npoints
2527 )
2528{
2529 if (!isValid())
2530 {
2531 ostringstream os;
2532 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2533 os << endl << "ERROR in SlbmInterface::getGreatCircleData" << endl
2534 << "GreatCircle is invalid." << endl
2535 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2536 throw SLBMException(os.str(),113);
2537 }
2538
2539 npoints = greatCircle->getNProfiles();
2540 Location loc;
2541 for (int i=0; i<greatCircle->getNProfiles(); i++)
2542 {
2543 // get the location of this layer profile
2544 greatCircle->getLayerProfileLocation(i, loc);
2545 lat[i] = loc.getLat();
2546 lon[i] = loc.getLon();
2547 depth[i] = loc.getDepth();
2548 }
2549}
2550
2551 inline void SlbmInterface::getGreatCircleLocations(
2552 vector<double> &lat,
2553 vector<double> &lon,
2554 vector<double> &depth
2555 )
2556{
2557 if (!isValid())
2558 {
2559 ostringstream os;
2560 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2561 os << endl << "ERROR in SlbmInterface::getGreatCircleData" << endl
2562 << "GreatCircle is invalid." << endl
2563 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2564 throw SLBMException(os.str(),113);
2565 }
2566 int npoints = getNHeadWavePoints();
2567 lat.resize(npoints);
2568 lon.resize(npoints);
2569 depth.resize(npoints);
2570 getGreatCircleLocations(lat.data(), lon.data(), depth.data(), npoints);
2571}
2572
2573
2574 inline void SlbmInterface::getInterpolatedPoint(
2575 const double& lat,
2576 const double& lon,
2577 int* nodeIds,
2578 double* coefficients,
2579 int& nWeights,
2580 double depth[NLAYERS],
2581 double pvelocity[NLAYERS],
2582 double svelocity[NLAYERS],
2583 double& pgradient,
2584 double& sgradient
2585 )
2586{
2587 Location location(lat, lon, 0.);
2588 QueryProfile* profile = grid->getQueryProfile(location);
2589 profile->getData(nodeIds, coefficients, nWeights, depth, pvelocity, svelocity, pgradient, sgradient);
2590 delete profile;
2591}
2592
2593 inline void SlbmInterface::getInterpolatedPoint(
2594 const double &lat,
2595 const double &lon,
2596 vector<int> &nodeIds,
2597 vector<double> &coefficients,
2598 vector<double> &depth,
2599 vector<double> &pvelocity,
2600 vector<double> &svelocity,
2601 double &pgradient,
2602 double &sgradient
2603 )
2604{
2605 // create a new location at the lat/lon
2606 Location location(lat, lon, 0.);
2607
2608 // interpolate a profile at that location
2609 QueryProfile* profile = grid->getQueryProfile(location);
2610
2611 // get the number of points used for that interpolation
2612 int nWeights = profile->getNCoefficients();
2613
2614 // allocate some memory
2615 nodeIds.resize(nWeights);
2616 coefficients.resize(nWeights);
2617 depth.resize(NLAYERS);
2618 pvelocity.resize(NLAYERS);
2619 svelocity.resize(NLAYERS);
2620
2621 // call the method
2622 profile->getData(nodeIds.data(), coefficients.data(), nWeights,
2623 depth.data(), pvelocity.data(), svelocity.data(), pgradient, sgradient);
2624 delete profile;
2625}
2626
2627 inline void SlbmInterface::getInterpolatedTransect(
2628 double lat[],
2629 double lon[],
2630 const int& nLatLon,
2631 int** nodeId,
2632 double** coefficients,
2633 int* nNeighbors,
2634 double depth[][NLAYERS],
2635 double pvelocity[][NLAYERS],
2636 double svelocity[][NLAYERS],
2637 double pgradient[NLAYERS],
2638 double sgradient[NLAYERS],
2639 int& nInvalid
2640 )
2641{
2642 nInvalid = 0;
2643 for (int i=0; i<nLatLon; i++)
2644 {
2645 try
2646 {
2647 getInterpolatedPoint(lat[i], lon[i], nodeId[i],
2648 coefficients[i], nNeighbors[i], depth[i], pvelocity[i], svelocity[i],
2649 pgradient[i], sgradient[i]);
2650 }
2651 catch (SLBMException ex)
2652 {
2653 for (int j=0; j<nNeighbors[i]; j++)
2654 {
2655 nodeId[i][j] = -1;
2656 coefficients[i][j] = NA_VALUE;
2657 }
2658
2659 for (int j=0; j<NLAYERS; j++)
2660 {
2661 depth[i][j] = NA_VALUE;
2662 pvelocity[i][j] = NA_VALUE;
2663 svelocity[i][j] = NA_VALUE;
2664 }
2665
2666 pgradient[i] = NA_VALUE;
2667 sgradient[i] = NA_VALUE;
2668
2669 ++nInvalid;
2670 }
2671 }
2672}
2673 inline void SlbmInterface::getInterpolatedTransect(
2674 vector<double> lat,
2675 vector<double> lon,
2676 vector<vector<int> > &nodeId,
2677 vector<vector<double> > &coefficients,
2678 vector<vector<double> > &depth,
2679 vector<vector<double> > &pvelocity,
2680 vector<vector<double> > &svelocity,
2681 vector<double> &pgradient,
2682 vector<double> &sgradient,
2683 int &nInvalid
2684 )
2685{
2686 nInvalid = 0;
2687
2688 // check lat/lon sizes match
2689 int nLatLon;
2690 if (lat.size() == lon.size())
2691 {
2692 nLatLon = lat.size();
2693 }
2694 else
2695 {
2696 ostringstream os;
2697 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2698 os << endl << "ERROR in SlbmInterface::getInterpolatedTransect" << endl
2699 << "Size of lat and lon vectors do not match." << endl
2700 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2701 throw SLBMException(os.str(),114);
2702 }
2703
2704 // resize vectors
2705 nodeId.resize(nLatLon);
2706 coefficients.resize(nLatLon);
2707 depth.resize(nLatLon);
2708 pvelocity.resize(nLatLon);
2709 svelocity.resize(nLatLon);
2710 pgradient.resize(nLatLon);
2711 sgradient.resize(nLatLon);
2712 for (int i=0; i<nLatLon; i++)
2713 {
2714 depth[i].resize(NLAYERS);
2715 pvelocity[i].resize(NLAYERS);
2716 svelocity[i].resize(NLAYERS);
2717 }
2718
2719
2720 for (int i=0; i<nLatLon; i++)
2721 {
2722 try
2723 {
2724 // create a new Location at the input lat/lon
2725 Location location(lat[i], lon[i], 0.);
2726
2727 // interpolate a profile at that location
2728 QueryProfile profile(*grid, location); // create a query profile at that location
2729
2730 // get the number of points used for that interpolation
2731 int nWeights = profile.getNCoefficients();
2732
2733 // resize vectors
2734 nodeId[i].resize(nWeights);
2735 coefficients[i].resize(nWeights);
2736
2737 getInterpolatedPoint(lat[i], lon[i], nodeId[i].data(), coefficients[i].data(), nWeights,
2738 depth[i].data(), pvelocity[i].data(), svelocity[i].data(), pgradient[i], sgradient[i]);
2739
2740 }
2741 catch (SLBMException ex)
2742 {
2743 nodeId[i].push_back(-1);
2744 coefficients[i].push_back(NA_VALUE);
2745 pgradient[i] = NA_VALUE;
2746 sgradient[i] = NA_VALUE;
2747
2748 for (int j=0; j<NLAYERS; j++)
2749 {
2750 depth[i][j] = NA_VALUE;
2751 pvelocity[i][j] = NA_VALUE;
2752 svelocity[i][j] = NA_VALUE;
2753 }
2754
2755 ++nInvalid;
2756 }
2757 }
2758}
2759
2760 inline void SlbmInterface::getNGridNodes(int& n)
2761{
2762 if (!grid)
2763 {
2764 n = -1;
2765 ostringstream os;
2766 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2767 os << endl << "ERROR in SlbmInterface::getNGridNodes" << endl
2768 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2769 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2770 throw SLBMException(os.str(),114);
2771 }
2772 n = grid->getNNodes();
2773}
2774
2775 inline int SlbmInterface::getNGridNodes()
2776{
2777 if (!grid)
2778 {
2779 ostringstream os;
2780 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2781 os << endl << "ERROR in SlbmInterface::getNGridNodes" << endl
2782 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2783 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2784 throw SLBMException(os.str(),114);
2785 }
2786 return grid->getNNodes();
2787}
2788
2789 inline void SlbmInterface::getNHeadWavePoints(int& nHeadWavePoints)
2790{
2791 if (!greatCircle)
2792 {
2793 nHeadWavePoints = -1;
2794 ostringstream os;
2795 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2796 os << endl << "ERROR in SlbmInterface::getNHeadWavePoints" << endl
2797 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2798 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2799 throw SLBMException(os.str(),113);
2800 }
2801 nHeadWavePoints = greatCircle->getNProfiles();
2802}
2803
2804//inline void SlbmInterface::getMaxInterpotionNodes(int& maxNodes)
2805//{
2806// if (!greatCircle)
2807// {
2808// nHeadWavePoints = -1;
2809// ostringstream os;
2810// os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2811// os << endl << "ERROR in SlbmInterface::getMaxInterpotionNodes" << endl
2812// << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2813// << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2814// throw SLBMException(os.str(),113);
2815// }
2816//
2817// maxNodes = 1;
2818// for (int i=0; i<greatCircle->getNProfiles(); i++)
2819// if (greatCircle->profiles[i]->getNodes().size() > maxNodes)
2820// maxNodes = greatCircle->profiles[i]->getNodes().size();
2821//}
2822
2823 inline void SlbmInterface::getSlownessUncertainty( const int& phase, const double& distance, double& uncert )
2824{
2825 if (!grid)
2826 {
2827 ostringstream os;
2828 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2829 os << endl << "ERROR in SlbmInterface::getSlownessUncertainty" << endl
2830 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2831 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2832 throw SLBMException(os.str(),114);
2833 }
2834
2835 if (grid->getUncertainty()[phase][SH] == NULL)
2836 {
2837 ostringstream os;
2838 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2839 os << endl << "ERROR in SlbmInterface::getSlownessUncertainty" << endl
2840 << "Uncertainty object is invalid.." << endl
2841 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2842 throw SLBMException(os.str(),602);
2843 }
2844 else
2845 {
2846 // retrieve slowness uncertainty in sec/radian
2847 uncert = grid->getUncertainty()[phase][SH]->getUncertainty( distance );
2848 }
2849}
2850
2851 inline void SlbmInterface::getSlownessUncertainty(double& slownessUncertainty)
2852{
2853 if (!grid)
2854 {
2855 ostringstream os;
2856 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2857 os << endl << "ERROR in SlbmInterface::getSlownessUncertainty" << endl
2858 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2859 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2860 throw SLBMException(os.str(),114);
2861 }
2862
2863 getSlownessUncertainty(greatCircle->getPhase(),
2864 greatCircle->getDistance(), slownessUncertainty);
2865}
2866
2867 inline string SlbmInterface::getUncertaintyTable(const int& phase, const int& attribute)
2868{
2869 if (!grid)
2870 {
2871 ostringstream os;
2872 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2873 os << endl << "ERROR in SlbmInterface::getUncertaintyTable" << endl
2874 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2875 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2876 throw SLBMException(os.str(),114);
2877 }
2878
2879 if (grid->getUncertainty()[phase][attribute] == NULL)
2880 {
2881 ostringstream os;
2882 os << "No uncertainty information is available for phase " <<
2883 UncertaintyPIU::getPhase(phase) << " attribute " <<
2884 UncertaintyPIU::getAttribute(attribute) << endl;
2885 return os.str();
2886 }
2887 return grid->getUncertainty()[phase][attribute]->toStringTable();
2888}
2889
2890 inline string SlbmInterface::getUncertaintyFileFormat(const int& phase, const int& attribute)
2891{
2892 if (!grid)
2893 {
2894 ostringstream os;
2895 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2896 os << endl << "ERROR in SlbmInterface::getUncertaintyFileFormat" << endl
2897 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2898 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2899 throw SLBMException(os.str(),114);
2900 }
2901
2902 if (grid->getUncertainty()[phase][attribute] == NULL)
2903 {
2904 ostringstream os;
2905 os << "No uncertainty information is available for phase " << phase << " attribute " << attribute << endl;
2906 return os.str();
2907 }
2908 return grid->getUncertainty()[phase][attribute]->toStringFile();
2909}
2910
2911 inline void SlbmInterface::getZhaoParameters(double& Vm, double& Gm, double& H, double& C, double& Cm, int& udSign)
2912{
2913 if (!greatCircle)
2914 {
2915 ostringstream os;
2916 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2917 os << endl << "ERROR in SlbmInterface::getZhaoParameters" << endl
2918 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2919 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2920 throw SLBMException(os.str(),113);
2921 }
2922 greatCircle->getZhaoParameters(Vm, Gm, H, C, Cm, udSign);
2923}
2924
2925 inline void SlbmInterface::getPgLgComponents(double& tTotal,
2926 double& tTaup, double& tHeadwave,
2927 double& pTaup, double& pHeadwave,
2928 double& trTaup, double& trHeadwave)
2929{
2930 if (!greatCircle)
2931 {
2932 ostringstream os;
2933 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2934 os << endl << "ERROR in SlbmInterface::getPgLgComponents" << endl
2935 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2936 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2937 throw SLBMException(os.str(),113);
2938 }
2939 greatCircle->getPgLgComponents(tTotal, tTaup, tHeadwave,
2940 pTaup, pHeadwave, trTaup, trHeadwave);
2941}
2942
2943
2944 inline void SlbmInterface::getNodeNeighbors(const int& nid, int neighbors[], int& nNeighbors)
2945{
2946 if (!grid)
2947 {
2948 ostringstream os;
2949 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2950 os << endl << "ERROR in SlbmInterface::getNodeNeighbors" << endl
2951 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2952 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2953 throw SLBMException(os.str(),114);
2954 }
2955 grid->getNodeNeighbors(nid, neighbors, nNeighbors);
2956}
2957
2958 inline void SlbmInterface::getActiveNodeNeighbors(const int& nid, int neighbors[], int& nNeighbors)
2959{
2960 if (!grid)
2961 {
2962 ostringstream os;
2963 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2964 os << endl << "ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2965 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2966 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2967 throw SLBMException(os.str(),114);
2968 }
2969 grid->getActiveNodeNeighbors(nid, neighbors, nNeighbors);
2970}
2971
2972 inline void SlbmInterface::getNodeNeighbors(const int& nid, vector<int>& neighbors)
2973{
2974 if (!grid)
2975 {
2976 ostringstream os;
2977 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2978 os << endl << "ERROR in SlbmInterface::getNodeNeighbors" << endl
2979 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2980 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2981 throw SLBMException(os.str(),114);
2982 }
2983 grid->getNodeNeighbors(nid, neighbors);
2984}
2985
2986 inline void SlbmInterface::getActiveNodeNeighbors(const int& nid, vector<int>& neighbors)
2987{
2988 if (!grid)
2989 {
2990 ostringstream os;
2991 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2992 os << endl << "ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2993 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2994 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
2995 throw SLBMException(os.str(),114);
2996 }
2997 grid->getActiveNodeNeighbors(nid, neighbors);
2998}
2999
3000 inline void SlbmInterface::getNodeNeighborInfo(const int& nid, int neighbors[],
3001 double distance[], double azimuth[], int& nNeighbors)
3002{
3003 if (!grid)
3004 {
3005 ostringstream os;
3006 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3007 os << endl << "ERROR in SlbmInterface::getNodeNeighborInfo" << endl
3008 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3009 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3010 throw SLBMException(os.str(),114);
3011 }
3012 grid->getNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
3013}
3014
3015 inline void SlbmInterface::getNodeNeighborInfo(const int nid,
3016 vector<int> &neighbors, vector<double> &distance, vector<double> &azimuth)
3017{
3018 if (!grid)
3019 {
3020 ostringstream os;
3021 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3022 os << endl << "ERROR in SlbmInterface::getNodeNeighborInfo" << endl
3023 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3024 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3025 throw SLBMException(os.str(),114);
3026 }
3027 grid->getNodeNeighborInfo(nid, neighbors, distance, azimuth);
3028}
3029
3030 inline void SlbmInterface::getActiveNodeNeighborInfo(const int& nid, int neighbors[],
3031 double distance[], double azimuth[], int& nNeighbors)
3032{
3033 if (!grid)
3034 {
3035 ostringstream os;
3036 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3037 os << endl << "ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
3038 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3039 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3040 throw SLBMException(os.str(),114);
3041 }
3042 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
3043}
3044
3045 inline void SlbmInterface::getActiveNodeNeighborInfo(const int& nid,
3046 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth)
3047{
3048 if (!grid)
3049 {
3050 ostringstream os;
3051 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3052 os << endl << "ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
3053 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3054 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3055 throw SLBMException(os.str(),114);
3056 }
3057 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth);
3058}
3059
3060 inline void SlbmInterface::getNodeSeparation(const int& node1, const int& node2, double& distance)
3061{
3062 if (!grid)
3063 {
3064 ostringstream os;
3065 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3066 os << endl << "ERROR in SlbmInterface::getNodeSeparation" << endl
3067 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3068 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3069 throw SLBMException(os.str(),114);
3070 }
3071 grid->getNodeSeparation(node1, node2, distance);
3072}
3073
3074 inline void SlbmInterface::getNodeAzimuth(const int& node1, const int& node2, double& azimuth)
3075{
3076 if (!grid)
3077 {
3078 ostringstream os;
3079 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3080 os << endl << "ERROR in SlbmInterface::getNodeAzimuth" << endl
3081 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3082 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3083 throw SLBMException(os.str(),114);
3084 }
3085 grid->getNodeAzimuth(node1, node2, azimuth);
3086}
3087
3088 inline void SlbmInterface::initializeActiveNodes(const double& latmin, const double& lonmin,
3089 const double& latmax, const double& lonmax)
3090{
3091 if (!grid)
3092 {
3093 ostringstream os;
3094 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3095 os << endl << "ERROR in SlbmInterface::initializeActiveNodes" << endl
3096 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3097 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3098 throw SLBMException(os.str(),114);
3099 }
3100 grid->initializeActiveNodes(latmin, lonmin, latmax, lonmax);
3101}
3102
3103 inline void SlbmInterface::initializeActiveNodes(double* lat, double* lon, const int& npoints, const bool& inDegrees)
3104{
3105 vector<double*> v;
3106 v.reserve(npoints);
3107 if (inDegrees)
3108 for (int i=0; i<npoints; ++i)
3109 v.push_back(GeoTessUtils::getVectorDegrees(lat[i], lon[i]));
3110 else
3111 for (int i=0; i<npoints; ++i)
3112 v.push_back(GeoTessUtils::getVector(lat[i], lon[i]));
3113 initializeActiveNodes(v);
3114}
3115 inline void SlbmInterface::initializeActiveNodes(const vector<double> lat, const vector<double> lon, const bool& inDegrees)
3116{
3117 int npoints;
3118 if (lat.size() == lon.size())
3119 {
3120 npoints = lat.size();
3121 }
3122 else
3123 {
3124 ostringstream os;
3125 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3126 os << endl << "ERROR in SlbmInterface::getInterpolatedTransect" << endl
3127 << "Size of lat and lon vectors do not match." << endl
3128 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3129 throw SLBMException(os.str(),114);
3130 }
3131 vector<double*> v;
3132 v.reserve(npoints);
3133 if (inDegrees)
3134 for (int i=0; i<npoints; ++i)
3135 v.push_back(GeoTessUtils::getVectorDegrees(lat[i], lon[i]));
3136 else
3137 for (int i=0; i<npoints; ++i)
3138 v.push_back(GeoTessUtils::getVector(lat[i], lon[i]));
3139 initializeActiveNodes(v);
3140}
3141
3142 inline void SlbmInterface::initializeActiveNodes(vector<double*>& unitVectors)
3143{
3144 initializeActiveNodes(new GeoTessPolygon(unitVectors));
3145}
3146
3147 inline void SlbmInterface::initializeActiveNodes(GeoTessPolygon* polygon)
3148{
3149 grid->initializeActiveNodes(polygon);
3150}
3151
3152 inline void SlbmInterface::initializeActiveNodes(const string& fileName)
3153{
3154 grid->initializeActiveNodes(new GeoTessPolygon(fileName));
3155}
3156
3157 inline void SlbmInterface::clearActiveNodes()
3158{
3159 grid->clearActiveNodes();
3160}
3161
3162
3163 inline int SlbmInterface::getNActiveNodes()
3164{
3165 if (!grid)
3166 {
3167 ostringstream os;
3168 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3169 os << endl << "ERROR in SlbmInterface::nextActiveNode" << endl
3170 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3171 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3172 throw SLBMException(os.str(),114);
3173 }
3174 return grid->getNActiveNodes();
3175}
3176
3177 inline int SlbmInterface::getGridNodeId(int activeNodeId)
3178{
3179 if (!grid)
3180 {
3181 ostringstream os;
3182 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3183 os << endl << "ERROR in SlbmInterface::getGridNodeId" << endl
3184 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3185 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3186 throw SLBMException(os.str(),114);
3187 }
3188 return grid->getGridNodeId(activeNodeId);
3189}
3190
3191 inline int SlbmInterface::getActiveNodeId(int gridNodeId)
3192{
3193 if (!grid)
3194 {
3195 ostringstream os;
3196 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3197 os << endl << "ERROR in SlbmInterface::getActiveNodeId" << endl
3198 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3199 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3200 throw SLBMException(os.str(),114);
3201 }
3202 return grid->getActiveNodeId(gridNodeId);
3203}
3204
3205 inline void SlbmInterface::getNodeHitCount(const int& nodeId, int& hitCount)
3206{
3207 if (!grid)
3208 {
3209 ostringstream os;
3210 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3211 os << endl << "ERROR in SlbmInterface::getNodeHitCount" << endl
3212 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3213 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3214 throw SLBMException(os.str(),114);
3215 }
3216 grid->getNodeHitCount(nodeId, hitCount);
3217}
3218
3219 inline void SlbmInterface::clearNodeHitCount()
3220{
3221 if (!grid)
3222 {
3223 ostringstream os;
3224 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3225 os << endl << "ERROR in SlbmInterface::clearNodeHitCount" << endl
3226 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3227 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3228 throw SLBMException(os.str(),114);
3229 }
3230 grid->clearNodeHitCount();
3231}
3232
3233 inline void SlbmInterface::getAverageMantleVelocity(const int& type, double& velocity)
3234{
3235 if (!grid)
3236 {
3237 ostringstream os;
3238 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3239 os << endl << "ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3240 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3241 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3242 throw SLBMException(os.str(),114);
3243 }
3244 velocity = grid->getAverageMantleVelocity(type);
3245}
3246
3247 inline double SlbmInterface::getAverageMantleVelocity(const int &type)
3248{
3249 if (!grid)
3250 {
3251 ostringstream os;
3252 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3253 os << endl << "ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3254 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3255 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3256 throw SLBMException(os.str(),114);
3257 }
3258 return grid->getAverageMantleVelocity(type);
3259}
3260
3261 inline void SlbmInterface::setAverageMantleVelocity(const int& type,
3262 const double& velocity)
3263{
3264 if (!grid)
3265 {
3266 ostringstream os;
3267 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3268 os << endl << "ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3269 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3270 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3271 throw SLBMException(os.str(),114);
3272 }
3273 grid->setAverageMantleVelocity(type, velocity);
3274}
3275
3276 inline void SlbmInterface::getTessId(string& tessId)
3277{
3278 if (!grid)
3279 {
3280 ostringstream os;
3281 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3282 os << endl << "ERROR in SlbmInterface::getTessId" << endl
3283 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3284 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3285 throw SLBMException(os.str(),114);
3286 }
3287 tessId = grid->getTessId();
3288}
3289
3290 inline void SlbmInterface::getFractionActive(double& fractionActive)
3291{
3292 if (!isValid())
3293 {
3294 fractionActive = NA_VALUE;
3295 ostringstream os;
3296 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3297 os << endl << "ERROR in SlbmInterface::getFractionActive" << endl
3298 << "GreatCircle is invalid." << endl
3299 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3300 throw SLBMException(os.str(),113);
3301 }
3302 fractionActive = greatCircle->getFractionActive();
3303}
3304
3305 inline string SlbmInterface::getClassCount()
3306{
3307 ostringstream os;
3308 os << "Class counts:" << endl;
3309 os << "GreatCircle = " << GreatCircle::getClassCount() << endl;
3310 os << "GridProfile = " << GridProfile::getClassCount() << endl;
3311 os << "GeoStack = " << GeoStack::getClassCount() << endl;
3312 os << "InterpolatedProfile = " << InterpolatedProfile::getClassCount() << endl;
3313 os << "CrustalProfile = " << CrustalProfile::getClassCount() << endl;
3314 os << "LayerProfile = " << LayerProfile::getClassCount() << endl;
3315 os << "QueryProfile = " << QueryProfile::getClassCount() << endl;
3316 os << "Location = " << Location::getClassCount() << endl;
3317 return os.str();
3318}
3319
3320 inline const string& SlbmInterface::getModelPath() const { return grid->getModelPath(); }
3321
3322 inline void SlbmInterface::getPiercePointSource(double& lat, double& lon, double& depth)
3323{
3324 if (!isValid())
3325 {
3326 lat = lon = NA_VALUE;
3327 ostringstream os;
3328 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3329 os << endl << "ERROR in SlbmInterface::getPiercePointSource" << endl
3330 << "GreatCircle is invalid." << endl
3331 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3332 throw SLBMException(os.str(),113);
3333 }
3334
3335
3336 if ((greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg) && !greatCircle->getSourceProfile()->isInCrust())
3337 {
3338 lat = lon = NA_VALUE;
3339 ostringstream os;
3340 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3341 os << endl << "ERROR in SlbmInterface::getPiercePointSource" << endl
3342 << "Cannot compute moho pierce points for crustal phase (" << getPhase() << ") when source is in the mantle." << endl
3343 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3344 throw SLBMException(os.str(),113);
3345 }
3346
3347 Location loc;
3348 greatCircle->getGreatCircleLocation(greatCircle->getSourceDistance(), loc);
3349
3350 lat = loc.getLat();
3351 lon = loc.getLon();
3352
3353 QueryProfile* profile = NULL;
3354 profile = grid->getQueryProfile(loc);
3355 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
3356 depth = profile->getDepth()[MIDDLE_CRUST_G];
3357 else
3358 depth = profile->getDepth()[MANTLE];
3359 delete profile;
3360}
3361
3362 inline void SlbmInterface::getPiercePointReceiver(double& lat, double& lon, double& depth)
3363{
3364 if (!isValid())
3365 {
3366 lat = lon = NA_VALUE;
3367 ostringstream os;
3368 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3369 os << endl << "ERROR in SlbmInterface::getPiercePointReceiver" << endl
3370 << "GreatCircle is invalid." << endl
3371 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3372 throw SLBMException(os.str(),113);
3373 }
3374
3375
3376 if ((greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg) && !greatCircle->getReceiverProfile()->isInCrust())
3377 {
3378 lat = lon = NA_VALUE;
3379 ostringstream os;
3380 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3381 os << endl << "ERROR in SlbmInterface::getPiercePointReceiver" << endl
3382 << "Cannot compute moho pierce points for crustal phase (" << getPhase() << ") when receiver is in the mantle." << endl
3383 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3384 throw SLBMException(os.str(),113);
3385 }
3386
3387 Location loc;
3388 greatCircle->getGreatCircleLocation(
3389 greatCircle->getDistance()-greatCircle->getReceiverDistance(), loc);
3390
3391 lat = loc.getLat();
3392 lon = loc.getLon();
3393
3394 QueryProfile* profile = NULL;
3395 profile = grid->getQueryProfile(loc);
3396 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
3397 depth = profile->getDepth()[MIDDLE_CRUST_G];
3398 else
3399 depth = profile->getDepth()[MANTLE];
3400 delete profile;
3401}
3402
3403 inline void SlbmInterface::getGreatCirclePoints(
3404 const double& aLat,
3405 const double& aLon,
3406 const double& bLat,
3407 const double& bLon,
3408 const int& npoints,
3409 double latitude[],
3410 double longitude[])
3411{
3412 Location a(aLat, aLon, 0.);
3413 Location b(bLat, bLon, 0.);
3414 double dx = a.distance(b)/(npoints-1);
3415
3416 double moveDirection[3];
3417 a.vectorTripleProduct(b, moveDirection);
3418 for (int i=0; i<npoints; i++)
3419 {
3420 a.move(moveDirection, i*dx, b);
3421 latitude[i] = b.getLat();
3422 longitude[i] = b.getLon();
3423 }
3424}
3425
3426 inline void SlbmInterface::getGreatCirclePoints(
3427 const double& aLat,
3428 const double& aLon,
3429 const double& bLat,
3430 const double& bLon,
3431 const int& npoints,
3432 vector<double> &latitude,
3433 vector<double> &longitude)
3434{
3435 latitude.resize(npoints);
3436 longitude.resize(npoints);
3437
3438 Location a(aLat, aLon, 0.);
3439 Location b(bLat, bLon, 0.);
3440 double dx = a.distance(b)/(npoints-1);
3441
3442 double moveDirection[3];
3443 a.vectorTripleProduct(b, moveDirection);
3444 for (int i=0; i<npoints; i++)
3445 {
3446 a.move(moveDirection, i*dx, b);
3447 latitude[i] = b.getLat();
3448 longitude[i] = b.getLon();
3449 }
3450}
3451
3452 inline void SlbmInterface::getGreatCirclePointsOnCenters(
3453 const double& aLat,
3454 const double& aLon,
3455 const double& bLat,
3456 const double& bLon,
3457 const int& npoints,
3458 double latitude[],
3459 double longitude[])
3460{
3461 Location a(aLat, aLon, 0.);
3462 Location b(bLat, bLon, 0.);
3463 double dx = a.distance(b)/npoints;
3464
3465 double moveDirection[3];
3466 a.vectorTripleProduct(b, moveDirection);
3467 for (int i=0; i<npoints; i++)
3468 {
3469 a.move(moveDirection, (i+0.5)*dx, b);
3470 latitude[i] = b.getLat();
3471 longitude[i] = b.getLon();
3472 }
3473}
3474
3475 inline void SlbmInterface::getGreatCirclePointsOnCenters(
3476 const double& aLat,
3477 const double& aLon,
3478 const double& bLat,
3479 const double& bLon,
3480 const int& npoints,
3481 vector<double> &latitude,
3482 vector<double> &longitude)
3483{
3484 latitude.resize(npoints);
3485 longitude.resize(npoints);
3486
3487 Location a(aLat, aLon, 0.);
3488 Location b(bLat, bLon, 0.);
3489 double dx = a.distance(b)/npoints;
3490
3491 double moveDirection[3];
3492 a.vectorTripleProduct(b, moveDirection);
3493 for (int i=0; i<npoints; i++)
3494 {
3495 a.move(moveDirection, (i+0.5)*dx, b);
3496 latitude[i] = b.getLat();
3497 longitude[i] = b.getLon();
3498 }
3499}
3500
3501 inline void SlbmInterface::getDistAz(const double& aLat, const double& aLon,
3502 const double& bLat, const double& bLon,
3503 double& distance, double& azimuth, const double& naValue)
3504{
3505 Location ptA(aLat, aLon);
3506 Location ptB(bLat, bLon);
3507 distance = ptA.distance(ptB);
3508 azimuth = ptA.azimuth(ptB, naValue);
3509}
3510
3511 inline void SlbmInterface::movePoint(const double& aLat, const double& aLon,
3512 const double& distance, const double& azimuth,
3513 double& bLat, double& bLon)
3514{
3515 Location ptA(aLat, aLon);
3516 Location ptB;
3517 ptA.move(azimuth, distance, ptB);
3518 bLat = ptB.getLat();
3519 bLon = ptB.getLon();
3520}
3521
3522 inline void SlbmInterface::setInterpolatorType(const string& interpolatorType)
3523{
3524 if (!grid)
3525 {
3526 ostringstream os;
3527 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3528 os << endl << "ERROR in SlbmInterface::setInterpolatorType" << endl
3529 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3530 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3531 throw SLBMException(os.str(),114);
3532 }
3533 grid->setInterpolatorType(interpolatorType);
3534}
3535
3536 inline string SlbmInterface::getInterpolatorType()
3537{
3538 if (!grid)
3539 {
3540 ostringstream os;
3541 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3542 os << endl << "ERROR in SlbmInterface::getInterpolatorType" << endl
3543 << "Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3544 << "Version " << SlbmVersion << " File " << __FILE__ << " line " << __LINE__ << endl << endl;
3545 throw SLBMException(os.str(),114);
3546 }
3547 return grid->getInterpolatorType();
3548}
3549
3550
3551} // end slbm namespace
3552
3553#endif // SlbmInterface_H
GreatCircle.h
GreatCircleFactory.h
GridGeoTess.h
SLBMException.h
SLBM_EXP
#define SLBM_EXP
Definition SLBMGlobals.h:181
UncertaintyPDU.h
UncertaintyPIU.h
slbm::CrustalProfile::getClassCount
static int getClassCount()
slbm::GeoStack::getClassCount
static int getClassCount()
slbm::GeoTessModelSLBM
Definition GeoTessModelSLBM.h:84
slbm::GreatCircle
The GreatCircle class manages information related to a great circle path between two Locations on the...
Definition GreatCircle.h:114
slbm::GreatCircle::getClassCount
static int getClassCount()
slbm::Grid
A 2 dimensional, horizontal grid of GirdProfile objects.
Definition Grid.h:91
slbm::GridProfile::getClassCount
static int getClassCount()
slbm::InterpolatedProfile::getClassCount
static int getClassCount()
slbm::InterpolatedProfile::getNCoefficients
int getNCoefficients()
Definition InterpolatedProfile.h:109
slbm::LayerProfile::getClassCount
static int getClassCount()
slbm::Location
The Location Class manages a single point in/on the Earth, which is described by the GRS80 ellipsoid.
Definition Location.h:78
slbm::Location::getLon
double getLon() const
Retrieve the longitude of this Location. Value will be between -PI and PI radians.
Definition Location.h:548
slbm::Location::distance
double distance(const Location &other) const
Definition Location.h:583
slbm::Location::azimuth
double azimuth(const Location &other) const
Find the azimuth from this Location to some other Location. Result will be between 0 and 2*PI radians...
Definition Location.h:593
slbm::Location::vectorTripleProduct
bool vectorTripleProduct(const Location &other, double vtp[]) const
Compute the vector triple product (this x other) x this, normalized to unit length....
Definition Location.h:691
slbm::Location::getClassCount
static int getClassCount()
slbm::Location::move
void move(const double &azimuth, const double &distance, Location &loc) const
Retrieve a Location that is a specified distance away from this Location, in a specified direction.
Definition Location.h:638
slbm::Location::getDepth
double getDepth() const
Definition Location.h:573
slbm::Location::getLat
double getLat() const
Retrieve the geographic latitude of this Location, radians.
Definition Location.h:542
slbm::QueryProfile
An InterpolatedProfile object that also has information about the the P and S wave velocity as a func...
Definition QueryProfile.h:68
slbm::QueryProfile::getDepth
double * getDepth()
Retrieve the depth of the top of the k'th interval, in km.
Definition QueryProfile.h:129
slbm::QueryProfile::getClassCount
static int getClassCount()
slbm::QueryProfile::getData
void getData(int *nodeIds, double *coefficients, int &nNeighbors, double *depths, double *pvelocities, double *svelocities, double &pgradient, double &sgradient)
Retrieve all the interval depth and velocity information contained in this QueryProfile object.
Definition QueryProfile.h:185
slbm::SLBMException
An Exception class for Grid and related objects.
Definition SLBMException.h:55
slbm::SlbmInterface::SlbmInterface
SlbmInterface(const double &earthRadius)
Parameterized constructor. Instantiates an SlbmInterface object that is only partly based on an ellip...
slbm::SlbmInterface::getRcvLon
double getRcvLon()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1827
slbm::SlbmInterface::getNActiveNodes
int getNActiveNodes()
Retrieve the number of active nodes in the Grid.
Definition SlbmInterface.h:3163
slbm::SlbmInterface::getSrcLon
double getSrcLon()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1815
slbm::SlbmInterface::getNHeadWavePoints
int getNHeadWavePoints()
Definition SlbmInterface.h:801
slbm::SlbmInterface::getActiveNodeData
void getActiveNodeData(const int &nodeId, double &latitude, double &longitude, double depth[NLAYERS], double pvelocity[NLAYERS], double svelocity[NLAYERS], double gradient[2])
Retrieve the lat (radians), lon (radians), interface depths (km), P and S wave interval velocities (k...
slbm::SlbmInterface::getNodeSeparation
void getNodeSeparation(const int &node1, const int &node2, double &distance)
Retrieve the angular separation of two grid nodes, in radians.
Definition SlbmInterface.h:3060
slbm::SlbmInterface::getHeadwaveDistance
double getHeadwaveDistance()
Definition SlbmInterface.h:415
slbm::SlbmInterface::getGreatCircleData
void getGreatCircleData(string &phase, double &actual_path_increment, double sourceDepth[NLAYERS], double sourceVelocity[NLAYERS], double receiverDepth[NLAYERS], double receiverVelocity[NLAYERS], int &npoints, double headWaveVelocity[], double gradient[])
Retrieve information about the great circle path including the interface depths at source and receive...
Definition SlbmInterface.h:2410
slbm::SlbmInterface::getModelPath
const string & getModelPath() const
A string containing the path to the SLBM model.
Definition SlbmInterface.h:3320
slbm::SlbmInterface::getGreatCirclePoints
void getGreatCirclePoints(const double &aLat, const double &aLon, const double &bLat, const double &bLon, const int &npoints, double latitude[], double longitude[])
Retrieve an array of lat, lon points along a great circle path between two specified points,...
Definition SlbmInterface.h:3403
slbm::SlbmInterface::getTravelTime
double getTravelTime()
Definition SlbmInterface.h:441
slbm::SlbmInterface::getUncertaintyTable
string getUncertaintyTable(const int &phase, const int &attribute)
Definition SlbmInterface.h:2867
slbm::SlbmInterface::getNodeNeighborInfo
void getNodeNeighborInfo(const int &nid, int neighbors[], double distance[], double azimuth[], int &nNeighbors)
Retrieve the node IDs of the nodes that surround the specified node.
Definition SlbmInterface.h:3000
slbm::SlbmInterface::setDelDepth
void setDelDepth(const double &del_depth)
Change the value of step change in depth used to compute depth derivatives (km).
slbm::SlbmInterface::getNodeAzimuth
void getNodeAzimuth(const int &node1, const int &node2, double &azimuth)
Retrieve the azimuth from grid node1 to grid node2, radians.
Definition SlbmInterface.h:3074
slbm::SlbmInterface::setDelDistance
void setDelDistance(const double &del_distance)
Change the value of step change in distance used to compute horizontal derivatives(in radians).
slbm::SlbmInterface::getWeightsSource
void getWeightsSource(int nodeids[], double weights[], int &nWeights)
Retrieve the node IDs and the interpolation coefficients for the source CrustalProfile.
Definition SlbmInterface.h:2284
slbm::SlbmInterface::getNGridNodes
int getNGridNodes()
Retrieve the number of Grid nodes in the Earth model.
Definition SlbmInterface.h:2775
slbm::SlbmInterface::get_dtt_ddist
double get_dtt_ddist()
Definition SlbmInterface.h:474
slbm::SlbmInterface::isEqual
bool isEqual(SlbmInterface *other)
Check if the model and/or greatCircle attached to the current SlbmInterface is equal that in another ...
slbm::SlbmInterface::getSourceDistance
double getSourceDistance()
Definition SlbmInterface.h:391
slbm::SlbmInterface::getNodeHitCount
int getNodeHitCount(const int &nodeId)
Definition SlbmInterface.h:1297
slbm::SlbmInterface::getActiveNodeNeighborInfo
void getActiveNodeNeighborInfo(const int &nid, int neighbors[], double distance[], double azimuth[], int &nNeighbors)
Retrieve the active node IDs of the nodes that surround the specified node.
Definition SlbmInterface.h:3030
slbm::SlbmInterface::getTravelTimeComponents
void getTravelTimeComponents(double &tTotal, double &tSource, double &tReceiver, double &tHeadwave, double &tGradient)
Retrieve the total travel time and the 4 components that contribute to it for the current GreatCircle...
Definition SlbmInterface.h:2217
slbm::SlbmInterface::getRayParameter
void getRayParameter(double &ray_parameter)
Retrieve the ray parameter.
slbm::SlbmInterface::getActiveNodeId
int getActiveNodeId(int gridNodeId)
Retrieve the active node ID that corresponds to a specified grid node ID.
Definition SlbmInterface.h:3191
slbm::SlbmInterface::setGridData
void setGridData(const int &nodeId, double depths[NLAYERS], double pvelocity[NLAYERS], double svelocity[NLAYERS], double gradient[2])
Modify the velocity and gradient information associated with a specified node in the Grid.
slbm::SlbmInterface::getModelObject
GeoTessModelSLBM * getModelObject()
Retrieve a pointer to the GeoTessModelSLBM object.
Definition SlbmInterface.h:1399
slbm::SlbmInterface::greatCircle
GreatCircle * greatCircle
The most recently requested GreatCircle object.
Definition SlbmInterface.h:1907
slbm::SlbmInterface::saveVelocityModel
void saveVelocityModel(const string &modelFileName, const int &format=4)
Save the velocity model currently in memory to the specified file.
slbm::SlbmInterface::SlbmInterface
SlbmInterface()
Default constructor. Instantiates an SlbmInterface object based on an ellipsoidal earth.
slbm::SlbmInterface::isValid
bool isValid()
Returns true if the current GreatCirlce object has been instantiated and is ready to be interrogated.
Definition SlbmInterface.h:363
slbm::SlbmInterface::getPhaseInt
int getPhaseInt()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1806
slbm::SlbmInterface::getActiveNodeWeights
void getActiveNodeWeights(int nodeId[], double weight[], int &nWeights)
Retrieve the weight assigned to each active node that was touched by the GreatCircle.
Definition SlbmInterface.h:2254
slbm::SlbmInterface::getWeightsReceiver
void getWeightsReceiver(int nodeids[], double weights[], int &nWeights)
Retrieve the node IDs and the interpolation coefficients for the receiver CrustalProfile....
Definition SlbmInterface.h:2331
slbm::SlbmInterface::clearGreatCircles
void clearGreatCircles()
slbm::SlbmInterface::getInterpolatedTransect
void getInterpolatedTransect(double lat[], double lon[], const int &nLatLon, int **neighbors, double **coefficients, int *nNeighbors, double depth[][NLAYERS], double pvelocity[][NLAYERS], double svelocity[][NLAYERS], double pgradient[NLAYERS], double sgradient[NLAYERS], int &nInvalid)
Retrieve interpolated data from the earth model along a transect defined by equal sized,...
Definition SlbmInterface.h:2627
slbm::SlbmInterface::getInterpolatedPoint
void getInterpolatedPoint(const double &lat, const double &lon, int *nodeIds, double *coefficients, int &nWeights, double depth[NLAYERS], double pvelocity[NLAYERS], double svelocity[NLAYERS], double &pgradient, double &sgradient)
Retrieve interpolated data from the earth model at a single specified latitude, longitude.
Definition SlbmInterface.h:2574
slbm::SlbmInterface::getWeights
void getWeights(int nodeId[], double weight[], int &nWeights)
Retrieve the weight assigned to each grid node that was touched by the GreatCircle.
Definition SlbmInterface.h:2239
slbm::SlbmInterface::getSlowness
void getSlowness(double &slowness)
Retrieve the horizontal slowness, i.e., the derivative of travel time wrt to receiver-source distance...
Definition SlbmInterface.h:2115
slbm::SlbmInterface::setPathIncrement
void setPathIncrement(const double &pathIncrement)
Set the desired spacing of great circle nodes along the head wave interface, in radians.
slbm::SlbmInterface::initializeActiveNodes
void initializeActiveNodes(const double &latmin, const double &lonmin, const double &latmax, const double &lonmax)
Specify the latitude and longitude range in radians for active nodes.
Definition SlbmInterface.h:3088
slbm::SlbmInterface::getTurningRadius
double getTurningRadius()
Definition SlbmInterface.h:1757
slbm::SlbmInterface::getDelDistance
void getDelDistance(double &del_distance)
Retrieve the value of step change in distance used to compute horizontal derivatives (radians).
slbm::SlbmInterface::setActiveNodeData
void setActiveNodeData(const int &nodeId, double depths[NLAYERS], double pvelocity[NLAYERS], double svelocity[NLAYERS], double gradient[2])
Modify the depth, velocity and gradient information associated with a specified active node in the Gr...
slbm::SlbmInterface::getDistAz
void getDistAz(const double &aLat, const double &aLon, const double &bLat, const double &bLon, double &distance, double &azimuth, const double &naValue)
compute distance and azimuth between two points, A and B (all quantities are in radians).
Definition SlbmInterface.h:3501
slbm::SlbmInterface::createGreatCircle
void createGreatCircle(const int &phase, const double &sourceLat, const double &sourceLon, const double &sourceDepth, const double &receiverLat, const double &receiverLon, const double &receiverDepth)
Instantiate a new GreatCircle object between two locations.
slbm::SlbmInterface::grid
Grid * grid
The Grid object that stores the velocity model.
Definition SlbmInterface.h:1902
slbm::SlbmInterface::clearActiveNodes
void clearActiveNodes()
Clear all active nodes. Clear all active nodes.
Definition SlbmInterface.h:3157
slbm::SlbmInterface::getTravelTimeUncertainty1D
void getTravelTimeUncertainty1D(double &travelTimeUncertainty)
Retrieve travel time uncertainty in sec using the phase and distance specified in last call to getGre...
slbm::SlbmInterface::get_dtt_dlon
double get_dtt_dlon()
Definition SlbmInterface.h:492
slbm::SlbmInterface::getFractionActive
double getFractionActive()
Definition SlbmInterface.h:1551
slbm::SlbmInterface::getPiercePointReceiver
void getPiercePointReceiver(double &lat, double &lon, double &depth)
Retrieve the latitude and longitude of the moho pierce point below the receiver, in radians.
Definition SlbmInterface.h:3362
slbm::SlbmInterface::setAverageMantleVelocity
void setAverageMantleVelocity(const int &type, const double &velocity)
Set the average P or S wave mantle velocity that is recorded in the model input file,...
Definition SlbmInterface.h:3261
slbm::SlbmInterface::modelsEqual
static bool modelsEqual(const string modelPath1, const string modelPath2)
Check if two models are equal.
slbm::SlbmInterface::loadVelocityModel
void loadVelocityModel(const string &modelPath)
Load the velocity model into memory from the specified file or directory. This method automatically d...
slbm::SlbmInterface::getGridNodeId
int getGridNodeId(int activeNodeId)
Retrieve the grid node ID that corresponds to a specified active node ID.
Definition SlbmInterface.h:3177
slbm::SlbmInterface::get_dtt_ddepth
double get_dtt_ddepth()
Definition SlbmInterface.h:501
slbm::SlbmInterface::getTurningRadius
void getTurningRadius(double &turning_radius)
Retrieve the turning radius of the ray.
slbm::SlbmInterface::getPiercePointSource
void getPiercePointSource(double &lat, double &lon, double &depth)
Retrieve the latitude and longitude of the moho pierce point below the source, in radians.
Definition SlbmInterface.h:3322
slbm::SlbmInterface::getCHMax
static void getCHMax(double &chMax)
Retrieve the current value of chMax. c is the zhao c parameter and h is the turning depth of the ray ...
slbm::SlbmInterface::getMaxDepth
static void getMaxDepth(double &maxDepth)
Retrieve the current value for the maximum source depth, in km.
slbm::SlbmInterface::getGreatCircleLocations
void getGreatCircleLocations(double lat[], double lon[], double depth[], int &npoints)
Retrieve the latitudes, longitudes and depths of all the profile positions along the headwave interfa...
Definition SlbmInterface.h:2522
slbm::SlbmInterface::getTessId
string getTessId()
Definition SlbmInterface.h:1543
slbm::SlbmInterface::getMaxDistance
static void getMaxDistance(double &maxDistance)
Retrieve the current value for the maximum source-receiver separation, in radians.
slbm::SlbmInterface::getDelDepth
double getDelDepth()
Definition SlbmInterface.h:1745
slbm::SlbmInterface::getPgLgComponents
void getPgLgComponents(double &tTotal, double &tTaup, double &tHeadwave, double &pTaup, double &pHeadwave, double &trTaup, double &trHeadwave)
Retrieve information about Pg/Lg travel time calculations.
Definition SlbmInterface.h:2925
slbm::SlbmInterface::getInterpolatorType
string getInterpolatorType()
Retrieve the type of interpolator currently in use; either "LINEAR" or "NATUTAL_NEIGHBOR".
Definition SlbmInterface.h:3536
slbm::SlbmInterface::getSlowness
double getSlowness()
Definition SlbmInterface.h:466
slbm::SlbmInterface::get_dtt_dlat
double get_dtt_dlat()
Definition SlbmInterface.h:483
slbm::SlbmInterface::getGreatCircleObject
GreatCircle * getGreatCircleObject()
Retrieve a pointer to the GreatCircle object.
Definition SlbmInterface.h:1975
slbm::SlbmInterface::getNodeNeighbors
void getNodeNeighbors(const int &nid, int neighbors[], int &nNeighbors)
Retrieve the node IDs of the nodes that surround the specified node.
Definition SlbmInterface.h:2944
slbm::SlbmInterface::clear
void clear()
Delete the current GreatCircle object from memory and clear the pool of stored CrustalProfile objects...
slbm::SlbmInterface::getMaxDistance
static double getMaxDistance()
Definition SlbmInterface.h:1568
slbm::SlbmInterface::getDistance
void getDistance(double &distance)
Retrieve the source-receiver separation, in radians.
Definition SlbmInterface.h:375
slbm::SlbmInterface::getNodeHitCount
void getNodeHitCount(const int &nodeId, int &hitCount)
Retrieve the number of times that the specified node has been 'touched' by a GreatCircle object.
Definition SlbmInterface.h:3205
slbm::SlbmInterface::createGreatCircle
void createGreatCircle(const string &phase, const double &sourceLat, const double &sourceLon, const double &sourceDepth, const double &receiverLat, const double &receiverLon, const double &receiverDepth)
Instantiate a new GreatCircle object between two locations.
Definition SlbmInterface.h:1943
slbm::SlbmInterface::getBufferSize
int getBufferSize() const
Returns the size of a DataBuffer object required to store this SLBMInterface objects model data.
slbm::SlbmInterface::getSrcLat
double getSrcLat()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1811
slbm::SlbmInterface::CH_MAX
static double CH_MAX
Definition SlbmInterface.h:1912
slbm::SlbmInterface::getRcvLat
double getRcvLat()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1823
slbm::SlbmInterface::getMaxDepth
static double getMaxDepth()
Definition SlbmInterface.h:1583
slbm::SlbmInterface::getSlownessUncertainty
void getSlownessUncertainty(const int &phase, const double &distance, double &uncert)
Retrieve the slowness uncertainty in sec/radian for specified phase, distance (in radians).
Definition SlbmInterface.h:2823
slbm::SlbmInterface::getActiveNodeWeightsSource
void getActiveNodeWeightsSource(int nodeids[], double weights[], int &nWeights)
Retrieve the active node IDs and the interpolation coefficients for the source CrustalProfile.
Definition SlbmInterface.h:2311
slbm::SlbmInterface::getGreatCircleNodeInfo
void getGreatCircleNodeInfo(int **neighbors, double **coefficients, const int &maxpoints, const int &maxnodes, int &npoints, int *nnodes)
Retrieve information about the interpolated points along the headwave path, including the number of p...
Definition SlbmInterface.h:2485
slbm::SlbmInterface::getDelDistance
double getDelDistance()
Definition SlbmInterface.h:1731
slbm::SlbmInterface::getModelString
string getModelString()
Definition SlbmInterface.h:1802
slbm::SlbmInterface::getDistance
double getDistance()
Retrieve the source-receiver separation, in radians.
Definition SlbmInterface.h:2130
slbm::SlbmInterface::getTravelTimeUncertainty
void getTravelTimeUncertainty(const int &phase, const double &distance, double &uncert)
Retrieve the travel time uncertainty in sec for specified phase, distance (in radians).
slbm::SlbmInterface::getSrcDep
double getSrcDep()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1819
slbm::SlbmInterface::movePoint
void movePoint(const double &aLat, const double &aLon, const double &distance, const double &azimuth, double &bLat, double &bLon)
Find point B that is the specified distance and azimuth from point A, in radians.
Definition SlbmInterface.h:3511
slbm::SlbmInterface::getRayParameter
double getRayParameter()
Definition SlbmInterface.h:1751
slbm::SlbmInterface::getRcvDep
double getRcvDep()
getter for read-only attributes property getter for read-only attributes property
Definition SlbmInterface.h:1831
slbm::SlbmInterface::toString
string toString(const int &verbosity)
Returns a human-readable string representation of the GreatCircle object.
Definition SlbmInterface.h:2378
slbm::SlbmInterface::getPhaseString
string getPhaseString()
Definition SlbmInterface.h:1807
slbm::SlbmInterface::getUncertaintyFileFormat
string getUncertaintyFileFormat(const int &phase, const int &attribute)
Definition SlbmInterface.h:2890
slbm::SlbmInterface::getZhaoParameters
void getZhaoParameters(double &Vm, double &Gm, double &H, double &C, double &Cm, int &udSign)
Retrieve some of the parameters that contribute to the calculation of of total travel time using the ...
Definition SlbmInterface.h:2911
slbm::SlbmInterface::~SlbmInterface
virtual ~SlbmInterface()
Copy constructor.
slbm::SlbmInterface::clearNodeHitCount
void clearNodeHitCount()
Clear the node hit count by setting the hit count of every node to zero.
Definition SlbmInterface.h:3219
slbm::SlbmInterface::getVersion
string getVersion()
Retrieve the SLBM Version number.
Definition SlbmInterface.h:138
slbm::SlbmInterface::getTravelTimeUncertainty
void getTravelTimeUncertainty(double &travelTimeUncertainty, bool calcRandomError=false)
Retrieve travel time uncertainty in sec using the phase and distance specified in last call to getGre...
slbm::SlbmInterface::getGridObject
Grid * getGridObject()
Retrieve a pointer to the Grid object.
Definition SlbmInterface.h:1393
slbm::SlbmInterface::getPathIncrement
void getPathIncrement(double &pathIncrement)
Retrieve the current value of the spacing of great circle nodes along the head wave interface,...
slbm::SlbmInterface::getPathIncrement
double getPathIncrement()
Retrieve the current value of the spacing of great circle nodes along the head wave interface,...
slbm::SlbmInterface::getGreatCirclePointsOnCenters
void getGreatCirclePointsOnCenters(const double &aLat, const double &aLon, const double &bLat, const double &bLon, const int &npoints, double latitude[], double longitude[])
Retrieve an array of lat, lon points along a great circle path between two specified points,...
Definition SlbmInterface.h:3452
slbm::SlbmInterface::getCHMax
static double getCHMax()
Definition SlbmInterface.h:1512
slbm::SlbmInterface::setInterpolatorType
void setInterpolatorType(const string &interpolatorType)
Specify the interpolation type to use, either 'linear' or 'natural_neighbor'.
Definition SlbmInterface.h:3522
slbm::SlbmInterface::getDelDepth
void getDelDepth(double &del_depth)
Retrieve the value of step change in depth used to compute depth derivatives (km).
slbm::SlbmInterface::getAverageMantleVelocity
void getAverageMantleVelocity(const int &type, double &velocity)
Retrieve the average P or S wave mantle velocity that is specified in the model input file,...
Definition SlbmInterface.h:3233
slbm::SlbmInterface::getGridData
void getGridData(const int &nodeId, double &latitude, double &longitude, double depth[NLAYERS], double pvelocity[NLAYERS], double svelocity[NLAYERS], double gradient[2])
Retrieve the lat (radians), lon (radians), interface depths (km), P and S wave interval velocities (k...
slbm::SlbmInterface::get_dtt_ddist
void get_dtt_ddist(double &slowness)
Retrieve the horizontal slowness, i.e., the derivative of travel time wrt to receiver-source distance...
Definition SlbmInterface.h:473
slbm::SlbmInterface::setMaxDistance
static void setMaxDistance(const double &maxDistance)
Set the maximum source-receiver separation for Pn/Sn phase, in radians.
slbm::SlbmInterface::getActiveNodeWeightsReceiver
void getActiveNodeWeightsReceiver(int nodeids[], double weights[], int &nWeights)
Retrieve the active node IDs and the interpolation coefficients for the receiver CrustalProfile....
Definition SlbmInterface.h:2358
slbm::SlbmInterface::setCHMax
static void setCHMax(const double &chMax)
Set the value of chMax. c is the zhao c parameter and h is the turning depth of the ray below the moh...
slbm::SlbmInterface::setMaxDepth
static void setMaxDepth(const double &maxDepth)
Set the maximum source depth for Pn/Sn phase, in km.
slbm::SlbmInterface::getActiveNodeNeighbors
void getActiveNodeNeighbors(const int &nid, int neighbors[], int &nNeighbors)
Retrieve the active node IDs of the nodes that surround the specified active node.
Definition SlbmInterface.h:2958
slbm::SlbmInterface::valid
bool valid
true if the current GreatCirlce object has been instantiated and is ready to be interrogated.
Definition SlbmInterface.h:1919
slbm::SlbmInterface::getPhase
string getPhase()
Retrieve the phase specified in last call to createGreatCircle().
Definition SlbmInterface.h:368
slbm::SlbmInterface::getReceiverDistance
double getReceiverDistance()
Definition SlbmInterface.h:401
slbm::SlbmInterface::getClassCount
string getClassCount()
Retrieve a table that lists the number of instances of various SLBM classes that are currently instan...
Definition SlbmInterface.h:3305
slbm::SlbmInterface::getHeadwaveDistanceKm
double getHeadwaveDistanceKm()
Definition SlbmInterface.h:430
slbm::UncertaintyPIU::getAttribute
int getAttribute()
A public convenience accessor used to verify the error data for the correct model phase is loaded in ...
Definition UncertaintyPIU.h:506
slbm::UncertaintyPIU::getPhase
int getPhase()
A public convenience accessor used to verify the error data for the correct model phase is loaded in ...
Definition UncertaintyPIU.h:501
util::DataBuffer
A byte array container used to hold binary data in the same manner as disk based file system.
Definition DataBuffer.h:81
slbm
Definition CrustalProfile.h:59