Exemple #1
0
def query_and_read_frame(frame_type, channels, start_time, end_time,
                         sieve=None, check_integrity=False):
    """Read time series from frame data.

    Query for the locatin of physical frames matching the frame type. Return
    a time series containing the channel between the given start and end times.

    Parameters
    ----------
    frame_type : string
        The type of frame file that we are looking for.
    channels : string or list of strings
        Either a string that contains the channel name or a list of channel
        name strings.
    start_time : LIGOTimeGPS or int
        The gps start time of the time series. Defaults to reading from the
        beginning of the available frame(s).
    end_time : LIGOTimeGPS or int
        The gps end time of the time series. Defaults to the end of the frame.
    sieve : string, optional
        Selects only frames where the frame URL matches the regular
        expression sieve
    check_integrity : boolean
        Do an expensive checksum of the file before returning.

    Returns
    -------
    Frame Data: TimeSeries or list of TimeSeries
        A TimeSeries or a list of TimeSeries, corresponding to the data from
        the frame file/cache for a given channel or channels.

    Examples
    --------
    >>> ts = query_and_read_frame('H1_LDAS_C02_L2', 'H1:LDAS-STRAIN',
    >>>                               968995968, 968995968+2048)
    """
    # Allows compatibility with our standard tools
    # We may want to place this into a higher level frame getting tool
    if frame_type == 'LOSC_STRAIN':
        from pycbc.frame.losc import read_strain_losc
        if not isinstance(channels, list):
            channels = [channels]
        data = [read_strain_losc(c[:2], start_time, end_time)
                for c in channels]
        return data if len(data) > 1 else data[0]
    if frame_type == 'LOSC':
        from pycbc.frame.losc import read_frame_losc
        return read_frame_losc(channels, start_time, end_time)

    logging.info('querying datafind server')
    paths = frame_paths(frame_type, int(start_time), int(numpy.ceil(end_time)))
    logging.info('found files: %s' % (' '.join(paths)))
    return read_frame(paths, channels,
                      start_time=start_time,
                      end_time=end_time,
                      sieve=sieve,
                      check_integrity=check_integrity)
Exemple #2
0
def query_and_read_frame(frame_type, channels, start_time, end_time,
                         sieve=None, check_integrity=False):
    """Read time series from frame data.

    Query for the locatin of physical frames matching the frame type. Return
    a time series containing the channel between the given start and end times.

    Parameters
    ----------
    frame_type : string
        The type of frame file that we are looking for.
    channels : string or list of strings
        Either a string that contains the channel name or a list of channel
        name strings.
    start_time : LIGOTimeGPS or int
        The gps start time of the time series. Defaults to reading from the
        beginning of the available frame(s).
    end_time : LIGOTimeGPS or int
        The gps end time of the time series. Defaults to the end of the frame.
    sieve : string, optional
        Selects only frames where the frame URL matches the regular
        expression sieve
    check_integrity : boolean
        Do an expensive checksum of the file before returning.

    Returns
    -------
    Frame Data: TimeSeries or list of TimeSeries
        A TimeSeries or a list of TimeSeries, corresponding to the data from
        the frame file/cache for a given channel or channels.

    Examples
    --------
    >>> ts = query_and_read_frame('H1_LDAS_C02_L2', 'H1:LDAS-STRAIN',
    >>>                               968995968, 968995968+2048)
    """
    # Allows compatibility with our standard tools
    # We may want to place this into a higher level frame getting tool
    if frame_type == 'LOSC':
        from pycbc.frame.losc import read_frame_losc
        return read_frame_losc(channels, start_time, end_time)

    logging.info('querying datafind server')
    paths = frame_paths(frame_type, int(start_time), int(numpy.ceil(end_time)))
    logging.info('found files: %s' % (' '.join(paths)))
    return read_frame(paths, channels,
                      start_time=start_time,
                      end_time=end_time,
                      sieve=sieve,
                      check_integrity=check_integrity)
Exemple #3
0
def query_and_read_frame(frame_type, channels, start_time, end_time):
    """Read time series from frame data.

    Query for the locatin of physical frames matching the frame type. Return
    a time series containing the channel between the given start and end times.

    Parameters
    ----------
    frame_type : string
        The type of frame file that we are looking for.         
    channels : string or list of strings
        Either a string that contains the channel name or a list of channel
        name strings.
    start_time : LIGOTimeGPS or int
        The gps start time of the time series. Defaults to reading from the 
        beginning of the available frame(s). 
    end_time : LIGOTimeGPS or int
        The gps end time of the time series. Defaults to the end of the frame.

    Returns
    -------
    Frame Data: TimeSeries or list of TimeSeries
        A TimeSeries or a list of TimeSeries, corresponding to the data from
        the frame file/cache for a given channel or channels. 
        
    Examples
    --------
    >>> ts = query_and_read_frame('H1_LDAS_C02_L2', 'H1:LDAS-STRAIN', 
    >>>                               968995968, 968995968+2048)
    """
    # Allows compatibility with our standard tools
    # We may want to place this into a higher level frame getting tool
    if frame_type == 'LOSC':
        from pycbc.frame.losc import read_frame_losc
        return read_frame_losc(channels, start_time, end_time)

    logging.info('querying datafind server')
    paths = frame_paths(frame_type, int(start_time), int(end_time))
    logging.info('found files: %s' % (' '.join(paths)))
    return read_frame(paths,
                      channels,
                      start_time=start_time,
                      end_time=end_time)