Commit 58881ef7 authored by Semih Demir's avatar Semih Demir
Browse files

gain selection and log message when gain retrieved from YAML

parent a3958d33
......@@ -61,6 +61,7 @@ Trigger:
asdf_folder : 'raw'
channels : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
overlap : 0.05
Gainrange : 'YAML' #other option: 'ASDF'
bandpass_f_min : 1000
bandpass_f_max : 12000
algorithm : 'recstalta' #other option: 'threshold'
......
......@@ -22,25 +22,6 @@ from obspy.core import UTCDateTime
def dug_trigger(sta_total, tparam, event_nr, event_nr_s):
sta_total.filter("bandpass", freqmin=tparam['bandpass_f_min'], freqmax=tparam['bandpass_f_max'])
# t_long = 5
# freqmin = 1
# corner = 1
# perc_taper = 0.1
# mode = 'rms'
# t_ma = 20
# nsigma = 6
# t_up = 0.78
# nr_len = 2
# nr_coeff = 2
# pol_len = 10
# pol_coeff = 10
# uncert_coeff = 3
# fbpicker = FBPicker(sta_total,t_long, freqmin, corner, perc_taper, mode, t_ma, nsigma, t_up, nr_len, nr_coeff, pol_len, pol_coeff, uncert_coeff)
# for j in range(len(sta_total)):
# tr = trace.detrend('linear')
# fbpicker.picks(sta_total[0])
# Triggering
t = 1 / sta_total[0].stats.sampling_rate
......@@ -48,9 +29,7 @@ def dug_trigger(sta_total, tparam, event_nr, event_nr_s):
tparam['sta_lta']['threshold_off'], sta_total, tparam['coincidence'],
sta=tparam['sta_lta']['st_window'] * t, lta=tparam['sta_lta']['lt_window'] * t,trigger_off_extension=0.01,
details=True)
# trigger_off_extension=0.01
# print(trig)
time_s = []
classification_s = []
# coins_sum_s=[]
......
......@@ -51,9 +51,21 @@ class Event(ObsPyEvent):
logging.info('Noise Visualisation at ' + str(t_start_plot)[11:-1] + ', processing started.')
def bandpass(self):
# bandpass filter using same parameters as for triggering
self.wf_stream.filter("bandpass", freqmin=self.prparam['bandpass_f_min'], freqmax=self.prparam['bandpass_f_max'])
# import numpy as np
# tparam = self.param['Trigger']
# stations = [i - 1 for i in tparam['channels']]
# if self.param['General']['active_trigger_channel'] and self.param['General'][
# 'active_trigger_channel'] - 1 not in stations:
# stations.insert(0, param['General']['active_trigger_channel'] - 1)
# stations.sort()
# for k in stations:
# print(np.amax(np.absolute(self.wf_stream.traces[k].data)))
def pick(self):
piparam = self.prparam['Picking']
df = self.wf_stream[0].stats.sampling_rate
......
......@@ -21,6 +21,7 @@ def event_processing(param, load_file, trig_time, event_id, classification):
logging.debug('Starting processing for event %d' % event_id)
wf_stream = get_waveforms(param, load_file, trig_time)
event = Event(param, wf_stream, event_id, classification)
if classification == 'noise':
event.event_plot(save_fig=True)
......@@ -34,11 +35,6 @@ def event_processing(param, load_file, trig_time, event_id, classification):
event.locate()
event.est_magnitude()
event.event_plot(save_fig=True)
# event.prparam['Picking']['algorithm'] = 'AICD'
# event.pick()
# event.locate()
# event.est_magnitude()
# event.event_plot(save_fig=True)
#event.prparam['Locate']['algorithm'] = 'hom_aniso'
#event.locate()
#event.est_magnitude()
......
......@@ -11,6 +11,8 @@ Version 0.0, 23.10.2018, Joseph Doetsch (doetschj)
from obspy import Stream
import pyasdf
import numpy as np
import logging
def get_waveforms(param, load_file, trig_time):
......@@ -23,6 +25,14 @@ def get_waveforms(param, load_file, trig_time):
ch_in = range(1, gparam['sensor_count' ] +1)
r = range(len(ch_in))
tparam = param['Trigger']
stations = [i - 1 for i in tparam['channels']]
if param['General']['active_trigger_channel'] and param['General'][
'active_trigger_channel'] - 1 not in stations:
stations.insert(0, param['General']['active_trigger_channel'] - 1)
stations.sort()
if len(load_file) == 1: # load 2 snippets if event in overlap otherwise load 1
wf_stream = Stream()
ds = pyasdf.ASDFDataSet(asdf_folder + '/' + load_file[0], mode='r')
......@@ -32,6 +42,14 @@ def get_waveforms(param, load_file, trig_time):
starttime=start_time,
endtime=end_time,
tag="raw_recording")
if tparam['Gainrange'] == 'YAML':
for k in stations:
# print(np.amax(np.absolute(wf_stream.traces[k].data)))
wf_stream.traces[k].data = wf_stream.traces[k].data / 32768 * \
param['Acquisition']['hardware_settings']['gain_selection'][k]
logging.info('Gain range event retrieved from YAML file')
else:
ds1 = pyasdf.ASDFDataSet(asdf_folder + '/' + load_file[0], mode='r')
......@@ -53,6 +71,12 @@ def get_waveforms(param, load_file, trig_time):
tag="raw_recording")
wf_stream = sta_p1 + sta_p2
wf_stream.merge(method=1, interpolation_samples=0)
if tparam['Gainrange'] == 'YAML':
for k in stations:
wf_stream.traces[k].data = wf_stream.traces[k].data / 32768 * \
param['Acquisition']['hardware_settings']['gain_selection'][k]
logging.info('Gain range event retrieved from YAML file')
else:
wf_stream = Stream()
......@@ -62,6 +86,12 @@ def get_waveforms(param, load_file, trig_time):
starttime=start_time,
endtime=end_time,
tag="raw_recording")
if tparam['Gainrange'] == 'YAML':
for k in stations:
wf_stream.traces[k].data = wf_stream.traces[k].data / 32768 * \
param['Acquisition']['hardware_settings']['gain_selection'][k]
logging.info('Gain range event retrieved from YAML file')
return wf_stream
......
......@@ -19,6 +19,7 @@ import pyasdf
from dug_seis.processing.dug_trigger import dug_trigger
from dug_seis.processing.event_processing import event_processing
import re
import numpy as np
def processing(param):
......@@ -79,6 +80,14 @@ def processing(param):
tr.stats.delta = sta_total[0].stats.delta
sta_total.merge(method=1, interpolation_samples=0)
if tparam['Gainrange']=='YAML':
for k in stations:
sta_total.traces[k].data = sta_total.traces[k].data / 32768 * \
param['Acquisition']['hardware_settings']['gain_selection'][k]
logging.info('Gain range trigger retrieved from YAML file')
logging.debug(sta_total)
trigger_out, event_nr = dug_trigger(sta_total, tparam, event_nr, event_nr_s) # run trigger function
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment