• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python connection.SearchConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyesgf.search.connection.SearchConnection的典型用法代码示例。如果您正苦于以下问题:Python SearchConnection类的具体用法?Python SearchConnection怎么用?Python SearchConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_shards_constrain

    def test_shards_constrain(self):
        # Test that a file-context constrains the shard list
        conn = SearchConnection(self.test_service, distrib=True)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        f_ctx = r1.file_context()

        # !TODO: white-box test.  Refactor.
        query_dict = f_ctx._build_query()
        full_query = f_ctx.connection._build_query(query_dict,
                                                   shards=f_ctx.shards)

        # !TODO: Force fail to see whether shards is passed through.
        # NOTE: 'shards' is NOT even a key in this dictionary. Needs rewrite!!!
        q_shard = full_query['shards']
        # Check it isn't a ',' separated list
        assert ',' not in q_shard
        q_shard_host = q_shard.split(':')[0]
        assert q_shard_host == r1.json['index_node']

        # Now make the query to make sure it returns data from
        # the right index_node
        f_results = f_ctx.search()
        f_r1 = f_results[0]
        assert f_r1.json['index_node'] == r1.json['index_node']
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:28,代码来源:test_results.py


示例2: test_context_facets1

def test_context_facets1():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5')

    context2 = context.constrain(model="IPSL-CM5A-LR")
    assert context2.facet_constraints['project'] == 'CMIP5'
    assert context2.facet_constraints['model'] == 'IPSL-CM5A-LR'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:7,代码来源:test_context.py


示例3: test_passed_cached_session

 def test_passed_cached_session(self):
     import requests_cache
     td = datetime.timedelta(hours=1)
     session = requests_cache.core.CachedSession(self.cache,
                                                 expire_after=td)
     conn = SearchConnection(self.test_service, session=session)
     context = conn.new_context(project='cmip5')
     assert context.facet_constraints['project'] == 'cmip5'
开发者ID:bird-house,项目名称:esgf-pyclient,代码行数:8,代码来源:test_connection.py


示例4: test_get_shard_list

def test_get_shard_list():
    conn = SearchConnection(TEST_SERVICE, distrib=True)
    shards = conn.get_shard_list()
    #!NOTE: the exact shard list will change depending on the shard replication configuration
    #    on the test server
    assert 'esgf-index2.ceda.ac.uk' in shards
    # IPSL now replicates all non-local shards.  Just check it has a few shards
    assert len(shards['esgf-index2.ceda.ac.uk']) > 3
开发者ID:coecms,项目名称:esgf-pyclient,代码行数:8,代码来源:test_connection.py


示例5: test_result1

def test_result1():
    conn = SearchConnection(TEST_SERVICE, distrib=False)

    ctx = conn.new_context(project='CMIP5')
    results = ctx.search()

    r1 = results[0]
    assert r1.dataset_id == 'cmip5.output1.IPSL.IPSL-CM5A-LR.1pctCO2.3hr.atmos.3hr.r1i1p1.v20110427|vesg.ipsl.fr'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_results.py


示例6: test_context_facet_multivalue2

def test_context_facet_multivalue2():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5', model='IPSL-CM5A-MR')
    assert context.facet_constraints.getall('model') == ['IPSL-CM5A-MR']

    
    context2 = context.constrain(model=['IPSL-CM5A-MR', 'IPSL-CM5A-LR'])
    assert sorted(context2.facet_constraints.getall('model')) == ['IPSL-CM5A-LR', 'IPSL-CM5A-MR']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py


示例7: test_result1

def test_result1():
    conn = SearchConnection(TEST_SERVICE, distrib=False)

    ctx = conn.new_context(project='CMIP5')
    results = ctx.search()

    r1 = results[0]
    assert re.match(r'cmip5\.output1\.IPSL\..\|vesg.ipsl.fr', r1.dataset_id)
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:8,代码来源:test_results.py


示例8: test_constrain_freetext

def test_constrain_freetext():
    conn = SearchConnection(TEST_SERVICE)

    context = conn.new_context(project='CMIP5', query='humidity')
    assert context.freetext_constraint == 'humidity'

    context = context.constrain(experiment='historical')
    assert context.freetext_constraint == 'humidity'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py


示例9: test_facet_count

def test_facet_count():
    conn = SearchConnection(TEST_SERVICE)
    
    context = conn.new_context(project='CMIP5')
    context2 = context.constrain(model="IPSL-CM5A-LR")

    counts = context2.facet_counts
    assert counts['model'].keys() == ['IPSL-CM5A-LR']
    assert counts['project'].keys() == ['CMIP5']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例10: test_context_facets_multivalue

def test_context_facets_multivalue():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5')

    context2 = context.constrain(model=['IPSL-CM5A-LR', 'IPSL-CM5A-MR'])
    assert context2.hit_count > 0
    
    assert context2.facet_constraints['project'] == 'CMIP5'
    assert sorted(context2.facet_constraints.getall('model')) == ['IPSL-CM5A-LR', 'IPSL-CM5A-MR']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例11: test_download_url

def test_download_url():
    conn = SearchConnection(CEDA_SERVICE, distrib=False)

    ctx = conn.new_context()
    results = ctx.search(drs_id='GeoMIP.output1.MOHC.HadGEM2-ES.G1.day.atmos.day.r1i1p1')
    files = results[0].file_context().search()

    download_url = files[0].download_url
    assert re.match(r'http://.*\.nc', download_url)
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:9,代码来源:test_util.py


示例12: test_constrain

def test_constrain():
    conn = SearchConnection(TEST_SERVICE)
    
    context = conn.new_context(project='CMIP5')
    count1 = context.hit_count
    context = context.constrain(model="IPSL-CM5A-LR")
    count2 = context.hit_count

    assert count1 > count2
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例13: test_index_node

    def test_index_node(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        service = urlparse(self.test_service)

        assert r1.index_node == service.hostname
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_results.py


示例14: test_download_url

    def test_download_url(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context()
        results = ctx.search(drs_id=('GeoMIP.output.MOHC.HadGEM2-ES.G1.day.'
                                     'atmos.day.r1i1p1'))
        files = results[0].file_context().search()

        download_url = files[0].download_url
        assert re.match(r'http://.*\.nc', download_url)
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_util.py


示例15: test_file_context

    def test_file_context(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        f_ctx = r1.file_context()

        assert f_ctx.facet_constraints['dataset_id'] == r1.dataset_id
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_results.py


示例16: test_context_facet_multivalue3

def test_context_facet_multivalue3():
    conn = SearchConnection(TEST_SERVICE)
    ctx = conn.new_context(project='CMIP5', query='humidity', experiment='rcp45')
    hits1 = ctx.hit_count
    assert hits1 > 0
    ctx2 = conn.new_context(project='CMIP5', query='humidity',
                           experiment=['rcp45','rcp85'])
    hits2 = ctx2.hit_count

    assert hits2 > hits1
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:10,代码来源:test_context.py


示例17: test_context_facet_options

def test_context_facet_options():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5', model='IPSL-CM5A-LR',
                               ensemble='r1i1p1', experiment='rcp60',
                               realm='seaIce'
        )

    assert context.get_facet_options().keys() == [
        'product', 'cf_standard_name', 'variable_long_name', 'cmor_table',
        'time_frequency', 'variable'
        ]
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:11,代码来源:test_context.py


示例18: test_distrib

def test_distrib():
    conn = SearchConnection(TEST_SERVICE, distrib=False)

    context = conn.new_context(project='CMIP5')
    count1 = context.hit_count

    conn2 = SearchConnection(TEST_SERVICE, distrib=True)
    context = conn2.new_context(project='CMIP5')
    count2 = context.hit_count

    assert count1 < count2
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:11,代码来源:test_context.py


示例19: test_context_facets3

def test_context_facets3():
    conn = SearchConnection(TEST_SERVICE)
    
    context = conn.new_context(project='CMIP5')
    context2 = context.constrain(model="IPSL-CM5A-LR")

    results = context2.search()
    result = results[0]

    assert result.json['project'] == ['CMIP5']
    assert result.json['model'] == ['IPSL-CM5A-LR']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:11,代码来源:test_context.py


示例20: test_opendap_fail

def test_opendap_fail():
    conn = SearchConnection(CEDA_SERVICE, distrib=False)

    ctx = conn.new_context()
    results = ctx.search(project='CMIP5', experiment='rcp45', time_frequency='mon',
                         realm='atmos', ensemble='r1i1p1')

    files_ctx = results[0].file_context()
    hit = files_ctx.search()[0]

    assert hit.opendap_url is None
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:11,代码来源:test_util.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python blocks.genesis函数代码示例发布时间:2022-05-25
下一篇:
Python search.SearchConnection类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap