38 #ifndef SlbmInterface_H
39 #define SlbmInterface_H
123 static bool modelsEqual(
const string modelPath1,
const string modelPath2);
208 void loadVelocityModelBinary(
const string& modelPath)
209 { loadVelocityModel(modelPath); };
227 void specifyOutputDirectory(
const string& directoryName);
238 void saveVelocityModelBinary();
273 void setInterpolatorType(
const string& interpolatorType);
280 string getInterpolatorType();
297 void createGreatCircle(
const string& phase,
298 const double& sourceLat,
299 const double& sourceLon,
300 const double& sourceDepth,
301 const double& receiverLat,
302 const double& receiverLon,
303 const double& receiverDepth);
321 const double& sourceLat,
322 const double& sourceLon,
323 const double& sourceDepth,
324 const double& receiverLat,
325 const double& receiverLon,
326 const double& receiverDepth);
359 string getPhase() {
return greatCircle->getPhaseString(); };
372 double getDistance();
381 void getSourceDistance(
double& dist);
391 void getReceiverDistance(
double& dist);
405 void getHeadwaveDistance(
double& dist);
420 void getHeadwaveDistanceKm(
double& dist);
431 void getTravelTime(
double& travelTime);
448 void getTravelTimeComponents(
double& tTotal,
double& tSource,
double& tReceiver,
449 double& tHeadwave,
double& tGradient);
456 void getSlowness(
double& slowness);
473 void get_dtt_dlat(
double& dtt_dlat);
482 void get_dtt_dlon(
double& dtt_dlon);
491 void get_dtt_ddepth(
double& dtt_ddepth);
580 void getWeights(
int nodeId[],
double weight[],
int& nWeights);
620 void getActiveNodeWeights(
int nodeId[],
double weight[],
int& nWeights);
655 void getWeights(vector<int>& nodeId, vector<double>& weight);
689 void getActiveNodeWeights(vector<int>& nodeId, vector<double>& weight);
704 void getWeightsSource(
int nodeids[],
double weights[],
int& nWeights);
705 void getWeightsSource(vector<int> &nodeids, vector<double> &weights);
720 void getActiveNodeWeightsSource(
int nodeids[],
double weights[],
int& nWeights);
721 void getActiveNodeWeightsSource(vector<int> &nodeids, vector<double> &weights);
733 void getWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights);
734 void getWeightsReceiver(vector<int> &nodeids, vector<double> &weights);
746 void getActiveNodeWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights);
747 void getActiveNodeWeightsReceiver(vector<int> &nodeids, vector<double> &weights);
770 string toString(
const int& verbosity);
775 void getNGridNodes(
int& n);
791 void getNHeadWavePoints(
int& nHeadWavePoints);
817 double depth[NLAYERS],
818 double pvelocity[NLAYERS],
819 double svelocity[NLAYERS],
845 double depth[NLAYERS],
846 double pvelocity[NLAYERS],
847 double svelocity[NLAYERS],
867 double depths[NLAYERS],
868 double pvelocity[NLAYERS],
869 double svelocity[NLAYERS],
889 double depths[NLAYERS],
890 double pvelocity[NLAYERS],
891 double svelocity[NLAYERS],
930 void getGreatCircleData(
932 double& actual_path_increment,
933 double sourceDepth[NLAYERS],
934 double sourceVelocity[NLAYERS],
935 double receiverDepth[NLAYERS],
936 double receiverVelocity[NLAYERS],
938 double headWaveVelocity[],
941 void getGreatCircleData(
943 double &actual_path_increment,
944 vector<double> &sourceDepth,
945 vector<double> &sourceVelocity,
946 vector<double> &receiverDepth,
947 vector<double> &receiverVelocity,
949 vector<double> &headWaveVelocity,
950 vector<double> &gradient
966 void getGreatCircleLocations(
double lat[],
double lon[],
double depth[],
int& npoints);
967 void getGreatCircleLocations(vector<double> &lat, vector<double> &lon, vector<double> &depth);
996 void getGreatCircleNodeInfo(
998 double** coefficients,
999 const int& maxpoints,
1000 const int& maxnodes,
1004 void getGreatCircleNodeInfo(vector<vector<int> >& neighbors, vector<vector<double> >& coefficients);
1029 void getInterpolatedPoint(
1033 double* coefficients,
1035 double depth[NLAYERS],
1036 double pvelocity[NLAYERS],
1037 double svelocity[NLAYERS],
1064 void getInterpolatedPoint(
1067 vector<int> &nodeId,
1068 vector<double> &coefficients,
1069 vector<double> &depth,
1070 vector<double> &pvelocity,
1071 vector<double> &svelocity,
1101 void getInterpolatedTransect(
1106 double** coefficients,
1108 double depth[][NLAYERS],
1109 double pvelocity[][NLAYERS],
1110 double svelocity[][NLAYERS],
1111 double pgradient[NLAYERS],
1112 double sgradient[NLAYERS],
1135 void getInterpolatedTransect(
1138 vector<vector<int> > &nodeId,
1139 vector<vector<double> > &coefficients,
1140 vector<vector<double> > &depth,
1141 vector<vector<double> > &pvelocity,
1142 vector<vector<double> > &svelocity,
1143 vector<double> &pgradient,
1144 vector<double> &sgradient,
1160 void initializeActiveNodes(
const double& latmin,
const double& lonmin,
1161 const double& latmax,
const double& lonmax);
1179 void initializeActiveNodes(
const string& polygonFileName);
1193 void initializeActiveNodes(GeoTessPolygon* polygon);
1216 void initializeActiveNodes(
double* lat,
double* lon,
const int& npoints,
const bool& inDegrees=
true);
1237 void initializeActiveNodes(
const vector<double> lat,
const vector<double> lon,
const bool& inDegrees=
true);
1254 void initializeActiveNodes(vector<double*>& unitVectors);
1259 int getNActiveNodes();
1263 void clearActiveNodes();
1270 int getGridNodeId(
int activeNodeId);
1277 int getActiveNodeId(
int gridNodeId);
1287 void getNodeHitCount(
const int& nodeId,
int& hitCount);
1296 void clearNodeHitCount();
1305 void getNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors);
1314 void getActiveNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors);
1320 void getNodeNeighbors(
const int& nid, vector<int>& neighbors);
1326 void getActiveNodeNeighbors(
const int& nid, vector<int>& neighbors);
1335 void getNodeNeighborInfo(
const int& nid,
int neighbors[],
double distance[],
1336 double azimuth[],
int& nNeighbors);
1337 void getNodeNeighborInfo(
const int nid,
1338 vector<int> &neighbors, vector<double> &distance, vector<double> &azimuth);
1347 void getActiveNodeNeighborInfo(
const int& nid,
int neighbors[],
double distance[],
1348 double azimuth[],
int& nNeighbors);
1357 void getActiveNodeNeighborInfo(
const int& nid,
1358 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth);
1363 void getNodeSeparation(
const int& node1,
const int& node2,
double& distance);
1368 void getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth);
1428 void getSlownessUncertainty(
const int& phase,
const double& distance,
double& uncert );
1436 void getSlownessUncertainty(
double& slownessUncertainty);
1438 string getUncertaintyTable(
const int& phase,
const int& attribute);
1440 string getUncertaintyFileFormat(
const int& phase,
const int& attribute);
1463 void getZhaoParameters(
double& Vm,
double& Gm,
double& H,
double& C,
double& Cm,
int& udSign);
1481 void getPgLgComponents(
double& tTotal,
double& tTaup,
double& tHeadwave,
1482 double& pTaup,
double& pHeadwave,
double& trTaup,
double& trHeadwave);
1514 void getAverageMantleVelocity(
const int& type,
double& velocity);
1515 double getAverageMantleVelocity(
const int &type);
1528 void setAverageMantleVelocity(
const int& type,
const double& velocity);
1533 void getTessId(
string& tessId);
1541 void getFractionActive(
double& fractionActive);
1582 string getClassCount();
1588 const string& getModelPath()
const;
1605 void getDistAz(
const double& aLat,
const double& aLon,
1606 const double& bLat,
const double& bLon,
1607 double& distance,
double& azimuth,
const double& naValue);
1621 void movePoint(
const double& aLat,
const double& aLon,
1622 const double& distance,
const double& azimuth,
1623 double& bLat,
double& bLon);
1633 void getPiercePointSource(
double& lat,
double& lon,
double& depth);
1643 void getPiercePointReceiver(
double& lat,
double& lon,
double& depth);
1661 void getGreatCirclePoints(
1668 double longitude[]);
1669 void getGreatCirclePoints(
1675 vector<double> &latitude,
1676 vector<double> &longitude);
1692 void getGreatCirclePointsOnCenters(
1699 double longitude[]);
1700 void getGreatCirclePointsOnCenters(
1706 vector<double> &latitude,
1707 vector<double> &longitude);
1854 double srcLat, srcLon, srcDep, rcvLat, rcvLon, rcvDep;
1863 inline void SlbmInterface::createGreatCircle(
1865 const double& sourceLat,
1866 const double& sourceLon,
1867 const double& sourceDepth,
1868 const double& receiverLat,
1869 const double& receiverLon,
1870 const double& receiverDepth)
1872 int iphase = (p==
"Pn" ? Pn : (p==
"Sn" ? Sn : (p==
"Pg" ? Pg : (p==
"Lg" ? Lg : -1))));
1876 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1877 os << endl <<
"ERROR in SlbmInterface::createGreatCircle" << endl
1878 << p <<
" is not a recognized phase. Must be one of Pn, Sn, Pg, Lg" << endl
1879 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1899 inline void SlbmInterface::get_dtt_dlat(
double& value)
1905 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1906 os << endl <<
"ERROR in SlbmInterface::get_dtt_dlat" << endl
1907 <<
"GreatCircle is invalid." << endl
1908 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1911 greatCircle->get_dtt_dlat(value);
1914 inline void SlbmInterface::get_dtt_dlon(
double& value)
1920 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1921 os << endl <<
"ERROR in SlbmInterface::get_dtt_dlon" << endl
1922 <<
"GreatCircle is invalid." << endl
1923 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1926 greatCircle->get_dtt_dlon(value);
1929 inline void SlbmInterface::get_dtt_ddepth(
double& value)
1935 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
1936 os << endl <<
"ERROR in SlbmInterface::get_dtt_ddepth" << endl
1937 <<
"GreatCircle is invalid." << endl
1938 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
1941 greatCircle->get_dtt_ddepth(value);
2034 inline void SlbmInterface::getSlowness(
double& value)
2040 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2041 os << endl <<
"ERROR in SlbmInterface::getSlowness" << endl
2042 <<
"GreatCircle is invalid." << endl
2043 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2046 greatCircle->get_dtt_ddist(value);
2049 inline double SlbmInterface::getDistance()
2051 if (greatCircle == NULL)
2058 return greatCircle->getDistance();
2061 inline void SlbmInterface::getSourceDistance(
double& distance)
2065 distance = NA_VALUE;
2067 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2068 os << endl <<
"ERROR in SlbmInterface::getSourceDistance" << endl
2069 <<
"GreatCircle is invalid." << endl
2070 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2073 distance = greatCircle->getSourceDistance();
2076 inline void SlbmInterface::getReceiverDistance(
double& distance)
2080 distance = NA_VALUE;
2082 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2083 os << endl <<
"ERROR in SlbmInterface::getReceiverDistance" << endl
2084 <<
"GreatCircle is invalid." << endl
2085 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2088 distance = greatCircle->getReceiverDistance();
2091 inline void SlbmInterface::getHeadwaveDistance(
double& distance)
2095 distance = NA_VALUE;
2097 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2098 os << endl <<
"ERROR in SlbmInterface::getHeadwaveDistance" << endl
2099 <<
"GreatCircle is invalid." << endl
2100 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2103 distance = greatCircle->getHeadwaveDistance();
2106 inline void SlbmInterface::getHeadwaveDistanceKm(
double& distance)
2110 distance = NA_VALUE;
2112 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2113 os << endl <<
"ERROR in SlbmInterface::getHeadwaveDistanceKm" << endl
2114 <<
"GreatCircle is invalid." << endl
2115 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2118 distance = greatCircle->getHeadwaveDistanceKm();
2121 inline void SlbmInterface::getTravelTime(
double& tTotal)
2127 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2128 os << endl <<
"ERROR in SlbmInterface::getTravelTime" << endl
2129 <<
"GreatCircle is invalid." << endl
2130 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2133 tTotal=greatCircle->getTravelTime();
2136 inline void SlbmInterface::getTravelTimeComponents(
2137 double& tTotal,
double& tSource,
double& tReceiver,
2138 double& tHeadwave,
double& tGradient)
2144 tReceiver = NA_VALUE;
2145 tHeadwave = NA_VALUE;
2146 tGradient = NA_VALUE;
2148 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2149 os << endl <<
"ERROR in SlbmInterface::getTravelTimeComponents" << endl
2150 <<
"GreatCircle is invalid." << endl
2151 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2154 greatCircle->getTravelTime(tTotal, tSource, tReceiver,
2155 tHeadwave, tGradient);
2158 inline void SlbmInterface::getWeights(
int nodeId[],
double weight[],
int& nWeights)
2164 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2165 os << endl <<
"ERROR in SlbmInterface::getWeights" << endl
2166 <<
"GreatCircle is invalid." << endl
2167 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2170 greatCircle->getWeights(nodeId, weight, nWeights);
2173 inline void SlbmInterface::getActiveNodeWeights(
int nodeId[],
double weight[],
int& nWeights)
2175 getWeights(nodeId, weight, nWeights);
2176 for (
int i=0; i<nWeights; ++i)
2177 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
2180 inline void SlbmInterface::getWeights(vector<int>& nodeId, vector<double>& weight)
2187 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2188 os << endl <<
"ERROR in SlbmInterface::getWeights" << endl
2189 <<
"GreatCircle is invalid." << endl
2190 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2193 greatCircle->getWeights(nodeId, weight);
2196 inline void SlbmInterface::getActiveNodeWeights(vector<int>& nodeId, vector<double>& weight)
2198 getWeights(nodeId, weight);
2199 for (
int i=0; i<(int)nodeId.size(); ++i)
2200 nodeId[i] = grid->getActiveNodeId(nodeId[i]);
2203 inline void SlbmInterface::getWeightsSource(
int nodeids[],
double weights[],
int& nWeights)
2208 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2209 os << endl <<
"ERROR in SlbmInterface::getWeightsSource" << endl
2210 <<
"GreatCircle is invalid." << endl
2211 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2214 greatCircle->getSourceProfile()->getWeights(nodeids, weights, nWeights);
2217 inline void SlbmInterface::getWeightsSource(vector<int> &nodeids, vector<double> &weights)
2220 int nWeights = greatCircle->getSourceProfile()->getNCoefficients();
2223 nodeids.resize(nWeights);
2224 weights.resize(nWeights);
2227 getWeightsSource(nodeids.data(), weights.data(), nWeights);
2230 inline void SlbmInterface::getActiveNodeWeightsSource(
int nodeids[],
double weights[],
int& nWeights)
2232 getWeightsSource(nodeids, weights, nWeights);
2233 for (
int i=0; i<nWeights; ++i)
2234 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2237 inline void SlbmInterface::getActiveNodeWeightsSource(vector<int> &nodeids, vector<double> &weights)
2240 int nWeights = greatCircle->getSourceProfile()->getNCoefficients();
2243 nodeids.resize(nWeights);
2244 weights.resize(nWeights);
2247 getActiveNodeWeightsSource(nodeids.data(), weights.data(), nWeights);
2250 inline void SlbmInterface::getWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights)
2255 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2256 os << endl <<
"ERROR in SlbmInterface::getWeightsReceiver" << endl
2257 <<
"GreatCircle is invalid." << endl
2258 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2261 greatCircle->getReceiverProfile()->getWeights(nodeids, weights, nWeights);
2264 inline void SlbmInterface::getWeightsReceiver(vector<int> &nodeids, vector<double> &weights)
2267 int nWeights = greatCircle->getReceiverProfile()->getNCoefficients();
2270 nodeids.resize(nWeights);
2271 weights.resize(nWeights);
2274 getWeightsReceiver(nodeids.data(), weights.data(), nWeights);
2277 inline void SlbmInterface::getActiveNodeWeightsReceiver(
int nodeids[],
double weights[],
int& nWeights)
2279 getWeightsReceiver(nodeids, weights, nWeights);
2280 for (
int i=0; i<nWeights; ++i)
2281 nodeids[i] = grid->getActiveNodeId(nodeids[i]);
2284 inline void SlbmInterface::getActiveNodeWeightsReceiver(vector<int> &nodeids, vector<double> &weights)
2287 int nWeights = greatCircle->getReceiverProfile()->getNCoefficients();
2290 nodeids.resize(nWeights);
2291 weights.resize(nWeights);
2294 getActiveNodeWeightsReceiver(nodeids.data(), weights.data(), nWeights);
2297 inline string SlbmInterface::toString(
const int& verbosity)
2302 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2303 os << endl <<
"ERROR in SlbmInterface::toString" << endl
2304 <<
"GreatCircle is invalid." << endl
2305 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2313 <<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
2314 <<
"Great Circle " << endl << endl
2315 << greatCircle->toString(verbosity);
2317 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint)
2320 getSlowness(slowness);
2321 os << endl <<
"Horizontal slowness = "
2322 << slowness <<
" sec/radian"
2329 inline void SlbmInterface::getGreatCircleData(
2331 double& actual_path_increment,
2332 double sourceDepth[NLAYERS],
2333 double sourceVelocity[NLAYERS],
2334 double receiverDepth[NLAYERS],
2335 double receiverVelocity[NLAYERS],
2337 double headWaveVelocity[],
2344 actual_path_increment = NA_VALUE;
2346 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2347 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2348 <<
"GreatCircle is invalid." << endl
2349 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2354 greatCircle->getData(p, actual_path_increment,
2355 sourceDepth, sourceVelocity, receiverDepth, receiverVelocity,
2356 npoints, headWaveVelocity, gradient);
2357 phase = (p==Pn ?
"Pn" : (p==Sn ?
"Sn" : (p==Pg ?
"Pg" : (p==Lg ?
"Lg"
2358 :
"unknown phase"))));
2361 inline void SlbmInterface::getGreatCircleData(
2363 double &actual_path_increment,
2364 vector<double> &sourceDepth,
2365 vector<double> &sourceVelocity,
2366 vector<double> &receiverDepth,
2367 vector<double> &receiverVelocity,
2369 vector<double> &headWaveVelocity,
2370 vector<double> &gradient
2376 actual_path_increment = NA_VALUE;
2378 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2379 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2380 <<
"GreatCircle is invalid." << endl
2381 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2386 getNHeadWavePoints(npoints);
2389 sourceDepth.resize(NLAYERS);
2390 sourceVelocity.resize(NLAYERS);
2391 receiverDepth.resize(NLAYERS);
2392 receiverVelocity.resize(NLAYERS);
2393 headWaveVelocity.resize(npoints);
2394 gradient.resize(npoints);
2397 greatCircle->getData(p, actual_path_increment,
2398 sourceDepth.data(), sourceVelocity.data(), receiverDepth.data(),
2399 receiverVelocity.data(), npoints, headWaveVelocity.data(), gradient.data());
2400 phase = (p==Pn ?
"Pn" : (p==Sn ?
"Sn" : (p==Pg ?
"Pg" : (p==Lg ?
"Lg"
2401 :
"unknown phase"))));
2404 inline void SlbmInterface::getGreatCircleNodeInfo(
2406 double** coefficients,
2407 const int& maxpoints,
2408 const int& maxnodes,
2416 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2417 os << endl <<
"ERROR in SlbmInterface::getGreatCircleNodeInfo" << endl
2418 <<
"GreatCircle is invalid." << endl
2419 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2423 greatCircle->getNodeInfo(neighbors, coefficients, maxpoints, maxnodes, npoints, nnodes);
2425 inline void SlbmInterface::getGreatCircleNodeInfo(
2426 vector<vector<int> >& neighbors, vector<vector<double> >& coefficients)
2431 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2432 os << endl <<
"ERROR in SlbmInterface::getGreatCircleNodeInfo" << endl
2433 <<
"GreatCircle is invalid." << endl
2434 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2438 greatCircle->getNodeInfo(neighbors, coefficients);
2441 inline void SlbmInterface::getGreatCircleLocations(
2451 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2452 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2453 <<
"GreatCircle is invalid." << endl
2454 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2458 npoints = greatCircle->getNProfiles();
2460 for (
int i=0; i<greatCircle->getNProfiles(); i++)
2463 greatCircle->getLayerProfileLocation(i, loc);
2470 inline void SlbmInterface::getGreatCircleLocations(
2471 vector<double> &lat,
2472 vector<double> &lon,
2473 vector<double> &depth
2479 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2480 os << endl <<
"ERROR in SlbmInterface::getGreatCircleData" << endl
2481 <<
"GreatCircle is invalid." << endl
2482 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2485 int npoints = getNHeadWavePoints();
2486 lat.resize(npoints);
2487 lon.resize(npoints);
2488 depth.resize(npoints);
2489 getGreatCircleLocations(lat.data(), lon.data(), depth.data(), npoints);
2493 inline void SlbmInterface::getInterpolatedPoint(
2497 double* coefficients,
2499 double depth[NLAYERS],
2500 double pvelocity[NLAYERS],
2501 double svelocity[NLAYERS],
2507 QueryProfile* profile = grid->getQueryProfile(location);
2508 profile->
getData(nodeIds, coefficients, nWeights, depth, pvelocity, svelocity, pgradient, sgradient);
2512 inline void SlbmInterface::getInterpolatedPoint(
2515 vector<int> &nodeIds,
2516 vector<double> &coefficients,
2517 vector<double> &depth,
2518 vector<double> &pvelocity,
2519 vector<double> &svelocity,
2528 QueryProfile* profile = grid->getQueryProfile(location);
2534 nodeIds.resize(nWeights);
2535 coefficients.resize(nWeights);
2536 depth.resize(NLAYERS);
2537 pvelocity.resize(NLAYERS);
2538 svelocity.resize(NLAYERS);
2541 profile->
getData(nodeIds.data(), coefficients.data(), nWeights,
2542 depth.data(), pvelocity.data(), svelocity.data(), pgradient, sgradient);
2546 inline void SlbmInterface::getInterpolatedTransect(
2551 double** coefficients,
2553 double depth[][NLAYERS],
2554 double pvelocity[][NLAYERS],
2555 double svelocity[][NLAYERS],
2556 double pgradient[NLAYERS],
2557 double sgradient[NLAYERS],
2562 for (
int i=0; i<nLatLon; i++)
2566 getInterpolatedPoint(lat[i], lon[i], nodeId[i],
2567 coefficients[i], nNeighbors[i], depth[i], pvelocity[i], svelocity[i],
2568 pgradient[i], sgradient[i]);
2572 for (
int j=0; j<nNeighbors[i]; j++)
2575 coefficients[i][j] = NA_VALUE;
2578 for (
int j=0; j<NLAYERS; j++)
2580 depth[i][j] = NA_VALUE;
2581 pvelocity[i][j] = NA_VALUE;
2582 svelocity[i][j] = NA_VALUE;
2585 pgradient[i] = NA_VALUE;
2586 sgradient[i] = NA_VALUE;
2592 inline void SlbmInterface::getInterpolatedTransect(
2595 vector<vector<int> > &nodeId,
2596 vector<vector<double> > &coefficients,
2597 vector<vector<double> > &depth,
2598 vector<vector<double> > &pvelocity,
2599 vector<vector<double> > &svelocity,
2600 vector<double> &pgradient,
2601 vector<double> &sgradient,
2609 if (lat.size() == lon.size())
2611 nLatLon = lat.size();
2616 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2617 os << endl <<
"ERROR in SlbmInterface::getInterpolatedTransect" << endl
2618 <<
"Size of lat and lon vectors do not match." << endl
2619 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2624 nodeId.resize(nLatLon);
2625 coefficients.resize(nLatLon);
2626 depth.resize(nLatLon);
2627 pvelocity.resize(nLatLon);
2628 svelocity.resize(nLatLon);
2629 pgradient.resize(nLatLon);
2630 sgradient.resize(nLatLon);
2631 for (
int i=0; i<nLatLon; i++)
2633 depth[i].resize(NLAYERS);
2634 pvelocity[i].resize(NLAYERS);
2635 svelocity[i].resize(NLAYERS);
2639 for (
int i=0; i<nLatLon; i++)
2644 Location location(lat[i], lon[i], 0.);
2653 nodeId[i].resize(nWeights);
2654 coefficients[i].resize(nWeights);
2656 getInterpolatedPoint(lat[i], lon[i], nodeId[i].data(), coefficients[i].data(), nWeights,
2657 depth[i].data(), pvelocity[i].data(), svelocity[i].data(), pgradient[i], sgradient[i]);
2662 nodeId[i].push_back(-1);
2663 coefficients[i].push_back(NA_VALUE);
2664 pgradient[i] = NA_VALUE;
2665 sgradient[i] = NA_VALUE;
2667 for (
int j=0; j<NLAYERS; j++)
2669 depth[i][j] = NA_VALUE;
2670 pvelocity[i][j] = NA_VALUE;
2671 svelocity[i][j] = NA_VALUE;
2679 inline void SlbmInterface::getNGridNodes(
int& n)
2685 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2686 os << endl <<
"ERROR in SlbmInterface::getNGridNodes" << endl
2687 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2688 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2691 n = grid->getNNodes();
2694 inline int SlbmInterface::getNGridNodes()
2699 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2700 os << endl <<
"ERROR in SlbmInterface::getNGridNodes" << endl
2701 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2702 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2705 return grid->getNNodes();
2708 inline void SlbmInterface::getNHeadWavePoints(
int& nHeadWavePoints)
2712 nHeadWavePoints = -1;
2714 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2715 os << endl <<
"ERROR in SlbmInterface::getNHeadWavePoints" << endl
2716 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2717 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2720 nHeadWavePoints = greatCircle->getNProfiles();
2742 inline void SlbmInterface::getSlownessUncertainty(
const int& phase,
const double& distance,
double& uncert )
2747 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2748 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2749 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2750 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2754 if (grid->getUncertainty()[phase][SH] == NULL)
2757 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2758 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2759 <<
"Uncertainty object is invalid.." << endl
2760 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2766 uncert = grid->getUncertainty()[phase][SH]->getUncertainty( distance );
2770 inline void SlbmInterface::getSlownessUncertainty(
double& slownessUncertainty)
2775 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2776 os << endl <<
"ERROR in SlbmInterface::getSlownessUncertainty" << endl
2777 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2778 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2782 getSlownessUncertainty(greatCircle->getPhase(),
2783 greatCircle->getDistance(), slownessUncertainty);
2786 inline string SlbmInterface::getUncertaintyTable(
const int& phase,
const int& attribute)
2791 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2792 os << endl <<
"ERROR in SlbmInterface::getUncertaintyTable" << endl
2793 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2794 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2798 if (grid->getUncertainty()[phase][attribute] == NULL)
2801 os <<
"No uncertainty information is available for phase " <<
2802 UncertaintyPIU::getPhase(phase) <<
" attribute " <<
2803 UncertaintyPIU::getAttribute(attribute) << endl;
2806 return grid->getUncertainty()[phase][attribute]->toStringTable();
2809 inline string SlbmInterface::getUncertaintyFileFormat(
const int& phase,
const int& attribute)
2814 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2815 os << endl <<
"ERROR in SlbmInterface::getUncertaintyFileFormat" << endl
2816 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2817 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2821 if (grid->getUncertainty()[phase][attribute] == NULL)
2824 os <<
"No uncertainty information is available for phase " << phase <<
" attribute " << attribute << endl;
2827 return grid->getUncertainty()[phase][attribute]->toStringFile();
2830 inline void SlbmInterface::getZhaoParameters(
double& Vm,
double& Gm,
double& H,
double& C,
double& Cm,
int& udSign)
2835 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2836 os << endl <<
"ERROR in SlbmInterface::getZhaoParameters" << endl
2837 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2838 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2841 greatCircle->getZhaoParameters(Vm, Gm, H, C, Cm, udSign);
2844 inline void SlbmInterface::getPgLgComponents(
double& tTotal,
2845 double& tTaup,
double& tHeadwave,
2846 double& pTaup,
double& pHeadwave,
2847 double& trTaup,
double& trHeadwave)
2852 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2853 os << endl <<
"ERROR in SlbmInterface::getPgLgComponents" << endl
2854 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2855 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2858 greatCircle->getPgLgComponents(tTotal, tTaup, tHeadwave,
2859 pTaup, pHeadwave, trTaup, trHeadwave);
2863 inline void SlbmInterface::getNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors)
2868 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2869 os << endl <<
"ERROR in SlbmInterface::getNodeNeighbors" << endl
2870 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2871 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2874 grid->getNodeNeighbors(nid, neighbors, nNeighbors);
2877 inline void SlbmInterface::getActiveNodeNeighbors(
const int& nid,
int neighbors[],
int& nNeighbors)
2882 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2883 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2884 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2885 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2888 grid->getActiveNodeNeighbors(nid, neighbors, nNeighbors);
2891 inline void SlbmInterface::getNodeNeighbors(
const int& nid, vector<int>& neighbors)
2896 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2897 os << endl <<
"ERROR in SlbmInterface::getNodeNeighbors" << endl
2898 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2899 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2902 grid->getNodeNeighbors(nid, neighbors);
2905 inline void SlbmInterface::getActiveNodeNeighbors(
const int& nid, vector<int>& neighbors)
2910 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2911 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighbors" << endl
2912 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2913 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2916 grid->getActiveNodeNeighbors(nid, neighbors);
2919 inline void SlbmInterface::getNodeNeighborInfo(
const int& nid,
int neighbors[],
2920 double distance[],
double azimuth[],
int& nNeighbors)
2925 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2926 os << endl <<
"ERROR in SlbmInterface::getNodeNeighborInfo" << endl
2927 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2928 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2931 grid->getNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
2934 inline void SlbmInterface::getNodeNeighborInfo(
const int nid,
2935 vector<int> &neighbors, vector<double> &distance, vector<double> &azimuth)
2940 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2941 os << endl <<
"ERROR in SlbmInterface::getNodeNeighborInfo" << endl
2942 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2943 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2946 grid->getNodeNeighborInfo(nid, neighbors, distance, azimuth);
2949 inline void SlbmInterface::getActiveNodeNeighborInfo(
const int& nid,
int neighbors[],
2950 double distance[],
double azimuth[],
int& nNeighbors)
2955 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2956 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
2957 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2958 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2961 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth, nNeighbors);
2964 inline void SlbmInterface::getActiveNodeNeighborInfo(
const int& nid,
2965 vector<int>& neighbors, vector<double>& distance, vector<double>& azimuth)
2970 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2971 os << endl <<
"ERROR in SlbmInterface::getActiveNodeNeighborInfo" << endl
2972 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2973 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2976 grid->getActiveNodeNeighborInfo(nid, neighbors, distance, azimuth);
2979 inline void SlbmInterface::getNodeSeparation(
const int& node1,
const int& node2,
double& distance)
2984 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2985 os << endl <<
"ERROR in SlbmInterface::getNodeSeparation" << endl
2986 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
2987 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
2990 grid->getNodeSeparation(node1, node2, distance);
2993 inline void SlbmInterface::getNodeAzimuth(
const int& node1,
const int& node2,
double& azimuth)
2998 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
2999 os << endl <<
"ERROR in SlbmInterface::getNodeAzimuth" << endl
3000 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3001 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3004 grid->getNodeAzimuth(node1, node2, azimuth);
3007 inline void SlbmInterface::initializeActiveNodes(
const double& latmin,
const double& lonmin,
3008 const double& latmax,
const double& lonmax)
3013 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3014 os << endl <<
"ERROR in SlbmInterface::initializeActiveNodes" << endl
3015 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3016 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3019 grid->initializeActiveNodes(latmin, lonmin, latmax, lonmax);
3022 inline void SlbmInterface::initializeActiveNodes(
double* lat,
double* lon,
const int& npoints,
const bool& inDegrees)
3027 for (
int i=0; i<npoints; ++i)
3028 v.push_back(GeoTessUtils::getVectorDegrees(lat[i], lon[i]));
3030 for (
int i=0; i<npoints; ++i)
3031 v.push_back(GeoTessUtils::getVector(lat[i], lon[i]));
3032 initializeActiveNodes(v);
3034 inline void SlbmInterface::initializeActiveNodes(
const vector<double> lat,
const vector<double> lon,
const bool& inDegrees)
3037 if (lat.size() == lon.size())
3039 npoints = lat.size();
3044 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3045 os << endl <<
"ERROR in SlbmInterface::getInterpolatedTransect" << endl
3046 <<
"Size of lat and lon vectors do not match." << endl
3047 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3053 for (
int i=0; i<npoints; ++i)
3054 v.push_back(GeoTessUtils::getVectorDegrees(lat[i], lon[i]));
3056 for (
int i=0; i<npoints; ++i)
3057 v.push_back(GeoTessUtils::getVector(lat[i], lon[i]));
3058 initializeActiveNodes(v);
3061 inline void SlbmInterface::initializeActiveNodes(vector<double*>& unitVectors)
3063 initializeActiveNodes(
new GeoTessPolygon(unitVectors));
3066 inline void SlbmInterface::initializeActiveNodes(GeoTessPolygon* polygon)
3068 grid->initializeActiveNodes(polygon);
3071 inline void SlbmInterface::initializeActiveNodes(
const string& fileName)
3073 grid->initializeActiveNodes(
new GeoTessPolygon(fileName));
3076 inline void SlbmInterface::clearActiveNodes()
3078 grid->clearActiveNodes();
3082 inline int SlbmInterface::getNActiveNodes()
3087 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3088 os << endl <<
"ERROR in SlbmInterface::nextActiveNode" << endl
3089 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3090 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3093 return grid->getNActiveNodes();
3096 inline int SlbmInterface::getGridNodeId(
int activeNodeId)
3101 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3102 os << endl <<
"ERROR in SlbmInterface::getGridNodeId" << endl
3103 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3104 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3107 return grid->getGridNodeId(activeNodeId);
3110 inline int SlbmInterface::getActiveNodeId(
int gridNodeId)
3115 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3116 os << endl <<
"ERROR in SlbmInterface::getActiveNodeId" << endl
3117 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3118 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3121 return grid->getActiveNodeId(gridNodeId);
3124 inline void SlbmInterface::getNodeHitCount(
const int& nodeId,
int& hitCount)
3129 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3130 os << endl <<
"ERROR in SlbmInterface::getNodeHitCount" << endl
3131 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3132 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3135 grid->getNodeHitCount(nodeId, hitCount);
3138 inline void SlbmInterface::clearNodeHitCount()
3143 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3144 os << endl <<
"ERROR in SlbmInterface::clearNodeHitCount" << endl
3145 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3146 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3149 grid->clearNodeHitCount();
3152 inline void SlbmInterface::getAverageMantleVelocity(
const int& type,
double& velocity)
3157 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3158 os << endl <<
"ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3159 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3160 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3163 velocity = grid->getAverageMantleVelocity(type);
3166 inline double SlbmInterface::getAverageMantleVelocity(
const int &type)
3171 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3172 os << endl <<
"ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3173 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3174 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3177 return grid->getAverageMantleVelocity(type);
3180 inline void SlbmInterface::setAverageMantleVelocity(
const int& type,
3181 const double& velocity)
3186 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3187 os << endl <<
"ERROR in SlbmInterface::setAverageMantleVelocity" << endl
3188 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3189 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3192 grid->setAverageMantleVelocity(type, velocity);
3195 inline void SlbmInterface::getTessId(
string& tessId)
3200 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3201 os << endl <<
"ERROR in SlbmInterface::getTessId" << endl
3202 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3203 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3206 tessId = grid->getTessId();
3209 inline void SlbmInterface::getFractionActive(
double& fractionActive)
3213 fractionActive = NA_VALUE;
3215 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3216 os << endl <<
"ERROR in SlbmInterface::getFractionActive" << endl
3217 <<
"GreatCircle is invalid." << endl
3218 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3221 fractionActive = greatCircle->getFractionActive();
3224 inline string SlbmInterface::getClassCount()
3227 os <<
"Class counts:" << endl;
3228 os <<
"GreatCircle = " << GreatCircle::getClassCount() << endl;
3229 os <<
"GridProfile = " << GridProfile::getClassCount() << endl;
3230 os <<
"GeoStack = " << GeoStack::getClassCount() << endl;
3231 os <<
"InterpolatedProfile = " << InterpolatedProfile::getClassCount() << endl;
3232 os <<
"CrustalProfile = " << CrustalProfile::getClassCount() << endl;
3233 os <<
"LayerProfile = " << LayerProfile::getClassCount() << endl;
3234 os <<
"QueryProfile = " << QueryProfile::getClassCount() << endl;
3235 os <<
"Location = " << Location::getClassCount() << endl;
3239 inline const string& SlbmInterface::getModelPath()
const {
return grid->getModelPath(); }
3241 inline void SlbmInterface::getPiercePointSource(
double& lat,
double& lon,
double& depth)
3245 lat = lon = NA_VALUE;
3247 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3248 os << endl <<
"ERROR in SlbmInterface::getPiercePointSource" << endl
3249 <<
"GreatCircle is invalid." << endl
3250 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3255 if ((greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg) && !greatCircle->getSourceProfile()->isInCrust())
3257 lat = lon = NA_VALUE;
3259 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3260 os << endl <<
"ERROR in SlbmInterface::getPiercePointSource" << endl
3261 <<
"Cannot compute moho pierce points for crustal phase (" << getPhase() <<
") when source is in the mantle." << endl
3262 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3267 greatCircle->getGreatCircleLocation(greatCircle->getSourceDistance(), loc);
3273 profile = grid->getQueryProfile(loc);
3274 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
3275 depth = profile->
getDepth()[MIDDLE_CRUST_G];
3277 depth = profile->
getDepth()[MANTLE];
3281 inline void SlbmInterface::getPiercePointReceiver(
double& lat,
double& lon,
double& depth)
3285 lat = lon = NA_VALUE;
3287 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3288 os << endl <<
"ERROR in SlbmInterface::getPiercePointReceiver" << endl
3289 <<
"GreatCircle is invalid." << endl
3290 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3295 if ((greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg) && !greatCircle->getReceiverProfile()->isInCrust())
3297 lat = lon = NA_VALUE;
3299 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3300 os << endl <<
"ERROR in SlbmInterface::getPiercePointReceiver" << endl
3301 <<
"Cannot compute moho pierce points for crustal phase (" << getPhase() <<
") when receiver is in the mantle." << endl
3302 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3307 greatCircle->getGreatCircleLocation(
3308 greatCircle->getDistance()-greatCircle->getReceiverDistance(), loc);
3314 profile = grid->getQueryProfile(loc);
3315 if (greatCircle->getPhase() == Pg || greatCircle->getPhase() == Lg)
3316 depth = profile->
getDepth()[MIDDLE_CRUST_G];
3318 depth = profile->
getDepth()[MANTLE];
3322 inline void SlbmInterface::getGreatCirclePoints(
3333 double dx = a.
distance(b)/(npoints-1);
3335 double moveDirection[3];
3337 for (
int i=0; i<npoints; i++)
3339 a.
move(moveDirection, i*dx, b);
3340 latitude[i] = b.
getLat();
3341 longitude[i] = b.
getLon();
3345 inline void SlbmInterface::getGreatCirclePoints(
3351 vector<double> &latitude,
3352 vector<double> &longitude)
3354 latitude.resize(npoints);
3355 longitude.resize(npoints);
3359 double dx = a.
distance(b)/(npoints-1);
3361 double moveDirection[3];
3363 for (
int i=0; i<npoints; i++)
3365 a.
move(moveDirection, i*dx, b);
3366 latitude[i] = b.
getLat();
3367 longitude[i] = b.
getLon();
3371 inline void SlbmInterface::getGreatCirclePointsOnCenters(
3384 double moveDirection[3];
3386 for (
int i=0; i<npoints; i++)
3388 a.
move(moveDirection, (i+0.5)*dx, b);
3389 latitude[i] = b.
getLat();
3390 longitude[i] = b.
getLon();
3394 inline void SlbmInterface::getGreatCirclePointsOnCenters(
3400 vector<double> &latitude,
3401 vector<double> &longitude)
3403 latitude.resize(npoints);
3404 longitude.resize(npoints);
3410 double moveDirection[3];
3412 for (
int i=0; i<npoints; i++)
3414 a.
move(moveDirection, (i+0.5)*dx, b);
3415 latitude[i] = b.
getLat();
3416 longitude[i] = b.
getLon();
3420 inline void SlbmInterface::getDistAz(
const double& aLat,
const double& aLon,
3421 const double& bLat,
const double& bLon,
3422 double& distance,
double& azimuth,
const double& naValue)
3427 azimuth = ptA.
azimuth(ptB, naValue);
3430 inline void SlbmInterface::movePoint(
const double& aLat,
const double& aLon,
3431 const double& distance,
const double& azimuth,
3432 double& bLat,
double& bLon)
3436 ptA.
move(azimuth, distance, ptB);
3441 inline void SlbmInterface::setInterpolatorType(
const string& interpolatorType)
3446 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3447 os << endl <<
"ERROR in SlbmInterface::setInterpolatorType" << endl
3448 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3449 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3452 grid->setInterpolatorType(interpolatorType);
3455 inline string SlbmInterface::getInterpolatorType()
3460 os << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(9);
3461 os << endl <<
"ERROR in SlbmInterface::getInterpolatorType" << endl
3462 <<
"Grid is invalid. Has the earth model been loaded with call to loadVelocityModel()?" << endl
3463 <<
"Version " << SlbmVersion <<
" File " << __FILE__ <<
" line " << __LINE__ << endl << endl;
3466 return grid->getInterpolatorType();
The GreatCircle class manages information related to a great circle path between two Locations on the...
A 2 dimensional, horizontal grid of GirdProfile objects.
The Location Class manages a single point in/on the Earth, which is described by the GRS80 ellipsoid.
double getLon() const
Retrieve the longitude of this Location. Value will be between -PI and PI radians.
double distance(const Location &other) const
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...
bool vectorTripleProduct(const Location &other, double vtp[]) const
Compute the vector triple product (this x other) x this, normalized to unit length....
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.
double getLat() const
Retrieve the geographic latitude of this Location, radians.
An InterpolatedProfile object that also has information about the the P and S wave velocity as a func...
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.
double * getDepth()
Retrieve the depth of the top of the k'th interval, in km.
An Exception class for Grid and related objects.
The primary interface to the SLBM library, providing access to all supported functionality.
SlbmInterface(const double &earthRadius)
Parameterized constructor. Instantiates an SlbmInterface object that is only partly based on an ellip...
double getRcvLon()
getter for read-only attributes property getter for read-only attributes property
double getSrcLon()
getter for read-only attributes property getter for read-only attributes property
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...
double getHeadwaveDistance()
void setDelDepth(const double &del_depth)
Change the value of step change in depth used to compute depth derivatives (km)
void setDelDistance(const double &del_distance)
Change the value of step change in distance used to compute horizontal derivatives(in radians).
bool isEqual(SlbmInterface *other)
Check if the model and/or greatCircle attached to the current SlbmInterface is equal that in another ...
double getSourceDistance()
int getNodeHitCount(const int &nodeId)
void getRayParameter(double &ray_parameter)
Retrieve the ray parameter.
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.
GreatCircle * greatCircle
The most recently requested GreatCircle object.
void saveVelocityModel(const string &modelFileName, const int &format=4)
Save the velocity model currently in memory to the specified file.
SlbmInterface()
Default constructor. Instantiates an SlbmInterface object based on an ellipsoidal earth.
bool isValid()
Returns true if the current GreatCirlce object has been instantiated and is ready to be interrogated.
void setPathIncrement(const double &pathIncrement)
Set the desired spacing of great circle nodes along the head wave interface, in radians.
double getTurningRadius()
void getDelDistance(double &del_distance)
Retrieve the value of step change in distance used to compute horizontal derivatives (radians)
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...
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.
Grid * grid
The Grid object that stores the velocity model.
void getTravelTimeUncertainty1D(double &travelTimeUncertainty)
Retrieve travel time uncertainty in sec using the phase and distance specified in last call to getGre...
double getFractionActive()
Grid * getGridObject()
Retrieve a pointer to the Grid object.
static bool modelsEqual(const string modelPath1, const string modelPath2)
Check if two models are equal.
void loadVelocityModel(const string &modelPath)
Load the velocity model into memory from the specified file or directory. This method automatically d...
void getTurningRadius(double &turning_radius)
Retrieve the turning radius of the ray.
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 ...
static void getMaxDepth(double &maxDepth)
Retrieve the current value for the maximum source depth, in km.
static void getMaxDistance(double &maxDistance)
Retrieve the current value for the maximum source-receiver separation, in radians.
GeoTessModelSLBM * getModelObject()
Retrieve a pointer to the GeoTessModelSLBM object.
void clear()
Delete the current GreatCircle object from memory and clear the pool of stored CrustalProfile objects...
static double getMaxDistance()
void getDistance(double &distance)
Retrieve the source-receiver separation, in radians.
int getBufferSize() const
Returns the size of a DataBuffer object required to store this SLBMInterface objects model data.
double getSrcLat()
getter for read-only attributes property getter for read-only attributes property
double getRcvLat()
getter for read-only attributes property getter for read-only attributes property
static double getMaxDepth()
void getTravelTimeUncertainty(const int &phase, const double &distance, double &uncert)
Retrieve the travel time uncertainty in sec for specified phase, distance (in radians).
double getSrcDep()
getter for read-only attributes property getter for read-only attributes property
double getRcvDep()
getter for read-only attributes property getter for read-only attributes property
virtual ~SlbmInterface()
Destructor.
string getVersion()
Retrieve the SLBM Version number.
void getTravelTimeUncertainty(double &travelTimeUncertainty, bool calcRandomError=false)
Retrieve travel time uncertainty in sec using the phase and distance specified in last call to getGre...
void getPathIncrement(double &pathIncrement)
Retrieve the current value of the spacing of great circle nodes along the head wave interface,...
double getPathIncrement()
Retrieve the current value of the spacing of great circle nodes along the head wave interface,...
void getDelDepth(double &del_depth)
Retrieve the value of step change in depth used to compute depth derivatives (km)
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...
void get_dtt_ddist(double &slowness)
Retrieve the horizontal slowness, i.e., the derivative of travel time wrt to receiver-source distance...
static void setMaxDistance(const double &maxDistance)
Set the maximum source-receiver separation for Pn/Sn phase, in radians.
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...
static void setMaxDepth(const double &maxDepth)
Set the maximum source depth for Pn/Sn phase, in km.
bool valid
true if the current GreatCirlce object has been instantiated and is ready to be interrogated.
string getPhase()
Retrieve the phase specified in last call to createGreatCircle().
double getReceiverDistance()
double getHeadwaveDistanceKm()
A byte array container used to hold binary data in the same manner as disk based file system.