本文整理汇总了Python中glue.lal.Cache.append方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.append方法的具体用法?Python Cache.append怎么用?Python Cache.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.lal.Cache
的用法示例。
在下文中一共展示了Cache.append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FrameCachetoLALCache
# 需要导入模块: from glue.lal import Cache [as 别名]
# 或者: from glue.lal.Cache import append [as 别名]
def FrameCachetoLALCache(fcache):
lcache = LALCache()
files = fcache.get_files()
for f in files:
lcache.append(LALCacheEntry.from_T050017(f))
return lcache
示例2: make_cache
# 需要导入模块: from glue.lal import Cache [as 别名]
# 或者: from glue.lal.Cache import append [as 别名]
def make_cache():
try:
from lal.utils import CacheEntry
except ImportError as e:
pytest.skip(str(e))
segs = SegmentList()
cache = Cache()
for seg in [(0, 1), (1, 2), (4, 5)]:
d = seg[1] - seg[0]
f = 'A-B-%d-%d.tmp' % (seg[0], d)
cache.append(CacheEntry.from_T050017(f, coltype=int))
segs.append(Segment(*seg))
return cache, segs
示例3: get_cache
# 需要导入模块: from glue.lal import Cache [as 别名]
# 或者: from glue.lal.Cache import append [as 别名]
def get_cache(start, end, ifo, ftype, framecache=False, server=None,\
verbose=False):
"""
Queries the LSC datafind server and returns a glue.lal.Cache object
containing the frame file paths in the given GPS (start, end) interval
for the given ifo and type (can be lists).
framecache=True returns a pylal.dq.dqFrameUTils.FrameCache object in stead.
Arguments:
start : float
GPS start time (s).
end : float
GPS end time (s).
ifo : [ string | list ]
ifo (or list of) to find, e.g. 'G1'.
ftype : [ string | list ]
frame data type (or list of) to find, e.g. 'G1_RDS_C01_L3'.
"""
# set lists
if isinstance(ftype, str):
types = [ftype]
else:
types = ftype
if isinstance(ifo, str):
ifos = [ifo]
else:
ifos = ifo
# construct span
span = segments.segment(start,end)
# set options
cache = LALCache()
entry_class = LALCacheEntry
# try querying the ligo_data_find server
if not server:
server = _find_datafind_server()
if verbose: sys.stdout.write("Opening connection to %s...\n" % server)
if re.search(':', server):
port = int(server.split(':')[-1])
else:
port = None
cert, key = _get_grid_proxy()
# if we have a credential then use it when setting up the connection
if cert and key and port!=80:
h = httplib.HTTPSConnection(server, key_file=key, cert_file=cert)
else:
h = httplib.HTTPConnection(server)
if verbose: sys.stdout.write("Querying server for frames...\n")
# loop over ifos and types
for ifo in ifos:
for t in types:
# construct the URL for a simple data find query
url = "/LDR/services/data/v1/gwf/%s/%s/%s,%s/file.json" % (ifo[0], t,\
str(start),\
str(end))
# query the server
h.request("GET", url)
response = h.getresponse()
_verify_response(response)
# unravel the response
urlList = cjson.decode(response.read())
for url in urlList:
cache.append(entry_class.from_T050017(url))
# close the server connection
h.close()
if verbose: sys.stdout.write("Connection to %s closed.\n" % server)
# convert to FrameCache if needed
if framecache:
cache = LALCachetoFrameCache(cache)
return cache