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


Python TimeSeries.write方法代码示例

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


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

示例1: dump_calibrated_data

# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import write [as 别名]
def dump_calibrated_data(fname):
    data = numpy.load(fname)

    # Figure out the times covered by the file from the filename
    # I should start using HDF5 so I can store metadata
    temp = fname.split('.')[0]
    temp = temp.split('-')
    ifo = temp[0]
    st, dur = int(temp[-2]), int(temp[-1])
    et = st + dur

    maxidx = len(data)
    width = 45

    weights = 1. - ((numpy.arange(-width, width) / float(width))**2)

    # The VCO frequencies are integers so we could dither them
    # to avoid quantization error if we wanted to be fancy
    # but it seems to make no differece
    if False:
        from numpy.random import triangular
        data[:, 1] += triangular(-1., 0., 1., size=len(data))

    # Just fit the whole thing at once, to get a single coefficient
    a, b = numpy.polyfit(data[:, 0], data[:, 1], 1)
    print "%.1f %u" % (a, b)

    # Slide through the data fitting PSL to IMC for data around each sample
    coeffs = []
    for idx in xrange(maxidx):
        idx1 = max(0, idx - width)
        idx2 = min(idx + width, maxidx)
        coeffs.append(numpy.polyfit(data[idx1:idx2, 0], data[idx1:idx2, 1], 1,
                                    w=weights[idx1 - idx + width:idx2 - idx + width]))
    coeffs = numpy.array(coeffs)
    times = numpy.arange(len(coeffs)) + 0.5
    connection = datafind.GWDataFindHTTPConnection()
    cache = connection.find_frame_urls(
        ifo[0], '%s_R' % ifo, st, et, urltype='file')

    imc = TimeSeries.read(cache, "%s:IMC-F_OUT_DQ" % ifo, st, et)
    imc = imc[::16384 / 256]
    print imc
    samp_times = numpy.arange(len(imc)) / 256.

    coeffs0 = numpy.interp(samp_times, times, coeffs[:, 0])
    coeffs1 = numpy.interp(samp_times, times, coeffs[:, 1]) - 7.6e7

    vco_interp = coeffs0 * imc.data + coeffs1

    chan = "%s:IMC-VCO_PREDICTION" % (ifo,)
    vco_data = TimeSeries(vco_interp, epoch=st,
                          sample_rate=imc.sample_rate.value,
                          name=chan, channel=chan)
    vco_data.write("%s-vcoprediction-%u-%u.hdf" % (ifo, st, dur), format='hdf')
开发者ID:pmeyers279,项目名称:online_whistle_monitor,代码行数:57,代码来源:get_imc_vco.py

示例2: load

# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import write [as 别名]
import sys
from numpy import *
from gwpy.timeseries import TimeSeries
from scipy.interpolate import interp1d

fname = sys.argv[1]
data = load(fname)

# Figure out the times covered by the file from the filename
# I should start using HDF5 so I can store metadata
temp = fname.split('.')[0]
temp = temp.split('-')
ifo = temp[0]
st, dur = int(temp[-2]), int(temp[-1])
et = st + dur

offset = 7.9e7
fvco = interp1d(arange(len(data)) + 0.5, data[:, 1] - offset, kind='cubic')

chan = "%s:IMC-VCO_INTERPOLATION" % (ifo,)
vco_data = TimeSeries(vco_interp, epoch=st, sample_rate=imc.sample_rate.value,
                      name=chan, channel=chan)
vco_data.write("%s-vcointerpolation-%u-%u.hdf" % (ifo, st, dur), format='hdf')
开发者ID:pmeyers279,项目名称:online_whistle_monitor,代码行数:25,代码来源:dump_interpolated_vco.py

示例3: polyfit

# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import write [as 别名]
a, b = polyfit(data[:, 0], data[:, 1], 1)
print "%.1f %u" % (a, b)

# Slide through the data fitting PSL to IMC for data around each sample
coeffs = []
for idx in xrange(maxidx):
    idx1 = max(0, idx - width)
    idx2 = min(idx + width, maxidx)
    coeffs.append(polyfit(data[idx1:idx2, 0], data[idx1:idx2, 1], 1,
                          w=weights[idx1 - idx + width:idx2 - idx + width]))
coeffs = array(coeffs)
times = arange(len(coeffs)) + 0.5
connection = datafind.GWDataFindHTTPConnection()
cache = connection.find_frame_urls(
    ifo[0], '%s_R' % ifo, st, et, urltype='file')

imc = TimeSeries.read(cache, "%s:IMC-F_OUT_DQ" % ifo, st, et)
imc = imc[::16384 / 256]
print imc
samp_times = arange(len(imc)) / 256.

coeffs0 = interp(samp_times, times, coeffs[:, 0])
coeffs1 = interp(samp_times, times, coeffs[:, 1]) - 7.6e7

vco_interp = coeffs0 * imc.data + coeffs1

chan = "%s:IMC-VCO_PREDICTION" % (ifo,)
vco_data = TimeSeries(vco_interp, epoch=st, sample_rate=imc.sample_rate.value,
                      name=chan, channel=chan)
vco_data.write("%s-vcoprediction-%u-%u.hdf" % (ifo, st, dur), format='hdf')
开发者ID:pmeyers279,项目名称:online_whistle_monitor,代码行数:32,代码来源:dump_calibrated_vco_v2.py


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