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:
parent
834e836a3d
commit
845fd6a7b3
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pdb
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
@ -146,10 +145,11 @@ class Data(object):
|
|||||||
self.wfdata = self.getOriginalWFData().copy()
|
self.wfdata = self.getOriginalWFData().copy()
|
||||||
self.dirty = False
|
self.dirty = False
|
||||||
|
|
||||||
def restituteWFData(self, invdlpath, prefilt):
|
def restituteWFData(self, invdlpath):
|
||||||
st = self.getWFData()
|
st = self.getWFData()
|
||||||
for tr in st:
|
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]
|
tr.stats.station = tr.stats.station[0:3]
|
||||||
dlp = '%s/*.dataless' % invdlpath
|
dlp = '%s/*.dataless' % invdlpath
|
||||||
invp = '%s/*.inv' % invdlpath
|
invp = '%s/*.inv' % invdlpath
|
||||||
@ -158,38 +158,88 @@ class Data(object):
|
|||||||
invfile = glob.glob(invp)
|
invfile = glob.glob(invp)
|
||||||
respfile = glob.glob(respp)
|
respfile = glob.glob(respp)
|
||||||
|
|
||||||
|
# check for dataless-SEED file
|
||||||
if len(dlfile) >= 1:
|
if len(dlfile) >= 1:
|
||||||
print "Found dataless-SEED file!"
|
print "Found dataless-SEED file(s)!"
|
||||||
print "Reading meta data information ..."
|
print "Reading meta data information ..."
|
||||||
print dlfile[0]
|
for j in range(len(dlfile)):
|
||||||
parser = Parser('%s' % dlfile[0])
|
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:
|
# check for inventory-xml file
|
||||||
print "Correcting for instrument response ..."
|
if len(invfile) >= 1:
|
||||||
st.simulate(pre_filt=prefilt, seedresp={'filename': parser, \
|
print "Found inventory-xml file(s)!"
|
||||||
'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!"
|
|
||||||
print "Reading meta data information ..."
|
print "Reading meta data information ..."
|
||||||
inv = read_inventory(invfile, format="STATIONXML")
|
for j in range(len(invfile)):
|
||||||
print "Applying instrument correction ..."
|
print invfile[j]
|
||||||
st.attach_response(inv)
|
inv = read_inventory(invfile[j], format="STATIONXML")
|
||||||
st.remove_response(output='VEL', pre_filt=prefilt)
|
for i in range(len(st)):
|
||||||
elif len(respfile) >= 1:
|
# check, whether this trace has already been corrected
|
||||||
print "Found response file!"
|
if len(st[i].stats) < 13:
|
||||||
print respfile
|
try:
|
||||||
seedresp={'filename': respfile[0], 'date': st[0].stats.starttime, \
|
print "Correcting %s, %s for instrument response ..." \
|
||||||
'units': "VEL"}
|
% (st[i].stats.station, st[i].stats.channel)
|
||||||
st.simulate(paz_remove=None, pre_filt=prefilt, seedresp=seedresp)
|
# get corner frequencies for pre-filtering
|
||||||
else:
|
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 "No dataless-SEED file,inventory-xml file nor RESP-file found!"
|
||||||
print "Go on processing data without source parameter determination!"
|
print "Go on processing data without source parameter determination!"
|
||||||
|
|
||||||
return st
|
return st
|
||||||
|
|
||||||
def getEvtData(self):
|
def getEvtData(self):
|
||||||
return self.evtdata
|
return self.evtdata
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user