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


Python Report.base_map方法代码示例

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


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

示例1: StatsTest

# 需要导入模块: from application.models import Report [as 别名]
# 或者: from application.models.Report import base_map [as 别名]
class StatsTest(unittest.TestCase):
    """ test for reporting api 
    """

    def setUp(self):
        # create resources
        self.polygon = [[[-63.154907226557498, -4.8118385341739005], [-64.143676757807498, -4.8118385341739005], [-64.132690429682498, -6.2879986723276584], [-62.814331054682498, -6.3535159310087908]]]
        self.inv_polygon = [[[y, x] for x, y in self.polygon[0]]]
        self.r = Report(start=date(year=2011, month=2, day=1),
                        end=date(year=2011, month=3, day=1),
                        finished=True)
        self.r.put()
        self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0)
        self.cell.put()
        self.area = Area(geo=json.dumps(self.inv_polygon), added_by=None, type=1, cell=self.cell)
        self.area.put()
        self.area.create_fusion_tables()
        self.ndfi = NDFI(self.r.comparation_range(), self.r.range())
        self.stats = Stats()

    def test_stats(self):
        """
        """
        # freeze map with on area
        report_id = self.r.key().id()
        data = self.ndfi.freeze_map(self.r.base_map(), 
                             int(settings.FT_TABLE_ID),
                             self.r.key().id())
        self.assertTrue('data' in data)
        self.assertTrue('id' in data['data'])
        self.assertTrue(len(data['data']['id']) > 0)
    
        asset_id = data['data']['id']
        print "report id: ", asset_id

        # get stats for this area
        st = self.stats.get_stats_for_polygon(report_id, asset_id, self.polygon)
        
        self.assertTrue(st is not None)
        polygon_stats = st[0]
        print polygon_stats
        self.assertTrue(float(polygon_stats['def']) > 0.0)
        self.assertAlmostEquals(0.0, float(polygon_stats['deg']))
        def_area = float(polygon_stats['def'])
        print "deforested area: ", def_area

        # get stats for this area
        # move the polygon a little bit
        p = [[[x, y + 1.0] for x, y in self.polygon[0]]]
        st = self.stats.get_stats_for_polygon(report_id, asset_id, p)
        self.assertTrue(st is not None)
        print st[0]
        polygon_stats = st['data']['properties']['classHistogram']['values']['null']['values']
        self.assertTrue(float(polygon_stats['def']) > 0.0)
        self.assertTrue(float(polygon_stats['def']) < def_area)
        print "new deforested area: ", float(polygon_stats['def'])

        # search in area whiout deforesation
        p = [[[x+4.0, y] for x, y in self.polygon[0]]]
        st = self.stats.get_stats_for_polygon(report_id, asset_id, p)
        self.assertTrue(st is not None)
        polygon_stats = st[0]
        self.assertAlmostEquals(0.0, float(polygon_stats['def']))
        self.assertAlmostEquals(0.0, float(polygon_stats['deg']))
开发者ID:Imazon,项目名称:DeforestationAnalysisTool,代码行数:66,代码来源:integration.py


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