def run(self): """ Generate the database. """ from axialdisp_soln import AnalyticalSoln soln = AnalyticalSoln() from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 3 cs._configure() from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() for component in ["x", "y", "z"]: if component == "x": xyz = numpy.array([[-40.0e+3, 0.0, 0.0], [+40.0e+3, 0.0, 0.0]], dtype=numpy.float64) ic = 0 elif component == "y": xyz = numpy.array([[0.0, -40.0e+3, 0.0], [0.0, +40.0e+3, 0.0]], dtype=numpy.float64) ic = 1 elif component == "z": xyz = numpy.array([[0.0, 0.0, -40.0e+3], [0.0, 0.0, 0.0]], dtype=numpy.float64) ic = 2 disp = soln.displacement(xyz) io.inventory.filename = "axial_disp%s.spatialdb" % component io._configure() data = { 'points': xyz, 'coordsys': cs, 'data_dim': 1, 'values': [ { 'name': "displacement-%s" % component, 'units': "m", 'data': numpy.ravel(disp[0, :, ic]) }, ] } io.write(data) return
def generate(sim, fileRoot, materials): for material in materials: filenameH5 = "../output/%s-%s.h5" % (sim, material) filenameDB = "%s-%s.spatialdb" % (fileRoot, material) # Open HDF5 file and get coordinates, cells, and stress. h5 = h5py.File(filenameH5, "r") vertices = h5['geometry/vertices'][:] cells = numpy.array(h5['topology/cells'][:], dtype=numpy.int) # Get stresses from final time step. stress = h5['cell_fields/stress'][-1,:,:] h5.close() # Compute coordinates of quadrature points. quadCoords = getCellCenters(vertices, cells) # Create writer for spatial database file writer = SimpleIOAscii() writer.inventory.filename = filenameDB writer._configure() values = [{'name': "stress-xx", 'units': "Pa", 'data': stress[:,0]}, {'name': "stress-yy", 'units': "Pa", 'data': stress[:,1]}, {'name': "stress-zz", 'units': "Pa", 'data': stress[:,2]}, {'name': "stress-xy", 'units': "Pa", 'data': stress[:,3]}, {'name': "stress-yz", 'units': "Pa", 'data': stress[:,4]}, {'name': "stress-xz", 'units': "Pa", 'data': stress[:,5]}, ] writer.write({'points': quadCoords, 'coordsys': cs, 'data_dim': 3, 'values': values}) return
def run(self): """ Generate the database. """ # Domain dx = 200.0 x = numpy.arange(-1000.0, 1000.1, dx) y = numpy.arange(-1000.0, 0.1, dx) nptsx = x.shape[0] nptsy = y.shape[0] xx = x * numpy.ones((nptsy, 1), dtype=numpy.float64) yy = y * numpy.ones((nptsx, 1), dtype=numpy.float64) xy = numpy.zeros((nptsx * nptsy, 2), dtype=numpy.float64) xy[:, 0] = numpy.ravel(xx) xy[:, 1] = numpy.ravel(numpy.transpose(yy)) from shearrotate_soln import AnalyticalSoln soln = AnalyticalSoln() disp = soln.displacement(xy) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() data = { 'points': xy, 'coordsys': cs, 'data_dim': 2, 'values': [{ 'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[0, :, 0]) }, { 'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[0, :, 1]) }] } from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = "shearrotate_disp.spatialdb" io._configure() io.write(data) return
def run(self): """ Generate the database. """ # Domain x = numpy.arange(-4000.0, 4000.1, 1000.0) y = numpy.arange(-4000.0, 4000.1, 1000.0) z = numpy.arange(-6000.0, 0000.1, 1000.0) nptsX = x.shape[0] nptsY = y.shape[0] nptsZ = z.shape[0] xx = x * numpy.ones( (nptsY*nptsZ, 1), dtype=numpy.float64) yy0 = y * numpy.ones( (nptsZ, 1), dtype=numpy.float64) yy = yy0.ravel() * numpy.ones( (nptsX, 1), dtype=numpy.float64) zz = z * numpy.ones( (nptsX*nptsY, 1), dtype=numpy.float64) xyz = numpy.zeros( (nptsX*nptsY*nptsZ, 3), dtype=numpy.float64) xyz[:,0] = numpy.ravel(xx) xyz[:,1] = numpy.ravel(numpy.transpose(yy)) xyz[:,2] = numpy.ravel(numpy.transpose(zz)) from rigidbody_soln import AnalyticalSoln soln = AnalyticalSoln() disp = soln.displacement(xyz) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 3 cs._configure() data = {'locs': xyz, 'coordsys': cs, 'data_dim': 2, 'values': [{'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[:,0])}, {'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[:,1])}, {'name': "displacement-z", 'units': "m", 'data': numpy.ravel(disp[:,2])}]} from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = "rigidbody_disp.spatialdb" io._configure() io.write(data) return
def run(self): """ Generate the database. """ # Domain x = numpy.arange(-4000.0, 4000.1, 500.0) y = numpy.arange(-4000.0, 4000.1, 500.0) z = numpy.arange(-6000.0, 0.1, 500.0) nxpts = x.shape[0] nypts = y.shape[0] nzpts = z.shape[0] xx = numpy.tile(x, (1,nypts*nzpts)) yy = numpy.tile(y, (nxpts,nzpts)).transpose() zz = numpy.tile(z, (nxpts*nypts,1)).transpose() xyz = numpy.zeros( (nxpts*nypts*nzpts, 3), dtype=numpy.float64) xyz[:,0] = numpy.ravel(xx) xyz[:,1] = numpy.ravel(yy) xyz[:,2] = numpy.ravel(zz) from axialdisp_soln import AnalyticalSoln soln = AnalyticalSoln() disp = soln.displacement(xyz) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 3 cs._configure() data = {'points': xyz, 'coordsys': cs, 'data_dim': 3, 'values': [{'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[:,0])}, {'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[:,1])}, {'name': "displacement-z", 'units': "m", 'data': numpy.ravel(disp[:,2])}]} from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = "axial_disp.spatialdb" io._configure() io.write(data) return
def run(self): """ Generate the database. """ # Domain x = numpy.arange(-4000.0, 4000.1, 500.0) y = numpy.arange(-4000.0, 4000.1, 500.0) npts = x.shape[0] xx = x * numpy.ones((npts, 1), dtype=numpy.float64) yy = y * numpy.ones((npts, 1), dtype=numpy.float64) xy = numpy.zeros((npts**2, 2), dtype=numpy.float64) xy[:, 0] = numpy.ravel(xx) xy[:, 1] = numpy.ravel(numpy.transpose(yy)) disp = self.soln.displacement(xy) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() data = { 'points': xy, 'coordsys': cs, 'data_dim': 2, 'values': [{ 'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[0, :, 0]) }, { 'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[0, :, 1]) }] } from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = self.filename io._configure() io.write(data) return
def run(self): """ Generate the database. """ from sheardisp_soln import AnalyticalSoln soln = AnalyticalSoln() from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 3 cs._configure() from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() for component in ["x","y","z"]: if component == "y": xyz = numpy.array([[-40.0e+3, 0.0, 0.0], [+40.0e+3, 0.0, 0.0]], dtype=numpy.float64) ic = 1 elif component == "x": xyz = numpy.array([[0.0, -40.0e+3, 0.0], [0.0, +40.0e+3, 0.0]], dtype=numpy.float64) ic = 0 elif component == "z": xyz = numpy.array([[0.0, 0.0, -40.0e+3], [0.0, 0.0, 0.0]], dtype=numpy.float64) ic = 2 disp = soln.displacement(xyz) io.inventory.filename = "shear_disp%s.spatialdb" % component io._configure() data = {'points': xyz, 'coordsys': cs, 'data_dim': 1, 'values': [{'name': "displacement-%s" % component, 'units': "m", 'data': numpy.ravel(disp[0,:,ic])}, ]} io.write(data) return
def run(self): """ Generate the database. """ # Domain x = numpy.arange(-4000.0, 4000.1, 1000.0) y = numpy.arange(-4000.0, 4000.1, 1000.0) npts = x.shape[0] xx = x * numpy.ones((npts, 1), dtype=numpy.float64) yy = y * numpy.ones((npts, 1), dtype=numpy.float64) xy = numpy.zeros((npts ** 2, 2), dtype=numpy.float64) xy[:, 0] = numpy.ravel(xx) xy[:, 1] = numpy.ravel(numpy.transpose(yy)) from sheardisp_soln import AnalyticalSoln soln = AnalyticalSoln() disp = soln.displacement(xy) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() data = { "points": xy, "coordsys": cs, "data_dim": 2, "values": [ {"name": "displacement-x", "units": "m", "data": numpy.ravel(disp[0, :, 0])}, {"name": "displacement-y", "units": "m", "data": numpy.ravel(disp[0, :, 1])}, ], } from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = "shear_disp.spatialdb" io._configure() io.write(data) return
def run(self): """ Generate the database. """ # Domain dx = 200.0 x = numpy.arange(-1000.0, 1000.1, dx) y = numpy.arange(-1000.0, 0.1, dx) nptsx = x.shape[0] nptsy = y.shape[0] xx = x * numpy.ones( (nptsy, 1), dtype=numpy.float64) yy = y * numpy.ones( (nptsx, 1), dtype=numpy.float64) xy = numpy.zeros( (nptsx*nptsy, 2), dtype=numpy.float64) xy[:,0] = numpy.ravel(xx) xy[:,1] = numpy.ravel(numpy.transpose(yy)) from compressrotate_soln import AnalyticalSoln soln = AnalyticalSoln() disp = soln.displacement(xy) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() data = {'points': xy, 'coordsys': cs, 'data_dim': 2, 'values': [{'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[0,:,0])}, {'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[0,:,1])}]} from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = "compressrotate_disp.spatialdb" io._configure() io.write(data) return
def run(self): """ Generate the database. """ # Domain x = numpy.arange(-4000.0, 4000.1, 500.0) y = numpy.arange(-4000.0, 4000.1, 500.0) npts = x.shape[0] xx = x * numpy.ones( (npts, 1), dtype=numpy.float64) yy = y * numpy.ones( (npts, 1), dtype=numpy.float64) xy = numpy.zeros( (npts**2, 2), dtype=numpy.float64) xy[:,0] = numpy.ravel(xx) xy[:,1] = numpy.ravel(numpy.transpose(yy)) disp = self.soln.displacement(xy) from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs.inventory.spaceDim = 2 cs._configure() data = {'points': xy, 'coordsys': cs, 'data_dim': 2, 'values': [{'name': "displacement-x", 'units': "m", 'data': numpy.ravel(disp[0,:,0])}, {'name': "displacement-y", 'units': "m", 'data': numpy.ravel(disp[0,:,1])}]} from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii io = SimpleIOAscii() io.inventory.filename = self.filename io._configure() io.write(data) return
def test_write(self): """ Test write(). """ # Database info cs = CSCart() cs.initialize() filename = "data/test.spatialdb" data = { 'points': numpy.array([[1.0, 2.0, 3.0], [0.5, 3.0, -3.0]], numpy.float64), 'coordsys': cs, 'data_dim': 1, 'values': [{ 'name': "One", 'units': "m", 'data': numpy.array([2.0, 8.0], numpy.float64) }, { 'name': "Two", 'units': "m", 'data': numpy.array([-2.0, 3.0], numpy.float64) }] } dataDim = 1 qlocs = numpy.array( [[0.875, 2.25, 1.5], [0.6, 2.8, -1.8], [1.0, 2.0, 3.0]], numpy.float64) valsE = numpy.array([[-0.75, 3.5], [2.0, 6.8], [-2.0, 2.0]], numpy.float64) errE = [0, 0, 0] # Write database from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii writer = SimpleIOAscii() writer.inventory.filename = filename writer._configure() writer.write(data) # Test write using query from spatialdata.spatialdb.SimpleDB import SimpleDB db = SimpleDB() db.inventory.label = "test" db.inventory.queryType = "linear" db.inventory.iohandler.inventory.filename = filename db.inventory.iohandler._configure() db._configure() db.open() db.queryVals(["two", "one"]) vals = numpy.zeros(valsE.shape, dtype=numpy.float64) err = [] nlocs = qlocs.shape[0] for i in xrange(nlocs): e = db.query(vals[i, :], qlocs[i, :], cs) err.append(e) db.close() self.assertEqual(len(valsE.shape), len(vals.shape)) for dE, d in zip(valsE.shape, vals.shape): self.assertEqual(dE, d) for vE, v in zip(numpy.reshape(valsE, -1), numpy.reshape(vals, -1)): self.assertAlmostEqual(vE, v, 6) return
{ 'name': "viscous-strain-xx", 'units': "None", 'data': vstrain[:, 0] }, { 'name': "viscous-strain-yy", 'units': "None", 'data': vstrain[:, 1] }, { 'name': "viscous-strain-zz", 'units': "None", 'data': vstrain[:, 2] }, { 'name': "viscous-strain-xy", 'units': "None", 'data': vstrain[:, 3] }, ] writer.write({ 'points': quadCoords, 'coordsys': cs, 'data_dim': 2, 'values': values }) # End of file
# Create coordinate system for spatial database from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs._configure() cs.setSpaceDim(2) # Create writer for spatial database file from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii writer = SimpleIOAscii() writer.inventory.filename = "afterslip_tractions.spatialdb" writer._configure() writer.write({ 'points': vertices, 'coordsys': cs, 'data_dim': 1, 'values': [{ 'name': "traction-shear", 'units': "Pa", 'data': tractions_shear }, { 'name': "traction-normal", 'units': "Pa", 'data': tractions_normal }] }) # End of file
{'name': "total-strain-xx", 'units': "None", 'data': zeros}, {'name': "total-strain-yy", 'units': "None", 'data': zeros}, {'name': "total-strain-xy", 'units': "None", 'data': zeros}, {'name': "viscous-strain-xx", 'units': "None", 'data': strainViscous[:,0]}, {'name': "viscous-strain-yy", 'units': "None", 'data': strainViscous[:,1]}, {'name': "viscous-strain-zz", 'units': "None", 'data': strainViscous[:,2]}, {'name': "viscous-strain-xy", 'units': "None", 'data': strainViscous[:,3]}, ] writer.write({'points': cellCenters, 'coordsys': cs, 'data_dim': 0, 'values': values}) # End of file
tractionShearLL = maskO*-5.80*(1.0+numpy.cos(numpy.pi*(r-1400.0)/600.0)) + maskI*-11.60 tractionShearUD = 0*tractionShearLL tractionNormal = 0*tractionShearLL cs = CSCart() cs._configure() cs.initialize() dataOut = {'points': points, 'coordsys': cs, 'data_dim': 1, 'values': [{'name': 'traction-shear-leftlateral', 'units': 'MPa', 'data': tractionShearLL}, {'name': 'traction-shear-updip', 'units': 'MPa', 'data': tractionShearUD}, {'name': 'traction-normal', 'units': 'MPa', 'data': tractionNormal}, ], } writer = SimpleIOAscii() writer.inventory.filename = "initial_traction.spatialdb" writer._configure() writer.write(dataOut) # End of file
def _makeSpatialdb(self): """ Function to generate a set of spatial databases (one for each impulse). """ # Create empty arrays for impulse values. # Only array1 will be modified. array1 = numpy.zeros( (self.numFaultVertices,), dtype=numpy.float64) array2 = numpy.zeros( (self.numFaultVertices,), dtype=numpy.float64) # Set up info for arrays that won't be modified. if (self.impulseType == "left-lateral-slip"): info2 = {'name': "fault-opening", 'units': "m", 'data': array2.flatten()} if (self.spaceDim == 3): info3 = {'name': "reverse-slip", 'units': "m", 'data': array2.flatten()} elif (self.impulseType == "fault-opening"): info2 = {'name': "left-lateral-slip", 'units': "m", 'data': array2.flatten()} if (self.spaceDim == 3): info3 = {'name': "reverse-slip", 'units': "m", 'data': array2.flatten()} elif (self.impulseType == "reverse-slip"): info2 = {'name': "left-lateral-slip", 'units': "m", 'data': array2.flatten()} info3 = {'name': "fault-opening", 'units': "m", 'data': array2.flatten()} # Create root output filename. suffIndex = self.spatialdbOutputRoot.rfind(".spatialdb") outputRoot = self.spatialdbOutputRoot if (suffIndex != -1): outputRoot = self.spatialdbOutputRoot[:suffIndex - 1] # Set data dimension. dataDim = self.spaceDim - 1 # Loop over impulses to generate and modify the appropriate entries. for impulse in range(self.numFaultVertices): # Set filename impulseNum = int(impulse) impulseString = repr(impulseNum).rjust(self.impulseNumberWidth, '0') filename = outputRoot + "_i" + impulseString + ".spatialdb" writer = SimpleIOAscii() writer.inventory.filename = filename writer._configure() # Modify database values. array1[impulse] = self.impulseValue if (impulse > 0): array1[impulse - 1] = -self.impulseValue if (impulse > 1): array1[impulse - 2] = 0.0 info1 = {'name': self.impulseType, 'units': "m", 'data': array1.flatten()} # Create data and write it to a database. if (self.spaceDim == 2): data = {'points': self.faultVertices, 'coordsys': self.geometry.coordsys, 'data_dim': dataDim, 'values': [info1, info2]} else: data = {'points': self.faultVertices, 'coordsys': self.geometry.coordsys, 'data_dim': dataDim, 'values': [info1, info2, info3]} writer.write(data) return
def generate(sim, fileRoot, materials): for material in materials: filenameH5 = "../output/%s-%s.h5" % (sim, material) filenameDB = "%s-%s.spatialdb" % (fileRoot, material) # Open HDF5 file and get coordinates, cells, and stress. h5 = h5py.File(filenameH5, "r") vertices = h5['geometry/vertices'][:] cells = numpy.array(h5['topology/cells'][:], dtype=numpy.int) # Get stresses from final time step. stress = h5['cell_fields/stress'][-1, :, :] h5.close() # Compute coordinates of quadrature points. quadCoords = getCellCenters(vertices, cells) # Create writer for spatial database file writer = SimpleIOAscii() writer.inventory.filename = filenameDB writer._configure() values = [ { 'name': "stress-xx", 'units': "Pa", 'data': stress[:, 0] }, { 'name': "stress-yy", 'units': "Pa", 'data': stress[:, 1] }, { 'name': "stress-zz", 'units': "Pa", 'data': stress[:, 2] }, { 'name': "stress-xy", 'units': "Pa", 'data': stress[:, 3] }, { 'name': "stress-yz", 'units': "Pa", 'data': stress[:, 4] }, { 'name': "stress-xz", 'units': "Pa", 'data': stress[:, 5] }, ] writer.write({ 'points': quadCoords, 'coordsys': cs, 'data_dim': 3, 'values': values }) return
{'name': "total-strain-xx", 'units': "None", 'data': zeros}, {'name': "total-strain-yy", 'units': "None", 'data': zeros}, {'name': "total-strain-xy", 'units': "None", 'data': zeros}, {'name': "viscous-strain-xx", 'units': "None", 'data': vstrain[:,0]}, {'name': "viscous-strain-yy", 'units': "None", 'data': vstrain[:,1]}, {'name': "viscous-strain-zz", 'units': "None", 'data': vstrain[:,2]}, {'name': "viscous-strain-xy", 'units': "None", 'data': vstrain[:,3]}, ] writer.write({'points': quadCoords, 'coordsys': cs, 'data_dim': 2, 'values': values}) # End of file
# Open HDF5 file and get coordinates, cells, and stress. h5 = h5py.File(filenameH5, "r") vertices = h5['geometry/vertices'][:] cells = numpy.array(h5['topology/cells'][:], dtype=numpy.int) stress = h5['cell_fields/stress'][0,:,:] h5.close() # Get cell centers for output. cellCoords = vertices[cells,:] cellCenters = numpy.mean(cellCoords, axis=1) # Create writer for spatial database file writer = SimpleIOAscii() writer.inventory.filename = filenameDB writer._configure() writer.write({'points': cellCenters, 'coordsys': cs, 'data_dim': 2, 'values': [{'name': "stress-xx", 'units': "Pa", 'data': stress[:,0]}, {'name': "stress-yy", 'units': "Pa", 'data': stress[:,1]}, {'name': "stress-xy", 'units': "Pa", 'data': stress[:,2]}, ]})
# Background shear tractions are reverse (in 2-D right-lateral is negative) # because the normal tractions are negative. tractions_bg_shear = coef_friction*tractions_bg_normal # Combine traction changes and background tractions tractions_shear = tractions_bg_shear + tractions_change[:,0] tractions_normal = tractions_bg_normal + tractions_change[:,1] # Create coordinate system for spatial database from spatialdata.geocoords.CSCart import CSCart cs = CSCart() cs._configure() cs.setSpaceDim(2) # Create writer for spatial database file from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii writer = SimpleIOAscii() writer.inventory.filename = "afterslip_tractions.spatialdb" writer._configure() writer.write({'points': vertices, 'coordsys': cs, 'data_dim': 1, 'values': [{'name': "traction-shear", 'units': "Pa", 'data': tractions_shear}, {'name': "traction-normal", 'units': "Pa", 'data': tractions_normal}]}) # End of file
def test_write(self): """ Test write(). """ # Database info cs = CSCart() cs.initialize() filename = "data/test.spatialdb" data = {'points': numpy.array( [ [1.0, 2.0, 3.0], [0.5, 3.0, -3.0]], numpy.float64), 'coordsys': cs, 'data_dim': 1, 'values': [{'name': "One", 'units': "m", 'data': numpy.array( [2.0, 8.0], numpy.float64)}, {'name': "Two", 'units': "m", 'data': numpy.array( [-2.0, 3.0], numpy.float64)}]} dataDim = 1 qlocs = numpy.array( [[0.875, 2.25, 1.5], [0.6, 2.8, -1.8], [1.0, 2.0, 3.0]], numpy.float64) valsE = numpy.array( [[-0.75, 3.5], [2.0, 6.8], [-2.0, 2.0]], numpy.float64) errE = [0, 0, 0] # Write database from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii writer = SimpleIOAscii() writer.inventory.filename = filename writer._configure() writer.write(data) # Test write using query from spatialdata.spatialdb.SimpleDB import SimpleDB db = SimpleDB() db.inventory.label = "test" db.inventory.queryType = "linear" db.inventory.iohandler.inventory.filename = filename db.inventory.iohandler._configure() db._configure() db.open() db.queryVals(["two", "one"]) vals = numpy.zeros(valsE.shape, dtype=numpy.float64) err = [] nlocs = qlocs.shape[0] for i in xrange(nlocs): e = db.query(vals[i,:], qlocs[i,:], cs) err.append(e) db.close() self.assertEqual(len(valsE.shape), len(vals.shape)) for dE, d in zip(valsE.shape, vals.shape): self.assertEqual(dE, d) for vE, v in zip(numpy.reshape(valsE, -1), numpy.reshape(vals, -1)): self.assertAlmostEqual(vE, v, 6) return