Commit f12d66d7 authored by Marius's avatar Marius
Browse files

Save detection plots

parent 7693adbe
......@@ -107,6 +107,10 @@ class Config(Object):
TPDef.T(),
help='list of tabulated phase definitions usable shifters')
detection_plots_path = String.T(
optional=True,
help='output path name for detection plots')
cache_path = String.T(
default='lassie_cache',
help='directory where lassie stores tabulated phases etc.')
......
......@@ -139,6 +139,12 @@ def scan(
util.ensuredirs(config.stackmax_path)
if config.detection_plots_path:
if op.exists(config.detection_plots_path):
shutil.rmtree(config.detection_plots_path)
os.mkdir(config.detection_plots_path)
util.ensuredirs(config.detection_plots_path)
ifcs = config.image_function_contributions
for ifc in ifcs:
ifc.setup(config)
......@@ -459,7 +465,7 @@ def scan(
f.close()
if show_detections:
if show_detections or config.detection_plots_path:
fmin = min(ifc.fmin for ifc in ifcs)
fmax = min(ifc.fmax for ifc in ifcs)
try:
......@@ -472,7 +478,9 @@ def scan(
wmin, wmax,
pdata, trs, fmin, fmax, idetection,
grid_station_shift_max=shift_max,
movie=show_movie)
movie=show_movie,
output_path=config.detection_plots_path,
show=show_detections)
except AttributeError as e:
logger.warn(e)
......
import os
import numpy as num
from pyrocko import automap
......@@ -110,7 +111,7 @@ def plot_detection(
fsmooth_min, xpeak, ypeak, zpeak, tr_stackmax, tpeaks, apeaks,
detector_threshold, wmin, wmax, pdata, trs_raw, fmin, fmax,
idetection, grid_station_shift_max,
movie=False):
movie=False, output_path=None, show=False):
from matplotlib import pyplot as plt
from matplotlib import cm
......@@ -380,7 +381,13 @@ def plot_detection(
ani = None
update(None)
plt.show()
if show:
plt.show()
if output_path:
fig.savefig(
os.path.join(output_path, 'detection_%i.png' % idetection))
del ani
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment