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


Python TimeSeries.from_nds2_buffer方法代码示例

本文整理汇总了Python中gwpy.timeseries.TimeSeries.from_nds2_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.from_nds2_buffer方法的具体用法?Python TimeSeries.from_nds2_buffer怎么用?Python TimeSeries.from_nds2_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gwpy.timeseries.TimeSeries的用法示例。


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

示例1: _next

# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import from_nds2_buffer [as 别名]
 def _next(self):
     uchannels = self._unique_channel_names(self.channels)
     new = TimeSeriesDict()
     span = 0
     epoch = 0
     self.logger.debug('Waiting for next NDS2 packet...')
     while span < self.interval:
         try:
             buffers = next(self.iterator)
         except RuntimeError as e:
             self.logger.error('RuntimeError caught: %s' % str(e))
             self.restart()
             break
         for buff, c in zip(buffers, uchannels):
             ts = TimeSeries.from_nds2_buffer(buff)
             try:
                 new.append({c: ts}, gap=self.gap, pad=self.pad)
             except ValueError as e:
                 if 'discontiguous' in str(e):
                     e.args = ('NDS connection dropped data between %d and '
                               '%d' % (epoch, ts.span[0]),)
                 raise
             span = abs(new[c].span)
             epoch = new[c].span[-1]
             self.logger.debug('%ds data for %s received'
                               % (abs(ts.span), str(c)))
     out = type(new)()
     for chan in self.channels:
         out[chan] = new[self._channel_basename(chan)].copy()
     return out
开发者ID:duncanmmacleod,项目名称:dataviewer,代码行数:32,代码来源:nds.py

示例2: _next

# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import from_nds2_buffer [as 别名]
 def _next(self):
     uchannels = self._unique_channel_names(self.channels)
     new = TimeSeriesDict()
     span = 0
     epoch = 0
     att = 0
     self.logger.debug('Waiting for next NDS2 packet...')
     while span < self.interval:
         try:
             buffers = next(self.iterator)
         except RuntimeError as e:
             self.logger.error('RuntimeError caught: %s' % str(e))
             if att < self.attempts:
                 att += 1
                 wait_time = att / 3 + 1
                 self.logger.warning(
                     'Attempting to reconnect to the nds server... %d/%d'
                     % (att, self.attempts))
                 self.logger.warning('Next attempt in minimum %d seconds' %
                                     wait_time)
                 self.restart()
                 sleep(wait_time - tconvert('now') % wait_time)
                 continue
             else:
                 self.logger.critical(
                     'Maximum number of attempts reached, exiting')
                 break
         att = 0
         for buff, c in zip(buffers, uchannels):
             ts = TimeSeries.from_nds2_buffer(buff)
             try:
                 new.append({c: ts}, gap=self.gap, pad=self.pad)
             except ValueError as e:
                 if 'discontiguous' in str(e):
                     e.message = (
                         'NDS connection dropped data between %d and '
                         '%d, restarting building the buffer from %d ') \
                         % (epoch, ts.span[0], ts.span[0])
                     self.logger.warning(str(e))
                     new = TimeSeriesDict()
                     new[c] = ts.copy()
                 elif ('starts before' in str(e)) or \
                         ('overlapping' in str(e)):
                     e.message = (
                         'Overlap between old data and new data in the '
                         'nds buffer, only the new data will be kept.')
                     self.logger.warning(str(e))
                     new = TimeSeriesDict()
                     new[c] = ts.copy()
                 else:
                     raise
             span = abs(new[c].span)
             epoch = new[c].span[-1]
             self.logger.debug('%ds data for %s received'
                               % (abs(ts.span), str(c)))
     out = type(new)()
     for chan in self.channels:
         out[chan] = new[self._channel_basename(chan)].copy()
     return out
开发者ID:mikelovskij,项目名称:dataviewer,代码行数:61,代码来源:nds.py


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