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

Python search.SearchConnection类代码示例

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

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



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

示例1: get_esgf_data_and_nodes

def get_esgf_data_and_nodes():
    PCMDI_SERVICE = 'http://pcmdi9.llnl.gov/esg-search/search'     
    conn = SearchConnection(PCMDI_SERVICE,distrib=True)
    ctx = conn.new_context(project='CMIP5',replica=False)
    #ctx = conn.new_context()
    #ctx = ctx.constrain(model='MPI-ESM-P',experiment='piControl',time_frequency='mon', data_node='aims3.llnl.gov')        
    
    my_result=[]    
    ctx = ctx.constrain(project='CMIP5',model='MPI-ESM-P',experiment='piControl', data_node='aims3.llnl.gov')  
    data_nodes = ctx.facet_counts['data_node'].keys()
    models = ctx.facet_counts['model'].keys()
    print "data nodes:", data_nodes
    print "models: ", models
        
    #constrain search to get to datasets
    
    #ctx = ctx.constrain(model='MPI-ESM-P',experiment='piControl',time_frequency='mon', data_node='aims3.llnl.gov')
    results = ctx.search()
    print 'Hits:', ctx.hit_count
    print 'Realms:', ctx.facet_counts['realm']
    print 'Ensembles:', ctx.facet_counts['ensemble']
    
    for i in range(0,ctx.hit_count):    
        file_ctx = results[i].file_context()
        files = file_ctx.search()
        size = files.batch_size
        
        for j in range(0,len(files)):
           my_result.append(files[j].file_id)
        print "files:", size
        
    return my_result
开发者ID:stephank16,项目名称:enes_graph_use_case,代码行数:32,代码来源:ENESNeoTools.py


示例2: get_esgf_cordex_info

    def get_esgf_cordex_info(self):
        
        res_dict = {}
        models = {}
        driving_models = {}
        
        conn = SearchConnection('http://esgf-data.dkrz.de/esg-search',distrib=True)
        ctx = conn.new_context(project='CORDEX',replica=False)
        #print ctx.hit_count
        
        domains = ctx.facet_counts['domain'].keys()
        #print domains

        for key in domains:
            ctx2 = conn.new_context(project='CORDEX',domain=key,replica=False)
            #print ctx2.hit_count 
            models[key] = ctx2.facet_counts['rcm_name'].keys()
            #print models[key]
            driving_models[key]={}
            for thismodel in models[key]:
              
                 ctx3 = conn.new_context(project='CORDEX',domain=key,rcm_name=thismodel,replica=False)
                 #print key,thismodel
                 #print ctx3.hit_count           
                 driving_models[key][thismodel] =  ctx3.facet_counts['driving_model'].keys()
    
        return driving_models
开发者ID:IS-ENES-Data,项目名称:scripts,代码行数:27,代码来源:coordination1.py


示例3: __init__

    def __init__(
            self,
            url='http://localhost:8081/esg-search',
            distrib=False,
            replica=False,
            latest=True,
            monitor=None):
        # replica is  boolean defining whether to return master records
        # or replicas, or None to return both.
        if replica is True:
            self.replica = None  # master + replica
        else:
            self.replica = False  # only master

        # latest: A boolean defining whether to return only latest versions
        #    or only non-latest versions, or None to return both.
        if latest is True:
            self.latest = True  # only latest versions
        else:
            self.latest = None  # all versions

        self.monitor = monitor

        from pyesgf.search import SearchConnection
        self.conn = SearchConnection(url, distrib=distrib)
        self.fields = 'id,instance_id,number_of_files,number_of_aggregations,size,url'
        # local context has *all* local datasets
        local_conn = SearchConnection(url, distrib=False)
        self.local_ctx = local_conn.new_context(fields=self.fields, replica=True, latest=None)
开发者ID:bird-house,项目名称:malleefowl,代码行数:29,代码来源:search.py


示例4: fetch_cmip5

def fetch_cmip5(experiment, variable, time_frequency, models, ensembles):
    """ Download CMIP5 data for a specified set of facets
    
    Uses pyesgf module to query the ESGF nodes RESTful API, and generate a
    wget script which is then executed.
    
    Input parameters defining facets can be strings or lists of strings.
    """
    conn = SearchConnection('http://pcmdi9.llnl.gov/esg-search', distrib=True)
    ctx = conn.new_context(project='CMIP5', experiment=experiment, 
                           time_frequency=time_frequency, variable=variable, 
                           model=models, ensemble=ensembles, latest=True,
                           download_emptypath='unknown')

    a = ctx.get_download_script()
    
    # write the download script out
    with open('getc5.sh','w') as f:
        f.write(a)
        
    # run the download script
    subprocess.Popen(['chmod', 'u+x', 'getc5.sh']).wait()
    subprocess.Popen(['./getc5.sh']).wait()  
    
    # delete any empty files.
    os.system('find ./*.nc -type f -size 0 -delete') 
开发者ID:swartn,项目名称:sam-vs-jet-paper,代码行数:26,代码来源:get_cmip5_data.py


示例5: test_context_facets2

    def test_context_facets2(self):
        conn = SearchConnection(self.test_service, cache=self.cache)
        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:bird-house,项目名称:esgf-pyclient,代码行数:7,代码来源:test_context.py


示例6: check_index

def check_index(index_node, dataset_name, publish):
    """
    Check whether a dataset is published to the Solr Index or not.

    :param str index_node: The index node to check
    :param str dataset_name: The dataset name
    :param bool publish: True if check for existence, False otherwise
    :returns: True iff the dataset was successfully published or unpublished from Solr, otherwise returns False
    :rtype: *boolean*

    """
    if publish:
        hit_count_num = 1
    else:
        hit_count_num = 0

    conn = SearchConnection('http://%s/esg-search' % index_node, distrib=False)
    limit = 50
    i = 0
    while i < limit:
        i += 1
        ctx = conn.new_context(master_id=dataset_name, data_node=socket.gethostname())
        if ctx.hit_count == hit_count_num:
            return True
        elif i < limit:
            print '.',
            time.sleep(10)
    return False
开发者ID:ESGF,项目名称:esg-publisher,代码行数:28,代码来源:testpublication_utility.py


示例7: 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:coecms,项目名称:esgf-pyclient,代码行数:7,代码来源:test_context.py


示例8: node_info

def node_info(request):
    if request.method == 'POST':
        ''' For demo purposes this is loading a local file '''
        try:
            from xml.etree.ElementTree import parse
            tree = parse('scripts/registration.xml')
            root = tree.getroot()
            name = json.loads(request.body)['node']

            response = {}
            for node in root:
                if node.attrib['shortName'] == name:
                    response['org'] = node.attrib['organization']
                    response['namespace'] = node.attrib['namespace']
                    response['email'] = node.attrib['supportEmail']
                    response['ip'] = node.attrib['ip']
                    response['longName'] = node.attrib['longName']
                    response['version'] = node.attrib['version']
                    response['shortName'] = name
                    response['adminPeer'] = node.attrib['adminPeer']
                    response['hostname'] = node.attrib['hostname']

                    for child in list(node):
                        if child.tag[-len('AuthorizationService'):] == "AuthorizationService":
                            response['authService'] = child.attrib["endpoint"]
                        if child.tag[-len('GeoLocation'):] == "GeoLocation":
                            response['location'] = child.attrib["city"]
                        if child.tag[-len('Metrics'):] == "Metrics":
                            for gchild in list(child):
                                if gchild.tag[-len('DownloadedData'):] == "DownloadedData":
                                    response['dataDownCount'] = gchild.attrib['count']
                                    response['dataDownSize'] = gchild.attrib['size']
                                    response['dataDownUsers'] = gchild.attrib['users']
                                if gchild.tag[-len('RegisteredUsers'):] == "RegisteredUsers":
                                    response['registeredUsers'] = gchild.attrib['count']

                    from pyesgf.search import SearchConnection
                    print 'attempting to connect to ' + 'http://' + response['hostname'] + 'esg-search/'
                    conn = SearchConnection('http://' + response['hostname'] + '/esg-search/', distrib=True)
                    try:
                        conn.get_shard_list()
                        response['status'] = 'up'
                    except Exception as e:
                        print repr(e)
                        response['status'] = 'down'

                    return HttpResponse(json.dumps(response))
        except Exception as e:
            import traceback
            print '1', e.__doc__
            print '2', sys.exc_info()
            print '3', sys.exc_info()[0]
            print '4', sys.exc_info()[1]
            print '5', traceback.tb_lineno(sys.exc_info()[2])
            ex_type, ex, tb = sys.exc_info()
            print '6', traceback.print_tb(tb)
            return HttpResponse(status=500)
    elif request.method == 'POST':
        print "Unexpected POST request"
        return HttpResponse(status=500)
开发者ID:jfharney,项目名称:acme-web-fe,代码行数:60,代码来源:views.py


示例9: test_constrain_regression1

def test_constrain_regression1():
    conn = SearchConnection(TEST_SERVICE)

    context = conn.new_context(project='CMIP5', model='IPSL-CM5A-LR')
    assert 'experiment' not in context.facet_constraints

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


示例10: 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:coecms,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py


示例11: 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() == ['data_node', 'cf_standard_name', 'variable_long_name', 
                               'cmor_table', 'time_frequency', 'variable']
开发者ID:coecms,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py


示例12: test_constrain_regression1

    def test_constrain_regression1(self):
        conn = SearchConnection(self.test_service, cache=self.cache)

        context = conn.new_context(project='CMIP5', model='IPSL-CM5A-LR')
        assert 'experiment' not in context.facet_constraints

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


示例13: 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:coecms,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py


示例14: test_constrain_freetext

    def test_constrain_freetext(self):
        conn = SearchConnection(self.test_service, cache=self.cache)

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

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


示例15: test_download_script

def test_download_script():
    conn = SearchConnection(TEST_SERVICE, distrib=False)
    ctx = conn.new_context(project='CMIP5', ensemble='r1i1p1', model='IPSL-CM5A-LR', realm='seaIce',
                           experiment='historicalGHG')
    script = ctx.get_download_script()

    assert '# ESG Federation download script' in script
    assert '# Search URL: %s' % TEST_SERVICE in script
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:8,代码来源:test_wget.py


示例16: test_context_facet_multivalue2

    def test_context_facet_multivalue2(self):
        conn = SearchConnection(self.test_service, cache=self.cache)
        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:bird-house,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例17: 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:coecms,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例18: test_constrain

    def test_constrain(self):
        conn = SearchConnection(self.test_service, cache=self.cache)

        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:bird-house,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例19: 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:coecms,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py


示例20: test_facet_count

    def test_facet_count(self):
        conn = SearchConnection(self.test_service, cache=self.cache)

        context = conn.new_context(project='CMIP5')
        context2 = context.constrain(model="IPSL-CM5A-LR")

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python connection.SearchConnection类代码示例发布时间:2022-05-25
下一篇:
Python query.MatchAllQuery类代码示例发布时间: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