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


Python Catalog.get_catalog_bounds方法代码示例

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


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

示例1: plot_clusters_all

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_catalog_bounds [as 别名]
    def plot_clusters_all(self, array_path, dep_lim = None, map_background = True):
        """
        receives a path to the array of quakes.

        optionally it receives a depth limit and a map_background boolean
        if map_background = True, then the cluster is plot with a background map
        if map_background = False, then the cluster is plot with the coast of japan 
        as background 
        
        in order to plot study the mainshocks and it's associated clusters,
        plot some clusters on the map 
        """
        # obtain array of shocks within the depth limit 
        all_quakes = pickle.load(open(array_path, 'rb'))
        useful_quakes = []
        for index in range(len(all_quakes)):
            current_quake = all_quakes[index]
            if dep_lim != None and current_quake.depth > dep_lim:
                continue
            useful_quakes.append(current_quake)

        # get instance of classes so we can access methods
        draw = Draw()
        cat = Catalog()

        # get dictionary that for every region name gives bound and zoom for all regions
        regions = {}
        regions["japan"] = [cat.get_catalog_bounds('../catalogs/new_jma.txt'), 5]
        regions["kanto"] = [cat.get_kanto_bounds(), 9]
        regions["kansai"] = [cat.get_kansai_bounds(), 9]
        regions["tohoku"] = [cat.get_tohoku_bounds(), 9]
        regions["east_japan"] = [cat.get_east_japan_bounds(), 9]
        
        # index to add legibility to the code
        BOUNDS = 0
        ZOOM = 1
        
        # set list of how many clusters to plot, and which years to plot 
        num_clusters = [10]
        year_bound = [[0.0, 12*366*24.0*3600]] # this way we consider all years

        # iterate through the list containing how many clusters we plot
        for num in num_clusters:

            # iterate through the years 
            for time in year_bound:
                
                # iterate through the regions
                for region, info in regions.items():
                    
                    # if we need to plot a map in the background
                    if map_background:

                        # plot image for the current region 
                        draw.plot_image_quakes(useful_quakes, time, info[BOUNDS], info[ZOOM], num_clusters = num, dep_lim = dep_lim)
                        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", region + "_back"])
                        call(["mv",  region + "_back-1.png", "../images/"])
                        call(["rm", "Rplots.pdf"])
                        input("Edit the image and then press Enter")

                        # plot cluster for current region in the given year, for the current number of clusters
                        self.plot_clusters(useful_quakes, num, time, info[BOUNDS],  "../images/" + region +"_back-1.png")
                        ## save it in the correct format, and do cleaning
                        call(["mv", "temp.png", "../images/" + region + "_clusters_map.png"])
                    
                    # if we dont want to plot a japan map in the background
                    else:

                        # plot image for the current region 
                        draw.plot_quakes_coast(useful_quakes, time, info[BOUNDS], num_clusters = num, dep_lim = dep_lim)
                        call(["mv", "temp.png", "../images/" + region + "_back_coast-1.png"])
                        input("Edit the image and then press Enter")

                        # plot cluster for current region in the given year, for the current number of clusters
                        self.plot_clusters(useful_quakes, num, time, info[BOUNDS],  "../images/" + region +"_back_coast-1.png")
                                
                        ## save it in the correct format, and do cleaning
                        call(["mv", "temp.png", "../images/" + region + "_clusters_coast.png"])
开发者ID:gabriel951,项目名称:pibic,代码行数:80,代码来源:stats.py

示例2: plot_heat_all

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_catalog_bounds [as 别名]
    def plot_heat_all(self, array_path, dep_lim = None, map_background = True):
        """
        receives the path to a serialized array object 
        optionally receives a depth limit and a map background boolean, to 
        indicate wheter we use the map as background or the coast as background
        in order to study the mainshocks plot heat map for all regions
        """
        # obtain array of shocks within the depth limit 
        all_quakes = pickle.load(open(array_path, 'rb'))
        useful_quakes = []
        for index in range(len(all_quakes)):
            current_quake = all_quakes[index]
            if dep_lim != None and current_quake.depth > dep_lim:
                continue
            useful_quakes.append(current_quake)

        # get instance of classes that we'll need methods
        draw = Draw() 
        cat = Catalog()

        # get dictionary that for every region name gives bound and zoom for all regions
        regions = {}
        regions["japan"] = [cat.get_catalog_bounds('../catalogs/new_jma.txt'), 5, 100]
        regions["kanto"] = [cat.get_kanto_bounds(), 9, 25]
        regions["kansai"] = [cat.get_kansai_bounds(), 9, 25]
        regions["tohoku"] = [cat.get_tohoku_bounds(), 9, 25]
        regions["east_japan"] = [cat.get_east_japan_bounds(), 9, 25]
        
        # index to add legibility to the code
        BOUNDS = 0
        ZOOM = 1
        BINS = 2

        # set time bound on which to plot and which years to plot 
        year_bound = [[0.0, 12*366*24.0*3600]] # this way all years are considered

        # iterate through the years 
        for time in year_bound:
            
            # iterate through the regions
            for region, info in regions.items():

                # if we are using a map as background
                if map_background: 

                    # plot image for the region
                    draw.plot_image_quakes(useful_quakes, time, info[BOUNDS], info[ZOOM])
                    call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", region + "_back_heat"])
                    call(["mv",  region + "_back_heat-1.png", "../images/"])
                    call(["rm", "Rplots.pdf"])
                    input("Edit the image and then press Enter")

                    # plot heat map for the region in the given year
                    self.plot_heat(useful_quakes, time, info[BOUNDS], info[BINS], "../images/" + region + "_back_heat-1.png",\
                            only_main = False)
                    # save it in the correct format, and do cleaning
                    call(["mv", "temp.png", "../images/" + region + "_heat.png"])

                else:
                    # plot image for the current region 
                    draw.plot_quakes_coast(useful_quakes, time, info[BOUNDS], dep_lim = dep_lim)
                    call(["mv", "temp.png", "../images/" + region + "_back_heat_coast-1.png"])
                    input("Edit the image and then press Enter")

                    # plot heat map for the region in the given year
                    self.plot_heat(useful_quakes, time, info[BOUNDS], info[BINS], "../images/" + region + "_back_heat_coast-1.png",\
                            only_main = False)
                    # save it in the correct format, and do cleaning
                    call(["mv", "temp.png", "../images/" + region + "_heat_coast.png"])
开发者ID:gabriel951,项目名称:pibic,代码行数:71,代码来源:stats.py

示例3: draw_all_maps

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import get_catalog_bounds [as 别名]
    def draw_all_maps(self):
        """
        draw the maps for the japan catalog, kanto region
        kansai region, tohoku region and east japan region
        """
        # get a catalog
        cat = Catalog();

        # get japan bounds
        bounds = cat.get_catalog_bounds("../catalogs/new_jma.txt")

        # draw map for japan 
        self.draw_map(bounds, 5)
        
        # convert image to png, save it on images folder and removes the pdf 
        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", "japan"])
        call(["cp",  "japan-1.png", "../images/"])
        call(["rm", "japan-1.png"])
        call(["rm", "Rplots.pdf"])

        # get kanto bounds
        bounds = cat.get_kanto_bounds()

        # draw map for kanto 
        self.draw_map(bounds, 9)

        # convert image to png, save it on images folder and removes the pdf 
        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", "kanto"])
        call(["cp",  "kanto-1.png", "../images/"])
        call(["rm", "kanto-1.png"])
        call(["rm", "Rplots.pdf"])

        # get kansai bounds
        bounds = cat.get_kansai_bounds()

        # draw map for kansai 
        self.draw_map(bounds, 9)

        # convert image to png, save it on images folder and removes the pdf 
        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", "kansai"])
        call(["cp",  "kansai-1.png", "../images/"])
        call(["rm", "kansai-1.png"])
        call(["rm", "Rplots.pdf"])

        # get tohoku bounds
        bounds = cat.get_tohoku_bounds()

        # draw map for tohoku 
        self.draw_map(bounds, 8)

        # convert image to png, save it on images folder and removes the pdf 
        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", "tohoku"])
        call(["cp",  "tohoku-1.png", "../images/"])
        call(["rm", "tohoku-1.png"])
        call(["rm", "Rplots.pdf"])

        # get east_japan bounds
        bounds = cat.get_east_japan_bounds()

        # draw map for east_japan 
        self.draw_map(bounds, 8)

        # convert image to png, save it on images folder and removes the pdf 
        call(["pdftoppm", "-rx", "300", "-ry", "300", "-png", "Rplots.pdf", "east_japan"])
        call(["cp",  "east_japan-1.png", "../images/"])
        call(["rm", "east_japan-1.png"])
        call(["rm", "Rplots.pdf"])
开发者ID:gabriel951,项目名称:pibic,代码行数:69,代码来源:draw.py


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