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


Python Catalog.get_smaller_catalog方法代码示例

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


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

示例1: apply_decluster_smaller

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_smaller_catalog [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()
        window_var = WindowVar()
        
        # 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 = 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)

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

示例2: apply_decluster_smaller

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_smaller_catalog [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

示例3: compare_window_kmeans

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_smaller_catalog [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

示例4: CatalogSimulation

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_smaller_catalog [as 别名]
        # obtain declustered catalog for Tohoku 
        bounds = catalog.get_tohoku_bounds()
        catalog.select_geographically(bounds, '../results/mainshocks.txt', '../results/mainshocks_tohoku.txt')

#### TESTS AND SIMULATIONS - just comment them out ####
# simulation to see how many earthquakes there are in a given range of magnitudes - TESTED
#sim = CatalogSimulation()
#sim.simple_report()

# see if it's possible to represent all Earthquakes on the catalog in memory - TESTED
#catalog = Catalog()
#catalog.get_earthquake_array()

# obtain a smaller catalog, will be good for preliminar tests - TESTED 
catalog = Catalog()
catalog.get_smaller_catalog(40)

# see if we can obtain a catalog which selects the regions geographically - TESTED
#catalog = Catalog()
#bounds = [120.0, 130.0, 30.0, 40.0]
#catalog.select_geographically(bounds, '../results/mainshocks.txt', '../results/stricted_mainshocks.txt')

# get declustered catalogs for Yuri - TESTED
#catalog = Catalog()
#sim = CatalogSimulation()
#sim.help_yuri(catalog)

# obtain a catalog of only mainshocks - NOT TESTED
#catalog = Catalog()
#catalog.get_mainshocks()
开发者ID:gabriel951,项目名称:pibic,代码行数:32,代码来源:catalog_simulation.py


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