当前位置: 首页>>代码示例>>Python>>正文


Python SimpleDB.open方法代码示例

本文整理汇总了Python中spatialdata.spatialdb.SimpleDB.SimpleDB.open方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleDB.open方法的具体用法?Python SimpleDB.open怎么用?Python SimpleDB.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spatialdata.spatialdb.SimpleDB.SimpleDB的用法示例。


在下文中一共展示了SimpleDB.open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getCellSizeDB

# 需要导入模块: from spatialdata.spatialdb.SimpleDB import SimpleDB [as 别名]
# 或者: from spatialdata.spatialdb.SimpleDB.SimpleDB import open [as 别名]
def getCellSizeDB(points):

    from spatialdata.geocoords.CSCart import CSCart
    from spatialdata.spatialdb.SimpleDB import SimpleDB
    from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii

    # Coordinate system for mesh (must match coordsys in ExodusII file)
    cs = CSCart()
    cs._configure()
    cs.initialize()

    # Spatial database with physical properties (Vs)
    dbIO = SimpleIOAscii()
    dbIO.inventory.filename = filenameDB
    dbIO._configure()
    db = SimpleDB()
    db.inventory.iohandler = dbIO
    db.inventory.label = "Physical properties"
    db.inventory.queryType = "linear"
    db._configure()
    
    (npoints, spacedim) = points.shape

    # Query database
    db.open()
    db.queryVals(["vs"])
    data = numpy.zeros((npoints, 1), dtype=numpy.float64)
    err = numpy.zeros((npoints,), dtype=numpy.int32)
    db.multiquery(data, err, points, cs)
    db.close()

    vs = data[:,0]
    cellSize = minPeriod*vs / 10.0
    return cellSize
开发者ID:panzhengyang,项目名称:pylith,代码行数:36,代码来源:exodus_add_properties.py

示例2: test

# 需要导入模块: from spatialdata.spatialdb.SimpleDB import SimpleDB [as 别名]
# 或者: from spatialdata.spatialdb.SimpleDB.SimpleDB import open [as 别名]
  def test(self):
    """
    Test GenSimpleDBApp with 1-D data in 2-D space.
    """
    from spatialdata.spatialdb.generator.GenSimpleDBApp import GenSimpleDBApp
    from spatialdata.geocoords.CSCart import CSCart
    from spatialdata.spatialdb.SimpleDB import SimpleDB
    
    app = GenSimpleDBApp()
    app.run()

    # Test write using query
    db = SimpleDB()
    db.inventory.iohandler.inventory.filename = \
        "data/gen1Din2D.spatialdb"
    db.inventory.iohandler._configure()
    db.inventory.label = "test"
    db.inventory.queryType = "nearest"
    db._configure()

    qlocs = numpy.array( [[-2.0,  2.0],
                          [ 3.0, -4.0],
                          [ 0.0,  0.7]],
                         numpy.float64)
    
    dataE = numpy.array( [[-0.15, 3.45],
                          [2.4, 6.4],
                          [-0.6, 3.45]], numpy.float64)
    errE = [0, 0, 0]

    from spatialdata.geocoords.CSCart import CSCart
    cs = CSCart()
    cs.inventory.spaceDim = 2
    cs._configure()

    db.open()
    db.queryVals(["two", "one"])
    data = numpy.zeros(dataE.shape, dtype=numpy.float64)
    err = []
    nlocs = qlocs.shape[0]
    for i in xrange(nlocs):
      e = db.query(data[i,:], qlocs[i,:], cs)
      err.append(e)
    db.close()    

    self.assertEqual(len(errE), len(err))
    for vE, v in zip(errE, err):
      self.assertEqual(vE, v)

    self.assertEqual(len(dataE.shape), len(data.shape))
    for dE, d in zip(dataE.shape, data.shape):
      self.assertEqual(dE, d)
    for vE, v in zip(numpy.reshape(dataE, -1), numpy.reshape(data, -1)):
      self.assertAlmostEqual(vE, v, 6)

    return
开发者ID:koson,项目名称:spatialdata,代码行数:58,代码来源:TestGenSimpleDBApp.py

示例3: test_write

# 需要导入模块: from spatialdata.spatialdb.SimpleDB import SimpleDB [as 别名]
# 或者: from spatialdata.spatialdb.SimpleDB.SimpleDB import open [as 别名]
  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
开发者ID:koson,项目名称:spatialdata,代码行数:66,代码来源:TestSimpleIOAscii.py


注:本文中的spatialdata.spatialdb.SimpleDB.SimpleDB.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。