예제 #1
0
 def test_plotBinningError(self):
     """
     Tests the plotting of a trace with a certain amount of sampling that
     had a binning problem.
     """
     tr = Trace(data=np.sin(np.linspace(0, 200, 432000)))
     outfile = os.path.join(self.path, 'binning_error.png')
     tr.plot(outfile=outfile)
예제 #2
0
 def test_plotBinningError(self):
     """
     Tests the plotting of a trace with a certain amount of sampling that
     had a binning problem.
     """
     tr = Trace(data=np.sin(np.linspace(0, 200, 432000)))
     outfile = os.path.join(self.path, 'binning_error.png')
     tr.plot(outfile=outfile)
예제 #3
0
 def test_plot_binning_error_2(self, image_path):
     """
     Tests the plotting of a trace with a certain amount of sampling that
     had a binning problem.
     """
     tr = Trace(data=np.sin(np.linspace(0, 200, 431979)))
     # create and compare image
     tr.plot(outfile=image_path)
예제 #4
0
 def test_plot(self):
     """
     Tests plot method if matplotlib is installed
     """
     try:
         import matplotlib  # @UnusedImport
     except ImportError:
         return
     tr = Trace(data=np.arange(25))
     tr.plot(show=False)
예제 #5
0
 def test_plot(self):
     """
     Tests plot method if matplotlib is installed
     """
     try:
         import matplotlib
     except ImportError:
         return
     tr = Trace(data=np.arange(25))
     tr.plot(show=False)
예제 #6
0
    def test_plotBinningError(self):
        """
        Tests the plotting of a trace with a certain amount of sampling that
        had a binning problem.
        """
        tr = Trace(data=np.sin(np.linspace(0, 200, 432000)))
        # create and compare image
        with ImageComparison(self.path, 'waveform_binning_error.png') as ic:
            tr.plot(outfile=ic.name)

        tr = Trace(data=np.sin(np.linspace(0, 200, 431979)))
        # create and compare image
        with ImageComparison(self.path, 'waveform_binning_error_2.png') as ic:
            tr.plot(outfile=ic.name)
예제 #7
0
    def test_plot_binning_error(self):
        """
        Tests the plotting of a trace with a certain amount of sampling that
        had a binning problem.
        """
        tr = Trace(data=np.sin(np.linspace(0, 200, 432000)))
        # create and compare image
        with ImageComparison(self.path, 'waveform_binning_error.png') as ic:
            tr.plot(outfile=ic.name)

        tr = Trace(data=np.sin(np.linspace(0, 200, 431979)))
        # create and compare image
        with ImageComparison(self.path, 'waveform_binning_error_2.png') as ic:
            tr.plot(outfile=ic.name)
예제 #8
0
def pca_display(pca, original_trace, transformed_wiggle, reconstructed_wiggle):
    original_wiggle = original_trace.data
    IPython.display.display(
        IPython.display.Audio(data=original_wiggle,
                              rate=playback_sampling_rate))
    IPython.display.display(
        IPython.display.Audio(data=reconstructed_wiggle,
                              rate=playback_sampling_rate))

    plot_wiggle(transformed_wiggle)

    reduced_trace = Trace(data=reconstructed_wiggle, header=None)

    print("principal_component  length: " + str(len(reduced_trace)))
    print("PCA Variance Ratio: ")
    print(pca.explained_variance_ratio_)

    original_trace.plot()
    reduced_trace.plot()
예제 #9
0
    def test_plotBinningError(self):
        """
        Tests the plotting of a trace with a certain amount of sampling that
        had a binning problem.
        """
        tr = Trace(data=np.sin(np.linspace(0, 200, 432000)))
        # create and compare image
        with NamedTemporaryFile(suffix='.png') as tf:
            tr.plot(outfile=tf.name)
            # compare images
            expected_image = os.path.join(self.path,
                                          'waveform_binning_error.png')
            compare_images(tf.name, expected_image, 0.001)

        tr = Trace(data=np.sin(np.linspace(0, 200, 431979)))
        # create and compare image
        with NamedTemporaryFile(suffix='.png') as tf:
            tr.plot(outfile=tf.name)
            # compare images
            expected_image = os.path.join(self.path,
                                          'waveform_binning_error_2.png')
            compare_images(tf.name, expected_image, 0.001)
예제 #10
0
def plot_helicorder(tr: Trace, outfile: str = None, **kwargs) -> plt.Axes:
    """
    Plot a helicorder style plot.  1 channel for a day of data.  Defaults to
    showing 60 minutes of data per line in the helicorder.
    :param st: Obspy Trace object of data to plot
    :type st: Stream
    :param **kwargs: Valid Stream.plot(type='dayplot') parameters
    :return: ax containing plot
    :rtype: plt.Axes
    """
    fig = tr.plot(type='dayplot',
                  interval=60,
                  show_y_UTC_label=False,
                  outfile=outfile,
                  **kwargs)
    return fig
예제 #11
0
plt.psd(y,NFFT=nfft, pad_to=nfft, Fs=fs,noverlap=nfft//2,detrend='mean')
plt.title("demean")
plt.show()

#https://github.com/obspy/obspy/issues/1095

# write out a seed file to put into other code.
tr=Trace()
tr.stats.station='KAS'
tr.stats.network='XX'
tr.stats.channel='00'
tr.stats.location='BHZ'
tr.data=y
tr.data = np.require(tr.data, dtype=np.int32)
tr.stats.sampling_rate=40.
tr.starttime=UTCDateTime('2017-09-19T00:00:00')
tr.stats.encoding='STEIM1'
tr.stats.reclen=512
print(tr.stats['starttime'])
print(tr.stats['endtime'])
tr.plot()
st=Stream()
st+=tr
print(st[0].stats)
print(st[0].data.dtype)
st.write('XX_KAS.00_BHZ.seed', format='MSEED')
#st.write('XX_KAS.00_BHZ.seed', format='MSEED', encoding='STEIM2')
#shift_time_of_file(fileIn, fileOut, 10000)
#