[cig-commits] r20442 - in cs/spatialdata/trunk: libsrc/spatialdb tests/pytests/spatialdb

brad at geodynamics.org brad at geodynamics.org
Fri Jun 29 14:24:38 PDT 2012


Author: brad
Date: 2012-06-29 14:24:38 -0700 (Fri, 29 Jun 2012)
New Revision: 20442

Modified:
   cs/spatialdata/trunk/libsrc/spatialdb/SimpleGridDB.cc
   cs/spatialdata/trunk/libsrc/spatialdb/SpatialDB.cc
   cs/spatialdata/trunk/tests/pytests/spatialdb/TestSimpleGridDB.py
Log:
Fixed units scaling issue and updated unit tests appropriately.

Modified: cs/spatialdata/trunk/libsrc/spatialdb/SimpleGridDB.cc
===================================================================
--- cs/spatialdata/trunk/libsrc/spatialdb/SimpleGridDB.cc	2012-06-29 19:08:40 UTC (rev 20441)
+++ cs/spatialdata/trunk/libsrc/spatialdb/SimpleGridDB.cc	2012-06-29 21:24:38 UTC (rev 20442)
@@ -186,6 +186,7 @@
   } // for
 } // queryVals
 
+#include <iostream>
 // ----------------------------------------------------------------------
 // Query the database.
 int
@@ -275,6 +276,13 @@
     const int indexData = _dataIndex(indexNearestX, indexNearestY, indexNearestZ);
     for (int iVal=0; iVal < querySize; ++iVal) {
       vals[iVal] = _data[indexData+_queryVals[iVal]];
+#if 0 // DEBUGGING
+    std::cout << "val["<<iVal<<"]: " << vals[iVal]
+	      << ", indexX: " << indexX
+	      << ", indexY: " << indexY
+	      << ", indexZ: " << indexZ
+	      << std::endl;
+#endif
     } // for
     break;
   } // NEAREST
@@ -448,7 +456,6 @@
   _cs->initialize();
 } // _readHeader
 
-#include <iostream>
 // ----------------------------------------------------------------------
 // Read data values.
 void
@@ -671,7 +678,6 @@
   return index;
 } // _search
 
-#include <iostream>
 // ----------------------------------------------------------------------
 // Interpolate to get values at target location defined by indices in 3-D.
 void

Modified: cs/spatialdata/trunk/libsrc/spatialdb/SpatialDB.cc
===================================================================
--- cs/spatialdata/trunk/libsrc/spatialdb/SpatialDB.cc	2012-06-29 19:08:40 UTC (rev 20441)
+++ cs/spatialdata/trunk/libsrc/spatialdb/SpatialDB.cc	2012-06-29 21:24:38 UTC (rev 20442)
@@ -132,6 +132,7 @@
 } // multiquery
 
 
+#include <iostream>
 // ----------------------------------------------------------------------
 // Convert values to SI units.
 void
@@ -148,15 +149,16 @@
   const std::string& none = "none";
   std::vector<double> scales(numVals);
   for (int iVal=0; iVal < numVals; ++iVal) {
-    if (none == units[iVal])
+    if (none != units[iVal]) {
       scales[iVal] = parser.parse(units[iVal].c_str());
-    else
+    } else {
       scales[iVal] = 1.0;
+    } // if/else
   } // for
 
   for (int iLoc=0; iLoc < numLocs; ++iLoc) {
     for (int iVal=0; iVal < numVals; ++iVal) {
-      vals[iVal] *= scales[iVal];
+      vals[iLoc*numVals+iVal] *= scales[iVal];
     } // for
   } // for
 } // _convertToSI

Modified: cs/spatialdata/trunk/tests/pytests/spatialdb/TestSimpleGridDB.py
===================================================================
--- cs/spatialdata/trunk/tests/pytests/spatialdb/TestSimpleGridDB.py	2012-06-29 19:08:40 UTC (rev 20441)
+++ cs/spatialdata/trunk/tests/pytests/spatialdb/TestSimpleGridDB.py	2012-06-29 21:24:38 UTC (rev 20442)
@@ -39,8 +39,8 @@
     cs = CSCart()
     cs._configure()
     queryVals = ["two", "one"]
-    dataE = numpy.array( [[2.20, 1.04],
-                          [2.22, 1.02]], numpy.float64)
+    dataE = numpy.array( [[0.0220, 1.04],
+                          [0.0222, 1.02]], numpy.float64)
     errE = [0, 0]
 
     db = self._db
@@ -74,8 +74,8 @@
     cs = CSCart()
     cs._configure()
     queryVals = ["two", "one"]
-    dataE = numpy.array( [[2.07, 1.17],
-                          [2.09, 1.15]], numpy.float64)
+    dataE = numpy.array( [[0.0207, 1.17],
+                          [0.0209, 1.15]], numpy.float64)
     errE = numpy.array([0, 0], numpy.int32)
 
     db = self._db



More information about the CIG-COMMITS mailing list