Commit 30d9d792 authored by Sebastian Heimann's avatar Sebastian Heimann
Browse files

can now use ${config_name} in paths; add title to figures

parent dd08690b
import os.path as op
from string import Template
from collections import defaultdict
from pyrocko.guts import Object, String
from import Earthmodel1D
......@@ -103,6 +105,17 @@ class HasPaths(Object):
for p in path]
def expand_template(template, d):
return Template(template).substitute(d)
except KeyError as e:
raise LassieError(
'invalid placeholder "%s" in template: "%s"' % (str(e), template))
except ValueError:
raise LassieError(
'malformed placeholder in template: "%s"' % template)
__all__ = [
......@@ -7,7 +7,8 @@ from pyrocko.fdsn import station as fs
from import TPDef
from lassie import receiver, ifc, grid, geo
from lassie.common import Earthmodel, HasPaths, Path, LassieError
from lassie.common import Earthmodel, HasPaths, Path, LassieError, \
guts_prefix = 'lassie'
......@@ -116,6 +117,17 @@ class Config(HasPaths):
self._receivers = None
self._grid = None
self._events = None
self._config_name = 'untitled'
def set_config_name(self, config_name):
self._config_name = config_name
def expand_path(self, path):
def extra(path):
return expand_template(path, dict(
return HasPaths.expand_path(self, path, extra=extra)
def get_events_path(self):
run_path = self.expand_path(self.run_path)
......@@ -226,6 +238,8 @@ def read_config(path):
raise LassieError('invalid Lassie configuration in file "%s"' % path)
config.set_basepath(op.dirname(path) or '.')
return config
import os
import numpy as num
from pyrocko import automap, plot
from pyrocko import automap, plot, util
from lassie import grid as gridmod, geo
km = 1000.
......@@ -126,6 +126,7 @@ def plot_detection(
fig = plt.figure(figsize=plot.mpl_papersize('a4', 'landscape'))
axes = plt.subplot2grid((2, 3), (0, 2), aspect=1.0)
......@@ -334,6 +335,9 @@ def plot_detection(
'%06i - %s' % (idetection, util.time_to_str(t0))))
frame_artists = []
progress_artists = []
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