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


Python Cache.append方法代码示例

本文整理汇总了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
开发者ID:GeraintPratten,项目名称:lalsuite,代码行数:12,代码来源:dqFrameUtils.py

示例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
开发者ID:stefco,项目名称:gwpy,代码行数:16,代码来源:test_io.py

示例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
开发者ID:GeraintPratten,项目名称:lalsuite,代码行数:88,代码来源:dqFrameUtils.py


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