[cig-commits] r13363 - in cs/spatialdata-0.1/trunk: libsrc/spatialdb modulesrc/spatialdb spatialdata/spatialdb tests/libtests/spatialdb tests/pytests/spatialdb

brad at geodynamics.org brad at geodynamics.org
Thu Nov 20 16:18:45 PST 2008


Author: brad
Date: 2008-11-20 16:18:45 -0800 (Thu, 20 Nov 2008)
New Revision: 13363

Modified:
   cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.cc
   cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.hh
   cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.icc
   cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe.src
   cs/spatialdata-0.1/trunk/spatialdata/spatialdb/SCECCVMH.py
   cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestSCECCVMH.cc
   cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSCECCVMH.py
Log:
Added minimum shear wave speed to SCEC CVM-H queries.

Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.cc	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.cc	2008-11-21 00:18:45 UTC (rev 13363)
@@ -44,6 +44,7 @@
   _mohoDepth(0),
   _csUTM(new geocoords::CSGeoProj),
   _squashLimit(-2000.0),
+  _minVs(0.0),
   _queryVals(0),
   _querySize(0),
   _squashTopo(false)
@@ -77,12 +78,27 @@
   delete _csUTM; _csUTM = 0;
 
   _squashLimit = 0.0;
+  _minVs = 0.0;
   delete[] _queryVals; _queryVals = 0;
   _querySize = 0;
   _squashTopo = 0;
 } // destructor
 
 // ----------------------------------------------------------------------
+// Set minimum shear wave speed.
+void
+spatialdata::spatialdb::SCECCVMH::minVs(const double value)
+{ // minVs
+  if (value < 0.0) {
+    std::ostringstream msg;
+    msg << "Value for minimum shear wave speed (" << value 
+	<< ") must be non-negative.";
+    throw std::runtime_error(msg.str());
+  } // if
+  _minVs = value;
+} // minVs
+
+// ----------------------------------------------------------------------
 // Open the database and prepare for querying.
 void
 spatialdata::spatialdb::SCECCVMH::open(void)
@@ -310,6 +326,12 @@
   } else
     outsideVoxet = _crustMantleVp->queryNearest(vp, _xyzUTM);
 
+  if (!outsideVoxet) {
+    const double minVp = _minVp();
+    if (*vp < minVp)
+      *vp = minVp;
+  } // if
+
   return outsideVoxet;
 } // _queryVp
 
@@ -337,11 +359,14 @@
 // ----------------------------------------------------------------------
 // Compute density from Vp.
 double
-spatialdata::spatialdb::SCECCVMH::_calcDensity(const double vp)
+spatialdata::spatialdb::SCECCVMH::_calcDensity(const double vp) const
 { // _calcDensity
-  double density = vp / 3.0 + 1280.0;
-  if (vp < 2160.0) {
-    if (vp != 1480.0) // if not water
+  const double minVp = _minVp();
+  const double vpAdj = (vp < minVp) ? minVp : vp;
+
+  double density = vpAdj / 3.0 + 1280.0;
+  if (vpAdj < 2160.0) {
+    if (vpAdj != 1480.0) // if not water
       density = 2000.0;
     else
       density = 1000.0; // water
@@ -353,7 +378,7 @@
 // ----------------------------------------------------------------------
 // Compute density from Vp.
 double
-spatialdata::spatialdb::SCECCVMH::_calcVs(const double vp)
+spatialdata::spatialdb::SCECCVMH::_calcVs(const double vp) const
 { // _calcVs
   double vs = (vp < 4250.0) ?
     (vp - 1360.0) / 1.16 :
@@ -365,6 +390,9 @@
     else 
       vs = 0.0; // water
 
+  if (vs < _minVs)
+    vs = _minVs;
+
   return vs;
 } // _calcVs
 

Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.hh
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.hh	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.hh	2008-11-21 00:18:45 UTC (rev 13363)
@@ -49,6 +49,14 @@
    */
   void dataDir(const char* dir);
  
+  /** Set minimum shear wave speed. Corresponding minima for Vp and
+   * density are enforced using nominal Vp->Vs relation and
+   * Vp->density relations.
+   *
+   * @param value Minimum shear wave speed.
+   */
+  void minVs(const double value);
+
   /** Set squashed topography/bathymetry flag and minimum elevation of
    * squashing.
    *
@@ -137,17 +145,21 @@
    * @param vp Vp in m/s.
    * @returns density in kg/m^3.
    */
-  static
-  double _calcDensity(const double vp);
+  double _calcDensity(const double vp) const;
 
   /** Compute density from Vp.
    *
    * @param vp Vp in m/s.
    * @returns Vs in m/s.
    */
-  static
-  double _calcVs(const double vp);
+  double _calcVs(const double vp) const;
 
+  /** Compute minimum Vp from minimum Vs.
+   *
+   * @returns Minimum Vp.
+   */
+  double _minVp(void) const;
+
 // PRIVATE MEMBERS //////////////////////////////////////////////////////
 private :
 
@@ -166,6 +178,7 @@
   geocoords::CSGeoProj* _csUTM;
 
   double _squashLimit; ///< Elevation above which topography is squashed.
+  double _minVs; ///< Minimum Vs to use.
   int* _queryVals; ///< Indices of values to be returned in queries.
   int _querySize; ///< Number of values requested to be returned in queries.
   bool _squashTopo; ///< Squash topography/bathymetry to sea level.

Modified: cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.icc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.icc	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/libsrc/spatialdb/SCECCVMH.icc	2008-11-21 00:18:45 UTC (rev 13363)
@@ -30,5 +30,13 @@
   _squashLimit = limit;
 }
 
+// Compute minimum Vp from minimum Vs.
+inline
+double
+spatialdata::spatialdb::SCECCVMH::_minVp(void) const {
+  // Use inverse of nominal Vp->Vs relation to compute minimum Vp.
+  const double minVp = 1360.0 + 1.16 * _minVs;
+  return minVp;
+}
 
 // End of file

Modified: cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe.src
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe.src	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe.src	2008-11-21 00:18:45 UTC (rev 13363)
@@ -745,6 +745,20 @@
     return
 
 
+  def minVs(self, value):
+    """
+    Set minimum shear wave speed.
+    """
+    # create shim for method 'minVs'
+    #embed{ void SCECCVMH_minVs(void* pObj, double value)
+    assert(0 != pObj);
+    ((spatialdata::spatialdb::SCECCVMH*) pObj)->minVs(value);
+    #}embed
+
+    SCECCVMH_minVs(self.thisptr, value)
+    return
+
+
   def squash(self, flag, limit):
     """
     Set squashed topography/bathymetry flag and minimum elevation of 

Modified: cs/spatialdata-0.1/trunk/spatialdata/spatialdb/SCECCVMH.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/spatialdb/SCECCVMH.py	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/spatialdata/spatialdb/SCECCVMH.py	2008-11-21 00:18:45 UTC (rev 13363)
@@ -39,6 +39,7 @@
     ##
     ## \b Properties
     ## @li \b data_dir Directory containing SCEC CVM-H data files.
+    ## @li \b min_vs Minimum shear wave speed.
     ## @li \b squash Squash topography/bathymetry to sea level.
     ## @li \b squash_limit Elevation above which topography is squashed.
     ##
@@ -50,6 +51,11 @@
     dataDir = pyre.inventory.str("data_dir", default=".")
     dataDir.meta['tip'] = "Directory containing SCEC CVM-H data files."
 
+    from pyre.units.length import meter
+    from pyre.units.time import second
+    minVs = pyre.inventory.dimensional("min_vs", default=500.0*meter/second)
+    minVs.meta['tip'] = "Minimum shear wave speed."
+
     squash = pyre.inventory.bool("squash", default=False)
     squash.meta['tip'] = "Squash topography/bathymetry to sea level."
 
@@ -78,6 +84,7 @@
     """
     SpatialDB.initialize(self)
     self.cppHandle.dataDir(self.dataDir)
+    self.cppHandle.minVs(self.minVs.value)
     self.cppHandle.squash(self.squash, self.squashLimit.value)
     return
   
@@ -90,6 +97,7 @@
     """
     SpatialDB._configure(self)
     self.dataDir = self.inventory.dataDir
+    self.minVs = self.inventory.minVs
     self.squash = self.inventory.squash
     self.squashLimit = self.inventory.squashLimit
     return

Modified: cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestSCECCVMH.cc
===================================================================
--- cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestSCECCVMH.cc	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/tests/libtests/spatialdb/TestSCECCVMH.cc	2008-11-21 00:18:45 UTC (rev 13363)
@@ -485,9 +485,10 @@
     2000.0,
   };
 
+  SCECCVMH db;
   const double tolerance = 1.0e-06;
   for (int i=0; i < size; ++i) {
-    const double density = SCECCVMH::_calcDensity(vp[i]);
+    const double density = db._calcDensity(vp[i]);
     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
 				 density/densityE[i], tolerance);
   } // for
@@ -524,9 +525,10 @@
     431.0344827586207,
   };
 
+  SCECCVMH db;
   const double tolerance = 1.0e-06;
   for (int i=0; i < size; ++i) {
-    const double vs = SCECCVMH::_calcVs(vp[i]);
+    const double vs = db._calcVs(vp[i]);
     if (fabs(vsE[i]) > tolerance)
       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
 				   vs/vsE[i], tolerance);

Modified: cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSCECCVMH.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSCECCVMH.py	2008-11-20 22:08:08 UTC (rev 13362)
+++ cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSCECCVMH.py	2008-11-21 00:18:45 UTC (rev 13363)
@@ -20,7 +20,7 @@
     from spatialdata.spatialdb.SCECCVMH import SCECCVMH
     db = SCECCVMH()
     db._configure()
-    db.dataDir = "/Users/brad/data/sceccvm-h/vx52/bin"
+    db.dataDir = "/home/brad/data/sceccvm-h/vx53/bin"
     db.initialize()
     self._db = db
     return



More information about the CIG-COMMITS mailing list