Esempio n. 1
0
    def create_trace(self, channel, stats, data):
        """Utility to create a new trace object.

        Parameters
        ----------
        channel : str
            channel name.
        stats : obspy.core.Stats
            channel metadata to clone.
        data : numpy.array
            channel data.

        Returns
        -------
        obspy.core.Trace
            trace containing data and metadata.
        """
        stats = Stats(stats)
        if self.data_type is None:
            stats.data_type = 'adjusted'
        else:
            stats.data_type = self.data_type
        if self.data_type is None:
            stats.location = 'A0'
        else:
            stats.location = self.location

        trace = super(AdjustedAlgorithm,
                      self).create_trace(channel, stats, data)
        return trace
    def create_trace(self, channel, stats, data):
        """Utility to create a new trace object.

        Parameters
        ----------
        channel : str
            channel name.
        stats : obspy.core.Stats
            channel metadata to clone.
        data : numpy.array
            channel data.

        Returns
        -------
        obspy.core.Trace
            trace containing data and metadata.
        """
        stats = Stats(stats)
        if self.data_type is None:
            stats.data_type = 'adjusted'
        else:
            stats.data_type = self.data_type
        if self.data_type is None:
            stats.location = 'A0'
        else:
            stats.location = self.location

        trace = super(AdjustedAlgorithm, self).create_trace(channel, stats,
            data)
        return trace
Esempio n. 3
0
def __create_trace(
    data,
    network="NT",
    station="BOU",
    channel="H",
    location="R0",
    data_interval="second",
    data_type="interval",
):
    """
    Utility to create a trace containing the given numpy array.

    Parameters
    ----------
    data: array
        The array to be inserted into the trace.

    Returns
    -------
    obspy.core.Stream
        Stream containing the channel.
    """
    stats = Stats()
    stats.starttime = UTCDateTime("2019-12-01")
    stats.delta = TimeseriesUtility.get_delta_from_interval(data_interval)
    stats.channel = channel
    stats.station = station
    stats.npts = len(data)
    stats.data_interval = data_interval
    stats.data_type = data_type
    numpy_data = numpy.array(data, dtype=numpy.float64)
    return Trace(numpy_data, stats)
Esempio n. 4
0
    sttime._set_year(2017)
    endtime._set_year(2017)
    sttime._set_month(8)
    endtime._set_month(8)
    sttime._set_day(13 + UTCDateTime(Time_stamps[0]).day)
    endtime._set_day(13 + UTCDateTime(Time_stamps[len(Time_stamps) - 1]).day)

    # Define stats
    stats = Stats()
    stats.starttime = sttime
    stats.station = station
    stats.network = 'NT'
    stats.location = 'R0'
    stats.data_interval = '256Hz'
    stats.delta = .00390625
    stats.data_type = 'variation'

    # Create list of arrays and channel names and intialize counter k
    arrays = [Hx, Hy, Ex, Ey]
    k = 0

    # Loop over channels to create an obspy stream of the data
    for ar in arrays:
        stats.npts = len(ar)
        stats.channel = channels[k]
        ar = np.asarray(ar)
        trace = Trace(ar, stats)
        stream += trace
        trace = None
        k += 1