Beispiel #1
0
import matplotlib.pyplot as plt
from obspy import read
from obspy.signal.trigger import recursive_sta_lta, trigger_onset

from seisnn.io import get_dir_list

predict_pkl_dir = "/mnt/tf_data/pkl/2017_02"
predict_pkl_list = get_dir_list(predict_pkl_dir)
for i, pkl in enumerate(predict_pkl_list):
    trace = read(pkl).traces[0]
    df = trace.stats.sampling_rate
    cft = recursive_sta_lta(trace.data, int(0.5 * df), int(1. * df))
    on_of = trigger_onset(cft, 1, 0.5)

    # Plotting the results
    ax = plt.subplot(211)
    plt.plot(trace.data, 'k')
    ymin, ymax = ax.get_ylim()
    plt.vlines(on_of[:, 0], ymin, ymax, color='r', linewidth=2)
    plt.vlines(on_of[:, 1], ymin, ymax, color='b', linewidth=2)
    plt.subplot(212, sharex=ax)
    plt.plot(cft, 'k')
    plt.hlines([3.5, 0.5], 0, len(cft), color=['r', 'b'], linestyle='--')
    plt.axis('tight')
    plt.show()
Beispiel #2
0
import os

from tensorflow.python import keras
from tensorflow.python.keras.optimizers import Adam

from seisnn.io import get_dir_list
from seisnn.tensorflow.generator import DataGenerator
from seisnn.tensorflow.model import Nest_Net

pkl_dir = "/mnt/tf_data/pkl/2017_02"
pkl_list = get_dir_list(pkl_dir)

split_point = -100
training_generator = DataGenerator(pkl_list[:split_point],
                                   batch_size=2,
                                   shuffle=False)
validation_generator = DataGenerator(pkl_list[split_point:], batch_size=32)

tensorboard = keras.callbacks.TensorBoard(log_dir='../logs',
                                          histogram_freq=0,
                                          write_graph=True,
                                          write_images=False)
model = Nest_Net(1, 3001, 1)
model.compile(optimizer=Adam(lr=1e-4),
              loss='binary_crossentropy',
              metrics=['accuracy'])
model.fit_generator(generator=training_generator,
                    validation_data=validation_generator,
                    epochs=1,
                    use_multiprocessing=True,
                    callbacks=[tensorboard])
Beispiel #3
0
from seisnn.io import get_dir_list
from seisnn.qc import precision_recall_f1_score
from seisnn.plot import plot_error_distribution

predict_dataset_dir = "/mnt/tf_data/dataset/2018_02_18_predict"
predict_dataset_list = get_dir_list(predict_dataset_dir)

precision, recall, f1 = precision_recall_f1_score(predict_dataset_list)
print("Precision = %f, Recall = %f, F1 = %f" % (precision, recall, f1))

plot_error_distribution(predict_dataset_list)