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


Python SiteCollection.filter方法代码示例

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


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

示例1: test_filter

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
    def test_filter(self):
        col = SiteCollection(self.SITES)
        filtered = col.filter(numpy.array([True, False, True, False]))
        arreq = numpy.testing.assert_array_equal
        arreq(filtered.vs30, [1.2, 2])
        arreq(filtered.vs30measured, [True, True])
        arreq(filtered.z1pt0, [3, 9])
        arreq(filtered.z2pt5, [5, 17])
        arreq(filtered.mesh.lons, [10, 0])
        arreq(filtered.mesh.lats, [20, 2])
        arreq(filtered.mesh.depths, [30, 0])
        arreq(filtered.sids, [0, 2])

        filtered = col.filter(numpy.array([False, True, True, True]))
        arreq(filtered.vs30, [55.4, 2, 4])
        arreq(filtered.vs30measured, [False, True, False])
        arreq(filtered.z1pt0, [6, 9, 22])
        arreq(filtered.z2pt5, [8, 17, 11])
        arreq(filtered.mesh.lons, [11, 0, 1])
        arreq(filtered.mesh.lats, [12, 2, 1])
        arreq(filtered.mesh.depths, [13, 0, 3])

        # test serialization to hdf5
        fd, fpath = tempfile.mkstemp(suffix='.hdf5')
        os.close(fd)
        with hdf5.File(fpath, 'w') as f:
            f['sitecol'] = filtered
            saved = f['sitecol']
            self.assertEqual(saved, filtered)
        os.remove(fpath)
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:32,代码来源:site_test.py

示例2: test_expand_1d

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
 def test_expand_1d(self):
     col = SiteCollection(self.SITES)
     col = col.filter(numpy.array([1, 0, 1, 1]))
     data_condensed = numpy.array([5, 6, 7])
     data_expanded = col.expand(data_condensed, placeholder=100)
     data_expanded_expected = numpy.array([5, 100, 6, 7])
     numpy.testing.assert_array_equal(data_expanded, data_expanded_expected)
开发者ID:amirj700,项目名称:oq-hazardlib,代码行数:9,代码来源:site_test.py

示例3: test_filter

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
    def test_filter(self):
        col = SiteCollection(self.SITES)
        filtered = col.filter(numpy.array([True, False, True, False]))
        self.assertIsInstance(filtered, FilteredSiteCollection)
        arreq = numpy.testing.assert_array_equal
        arreq(filtered.vs30, [1.2, 2])
        arreq(filtered.vs30measured, [True, True])
        arreq(filtered.z1pt0, [3, 9])
        arreq(filtered.z2pt5, [5, 17])
        arreq(filtered.mesh.lons, [10, 0])
        arreq(filtered.mesh.lats, [20, 2])
        self.assertIs(filtered.mesh.depths, None)

        filtered = col.filter(numpy.array([False, True, True, True]))
        self.assertIsInstance(filtered, FilteredSiteCollection)
        arreq(filtered.vs30, [55.4, 2, 4])
        arreq(filtered.vs30measured, [False, True, False])
        arreq(filtered.z1pt0, [6, 9, 22])
        arreq(filtered.z2pt5, [8, 17, 11])
        arreq(filtered.mesh.lons, [11, 0, 1])
        arreq(filtered.mesh.lats, [12, 2, 1])
        self.assertIs(filtered.mesh.depths, None)
开发者ID:FrancescoIngv,项目名称:oq-hazardlib,代码行数:24,代码来源:site_test.py

示例4: test_double_filter

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
 def test_double_filter(self):
     col = SiteCollection(self.SITES)
     filtered = col.filter(numpy.array([True, False, True, True]))
     filtered2 = filtered.filter(numpy.array([False, True, False]))
     arreq = numpy.testing.assert_array_equal
     arreq(filtered2.vs30, [2])
     arreq(filtered2.vs30measured, [True])
     arreq(filtered2.z1pt0, [9])
     arreq(filtered2.z2pt5, [17])
     arreq(filtered2.mesh.lons, [0])
     arreq(filtered2.mesh.lats, [2])
     arreq(filtered2.mesh.depths, [0])
     filtered2 = filtered.filter(numpy.array([True, False, True]))
     arreq(filtered2.vs30, [1.2, 4.])
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:16,代码来源:site_test.py

示例5: test_filter_all_in

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
 def test_filter_all_in(self):
     col = SiteCollection(self.SITES)
     filtered = col.filter(numpy.ones(len(self.SITES), bool))
     self.assertIs(filtered, col)
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:6,代码来源:site_test.py

示例6: test_filter_all_out

# 需要导入模块: from openquake.hazardlib.site import SiteCollection [as 别名]
# 或者: from openquake.hazardlib.site.SiteCollection import filter [as 别名]
 def test_filter_all_out(self):
     col = SiteCollection(self.SITES)
     filtered = col.filter(numpy.zeros(len(self.SITES), bool))
     self.assertIs(filtered, None)
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:6,代码来源:site_test.py


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