38 #ifndef SlbmInterface_H
39 #define SlbmInterface_H
190 void loadVelocityModelBinary(
const string& modelPath)
191 { loadVelocityModel(modelPath); };
209 void specifyOutputDirectory(
const string& directoryName);
220 void saveVelocityModelBinary();
255 void setInterpolatorType(
const string& interpolatorType);
262 string getInterpolatorType();
279 void createGreatCircle(
const string& phase,
280 const double& sourceLat,
281 const double& sourceLon,
282 const double& sourceDepth,
283 const double& receiverLat,
284 const double& receiverLon,
285 const double& receiverDepth);
303 const double& sourceLat,
304 const double& sourceLon,
305 const double& sourceDepth,
306 const double& receiverLat,
307 const double& receiverLon,
308 const double& receiverDepth);
341 string getPhase() {
return greatCircle->getPhaseString(); };
354 double getDistance();
363 void getSourceDistance(
double& dist);
372 void getReceiverDistance(
double& dist);
385 void getHeadwaveDistance(
double& dist);
399 void getHeadwaveDistanceKm(
double& dist);
409 void getTravelTime(
double& travelTime);
425 void getTravelTimeComponents(
double& tTotal,
double& tSource,
double& tReceiver,
426 double& tHeadwave,
double& tGradient);
433 void getSlowness(
double& slowness);
449 void get_dtt_dlat(
double& dtt_dlat);
458 void get_dtt_dlon(
double& dtt_dlon);
467 void get_dtt_ddepth(
double& dtt_ddepth);
556 void getWeights(
int nodeId[],
double weight[],
int& nWeights);
596 void getActiveNodeWeights(
int nodeId[],
double weight[],
int& nWeights);
631 void getWeights(vector<int>& nodeId, vector<double>& weight);
665 void getActiveNodeWeights(vector<int>& nodeId, vector<double>& weight);
680 void getWeightsSource(
int nodeids[],
double weights[],
int& nWeights);
695 void getActiveNodeWeightsSource(
int nodeids[],
double weights[],
int& nWeights);
707 void getWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights);
719 void getActiveNodeWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights);
742 string toString(
const int& verbosity);
747 void getNGridNodes(
int& n);
763 void getNHeadWavePoints(
int& nHeadWavePoints);
788 double depth[NLAYERS],
789 double pvelocity[NLAYERS],
790 double svelocity[NLAYERS],
816 double depth[NLAYERS],
817 double pvelocity[NLAYERS],
818 double svelocity[NLAYERS],
838 double depths[NLAYERS],
839 double pvelocity[NLAYERS],
840 double svelocity[NLAYERS],
860 double depths[NLAYERS],
861 double pvelocity[NLAYERS],
862 double svelocity[NLAYERS],
901 void getGreatCircleData(
903 double& actual_path_increment,
904 double sourceDepth[NLAYERS],
905 double sourceVelocity[NLAYERS],
906 double receiverDepth[NLAYERS],
907 double receiverVelocity[NLAYERS],
909 double headWaveVelocity[],
926 void getGreatCircleLocations(
double lat[],
double lon[],
double depth[],
int& npoints);
955 void getGreatCircleNodeInfo(
957 double** coefficients,
958 const int& maxpoints,
987 void getInterpolatedPoint(
991 double* coefficients,
993 double depth[NLAYERS],
994 double pvelocity[NLAYERS],
995 double svelocity[NLAYERS],
1025 void getInterpolatedTransect(
1030 double** coefficients,
1032 double depth[][NLAYERS],
1033 double pvelocity[][NLAYERS],
1034 double svelocity[][NLAYERS],
1035 double pgradient[NLAYERS],
1036 double sgradient[NLAYERS],
1052 void initializeActiveNodes(
const double& latmin,
const double& lonmin,
1053 const double& latmax,
const double& lonmax);
1071 void initializeActiveNodes(
const string& polygonFileName);
1085 void initializeActiveNodes(GeoTessPolygon* polygon);
1108 void initializeActiveNodes(
double* lat,
double* lon,
const int& npoints,
const bool& inDegrees=
true);
1125 void initializeActiveNodes(vector<double*>& unitVectors);
1130 int getNActiveNodes();
1134 void clearActiveNodes();
1141 int getGridNodeId(
int activeNodeId);
1148 int getActiveNodeId(
int gridNodeId);
1158 void getNodeHitCount(
const int& nodeId,
int& hitCount);
1165 void clearNodeHitCount();
1174 void getNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors);
1183 void getActiveNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors);
1189 void getNodeNeighbors(
const int& nid, vector<int>& neighbors);
1195 void getActiveNodeNeighbors(
const int& nid, vector<int>& neighbors);
1204 void getNodeNeighborInfo(
const int& nid,
int neighbors[],
double distance[],
1205 double azimuth[],
int& nNeighbors);
1214 void getActiveNodeNeighborInfo(
const int& nid,
int neighbors[],
double distance[],
1215 double azimuth[],
int& nNeighbors);
1224 void getActiveNodeNeighborInfo(
const int& nid,
1225 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth);
1230 void getNodeSeparation(
const int& node1,
const int& node2,
double& distance);
1235 void getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth);
1289 void getSlownessUncertainty(
const int& phase,
const double& distance,
double& uncert );
1297 void getSlownessUncertainty(
double& slownessUncertainty);
1299 string getUncertaintyTable(
const int& attribute,
const int& phase);
1301 string getUncertaintyFileFormat(
const int& attribute,
const int& phase);
1324 void getZhaoParameters(
double& Vm,
double& Gm,
double& H,
double& C,
double& Cm,
int& udSign);
1342 void getPgLgComponents(
double& tTotal,
1343 double& tTaup,
double& tHeadwave,
1344 double& pTaup,
double& pHeadwave,
1345 double& trTaup,
double& trHeadwave);
1376 void getAverageMantleVelocity(
const int& type,
double& velocity);
1389 void setAverageMantleVelocity(
const int& type,
const double& velocity);
1394 void getTessId(
string& tessId);
1401 void getFractionActive(
double& fractionActive);
1439 string getClassCount();
1445 const string& getModelPath()
const;
1462 void getDistAz(
const double& aLat,
const double& aLon,
1463 const double& bLat,
const double& bLon,
1464 double& distance,
double& azimuth,
const double& naValue);
1478 void movePoint(
const double& aLat,
const double& aLon,
1479 const double& distance,
const double& azimuth,
1480 double& bLat,
double& bLon);
1490 void getPiercePointSource(
double& lat,
double& lon,
double& depth);
1500 void getPiercePointReceiver(
double& lat,
double& lon,
double& depth);
1518 void getGreatCirclePoints(
1525 double longitude[]);
1541 void getGreatCirclePointsOnCenters(
1548 double longitude[]);
1666 double srcLat, srcLon, srcDep, rcvLat, rcvLon, rcvDep;
1675 inline void SlbmInterface::createGreatCircle(
1677 const double& sourceLat,
1678 const double& sourceLon,
1679 const double& sourceDepth,
1680 const double& receiverLat,
1681 const double& receiverLon,
1682 const double& receiverDepth)
1684 int iphase = (p==
"Pn" ? Pn : (p==
"Sn" ? Sn : (p==
"Pg" ? Pg : (p==
"Lg" ? Lg : -1))));
1688 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1689 os << endl <<
"ERROR in SlbmInterface::createGreatCircle" << endl
1690 << p <<
" is not a recognized phase. Must be one of Pn, Sn, Pg, Lg" << endl
1691 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1711 inline void SlbmInterface::get_dtt_dlat(
double& value)
1717 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1718 os << endl <<
"ERROR in SlbmInterface::get_dtt_dlat" << endl
1719 <<
"GreatCircle is invalid." << endl
1720 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1723 greatCircle->get_dtt_dlat(value);
1726 inline void SlbmInterface::get_dtt_dlon(
double& value)
1732 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1733 os << endl <<
"ERROR in SlbmInterface::get_dtt_dlon" << endl
1734 <<
"GreatCircle is invalid." << endl
1735 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1738 greatCircle->get_dtt_dlon(value);
1741 inline void SlbmInterface::get_dtt_ddepth(
double& value)
1747 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1748 os << endl <<
"ERROR in SlbmInterface::get_dtt_ddepth" << endl
1749 <<
"GreatCircle is invalid." << endl
1750 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1753 greatCircle->get_dtt_ddepth(value);
1846 inline void SlbmInterface::getSlowness(
double& value)
1852 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1853 os << endl <<
"ERROR in SlbmInterface::getSlowness" << endl
1854 <<
"GreatCircle is invalid." << endl
1855 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1858 greatCircle->get_dtt_ddist(value);
1861 inline double SlbmInterface::getDistance()
1863 if (greatCircle == NULL)
1870 return greatCircle->getDistance();
1873 inline void SlbmInterface::getSourceDistance(
double& distance)
1877 distance = NA_VALUE;
1879 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1880 os << endl <<
"ERROR in SlbmInterface::getSourceDistance" << endl
1881 <<
"GreatCircle is invalid." << endl
1882 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1885 distance = greatCircle->getSourceDistance();
1888 inline void SlbmInterface::getReceiverDistance(
double& distance)
1892 distance = NA_VALUE;
1894 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1895 os << endl <<
"ERROR in SlbmInterface::getReceiverDistance" << endl
1896 <<
"GreatCircle is invalid." << endl
1897 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1900 distance = greatCircle->getReceiverDistance();
1903 inline void SlbmInterface::getHeadwaveDistance(
double& distance)
1907 distance = NA_VALUE;
1909 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1910 os << endl <<
"ERROR in SlbmInterface::getHeadwaveDistance" << endl
1911 <<
"GreatCircle is invalid." << endl
1912 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1915 distance = greatCircle->getHeadwaveDistance();
1918 inline void SlbmInterface::getHeadwaveDistanceKm(
double& distance)
1922 distance = NA_VALUE;
1924 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1925 os << endl <<
"ERROR in SlbmInterface::getHeadwaveDistanceKm" << endl
1926 <<
"GreatCircle is invalid." << endl
1927 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1930 distance = greatCircle->getHeadwaveDistanceKm();
1933 inline void SlbmInterface::getTravelTime(
double& tTotal)
1939 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1940 os << endl <<
"ERROR in SlbmInterface::getTravelTime" << endl
1941 <<
"GreatCircle is invalid." << endl
1942 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1945 tTotal=greatCircle->getTravelTime();
1948 inline void SlbmInterface::getTravelTimeComponents(
1949 double& tTotal,
double& tSource,
double& tReceiver,
1950 double& tHeadwave,
double& tGradient)
1956 tReceiver = NA_VALUE;
1957 tHeadwave = NA_VALUE;
1958 tGradient = NA_VALUE;
1960 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1961 os << endl <<
"ERROR in SlbmInterface::getTravelTimeComponents" << endl
1962 <<
"GreatCircle is invalid." << endl
1963 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1966 greatCircle->getTravelTime(tTotal, tSource, tReceiver,
1967 tHeadwave, tGradient);
1970 inline void SlbmInterface::getWeights(
int nodeId[],
double weight[],
int& nWeights)
1976 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1977 os << endl <<
"ERROR in SlbmInterface::getWeights" << endl
1978 <<
"GreatCircle is invalid." << endl
1979 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1982 greatCircle->getWeights(nodeId, weight, nWeights);
1985 inline void SlbmInterface::getActiveNodeWeights(
int nodeId[],
double weight[],
int& nWeights)
1987 getWeights(nodeId, weight, nWeights);
1988 for (
int i=0; i<nWeights; ++i)
1989 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
1992 inline void SlbmInterface::getWeights(
1993 vector<int>& nodeId, vector<double>& weight)
2000 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2001 os << endl <<
"ERROR in SlbmInterface::getWeights" << endl
2002 <<
"GreatCircle is invalid." << endl
2003 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2006 greatCircle->getWeights(nodeId, weight);
2009 inline void SlbmInterface::getActiveNodeWeights(
2010 vector<int>& nodeId, vector<double>& weight)
2012 getWeights(nodeId, weight);
2013 for (
int i=0; i<(int)nodeId.size(); ++i)
2014 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
2017 inline void SlbmInterface::getWeightsSource(
int nodeids[],
double weights[],
int& nWeights)
2022 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2023 os << endl <<
"ERROR in SlbmInterface::getWeightsSource" << endl
2024 <<
"GreatCircle is invalid." << endl
2025 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2028 greatCircle->getSourceProfile()->getWeights(nodeids, weights, nWeights);
2031 inline void SlbmInterface::getActiveNodeWeightsSource(
int nodeids[],
double weights[],
int& nWeights)
2033 getWeightsSource(nodeids, weights, nWeights);
2034 for (
int i=0; i<nWeights; ++i)
2035 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2038 inline void SlbmInterface::getWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights)
2043 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2044 os << endl <<
"ERROR in SlbmInterface::getWeightsReceiver" << endl
2045 <<
"GreatCircle is invalid." << endl
2046 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2049 greatCircle->getReceiverProfile()->getWeights(nodeids, weights, nWeights);
2052 inline void SlbmInterface::getActiveNodeWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights)
2054 getWeightsReceiver(nodeids, weights, nWeights);
2055 for (
int i=0; i<nWeights; ++i)
2056 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2059 inline string SlbmInterface::toString(
const int& verbosity)
2064 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2065 os << endl <<
"ERROR in SlbmInterface::toString" << endl
2066 <<
"GreatCircle is invalid." << endl
2067 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2075 <<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
2076 <<
"Great Circle " << endl << endl
2077 << greatCircle->toString(verbosity);
2079 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint)
2082 getSlowness(slowness);
2083 os << endl <<
"Horizontal slowness = "
2084 << slowness <<
" sec/radian"
2091 inline void SlbmInterface::getGreatCircleData(
2093 double& actual_path_increment,
2094 double sourceDepth[NLAYERS],
2095 double sourceVelocity[NLAYERS],
2096 double receiverDepth[NLAYERS],
2097 double receiverVelocity[NLAYERS],
2099 double headWaveVelocity[],
2106 actual_path_increment = NA_VALUE;
2108 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2109 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2110 <<
"GreatCircle is invalid." << endl
2111 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2116 greatCircle->getData(p, actual_path_increment,
2117 sourceDepth, sourceVelocity, receiverDepth, receiverVelocity,
2118 npoints, headWaveVelocity, gradient);
2119 phase = (p==Pn ?
"Pn" : (p==Sn ?
"Sn" : (p==Pg ?
"Pg" : (p==Lg ?
"Lg"
2120 :
"unknown phase"))));
2123 inline void SlbmInterface::getGreatCircleNodeInfo(
2125 double** coefficients,
2126 const int& maxpoints,
2127 const int& maxnodes,
2135 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2136 os << endl <<
"ERROR in SlbmInterface::getGreatCircleNodeInfo" << endl
2137 <<
"GreatCircle is invalid." << endl
2138 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2142 greatCircle->getNodeInfo(neighbors, coefficients, maxpoints, maxnodes, npoints, nnodes);
2145 inline void SlbmInterface::getGreatCircleLocations(
2155 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2156 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2157 <<
"GreatCircle is invalid." << endl
2158 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2162 npoints = greatCircle->getNProfiles();
2164 for (
int i=0; i<greatCircle->getNProfiles(); i++)
2167 greatCircle->getLayerProfileLocation(i, loc);
2175 inline void SlbmInterface::getInterpolatedPoint(
2179 double* coefficients,
2181 double depth[NLAYERS],
2182 double pvelocity[NLAYERS],
2183 double svelocity[NLAYERS],
2189 QueryProfile* profile = grid->getQueryProfile(location);
2190 profile->
getData(nodeId, coefficients, nNeighbors, depth, pvelocity, svelocity, pgradient, sgradient);
2194 inline void SlbmInterface::getInterpolatedTransect(
2199 double** coefficients,
2201 double depth[][NLAYERS],
2202 double pvelocity[][NLAYERS],
2203 double svelocity[][NLAYERS],
2204 double pgradient[NLAYERS],
2205 double sgradient[NLAYERS],
2210 for (
int i=0; i<nLatLon; i++)
2214 getInterpolatedPoint(lat[i], lon[i], nodeId[i],
2215 coefficients[i], nNeighbors[i], depth[i], pvelocity[i], svelocity[i],
2216 pgradient[i], sgradient[i]);
2220 for (
int j=0; j<nNeighbors[i]; j++)
2223 coefficients[i][j] = NA_VALUE;
2226 for (
int j=0; j<NLAYERS; j++)
2228 depth[i][j] = NA_VALUE;
2229 pvelocity[i][j] = NA_VALUE;
2230 svelocity[i][j] = NA_VALUE;
2233 pgradient[i] = NA_VALUE;
2234 sgradient[i] = NA_VALUE;
2241 inline void SlbmInterface::getNGridNodes(
int& n)
2247 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2248 os << endl <<
"ERROR in SlbmInterface::getNGridNodes" << endl
2249 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2250 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2253 n = grid->getNNodes();
2256 inline int SlbmInterface::getNGridNodes()
2261 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2262 os << endl <<
"ERROR in SlbmInterface::getNGridNodes" << endl
2263 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2264 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2267 return grid->getNNodes();
2270 inline void SlbmInterface::getNHeadWavePoints(
int& nHeadWavePoints)
2274 nHeadWavePoints = -1;
2276 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2277 os << endl <<
"ERROR in SlbmInterface::getNHeadWavePoints" << endl
2278 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2279 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2282 nHeadWavePoints = greatCircle->getNProfiles();
2304 inline void SlbmInterface::getSlownessUncertainty(
const int& phase,
const double& distance,
double& uncert )
2309 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2310 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2311 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2312 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2316 if (grid->getUncertainty()[phase][SH] == NULL)
2319 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2320 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2321 <<
"Uncertainty object is invalid.." << endl
2322 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2328 uncert = grid->getUncertainty()[phase][SH]->getUncertainty( distance );
2332 inline void SlbmInterface::getSlownessUncertainty(
double& slownessUncertainty)
2337 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2338 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2339 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2340 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2344 getSlownessUncertainty(greatCircle->getPhase(),
2345 greatCircle->getDistance(), slownessUncertainty);
2348 inline string SlbmInterface::getUncertaintyTable(
const int& phase,
const int& attribute)
2353 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2354 os << endl <<
"ERROR in SlbmInterface::getUncertaintyTable" << endl
2355 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2356 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2360 if (grid->getUncertainty()[phase][attribute] == NULL)
2363 os <<
"No uncertainty information is available for phase " <<
2364 Uncertainty::getPhase(phase) <<
" attribute " <<
2365 Uncertainty::getAttribute(attribute) << endl;
2368 return grid->getUncertainty()[phase][attribute]->toStringTable();
2371 inline string SlbmInterface::getUncertaintyFileFormat(
const int& phase,
const int& attribute)
2376 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2377 os << endl <<
"ERROR in SlbmInterface::getUncertaintyFileFormat" << endl
2378 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2379 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2383 if (grid->getUncertainty()[phase][attribute] == NULL)
2386 os <<
"No uncertainty information is available for phase " << phase <<
" attribute " << attribute << endl;
2389 return grid->getUncertainty()[phase][attribute]->toStringFile();
2392 inline void SlbmInterface::getZhaoParameters(
double& Vm,
double& Gm,
double& H,
double& C,
double& Cm,
int& udSign)
2397 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2398 os << endl <<
"ERROR in SlbmInterface::getZhaoParameters" << endl
2399 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2400 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2403 greatCircle->getZhaoParameters(Vm, Gm, H, C, Cm, udSign);
2406 inline void SlbmInterface::getPgLgComponents(
double& tTotal,
2407 double& tTaup,
double& tHeadwave,
2408 double& pTaup,
double& pHeadwave,
2409 double& trTaup,
double& trHeadwave)
2414 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2415 os << endl <<
"ERROR in SlbmInterface::getPgLgComponents" << endl
2416 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2417 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2420 greatCircle->getPgLgComponents(tTotal, tTaup, tHeadwave,
2421 pTaup, pHeadwave, trTaup, trHeadwave);
2425 inline void SlbmInterface::getNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors)
2430 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2431 os << endl <<
"ERROR in SlbmInterface::getNodeNeighbors" << endl
2432 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2433 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2436 grid->getNodeNeighbors(nid, neighbors, nNeighbors);
2439 inline void SlbmInterface::getActiveNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors)
2444 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2445 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2446 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2447 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2450 grid->getActiveNodeNeighbors(nid, neighbors, nNeighbors);
2453 inline void SlbmInterface::getNodeNeighbors(
const int& nid, vector<int>& neighbors)
2458 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2459 os << endl <<
"ERROR in SlbmInterface::getNodeNeighbors" << endl
2460 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2461 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2464 grid->getNodeNeighbors(nid, neighbors);
2467 inline void SlbmInterface::getActiveNodeNeighbors(
const int& nid, vector<int>& neighbors)
2472 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2473 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2474 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2475 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2478 grid->getActiveNodeNeighbors(nid, neighbors);
2481 inline void SlbmInterface::getNodeNeighborInfo(
const int& nid,
int neighbors[],
2482 double distance[],
double azimuth[],
int& nNeighbors)
2487 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2488 os << endl <<
"ERROR in SlbmInterface::getNodeNeighborInfo" << endl
2489 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2490 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2493 grid->getNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
2496 inline void SlbmInterface::getActiveNodeNeighborInfo(
const int& nid,
int neighbors[],
2497 double distance[],
double azimuth[],
int& nNeighbors)
2502 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2503 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
2504 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2505 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2508 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
2511 inline void SlbmInterface::getActiveNodeNeighborInfo(
const int& nid,
2512 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth)
2517 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2518 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
2519 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2520 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2523 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth);
2526 inline void SlbmInterface::getNodeSeparation(
const int& node1,
const int& node2,
double& distance)
2531 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2532 os << endl <<
"ERROR in SlbmInterface::getNodeSeparation" << endl
2533 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2534 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2537 grid->getNodeSeparation(node1, node2, distance);
2540 inline void SlbmInterface::getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth)
2545 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2546 os << endl <<
"ERROR in SlbmInterface::getNodeAzimuth" << endl
2547 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2548 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2551 grid->getNodeAzimuth(node1, node2, azimuth);
2554 inline void SlbmInterface::initializeActiveNodes(
const double& latmin,
const double& lonmin,
2555 const double& latmax,
const double& lonmax)
2560 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2561 os << endl <<
"ERROR in SlbmInterface::initializeActiveNodes" << endl
2562 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2563 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2566 grid->initializeActiveNodes(latmin, lonmin, latmax, lonmax);
2569 inline void SlbmInterface::initializeActiveNodes(
double* lat,
double* lon,
const int& npoints,
const bool& degrees)
2574 for (
int i=0; i<npoints; ++i)
2575 v.push_back(GeoTessUtils::getVectorDegrees(lat[i], lon[i]));
2577 for (
int i=0; i<npoints; ++i)
2578 v.push_back(GeoTessUtils::getVector(lat[i], lon[i]));
2579 initializeActiveNodes(v);
2582 inline void SlbmInterface::initializeActiveNodes(vector<double*>& unitVectors)
2584 initializeActiveNodes(
new GeoTessPolygon(unitVectors));
2587 inline void SlbmInterface::initializeActiveNodes(GeoTessPolygon* polygon)
2589 grid->initializeActiveNodes(polygon);
2592 inline void SlbmInterface::initializeActiveNodes(
const string& fileName)
2594 grid->initializeActiveNodes(
new GeoTessPolygon(fileName));
2597 inline void SlbmInterface::clearActiveNodes()
2599 grid->clearActiveNodes();
2603 inline int SlbmInterface::getNActiveNodes()
2608 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2609 os << endl <<
"ERROR in SlbmInterface::nextActiveNode" << endl
2610 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2611 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2614 return grid->getNActiveNodes();
2617 inline int SlbmInterface::getGridNodeId(
int activeNodeId)
2622 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2623 os << endl <<
"ERROR in SlbmInterface::getGridNodeId" << endl
2624 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2625 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2628 return grid->getGridNodeId(activeNodeId);
2631 inline int SlbmInterface::getActiveNodeId(
int gridNodeId)
2636 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2637 os << endl <<
"ERROR in SlbmInterface::getActiveNodeId" << endl
2638 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2639 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2642 return grid->getActiveNodeId(gridNodeId);
2645 inline void SlbmInterface::getNodeHitCount(
const int& nodeId,
int& hitCount)
2650 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2651 os << endl <<
"ERROR in SlbmInterface::getNodeHitCount" << endl
2652 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2653 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2656 grid->getNodeHitCount(nodeId, hitCount);
2659 inline void SlbmInterface::clearNodeHitCount()
2664 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2665 os << endl <<
"ERROR in SlbmInterface::clearNodeHitCount" << endl
2666 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2667 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2670 grid->clearNodeHitCount();
2673 inline void SlbmInterface::getAverageMantleVelocity(
const int& type,
double& velocity)
2678 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2679 os << endl <<
"ERROR in SlbmInterface::setAverageMantleVelocity" << endl
2680 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2681 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2684 velocity = grid->getAverageMantleVelocity(type);
2687 inline void SlbmInterface::setAverageMantleVelocity(
const int& type,
2688 const double& velocity)
2693 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2694 os << endl <<
"ERROR in SlbmInterface::setAverageMantleVelocity" << endl
2695 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2696 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2699 grid->setAverageMantleVelocity(type, velocity);
2702 inline void SlbmInterface::getTessId(
string& tessId)
2707 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2708 os << endl <<
"ERROR in SlbmInterface::getTessId" << endl
2709 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2710 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2713 tessId = grid->getTessId();
2716 inline void SlbmInterface::getFractionActive(
double& fractionActive)
2720 fractionActive = NA_VALUE;
2722 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2723 os << endl <<
"ERROR in SlbmInterface::getFractionActive" << endl
2724 <<
"GreatCircle is invalid." << endl
2725 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2728 fractionActive = greatCircle->getFractionActive();
2731 inline string SlbmInterface::getClassCount()
2734 os <<
"Class counts:" << endl;
2735 os <<
"GreatCircle = " << GreatCircle::getClassCount() << endl;
2736 os <<
"GridProfile = " << GridProfile::getClassCount() << endl;
2737 os <<
"GeoStack = " << GeoStack::getClassCount() << endl;
2738 os <<
"InterpolatedProfile = " << InterpolatedProfile::getClassCount() << endl;
2739 os <<
"CrustalProfile = " << CrustalProfile::getClassCount() << endl;
2740 os <<
"LayerProfile = " << LayerProfile::getClassCount() << endl;
2741 os <<
"QueryProfile = " << QueryProfile::getClassCount() << endl;
2742 os <<
"Location = " << Location::getClassCount() << endl;
2746 inline const string& SlbmInterface::getModelPath()
const {
return grid->getModelPath(); }
2748 inline void SlbmInterface::getPiercePointSource(
double& lat,
double& lon,
double& depth)
2752 lat = lon = NA_VALUE;
2754 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2755 os << endl <<
"ERROR in SlbmInterface::getPiercePointSource" << endl
2756 <<
"GreatCircle is invalid." << endl
2757 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2762 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
2764 lat = lon = NA_VALUE;
2766 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2767 os << endl <<
"ERROR in SlbmInterface::getPiercePointSource" << endl
2768 <<
"Cannot compute moho pierce points for " << getPhase() << endl
2769 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2773 if (!greatCircle->getSourceProfile()->isInCrust())
2775 lat = lon = NA_VALUE;
2777 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2778 os << endl <<
"ERROR in SlbmInterface::getPiercePointSource" << endl
2779 <<
"Cannot compute moho pierce point for source in the mantle." << endl
2780 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2785 greatCircle->getGreatCircleLocation(greatCircle->getSourceDistance(), loc);
2791 profile = grid->getQueryProfile(loc);
2792 depth = profile->
getDepth()[MANTLE];
2796 inline void SlbmInterface::getPiercePointReceiver(
double& lat,
double& lon,
double& depth)
2800 lat = lon = NA_VALUE;
2802 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2803 os << endl <<
"ERROR in SlbmInterface::getPiercePointReceiver" << endl
2804 <<
"GreatCircle is invalid." << endl
2805 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2810 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
2812 lat = lon = NA_VALUE;
2814 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2815 os << endl <<
"ERROR in SlbmInterface::getPiercePointReceiver" << endl
2816 <<
"Cannot compute moho pierce points for " << getPhase() << endl
2817 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2821 if (!greatCircle->getReceiverProfile()->isInCrust())
2823 lat = lon = NA_VALUE;
2825 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2826 os << endl <<
"ERROR in SlbmInterface::getPiercePointReceiver" << endl
2827 <<
"Cannot compute moho pierce point for receiver in the mantle." << endl
2828 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2833 greatCircle->getGreatCircleLocation(
2834 greatCircle->getDistance()-greatCircle->getReceiverDistance(), loc);
2840 profile = grid->getQueryProfile(loc);
2841 depth = profile->
getDepth()[MANTLE];
2845 inline void SlbmInterface::getGreatCirclePoints(
2856 double dx = a.
distance(b)/(npoints-1);
2858 double moveDirection[3];
2860 for (
int i=0; i<npoints; i++)
2862 a.
move(moveDirection, i*dx, b);
2863 latitude[i] = b.
getLat();
2864 longitude[i] = b.
getLon();
2868 inline void SlbmInterface::getGreatCirclePointsOnCenters(
2881 double moveDirection[3];
2883 for (
int i=0; i<npoints; i++)
2885 a.
move(moveDirection, (i+0.5)*dx, b);
2886 latitude[i] = b.
getLat();
2887 longitude[i] = b.
getLon();
2891 inline void SlbmInterface::getDistAz(
const double& aLat,
const double& aLon,
2892 const double& bLat,
const double& bLon,
2893 double& distance,
double& azimuth,
const double& naValue)
2898 azimuth = ptA.
azimuth(ptB, naValue);
2901 inline void SlbmInterface::movePoint(
const double& aLat,
const double& aLon,
2902 const double& distance,
const double& azimuth,
2903 double& bLat,
double& bLon)
2907 ptA.
move(azimuth, distance, ptB);
2912 inline void SlbmInterface::setInterpolatorType(
const string& interpolatorType)
2917 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2918 os << endl <<
"ERROR in SlbmInterface::setInterpolatorType" << endl
2919 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2920 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2923 grid->setInterpolatorType(interpolatorType);
2926 inline string SlbmInterface::getInterpolatorType()
2931 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2932 os << endl <<
"ERROR in SlbmInterface::getInterpolatorType" << endl
2933 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2934 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2937 return grid->getInterpolatorType();
2944 #endif // SlbmInterface_H