本文整理匯總了Python中pyesgf.search.connection.SearchConnection.new_context方法的典型用法代碼示例。如果您正苦於以下問題:Python SearchConnection.new_context方法的具體用法?Python SearchConnection.new_context怎麽用?Python SearchConnection.new_context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyesgf.search.connection.SearchConnection
的用法示例。
在下文中一共展示了SearchConnection.new_context方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_context_facet_multivalue3
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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
示例2: test_distrib
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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
示例3: test_context_facets1
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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'
示例4: test_shards_constrain
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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']
示例5: test_passed_cached_session
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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'
示例6: test_result1
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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)
示例7: test_context_facet_multivalue2
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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']
示例8: test_result1
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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'
示例9: test_constrain_freetext
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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'
示例10: test_constrain
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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
示例11: test_download_url
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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)
示例12: test_facet_count
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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']
示例13: test_context_facets_multivalue
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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']
示例14: test_download_url
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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)
示例15: test_index_node
# 需要導入模塊: from pyesgf.search.connection import SearchConnection [as 別名]
# 或者: from pyesgf.search.connection.SearchConnection import new_context [as 別名]
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