當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。