[updates] generate_array_maps multiprocessing, added extension '_autopylot' to picks generated by autopylot to prevent overwriting on auto-save
This commit is contained in:
parent
3be78ec576
commit
be1e49fa57
@ -483,7 +483,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
saveEvtPath = eventpath
|
saveEvtPath = eventpath
|
||||||
else:
|
else:
|
||||||
saveEvtPath = savepath
|
saveEvtPath = savepath
|
||||||
fnqml = '%s/PyLoT_%s' % (saveEvtPath, evID)
|
fnqml = '%s/PyLoT_%s_autopylot' % (saveEvtPath, evID)
|
||||||
data.exportEvent(fnqml, fnext='.xml', fcheck=['auto', 'magnitude', 'origin'])
|
data.exportEvent(fnqml, fnext='.xml', fcheck=['auto', 'magnitude', 'origin'])
|
||||||
if locflag == 1:
|
if locflag == 1:
|
||||||
# HYPO71
|
# HYPO71
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
from PyLoT import Project
|
from PyLoT import Project
|
||||||
from pylot.core.util.dataprocessing import Metadata
|
from pylot.core.util.dataprocessing import Metadata
|
||||||
@ -9,17 +10,33 @@ from pylot.core.util.array_map import Array_map
|
|||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def main(project_file_path, manual=False, auto=True, file_format='png', f_ext=''):
|
def main(project_file_path, manual=False, auto=True, file_format='png', f_ext='', ncores=None):
|
||||||
project = Project.load(project_file_path)
|
project = Project.load(project_file_path)
|
||||||
nEvents = len(project.eventlist)
|
nEvents = len(project.eventlist)
|
||||||
|
input_list = []
|
||||||
|
|
||||||
for index, event in enumerate(project.eventlist):
|
for index, event in enumerate(project.eventlist):
|
||||||
eventdir = event.path
|
|
||||||
# MP MP TESTING +++
|
# MP MP TESTING +++
|
||||||
#if not eventdir.endswith('20170908_044946.a'):
|
#if not eventdir.endswith('20170908_044946.a'):
|
||||||
# continue
|
# continue
|
||||||
# MP MP ----
|
# MP MP ----
|
||||||
print('Working on event: {} ({}/{})'.format(eventdir, index + 1, nEvents))
|
kwargs = dict(event=event, nEvents=nEvents, index=index, manual=manual, auto=auto, file_format=file_format,
|
||||||
|
f_ext=f_ext)
|
||||||
|
input_list.append(kwargs)
|
||||||
|
|
||||||
|
if ncores == 1:
|
||||||
|
for item in input_list:
|
||||||
|
array_map_worker(item)
|
||||||
|
else:
|
||||||
|
pool = multiprocessing.Pool(ncores)
|
||||||
|
result = pool.map(array_map_worker, input_list)
|
||||||
|
pool.close()
|
||||||
|
pool.join()
|
||||||
|
|
||||||
|
def array_map_worker(input_dict):
|
||||||
|
event = input_dict['event']
|
||||||
|
eventdir = event.path
|
||||||
|
print('Working on event: {} ({}/{})'.format(eventdir, input_dict['index'] + 1, input_dict['nEvents']))
|
||||||
# check for picks
|
# check for picks
|
||||||
manualpicks = event.getPicks()
|
manualpicks = event.getPicks()
|
||||||
autopicks = event.getAutopicks()
|
autopicks = event.getAutopicks()
|
||||||
@ -27,9 +44,9 @@ def main(project_file_path, manual=False, auto=True, file_format='png', f_ext=''
|
|||||||
metadata_path = os.path.join(eventdir, 'resp')
|
metadata_path = os.path.join(eventdir, 'resp')
|
||||||
metadata = Metadata(inventory=metadata_path, verbosity=0)
|
metadata = Metadata(inventory=metadata_path, verbosity=0)
|
||||||
for pick_type in ['manual', 'auto']:
|
for pick_type in ['manual', 'auto']:
|
||||||
if pick_type == 'manual' and (not manualpicks or not manual):
|
if pick_type == 'manual' and (not manualpicks or not input_dict['manual']):
|
||||||
continue
|
continue
|
||||||
if pick_type == 'auto' and (not autopicks or not auto):
|
if pick_type == 'auto' and (not autopicks or not input_dict['auto']):
|
||||||
continue
|
continue
|
||||||
# create figure to plot on
|
# create figure to plot on
|
||||||
fig = plt.figure(figsize=(16,9))
|
fig = plt.figure(figsize=(16,9))
|
||||||
@ -39,14 +56,12 @@ def main(project_file_path, manual=False, auto=True, file_format='png', f_ext=''
|
|||||||
map.comboBox_am.setCurrentIndex(map.comboBox_am.findText(pick_type))
|
map.comboBox_am.setCurrentIndex(map.comboBox_am.findText(pick_type))
|
||||||
# add picks to map and save file
|
# add picks to map and save file
|
||||||
map.refresh_drawings(manualpicks, autopicks)
|
map.refresh_drawings(manualpicks, autopicks)
|
||||||
fpath_out = os.path.join(eventdir, 'array_map_{}_{}{}.{}'.format(event.pylot_id, pick_type, f_ext,
|
fpath_out = os.path.join(eventdir, 'array_map_{}_{}{}.{}'.format(event.pylot_id, pick_type, input_dict['f_ext'],
|
||||||
file_format))
|
input_dict['file_format']))
|
||||||
fig.savefig(fpath_out, dpi=300.)
|
fig.savefig(fpath_out, dpi=300.)
|
||||||
print('Wrote file: {}'.format(fpath_out))
|
print('Wrote file: {}'.format(fpath_out))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#main('/home/marcel/pylot_m7_mantle_correlated_ORIG_AUTOPYLOT.plp')
|
#main('/home/marcel/pylot_m7_mantle_correlated.plp', f_ext='_0.5Hz')
|
||||||
#main('/home/marcel/test_project_obs_highf.plp', f_ext='_highf')
|
main('/home/marcel/alparray_m7_mantle_correlated_v3.plp', f_ext='_correlated_0.5Hz')
|
||||||
#main('/home/marcel/test_project_obs_lowf.plp', f_ext='_lowf')
|
#main('/home/marcel/alparray_m6.5-6.9_mantle_correlated_v3.plp', f_ext='_correlated_0.5Hz')
|
||||||
#main('/home/marcel/test_project_obs_hybrid.plp', f_ext='_hybrid')
|
|
||||||
main('/home/marcel/test_project_obs_uhf.plp', f_ext='_uhf')
|
|
||||||
|
@ -3793,7 +3793,7 @@ class TuneAutopicker(QWidget):
|
|||||||
'savexml': False,
|
'savexml': False,
|
||||||
'obspyDMT_wfpath': wfpath}
|
'obspyDMT_wfpath': wfpath}
|
||||||
event = self.get_current_event()
|
event = self.get_current_event()
|
||||||
self.parent().saveData(event, event.path, '.xml')
|
#self.parent().saveData(event, event.path, '.xml') MP MP uncommented because overwriting pick files in tune mode
|
||||||
for key in self.fig_dict.keys():
|
for key in self.fig_dict.keys():
|
||||||
if not key == 'plot_style':
|
if not key == 'plot_style':
|
||||||
self.fig_dict[key].clear()
|
self.fig_dict[key].clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user