Beispiel #1
0
def rate_per_bin(table, stride, column, bins, start=None, end=None):
    """@returns a list of TimeSeries representing the rate of events
    in each bin for the given LIGO_LW table
    """
    # get time
    tarray = triggers.get_time_column(table).astype(float)
    tarray.sort()
    # get limits
    if not start:
        start = tarray[0]
    if not end:
        end = tarray[-1]
    start = float(start)
    end = float(end)
    duration = end - start
    # contruct time bins
    stride = float(stride)
    duration = stride * round(duration/stride)
    bins = numpy.linspace(start, start+duration, num = duration//stride)
    # calculate rate per bin
    carray = triggers.get_column(str(column))
    out = []
    for bin_l,bin_r in bins:
        in_bin = (bin_l <= carray) & (carray < bin_r)
        rate = CreateREAL8TimeSeries("Rate (Hz) [%s <= %s < %s]"
                                     % (bin_l, column, bin_r),
                                     LIGOTimeGPS(start), 0,
                                     stride, lalHertzUnit, bins.size-1)
        hist,_ = numpy.histogram(tarray, bins=bins)
        rate.data.data = (hist / stride).astype(numpy.float64)
        out.append(rate)
    return out
def rate_per_bin(table, stride, column, bins, start=None, end=None):
    """@returns a list of TimeSeries representing the rate of events
    in each bin for the given LIGO_LW table
    """
    # get time
    tarray = triggers.get_time_column(table).astype(float)
    tarray.sort()
    # get limits
    if not start:
        start = tarray[0]
    if not end:
        end = tarray[-1]
    start = float(start)
    end = float(end)
    duration = end - start
    # contruct time bins
    stride = float(stride)
    duration = stride * round(duration / stride)
    bins = numpy.linspace(start, start + duration, num=duration // stride)
    # calculate rate per bin
    carray = triggers.get_column(str(column))
    out = []
    for bin_l, bin_r in bins:
        in_bin = (bin_l <= carray) & (carray < bin_r)
        rate = CreateREAL8TimeSeries(
            "Rate (Hz) [%s <= %s < %s]" % (bin_l, column, bin_r),
            LIGOTimeGPS(start), 0, stride, lalHertzUnit, bins.size - 1)
        hist, _ = numpy.histogram(tarray, bins=bins)
        rate.data.data = (hist / stride).astype(numpy.float64)
        out.append(rate)
    return out
Beispiel #3
0
def rate(table, stride, start=None, end=None):
    """@returns a TimeSeries of rate over time for all triggers in the
    given LIGO_LW table.
    """
    # get time
    tarray = triggers.get_time_column(table).astype(float)
    tarray.sort()
    # get limits
    if not start:
        start = tarray[0]
    if not end:
        end = tarray[-1]
    start = float(start)
    end = float(end)
    duration = end - start
    # contruct time bins
    stride = float(stride)
    duration = stride * round(duration/stride)
    bins = numpy.linspace(start, start+duration, num = duration//stride)
    # calculate rate
    rate = CreateREAL8TimeSeries("Rate (Hz)", LIGOTimeGPS(start), 0,
                                 stride, lalHertzUnit, bins.size-1)
    hist,_ = numpy.histogram(tarray, bins=bins)
    rate.data.data = hist.astype(numpy.float64)/stride
    return rate
def rate(table, stride, start=None, end=None):
    """@returns a TimeSeries of rate over time for all triggers in the
    given LIGO_LW table.
    """
    # get time
    tarray = triggers.get_time_column(table).astype(float)
    tarray.sort()
    # get limits
    if not start:
        start = tarray[0]
    if not end:
        end = tarray[-1]
    start = float(start)
    end = float(end)
    duration = end - start
    # contruct time bins
    stride = float(stride)
    duration = stride * round(duration / stride)
    bins = numpy.linspace(start, start + duration, num=duration // stride)
    # calculate rate
    rate = CreateREAL8TimeSeries("Rate (Hz)", LIGOTimeGPS(start), 0, stride,
                                 lalHertzUnit, bins.size - 1)
    hist, _ = numpy.histogram(tarray, bins=bins)
    rate.data.data = hist.astype(numpy.float64) / stride
    return rate