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


Python Catalog.get_earthquake_array方法代码示例

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


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

示例1: apply_decluster

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_earthquake_array [as 别名]
    def apply_decluster(self):
        """
        apply window method to the whole catalog and write mainshocks on file
        """
        # get instances of classes we'll need
        catalog = Catalog()
        window_var = WindowVar()
        
        # from the catalog we want, get earthquakes array on memory
        earthquake_array = catalog.get_earthquake_array('../catalogs/new_jma.txt')

        # decluster array, separating mainshocks and aftershocks
        declustered_array = window_var.decluster(earthquake_array)

        # save declustered array using pickle
        file_aux1 = open('data_persistence/declustered_array_window_var', 'wb')
        pickle.dump(declustered_array, file_aux1)
        
        # open declustered array using another name 
        file_aux2 = open('data_persistence/declustered_array_window_var', 'rb')
        new_declustered_array = pickle.load(file_aux2)

        # save declustered array
        # record the mainshocks on a catalog
        catalog.record_mainshocks(declustered_array, file_write='../results/window_var_method/mainshocks.txt', file_read='../catalogs/jma.txt')
开发者ID:gabriel951,项目名称:pibic,代码行数:27,代码来源:window_var_simulation.py

示例2: apply_decluster

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_earthquake_array [as 别名]
    def apply_decluster(self):
        """
        apply window method to the whole catalog and write mainshocks on file
        """
        # get instances of classes we'll need
        catalog = Catalog()
        kmeans = KMeans() 

        # from the catalog we want, get earthquakes array on memory
        earthquake_array = catalog.get_earthquake_array('../catalogs/new_jma.txt')

        # decluster array, separating mainshocks and aftershocks
        declustered_array = kmeans.do_kmeans(earthquake_array)
        
        # record the mainshocks on a catalog
        catalog.record_mainshocks(declustered_array, file_write='../results/mainshocks.txt', file_read='../catalogs/jma.txt')
开发者ID:gabriel951,项目名称:pibic,代码行数:18,代码来源:kmeans_simulation.py

示例3: apply_decluster_smaller

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_earthquake_array [as 别名]
    def apply_decluster_smaller(self):
        """
        apply window method to a smaller catalog and write mainshocks on file
        """
        # get instances of classes we'll need
        catalog = Catalog()
        kmeans = KMeans() 

        # obtain a smaller catalog, so we can run this function faster
        catalog.get_smaller_catalog(300)

        # from the catalog we want, get earthquakes array on memory
        earthquake_array = catalog.get_earthquake_array()
        
        # decluster array, separating mainshocks and aftershocks
        declustered_array = kmeans.do_kmeans(earthquake_array, 25)
        
        # record the mainshocks on a catalog
        catalog.record_mainshocks(declustered_array, file_write='../results/mainshocks.txt', file_read='../catalogs/reduced_jma.txt')
开发者ID:gabriel951,项目名称:pibic,代码行数:21,代码来源:kmeans_simulation.py

示例4: compare_window_kmeans

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_earthquake_array [as 别名]
def compare_window_kmeans(num_entries):
    """
    receives a number of entries 
    the function applies to a catalog with that number of entries
    the window method and the kmeans to decluster the catalog
    the function returns a comparation, showing how much there is 
    of a difference between the two

    Complexity: O(n^2)
    """

    # obtain a smaller catalog 
    catalog = Catalog()
    catalog.get_smaller_catalog(num_entries)

    # get earthquake array of that catalog 
    quakes = catalog.get_earthquake_array()

    # get declustered array of that catalog, according to the window method
    window = Window()
    window_quakes = window.decluster(quakes)

    # get the number of mainshocks of that catalog, according to the kmeans clustering method
    num_mainshocks = 0 
    for i in range(len(window_quakes)):
        if window_quakes[i].is_aftershock == False:
            num_mainshocks += 1
    print(num_mainshocks)

    # apply declustering using the kmeans method to the catalog
    kmeans = KMeans()
    kmeans_quakes = kmeans.do_kmeans(quakes, num_mainshocks)

    # show what are the differences between both methods
    for i in range(len(quakes)):
        if window_quakes[i].is_aftershock != kmeans_quakes[i].is_aftershock:
            print("found a difference!")
开发者ID:gabriel951,项目名称:pibic,代码行数:39,代码来源:method_comparation.py


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