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


Python CSCart.initialize方法代码示例

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


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

示例1: getCellSizeDB

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [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_initialize

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [as 别名]
  def test_initialize(self):
    from spatialdata.geocoords.CSCart import CSCart
    cs = CSCart()
    cs.inventory.units = "km"
    cs.inventory.spaceDim = 2
    cs._configure()
    cs.initialize()

    self.assertEqual(1.0e+3, cs.toMeters())
    self.assertEqual(2, cs.spaceDim())

    return
开发者ID:geodynamics,项目名称:spatialdata,代码行数:14,代码来源:TestCSCart.py

示例3: xrange

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [as 别名]
points = numpy.zeros((numY*numZ, 3), dtype=numpy.float64)
for iY in xrange(numY):
    points[:,0] = 0.0
    points[iY*numZ:(iY+1)*numZ,1] = y[iY]
    points[iY*numZ:(iY+1)*numZ,2] = z

r = (points[:,1]**2+(points[:,2]+7500.0)**2)**0.5
maskO = numpy.bitwise_and(r > radiusInner, r <= radiusOuter)
maskI = r <= radiusInner
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},
                      ],
           }
开发者ID:geodynamics,项目名称:pylith_benchmarks,代码行数:33,代码来源:create_tractions.py

示例4: test_io

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [as 别名]
    def test_io(self):
        from spatialdata.spatialdb.SimpleGridAscii import SimpleGridAscii

        filename = "data/gridio.spatialdb"
        x = numpy.array([-2.0, 0.0, 3.0], dtype=numpy.float64)
        y = numpy.array([0.0, 1.0], dtype=numpy.float64)
        z = numpy.array([-2.0, -1.0, 2.0], dtype=numpy.float64)

        points = numpy.array(
            [
                [-2.0, 0.0, -2.0],
                [-2.0, 1.0, -2.0],
                [-2.0, 0.0, -1.0],
                [-2.0, 1.0, -1.0],
                [-2.0, 0.0, 2.0],
                [-2.0, 1.0, 2.0],
                [0.0, 0.0, -2.0],
                [0.0, 1.0, -2.0],  # query (5.7, 8.2)
                [0.0, 0.0, -1.0],
                [0.0, 1.0, -1.0],
                [0.0, 0.0, 2.0],
                [0.0, 1.0, 2.0],
                [3.0, 0.0, -2.0],
                [3.0, 1.0, -2.0],
                [3.0, 0.0, -1.0],
                [3.0, 1.0, -1.0],
                [3.0, 0.0, 2.0],
                [3.0, 1.0, 2.0],
            ],
            dtype=numpy.float64,
        )
        one = numpy.array(
            [6.6, 5.5, 2.3, 5.7, 6.3, 3.4, 7.2, 5.7, 3.4, 5.7, 9.4, 7.2, 4.8, 9.2, 5.8, 4.7, 7.8, 2.9],
            dtype=numpy.float64,
        )
        two = numpy.array(
            [3.4, 6.7, 4.1, 2.0, 6.7, 6.4, 6.8, 8.2, 9.8, 2.3, 8.5, 9.3, 7.5, 8.3, 8.5, 8.9, 6.2, 8.3],
            dtype=numpy.float64,
        )

        cs = CSCart()
        cs.initialize()

        writer = SimpleGridAscii()
        writer.inventory.filename = filename
        writer._configure()
        writer.write(
            {
                "points": points,
                "x": x,
                "y": y,
                "z": z,
                "coordsys": cs,
                "data_dim": 3,
                "values": [{"name": "one", "units": "m", "data": one}, {"name": "two", "units": "m", "data": two}],
            }
        )

        db = SimpleGridDB()
        db.inventory.label = "test"
        db.inventory.queryType = "nearest"
        db.inventory.filename = filename
        db._configure()
        self._db = db

        locs = numpy.array([[0.1, 0.95, -1.8]], numpy.float64)
        cs = CSCart()
        cs._configure()
        queryVals = ["two", "one"]
        dataE = numpy.array([[8.2, 5.7]], numpy.float64)
        errE = [0]

        db = self._db
        db.open()
        db.queryVals(queryVals)
        data = numpy.zeros(dataE.shape, dtype=numpy.float64)
        err = []
        nlocs = locs.shape[0]
        for i in xrange(nlocs):
            e = db.query(data[i, :], locs[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,代码行数:96,代码来源:TestSimpleGridDB.py

示例5: test_io_2d

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [as 别名]
  def test_io_2d(self):
    from spatialdata.spatialdb.SimpleGridAscii import SimpleGridAscii

    filename = "data/gridio2d.spatialdb"
    x = numpy.array([-2.0, 0.0, 3.0], dtype=numpy.float64)
    y = numpy.array([0.0, 1.0], dtype=numpy.float64)

    points = numpy.array([
        [-2.0,  0.0],
        [-2.0,  1.0],
        [ 0.0,  0.0],
        [ 0.0,  1.0], # query (5.7, 8.2)
        [ 3.0,  0.0],
        [ 3.0,  1.0],
        ], dtype=numpy.float64)
    one = numpy.array([6.6, 5.5, 7.2, 5.7, 4.8, 9.2], dtype=numpy.float64)
    two = numpy.array([3.4, 6.7, 6.8, 8.2, 7.5, 8.3], dtype=numpy.float64)

    cs = CSCart()
    cs.inventory.spaceDim = 2
    cs._configure()
    cs.initialize()

    writer = SimpleGridAscii()
    writer.inventory.filename = filename
    writer._configure()
    writer.write({'points': points,
                  'x': x,
                  'y': y,
                  'coordsys': cs,
                  'data_dim': 2,
                  'values': [{'name': "one",
                              'units': "m",
                              'data': one},
                             {'name': "two",
                              'units': "m",
                              'data': two},
                             ]})

    db = SimpleGridDB()
    db.inventory.label = "test"
    db.inventory.queryType = "nearest"
    db.inventory.filename = filename
    db._configure()
    self._db = db

    locs = numpy.array( [[0.1, 0.95]], numpy.float64)
    queryVals = ["two", "one"]
    dataE = numpy.array( [[8.2, 5.7]], numpy.float64)
    errE = [0]

    db = self._db
    db.open()
    db.queryVals(queryVals)
    data = numpy.zeros(dataE.shape, dtype=numpy.float64)
    err = []
    nlocs = locs.shape[0]
    for i in xrange(nlocs):
      e = db.query(data[i,:], locs[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:geodynamics,项目名称:spatialdata,代码行数:75,代码来源:TestSimpleGridDB.py

示例6: test_write

# 需要导入模块: from spatialdata.geocoords.CSCart import CSCart [as 别名]
# 或者: from spatialdata.geocoords.CSCart.CSCart import initialize [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.geocoords.CSCart.CSCart.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。