[update] some bugfixes relating array_maps, removed some unneccessary files

This commit is contained in:
2019-10-23 11:33:37 +02:00
parent e94129ec36
commit 18aa67e5ba
11 changed files with 36 additions and 5184 deletions

View File

@@ -454,7 +454,10 @@ class Data(object):
try:
real_or_syn_data[synthetic] += read(fname, format='GSE2')
except Exception as e:
warnmsg += '{0}\n{1}\n'.format(fname, e)
try:
real_or_syn_data[synthetic] += read(fname, format='SEGY')
except Exception as e:
warnmsg += '{0}\n{1}\n'.format(fname, e)
except SacIOError as se:
warnmsg += '{0}\n{1}\n'.format(fname, se)
if warnmsg:

View File

@@ -17,7 +17,7 @@ plt.interactive(False)
class Array_map(QtGui.QWidget):
def __init__(self, parent, metadata, figure=None, pointsize=30., width=5e6, height=2e6):
def __init__(self, parent, metadata, figure=None, pointsize=30., linewidth=1.5, width=5e6, height=2e6):
'''
Create a map of the array.
:param parent: PyLoT Mainwindow class
@@ -27,6 +27,7 @@ class Array_map(QtGui.QWidget):
self._parent = parent
self.metadata = metadata
self.pointsize = pointsize
self.linewidth = linewidth
self.width = width
self.height = height
self.picks = None
@@ -111,7 +112,7 @@ class Array_map(QtGui.QWidget):
stat_dict = self.stations_dict['{}.{}'.format(network, station)]
lat = stat_dict['latitude']
lon = stat_dict['longitude']
self.highlighted_stations.append(self.basemap.scatter(lon, lat, s=50, edgecolors=color,
self.highlighted_stations.append(self.basemap.scatter(lon, lat, s=self.pointsize, edgecolors=color,
facecolors='none', latlon=True,
zorder=12, label='deleted'))
self.canvas.draw()
@@ -388,8 +389,9 @@ class Array_map(QtGui.QWidget):
# self.test_gradient()
levels = np.linspace(self.get_min_from_picks(), self.get_max_from_picks(), nlevel)
self.contourf = self.basemap.contour(self.longrid, self.latgrid, self.picksgrid_active,
levels, latlon=True, zorder=9, alpha=0.7, cmap=self.get_colormap())
self.contourf = self.basemap.contour(self.longrid, self.latgrid, self.picksgrid_active, levels,
linewidths=self.linewidth, latlon=True, zorder=9, alpha=0.7,
cmap=self.get_colormap())
def get_colormap(self):
return plt.get_cmap(self.cmaps_box.currentText())
@@ -440,7 +442,7 @@ class Array_map(QtGui.QWidget):
self._station_onpick_ids = stations
if self.eventLoc:
lats, lons = self.eventLoc
self.sc_event = self.basemap.scatter(lons, lats, s=100, facecolor='red',
self.sc_event = self.basemap.scatter(lons, lats, s=2*self.pointsize, facecolor='red',
latlon=True, zorder=11, label='Event (might be outside map region)')
def scatter_picked_stations(self):
@@ -456,8 +458,8 @@ class Array_map(QtGui.QWidget):
if len(lons) == 2 and len(lats) == 2:
self.sc_picked = self.basemap.scatter(lons[1], lats[1], s=self.pointsize, edgecolors='white', cmap=cmap,
c=picks[1], latlon=True, zorder=11)
else:
self.sc_picked = self.basemap.scatter(lons, lats, s=50, edgecolors='white', cmap=cmap,
if len(lons) > 2 and len(lats) > 2:
self.sc_picked = self.basemap.scatter(lons, lats, s=self.pointsize, edgecolors='white', cmap=cmap,
c=picks, latlon=True, zorder=11, label='Picked')
def annotate_ax(self):
@@ -476,7 +478,7 @@ class Array_map(QtGui.QWidget):
if st in self.marked_stations:
color = 'red'
self.annotations.append(self.main_ax.annotate(' %s' % st, xy=(x, y),
fontsize='x-small', fontweight='semibold',
fontsize=self.pointsize/6., fontweight='semibold',
color=color, zorder=14))
self.legend = self.main_ax.legend(loc=1)
self.legend.get_frame().set_facecolor((1, 1, 1, 0.75))

View File

@@ -9,12 +9,16 @@ from pylot.core.util.array_map import Array_map
import matplotlib.pyplot as plt
def main(project_file_path, manual=False, auto=True):
def main(project_file_path, manual=False, auto=True, file_format='png', f_ext=''):
project = Project.load(project_file_path)
nEvents = len(project.eventlist)
for index, event in enumerate(project.eventlist):
eventdir = event.path
# MP MP TESTING +++
#if not eventdir.endswith('20170908_044946.a'):
# continue
# MP MP ----
print('Working on event: {} ({}/{})'.format(eventdir, index + 1, nEvents))
# check for picks
manualpicks = event.getPicks()
@@ -30,14 +34,19 @@ def main(project_file_path, manual=False, auto=True):
# create figure to plot on
fig = plt.figure(figsize=(16,9))
# create array map object
map = Array_map(None, metadata, figure=fig, width=2.13e6, height=1.2e6)
map = Array_map(None, metadata, figure=fig, width=2.13e6, height=1.2e6, pointsize=15., linewidth=1.0)
# set combobox to auto/manual to plot correct pick type
map.comboBox_am.setCurrentIndex(map.comboBox_am.findText(pick_type))
# add picks to map and save file
map.refresh_drawings(manualpicks, autopicks)
fpath_out = os.path.join(eventdir, 'array_map_{}_{}.svg'.format(event.pylot_id, pick_type))
fpath_out = os.path.join(eventdir, 'array_map_{}_{}{}.{}'.format(event.pylot_id, pick_type, f_ext,
file_format))
fig.savefig(fpath_out, dpi=300.)
print('Wrote file: {}'.format(fpath_out))
if __name__ == '__main__':
main('/home/marcel/pylot_m7_mantle_correlated.plp')
#main('/home/marcel/pylot_m7_mantle_correlated_ORIG_AUTOPYLOT.plp')
#main('/home/marcel/test_project_obs_highf.plp', f_ext='_highf')
#main('/home/marcel/test_project_obs_lowf.plp', f_ext='_lowf')
#main('/home/marcel/test_project_obs_hybrid.plp', f_ext='_hybrid')
main('/home/marcel/test_project_obs_uhf.plp', f_ext='_uhf')

View File

@@ -2645,6 +2645,10 @@ class PickDlg(QDialog):
quality = get_quality_class(picks['spe'], self.parameter['timeerrorsS'])
phaseID = 'S'
# if no mpp is there, return
if not picks['mpp']:
return
mpp = picks['mpp'] - self.getStartTime()
if picks['epp'] and picks['lpp'] and not textOnly:
epp = picks['epp'] - self.getStartTime()
@@ -2824,6 +2828,8 @@ class PickDlg(QDialog):
for phase in picks:
if not type(picks[phase]) in [dict, AttribDict]:
continue
if not picks[phase]['mpp']:
continue
pick_rel = picks[phase]['mpp'] - starttime
# add relative pick time, phaseID and picktype index
X.append((pick_rel, phase, picktype))