[bugfix] gaps are now merged when data are loaded and not when plotting (could cause problems with data object being empty)

This commit is contained in:
2019-08-14 14:52:56 +02:00
parent 15882ed27e
commit c1cb0e4a37
12 changed files with 5194 additions and 12 deletions

View File

@@ -14,7 +14,7 @@ from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \
from pylot.core.util.errors import FormatError, OverwriteError
from pylot.core.util.event import Event
from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
from pylot.core.util.utils import fnConstructor, full_range, check4rotated, trim_station_components
from pylot.core.util.utils import fnConstructor, full_range, check4rotated, check4gapsAndMerge, trim_station_components
class Data(object):
@@ -417,6 +417,8 @@ class Data(object):
# various pre-processing steps:
# remove possible underscores in station names
# self.wfdata = remove_underscores(self.wfdata)
# check for gaps and merge
self.wfdata = check4gapsAndMerge(self.wfdata)
# check for stations with rotated components
if checkRotated and metadata is not None:
self.wfdata = check4rotated(self.wfdata, metadata, verbosity=0)

View File

@@ -878,7 +878,7 @@ def merge_stream(stream):
return stream, gaps
def check4gaps(data):
def check4gapsAndRemove(data):
"""
check for gaps in Stream and remove them
:param data: stream of seismic data
@@ -898,6 +898,25 @@ def check4gaps(data):
return data
def check4gapsAndMerge(data):
"""
check for gaps in Stream and merge if gaps are found
:param data: stream of seismic data
:type data: `~obspy.core.stream.Stream`
:return: data stream
:rtype: `~obspy.core.stream.Stream`
"""
gaps = data.get_gaps()
if gaps:
merged = ['{}.{}.{}.{}'.format(*gap[:4]) for gap in gaps]
data.merge(method=1)
print('Merged the following stations because of gaps:')
for merged_station in merged:
print(merged_station)
return data
def check4doubled(data):
"""
check for doubled stations for same channel in Stream and take only the first one

View File

@@ -1312,14 +1312,6 @@ class PylotCanvas(FigureCanvas):
if mapping:
plot_positions = self.calcPlotPositions(st_select, compclass)
gaps = st_select.get_gaps()
if gaps:
merged = ['{}.{}.{}.{}'.format(*gap[:4]) for gap in gaps]
st_select.merge(method=1)
print('Merged the following stations because of gaps:')
for merged_station in merged:
print(merged_station)
# list containing tuples of network, station, channel and plot position (for sorting)
nslc = []
for plot_pos, trace in enumerate(st_select):