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


Python Catalog.record_mainshocks方法代码示例

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


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

示例1: apply_decluster

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

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import record_mainshocks [as 别名]
    def study_chi_square(self, mag_thresh, region, time_spacing):
        """
        receives a magnitude threshold, a region and a interval of time
        perform a poisson test on the clusters that had quakes with magnitude above the threshold
        prints the results and returns nothing
        """
        CLUSTER_NUM = 1

        # auxiliar class
        stat = Statistic()
        cat = Catalog()
        slc = Single_Link()

        print('\nApplying chi-squared for magnitude ' + str(mag_thresh) + ' and region ' + str(region) + \
                ' and time interval of ' + str(time_spacing) + ' seconds')
            
        # get the name of the declustered and undeclustered catalog 
        decluster_catalog = '../results/single_link/temp_decluster_' + region + '.txt'
        original_catalog = '../results/single_link/temp_original_' + region + '.txt'
        aux_catalog = '../results/single_link/temp_aux_' + region + '.txt'
        
        # obtain catalog containing the quakes of the region - cat_region
        cat_orig = '../catalogs/new_jma.txt'
        cat_region = '../results/single_link/temp.txt'
        bounds = get_region_bounds(region)
        cat.select_geographically(bounds, cat_orig, cat_region) 

        # generates catalog containing only the mainshocks of clusters that had one quake (at least) 
        # with a shock greater than the magnitude threshold
        # open quake declustered array 
        path = '../results/single_link/declustered_array_' + region
        quakes = pickle.load(open(path, 'rb'))

        # mark every quake initially as an aftershock
        for quake in quakes: 
            quake.is_aftershock = True

        # iterate through all quakes 
        count = 0
        for quake in quakes:

            # if the current quake has magnitude bigger than or equal to the threshold
            if quake.mag >= mag_thresh: 

                # mark as mainshock the centroid it belongs to 
                quakes[quake.centroid_index].is_aftershock = False
                count += 1
        #print(count)
        # from the quake and catalog to read from, obtain declustered catalog 
        cat.record_mainshocks(quakes, aux_catalog, cat_region)
        cat.get_mainshocks(decluster_catalog, aux_catalog, index = 5)
         
        # obtain original catalog for the region, only with quakes bigger than magnitude
        cat.get_mag_threshold(cat_region, original_catalog, mag_thresh) 

        # apply the chisquared test for the declustered catalog and for the original catalog 
        print("Applying chi-squared for declustered catalog")
        stat.do_chi_square(decluster_catalog, 0.05, time_spacing)

        print("Applying chi-squared for the original catalog")
        stat.do_chi_square(original_catalog, 0.05, time_spacing)
开发者ID:gabriel951,项目名称:pibic,代码行数:63,代码来源:single_link_simulation.py

示例5: study_chisquare

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import record_mainshocks [as 别名]
    def study_chisquare(self, folder, array_path, days, alpha, mag_threshold=None):
        """
        receives a folder to look for the quakes, the path where the earthquake array is located,
        the number of days, a significance level and optionally a magnitude threshold

        performs a chisquare test for the 4 regions of japan and all the japan
        by taking the observed frequencies in that number of days
        """
        # auxiliar classes needed
        catalog = Catalog()
        stat = Statistic()

        # calculate the number of seconds to be done on the interval
        time_interval = days * 24.0 * 360.0

        # generate catalog in a good format to work with 
        quakes = pickle.load(open(array_path, 'rb'))
        catalog.record_mainshocks(quakes, folder + 'quakes.txt', '../catalogs/new_jma.txt')
        
        # get the core catalog name, and obtain it 
        if mag_threshold == None:
            CATALOG_EXTENSION = 'quakes.txt'
        else:
            CATALOG_EXTENSION = 'quakes_' + str(mag_threshold) + '.txt'
            catalog.get_mag_threshold(folder + 'quakes.txt', folder + CATALOG_EXTENSION ,mag_threshold)

        # do chi square test for all japan, with aftershocks
        print("Doing chi-square test for all japan, including aftershocks on analysis:")
        stat.do_chi_square(folder + CATALOG_EXTENSION, 0.05, time_interval)
        # do chi square test for all japan, without aftershocks
        print("\nDoing chi-square test for all japan, excluding aftershocks on analysis")
        catalog.get_mainshocks(folder + 'japan_mainshocks.txt', folder + CATALOG_EXTENSION, 5)
        stat.do_chi_square(folder + 'japan_mainshocks.txt', 0.05, time_interval)
       
        # get bounds for kanto
        bounds = catalog.get_kanto_bounds()
        # construct a catalog for quakes that happened in kanto
        catalog.select_geographically(bounds, folder + CATALOG_EXTENSION, 
                                        folder + 'quakes_kanto.txt')
        # do chi_squared test for kanto, with aftershocks
        print("\nDoing chi-square test for kanto, including aftershocks on analysis:")
        stat.do_chi_square(folder + 'quakes_kanto.txt', 0.05, time_interval)
        # do chi_squared test for kanto, without aftershocks
        print("\nDoing chi-square test for kanto, excluding aftershocks on analysis")
        catalog.get_mainshocks(folder + 'mainshocks_kanto.txt', folder + 'quakes_kanto.txt', 5)
        stat.do_chi_square(folder + 'mainshocks_kanto.txt', 0.05, time_interval)


        # get bounds for kansai
        bounds = catalog.get_kansai_bounds()
        # construct a catalog for quakes that happened in kansai
        catalog.select_geographically(bounds, folder + CATALOG_EXTENSION, 
                                        folder + 'quakes_kansai.txt')
        # do chi_squared test for kansai, with aftershocks
        print("\nDoing chi-square test for kansai, including aftershocks on analysis:")
        stat.do_chi_square(folder + 'quakes_kansai.txt', 0.05, time_interval)
        # do chi_squared test for kansai, without aftershocks
        print("\nDoing chi-square test for kansai, excluding aftershocks on analysis")
        catalog.get_mainshocks(folder + 'mainshocks_kansai.txt', folder + 'quakes_kansai.txt', 5)
        stat.do_chi_square(folder + 'mainshocks_kansai.txt', 0.05, time_interval)

        # get bounds for tohoku
        bounds = catalog.get_tohoku_bounds()
        # construct a catalog for quakes that happened in tohoku
        catalog.select_geographically(bounds, folder + CATALOG_EXTENSION, 
                                        folder + 'quakes_tohoku.txt')
        # do chi_squared test for tohoku, with aftershocks
        print("\nDoing chi-square test for tohoku, including aftershocks on analysis:")
        stat.do_chi_square(folder + 'quakes_tohoku.txt', 0.05, time_interval)
        # do chi_squared test for tohoku, without aftershocks
        print("\nDoing chi-square test for tohoku, excluding aftershocks on analysis")
        catalog.get_mainshocks(folder + 'mainshocks_tohoku.txt', folder + 'quakes_tohoku.txt', 5)
        stat.do_chi_square(folder + 'mainshocks_tohoku.txt', 0.05, time_interval)

        # get bounds for east_japan
        bounds = catalog.get_east_japan_bounds()
        # construct a catalog for quakes that happened in east_japan
        catalog.select_geographically(bounds, folder + CATALOG_EXTENSION, 
                                        folder + 'quakes_east_japan.txt')
        # do chi_squared test for east_japan, with aftershocks
        print("\nDoing chi-square test for east_japan, including aftershocks on analysis:")
        stat.do_chi_square(folder + 'quakes_east_japan.txt', 0.05, time_interval)
        # do chi_squared test for east_japan, without aftershocks
        print("\nDoing chi-square test for east_japan, excluding aftershocks on analysis")
        catalog.get_mainshocks(folder + 'mainshocks_east_japan.txt', folder + 'quakes_east_japan.txt', 5)
        stat.do_chi_square(folder + 'mainshocks_east_japan.txt', 0.05, time_interval)
开发者ID:gabriel951,项目名称:pibic,代码行数:88,代码来源:stats.py


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