restituteWFData: able to handle several dataless-, inventory- or resp-files, calculates prefiltering from sampling rate of trace. Processing with inventory- or resp-file has yet not been checked!

This commit is contained in:
Ludger Küperkoch 2015-08-27 11:04:46 +02:00
parent 834e836a3d
commit 845fd6a7b3

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pdb
import os
import glob
import matplotlib.pyplot as plt
@ -146,10 +145,11 @@ class Data(object):
self.wfdata = self.getOriginalWFData().copy()
self.dirty = False
def restituteWFData(self, invdlpath, prefilt):
def restituteWFData(self, invdlpath):
st = self.getWFData()
for tr in st:
if tr.stats.station[3] == '_': # this is for some ugly station naming
# remove underscores
if tr.stats.station[3] == '_':
tr.stats.station = tr.stats.station[0:3]
dlp = '%s/*.dataless' % invdlpath
invp = '%s/*.inv' % invdlpath
@ -158,38 +158,88 @@ class Data(object):
invfile = glob.glob(invp)
respfile = glob.glob(respp)
# check for dataless-SEED file
if len(dlfile) >= 1:
print "Found dataless-SEED file!"
print "Found dataless-SEED file(s)!"
print "Reading meta data information ..."
print dlfile[0]
parser = Parser('%s' % dlfile[0])
for j in range(len(dlfile)):
print dlfile[j]
parser = Parser('%s' % dlfile[j])
for i in range(len(st)):
# check, whether this trace has already been corrected
if len(st[i].stats) < 13:
try:
print "Correcting %s, %s for instrument response ..." \
% (st[i].stats.station, st[i].stats.channel)
# get corner frequencies for pre-filtering
fny = st[i].stats.sampling_rate / 2
fc21 = fny - (fny * 0.05)
fc22 = fny - (fny * 0.02)
prefilt = [0.5, 0.9, fc21, fc22]
# instrument correction
st[i].simulate(pre_filt=prefilt, seedresp={'filename': parser, \
'date': st[i].stats.starttime, 'units': "VEL"})
except ValueError, e:
vmsg = '{0}'.format(e)
print vmsg
else:
print "Trace has already been corrected!"
try:
print "Correcting for instrument response ..."
st.simulate(pre_filt=prefilt, seedresp={'filename': parser, \
'date': st[0].stats.starttime, 'units': "VEL"})
except ValueError, e:
vmsg = '{0}'.format(e)
print vmsg
elif len(invfile) >= 1:
print "Found inventory-xml file!"
# check for inventory-xml file
if len(invfile) >= 1:
print "Found inventory-xml file(s)!"
print "Reading meta data information ..."
inv = read_inventory(invfile, format="STATIONXML")
print "Applying instrument correction ..."
st.attach_response(inv)
st.remove_response(output='VEL', pre_filt=prefilt)
elif len(respfile) >= 1:
print "Found response file!"
print respfile
seedresp={'filename': respfile[0], 'date': st[0].stats.starttime, \
'units': "VEL"}
st.simulate(paz_remove=None, pre_filt=prefilt, seedresp=seedresp)
else:
for j in range(len(invfile)):
print invfile[j]
inv = read_inventory(invfile[j], format="STATIONXML")
for i in range(len(st)):
# check, whether this trace has already been corrected
if len(st[i].stats) < 13:
try:
print "Correcting %s, %s for instrument response ..." \
% (st[i].stats.station, st[i].stats.channel)
# get corner frequencies for pre-filtering
fny = st[i].stats.sampling_rate / 2
fc21 = fny - (fny * 0.05)
fc22 = fny - (fny * 0.02)
prefilt = [0.5, 0.9, fc21, fc22]
# instrument correction
st[i].attach_response(inv)
st[i].remove_response(output='VEL', pre_filt=prefilt)
except ValueError, e:
vmsg = '{0}'.format(e)
print vmsg
# check for RESP-file
if len(respfile) >= 1:
print "Found response file(s)!"
print "Reading meta data information ..."
for j in range(len(respfile)):
print respfile[j]
for i in range(len(st)):
# check, whether this trace has already been corrected
if len(st[i].stats) < 13:
try:
print "Correcting %s, %s for instrument response ..." \
% (st[i].stats.station, st[i].stats.channel)
# get corner frequencies for pre-filtering
fny = st[i].stats.sampling_rate / 2
fc21 = fny - (fny * 0.05)
fc22 = fny - (fny * 0.02)
prefilt = [0.5, 0.9, fc21, fc22]
# instrument correction
seedresp={'filename': respfile[0], 'date': st[0].stats.starttime, \
'units': "VEL"}
st[i].simulate(paz_remove=None, pre_filt=prefilt, seedresp=seedresp)
except ValueError, e:
vmsg = '{0}'.format(e)
print vmsg
if len(respfile) < 1 and len(invfile) < 1 and len(dlfile) < 1:
print "No dataless-SEED file,inventory-xml file nor RESP-file found!"
print "Go on processing data without source parameter determination!"
return st
def getEvtData(self):
return self.evtdata