initial commit

main
Sebastian Heimann 9 months ago
commit 357785adc9

@ -0,0 +1,11 @@
name = 20140405054456
time = 2014-04-05 05:44:55.00
latitude = -20.2284
longitude = -70.538
depth = 25164
--------------------------------------------
name = 20140411120052
time = 2014-04-11 12:00:52.000
latitude = -20.1669
longitude = -70.5
depth = 19934

@ -0,0 +1,15 @@
--- !abedeto.Config
path_prefix: '..'
events_path: 'catalogs/events.pf'
custom_arrays: []
quantity: 'velocity'
fmin: 0.5
fmax: 2.0
depth_min: 1000.0
depth_max: 20000.0
depth_delta: 1000.0
tmin: '{stored:P}-10'
tmax: '{stored:P}+52'
store_id_template: 'gf_{event}_{array}'
normalize: false

@ -0,0 +1,23 @@
from setuptools import setup
setup(
name='abedeto',
version='2.0',
author='The Abedeto Developers',
maintainer='Sebastian Heimann',
maintainer_email='sebastian.heimann@uni-potsdam.de',
license='AGPLv3',
package_dir={
'abedeto': 'src'
},
packages=[
'abedeto',
],
install_requires=[
'pyrocko>2022.11.29',
],
entry_points={
'console_scripts': ['abedeto = abedeto.app:main']
}
)

@ -0,0 +1,84 @@
from pyrocko import squirrel, gf
from . import config, core
def lsplit(s):
if s is None:
return None
return [v.strip() for v in s.split(',')]
class AbedetoInit(squirrel.SquirrelCommand):
def make_subparser(self, subparsers):
return subparsers.add_parser(
'init', help='Get initial configuration.')
def setup(self, parser):
pass
def run(self, parser, args):
conf = config.Config(
events_path='events.yaml',
quantity='velocity',
fmin=0.5,
fmax=2.0,
depth_min=1000.,
depth_max=20000.,
depth_delta=1000.,
normalize=False,
tmin=gf.Timing('{stored:P}-10'),
tmax=gf.Timing('{stored:P}+52'))
print(conf)
class AbedetoInfo(squirrel.SquirrelCommand):
def make_subparser(self, subparsers):
return subparsers.add_parser(
'info', help='Show available arrays and events.')
def setup(self, parser):
parser.add_argument(
'config_path',
help='Path to configuration file.')
def run(self, parser, args):
conf = config.load(args.config_path)
abedeto = core.Abedeto(conf)
print(abedeto)
class AbedetoDownload(squirrel.SquirrelCommand):
def make_subparser(self, subparsers):
return subparsers.add_parser(
'download', help='Downlad seismic waveforms.')
def setup(self, parser):
parser.add_argument(
'config_path',
help='Path to configuration file.')
parser.add_argument(
'--events',
dest='event_names',
metavar='EVENT,...',
help='Names of events to download.')
parser.add_argument(
'--arrays',
dest='array_names',
metavar='ARRAY,...',
help='Names of arrays to download.')
def run(self, parser, args):
conf = config.load(args.config_path)
abedeto = core.Abedeto(conf)
event_names = lsplit(args.event_names)
array_names = lsplit(args.array_names)
abedeto.download(event_names, array_names)
def main():
squirrel.run(
subcommands=[AbedetoInit(), AbedetoInfo(), AbedetoDownload()],
description='What was the depth, again?')

@ -0,0 +1,85 @@
from pyrocko.guts import Object, String, List
from pyrocko.squirrel import CodesNSLCE
from pyrocko.has_paths import HasPaths, Path
class SeismicArray(Object):
pass
class SeismicArrayFromFDSN(SeismicArray):
name = String.T()
site = String.T()
codes = List.T(CodesNSLCE.T())
seismic_arrays = [
SeismicArrayFromFDSN(
name=name,
site='iris',
codes=[CodesNSLCE(c) for c in codes])
for (name, codes) in [
('YKA', ['CN.YKA*..SHZ']),
# ('ESK', ['IM.EKB?..SHZ',
# 'IM.EKR*..SHZ']),
# ('ESK1', 'IM.EKA?..SHZ'),
('ILAR', ['IM.IL*..SHZ']),
('IMAR', ['IM.IM0?..SHZ']),
# 'NIA', 'IM.I56H?..SHZ',
# 'PFIA', ['IM.I57H?..SHZ',
# 'IM.I57L?..SHZ'],
('BMA', ['IM.BM0?..SHZ']),
('BCA', ['IM.BC0?..SHZ']),
# 'HIA', 'IM.I59H?..SHZ',
('NVAR', ['IM.NV*..SHZ']),
('PDAR', ['IM.PD0*..SHZ', 'IM.PD1*..SHZ']),
('TXAR', ['IM.TX*..SHZ']),
# 'Pilbara', 'AU.PSA*..SHZ',
('AliceSprings', ['AU.AS*..SHZ']),
# 'GERES', ['IM.GEA?..SHZ',
# 'IM.GEB?..SHZ',
# 'IM.GEC?..SHZ',
# 'IM.GED?..SHZ'],
# Diego Garcia Hydroacoustic array noqa
('DGHAland', ['IM.I52H?..SHZ']),
('DGHAS', ['IM.H08S?..SHZ']),
('DGHAN', ['IM.H08N?..SHZ']),
# Tristan da Cunha. 'SHZ', BDF. noqa
# 'TDC', ['IM.H09N?..SHZ',
# 'IM.I49H?..SHZ'],
# 'NarroginIA', 'IM.I04H?..SHZ',
# 'CocosIslands', 'IM.I06H?..SHZ',
('Warramunga', ['IM.I07H?..SHZ'])
# 'BermudaIA', 'IM.I51H?..SHZ',
# 'FairbanksIA', 'IM.I53H?..SHZ'
]
] + [
SeismicArrayFromFDSN(
name=name,
site='geofon',
codes=[CodesNSLCE(c) for c in codes])
for (name, codes) in [
('ROHRBACH', ['6A.V*..SHZ']),
('AntaOffshore', ['GR.I27L?.*.SHZ']),
('AntaOnshore', ['AW.VNA*.*.SHZ']),
]
] + [
SeismicArrayFromFDSN(
name=name,
site='bgr',
codes=[CodesNSLCE(c) for c in codes])
for (name, codes) in [
('GERES', [
'GR.GEA?.*.SHZ',
'GR.GEB?.*.SHZ',
'GR.GEC?.*.SHZ',
'GR.GED?.*.SHZ']),
]
]
class SeismicArrayFromFile(SeismicArray, HasPaths):
name = String.T()
stations_path = Path.T()

@ -0,0 +1,45 @@
import os.path as op
from pyrocko.guts import List, Bool, Float, StringChoice, String
from pyrocko import guts, gf
from pyrocko.has_paths import HasPaths, Path
from .error import AbedetoError
from .arrays import SeismicArray
guts_prefix = 'abedeto'
class Quantity(StringChoice):
choices = ['raw', 'velocity']
class Config(HasPaths):
events_path = Path.T()
custom_arrays = List.T(SeismicArray.T())
quantity = Quantity.T()
fmin = Float.T()
fmax = Float.T()
depth_min = Float.T()
depth_max = Float.T()
depth_delta = Float.T()
normalize = Bool.T()
tmin = gf.Timing.T()
tmax = gf.Timing.T()
store_id_template = String.T(default='gf_{event}_{array}')
abedeto_path = Path.T(default='abedeto')
def load(path):
config = guts.load(filename=path)
if not isinstance(config, Config):
raise AbedetoError('Invalid Abedeto configuration: %s' % path)
config.set_basepath(op.dirname(path) or '.')
return config
def dump(config, path):
basepath = config.get_basepath()
dirname = op.dirname(path) or '.'
config.change_basepath(dirname)
guts.dump(config, filename=path)
config.change_basepath(basepath)

@ -0,0 +1,79 @@
import os
import logging
from pyrocko import model
from . import arrays
logger = logging.getLogger('abedeto.core')
class Abedeto:
def __init__(self, config):
self._config = config
self._events = model.load_events(
config.expand_path(config.events_path))
self._arrays = arrays.seismic_arrays + config.custom_arrays
def get_abedeto_dir(self):
return self._config.expand_path(self._config.abedeto_path)
def get_array_names(self):
return [arr.name for arr in self._arrays]
def get_event_names(self):
return [ev.name for ev in self._events]
def __str__(self):
return '''
Events:
%s
Arrays:
%s
''' % (
'\n'.join(' %s' % name for name in self.get_event_names()),
'\n'.join(' %s' % name for name in self.get_array_names()))
def iter_event_array(self, event_names=None, array_names=None):
if not event_names:
event_names = self.get_event_names()
if not array_names:
array_names = self.get_array_names()
for event in self._events:
if event.name in event_names:
for array in self._arrays:
if array.name in array_names:
yield event, array
def get_store_id(self, event, array):
return self._config.store_id_template.format(
event=event.name, array=array.name)
def get_store_path(self, store_id):
return os.path.join(self.get_abedeto_dir(), 'gf_stores', store_id)
def get_store(self, event, array):
store_id = self.get_store_id(event, array)
path = self.get_store_path(store_id)
if not os.path.exists(path):
# propose and create store, calculate ttt
else:
store = # open store
return store
def download(self, event_names=None, array_names=None):
for event, array in self.iter_event_array(event_names, array_names):
logger.info(
'Downloading event %s, array %s' % (event.name, array.name))
store = self.get_store(event, array)
tmin = store.t(self._config.tmin, event, station)
tmax = store.t(self._config.tmax, event, station)

@ -0,0 +1,3 @@
class AbedetoError(Exception):
pass
Loading…
Cancel
Save