Browse Source

grond init: including examples // updated docs

priors
miili 2 years ago
parent
commit
40d9287dfb
26 changed files with 292 additions and 63 deletions
  1. +2
    -6
      docs/source/examples/satellite_insar/index.rst
  2. +2
    -5
      docs/source/examples/waveform_regional/index.rst
  3. +2
    -5
      docs/source/examples/waveform_wphase/index.rst
  4. +4
    -3
      setup.py
  5. +56
    -29
      src/apps/cmd_init.py
  6. +23
    -15
      src/apps/grond.py
  7. +0
    -0
      src/data/examples/example_insar/README.md
  8. +0
    -0
      src/data/examples/example_insar/bin/download_gf_stores.sh
  9. +0
    -0
      src/data/examples/example_insar/bin/download_insar_data.sh
  10. +0
    -0
      src/data/examples/example_insar/config/insar_rectangular.gronf
  11. +0
    -0
      src/data/examples/example_regional-cmt/README.md
  12. +0
    -0
      src/data/examples/example_regional-cmt/bin/download_gf_stores.sh
  13. +0
    -0
      src/data/examples/example_regional-cmt/bin/grondown
  14. +0
    -0
      src/data/examples/example_regional-cmt/bin/grondown_regional.sh
  15. +0
    -0
      src/data/examples/example_regional-cmt/config/regional_cmt.gronf
  16. +0
    -0
      src/data/examples/example_wphase/README.md
  17. +0
    -0
      src/data/examples/example_wphase/bin/download_gf_stores.sh
  18. +0
    -0
      src/data/examples/example_wphase/bin/grondown
  19. +0
    -0
      src/data/examples/example_wphase/bin/grondown_wphase.sh
  20. +0
    -0
      src/data/examples/example_wphase/config/wphase_cmt.gronf
  21. +0
    -0
      src/data/snippets/README.md
  22. +80
    -0
      src/data/snippets/section_dataset.gronf
  23. +0
    -0
      src/data/snippets/section_noise_analyser.gronf
  24. +18
    -0
      src/data/snippets/target_gnss.gronf
  25. +44
    -0
      src/data/snippets/target_insar.gronf
  26. +61
    -0
      src/data/snippets/target_waveform.gronf

+ 2
- 6
docs/source/examples/satellite_insar/index.rst View File

@ -7,15 +7,11 @@ Setup
-----
To repeat this exercise on your machine, you should first `install Pyrocko
<https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then, copy the
exercise project directory from Grond's git repos to a place of your choice.
<https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then create the example project with:
.. code-block :: sh
# git clone https://github.com/pyrocko/grond # <- done during installation
cd grond
cp -r examples/grond-playground-insar ~/grond-playground-insar
cd ~/grond-playground-insar
grond init example_insar grond-playground-insar/
The project folder


+ 2
- 5
docs/source/examples/waveform_regional/index.rst View File

@ -6,14 +6,11 @@ This step-by-step guide explains how to obtain a probabilistic centroid moment t
Setup
-----
To repeat this exercise on your machine, you should first `install Pyrocko <https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then, copy the exercise project directory from Grond's git repositories to a place of your choice:
To repeat this exercise on your machine, you should first `install Pyrocko <https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then create the example project with:
.. code-block :: sh
# git clone https://gitext.gfz-potsdam.de/heimann/grond.git # <- done during installation
cd grond
cp -r examples/grond-playground-regional ~/grond-playground-regional
cd ~/grond-playground-regional
grond init example_regional-cmt grond-playground-regional/
The project folder


+ 2
- 5
docs/source/examples/waveform_wphase/index.rst View File

@ -6,14 +6,11 @@ This step-by-step guide explains how to obtain a probabilistic W-phase centroid
Setup
-----
To repeat this exercise on your machine, you should first `install Pyrocko <https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then, copy the exercise project directory from Grond's git repositories to a place of your choice:
To repeat this exercise on your machine, you should first `install Pyrocko <https://pyrocko.org/docs/current/install/>`_ and Grond (see :doc:`/install/index`), if you have not already done so. Then create the example project with:
.. code-block :: sh
# git clone https://gitext.gfz-potsdam.de/heimann/grond.git # <- done during installation
cd grond
cp -r examples/grond-playground-wphase ~/grond-playground-wphase
cd ~/grond-playground-wphase
grond init example_wphase grond-playground-wphase/
The project folder


+ 4
- 3
setup.py View File

@ -135,9 +135,10 @@ setup(
'report/app/css/*.css',
'report/app/js/*.js',
'data/init/*.gronf',
'data/init/*.txt',
'data/init/*.md'
'data/snippets/*.gronf',
'data/snippets/*.md',
'data/examples/*/*',
'data/examples/*/*/*'
]},
data_files=[],


+ 56
- 29
src/apps/cmd_init.py View File

@ -1,9 +1,8 @@
import logging
import glob
import shutil
import os.path as op
from pyrocko import util
from distutils.dir_util import copy_tree
logger = logging.getLogger('grond.init')
km = 1e3
@ -11,37 +10,40 @@ km = 1e3
class GrondInit(object):
folder = op.join(op.dirname(__file__), '..', 'data', 'init')
snippet_path = op.join(op.dirname(__file__), '..', 'data', 'snippets')
example_path = op.join(op.dirname(__file__), '..', 'data', 'examples')
def __init__(self):
pass
def get_examples(self):
return {
self.filename_to_abbrv(fn): self._get_description(fn)
for fn in self.example_files
self.filename_to_abbrv(fn): self._get_example_description(fn)
for fn in self.example_dirs
}
def get_sections(self):
return {
self.filename_to_abbrv(fn): self._get_description(fn)
for fn in self.section_files
for fn in self.snippet_files
}
@property
def example_files(self):
return self._get_files('example_*.gronf')
def example_dirs(self):
return glob.glob(op.join(self.example_path, '*'))
@property
def section_files(self):
return self._get_files('section_*.gronf')
return self._get_snippet_files('section_*.gronf')
@property
def snippet_files(self):
return self._get_files('snippet_*.gronf')
return self._get_snippet_files('*.gronf')
def _get_files(self, name):
return glob.glob(op.join(self.folder, name))
def _get_snippet_files(self, name):
files = glob.glob(op.join(self.snippet_path, name))
files.sort()
return files
@staticmethod
def _get_description(filename):
@ -51,39 +53,64 @@ class GrondInit(object):
return ln.split(':')[-1].strip('# \n')
return 'No description!'
def _get_example_description(self, example_dir):
config_file = self._get_example_config(example_dir)
with open(config_file, 'rt') as f:
for ln in f.readlines():
if ln.startswith('#'):
return ln.split(':')[-1].strip('# \n')
return 'No description!'
@staticmethod
def _get_example_config(example_dir):
config_file = glob.glob(op.join(example_dir, 'config', '*.gronf'))
if len(config_file) == 0:
raise OSError('No example config file found!')
return config_file[0]
@staticmethod
def filename_to_abbrv(filename):
return op.basename(filename).split('.')[0]
def init_example(self, abbrv, path, force=False):
def log(path, names):
logger.info('Copying %s', path)
return []
path = op.abspath(path)
if op.exists(path) and not force:
raise OSError('Directory already exists: %s' % op.basename(path))
elif op.exists(path) and force:
pass
example_dir = self.abbrv_to_example_dir(abbrv)
logger.info('Initialising example configuration for %s...' % abbrv)
sub_dirs = ['config', 'gf_stores', 'data']
for d in sub_dirs:
p = op.join(path, d + '/')
logger.debug('Creating directory: %s' % p)
util.ensuredirs(p)
fn = self.abbrv_to_filename(abbrv)
logger.debug('Copying config file: %s' % fn)
shutil.copyfile(fn, op.join(path, 'config', op.basename(fn)))
logger.debug('Copying README.md: %s' % fn)
shutil.copyfile(op.join(self.folder, 'README_example.md'),
op.join(path, 'README.md'))
logger.info('Initialising example %s in %s' % (example_dir, path))
copy_tree(example_dir, path)
def abbrv_to_filename(self, abbrv):
ext = '.gronf'
fn = op.join(self.folder, abbrv + ext)
fn = op.join(self.snippet_path, abbrv + ext)
if fn not in self._get_files('*.gronf'):
if fn not in self._get_snippet_files('*.gronf'):
raise OSError('File not found: %s' % fn)
return fn
def get_content(self, abbrv):
def abbrv_to_example_dir(self, abbrv):
return op.join(self.example_path, abbrv)
def get_content_example(self, abbrv):
try:
print(abbrv, self.abbrv_to_example_dir(abbrv))
fn = self._get_example_config(
self.abbrv_to_example_dir(abbrv))
except OSError:
return False
with open(fn, 'r') as f:
return f.read()
def get_content_snippet(self, abbrv):
try:
fn = self.abbrv_to_filename(abbrv)
except OSError:


+ 23
- 15
src/apps/grond.py View File

@ -166,7 +166,7 @@ To look at the results, run
'''
def __new__(cls, command, **kwargs):
return 'Hint:\n' +\
return '{c.BOLD}Hint{c.END}\n'.format(c=Color) +\
getattr(cls, command).format(**kwargs)
@ -504,29 +504,37 @@ def command_init(args):
if args[0] == 'list':
print(help_text)
sys.exit(0)
elif args[0].startswith('section_'):
sec = grond_init.get_content(args[0])
if not sec:
help_and_die(parser, 'Unknown section: %s' % args)
if args[0].startswith('example_'):
if len(args) == 1:
config = grond_init.get_content_example(args[0])
if not config:
help_and_die(parser, 'Unknown example: %s' % args[0])
sys.stdout.write(sec)
sys.stdout.write(config)
elif args[0].startswith('example_'):
if len(args) == 1:
help_and_die(parser, 'Not project directory given!' % args)
if op.exists(op.abspath(args[1])) and not options.force:
print('\n{c.BOLD}Hint{c.END}\n\n'
'To create a project, use: grond init {example} project-dir/'
.format(c=Color, example=args[0]))
elif op.exists(op.abspath(args[1])) and not options.force:
help_and_die(
parser,
'Directory %s already exists! Use --force to overwrite.'
% args[1])
try:
grond_init.init_example(args[0], args[1], force=options.force)
except OSError as e:
print(str(e))
else:
try:
grond_init.init_example(args[0], args[1], force=options.force)
except OSError as e:
print(str(e))
else:
help_and_die(parser, 'Unknown init: %s' % args)
sec = grond_init.get_content_snippet(args[0])
if not sec:
help_and_die(parser, 'Unknown snippet: %s' % args[0])
sys.stdout.write(sec)
def command_init_old(args):


src/data/examples/grond-playground-insar/README.md → src/data/examples/example_insar/README.md View File


src/data/examples/grond-playground-insar/bin/download_gf_stores.sh → src/data/examples/example_insar/bin/download_gf_stores.sh View File


src/data/examples/grond-playground-insar/bin/download_insar_data.sh → src/data/examples/example_insar/bin/download_insar_data.sh View File


src/data/examples/grond-playground-insar/config/insar_rectangular.gronf → src/data/examples/example_insar/config/insar_rectangular.gronf View File


src/data/examples/grond-playground-regional/README.md → src/data/examples/example_regional-cmt/README.md View File


src/data/examples/grond-playground-regional/bin/download_gf_stores.sh → src/data/examples/example_regional-cmt/bin/download_gf_stores.sh View File


src/data/examples/grond-playground-regional/bin/grondown → src/data/examples/example_regional-cmt/bin/grondown View File


src/data/examples/grond-playground-regional/bin/grondown_regional.sh → src/data/examples/example_regional-cmt/bin/grondown_regional.sh View File


src/data/examples/grond-playground-regional/config/regional_cmt.gronf → src/data/examples/example_regional-cmt/config/regional_cmt.gronf View File


src/data/examples/grond-playground-wphase/README.md → src/data/examples/example_wphase/README.md View File


src/data/examples/grond-playground-wphase/bin/download_gf_stores.sh → src/data/examples/example_wphase/bin/download_gf_stores.sh View File


src/data/examples/grond-playground-wphase/bin/grondown → src/data/examples/example_wphase/bin/grondown View File


src/data/examples/grond-playground-wphase/bin/grondown_wphase.sh → src/data/examples/example_wphase/bin/grondown_wphase.sh View File


src/data/examples/grond-playground-wphase/config/wphase_cmt.gronf → src/data/examples/example_wphase/config/wphase_cmt.gronf View File


src/data/init/README.md → src/data/snippets/README.md View File


+ 80
- 0
src/data/snippets/section_dataset.gronf View File

@ -0,0 +1,80 @@
%YAML 1.1
# Section: Full dataset configuration.
# -----------------------------------------------------------------------------
# Configuration section for dataset (input data)
#
# The placeholder '${event_name}' will be expanded to the current event. This
# enables us to use the same configuration for multiple events. The available
# events are detected by looking into possible expansions of
# dataset_config.events_path
# -----------------------------------------------------------------------------
dataset_config: !grond.DatasetConfig
# Optional prefix for all paths in this config file
path_prefix: .
# List of files with station coordinates in Pyrocko format.
stations_path: builtins.str (grond.meta.Path), optional
# List of files with station coordinates.
stations_stationxml_paths:
- 'data/events/${event_name}/waveforms/stations.geofon.xml'
- 'data/events/${event_name}/waveforms/stations.iris.xml'
# File with hypocenter information and possibly reference solution
events_path: 'data/events/${event_name}/event.txt'
# List of directories with raw waveform data
waveform_paths: ['data/events/${event_name}/waveforms/raw']
# List of directories with kite InSAR scenes
kite_scene_paths: ['data/events/${event_name}/insar']
# List of directories with GNSS data
gnss_campaign_paths: ['data/events/${event_name}/gnss']
# List of files with instrument response information (can be the same as in
# stations_stationxml_paths above)
responses_stationxml_paths:
- 'data/events/${event_name}/waveforms/stations.geofon.xml'
'data/events/${event_name}/event.txt'
# List of SACPZ response files for restitution of the raw waveform data.
responses_sacpz_path: 'data/events/${event_name}/responce.pz'
# File containing station correction informations.
station_corrections_path: 'data/events/${event_name}/corrections.txt'
# List event picks files
picks_paths:
- 'data/events/${event_name}/picks.txt'
# List of stations/components to be excluded according to their STA, NET.STA,
# NET.STA.LOC, or NET.STA.LOC.CHA codes
blacklist: ['GE.UGM', 'GE.PLAI']
# List of files with additional exclusion lists (one entry per line, same
# format as above)
blacklist_paths:
- 'data/events/${event_name}/waveforms/blacklist.txt'
# List of text files with whitelisted stations.
whitelist_paths:
- 'data/events/${event_name}/waveforms/whitelist.txt'
# if not None, list of stations/components to include according to their STA, NET.STA, NET.STA.LOC, or NET.STA.LOC.CHA codes.
# Note: when whitelisting on channel level, both, the raw and the processed channel codes have to be listed.
whitelist: ['GE.ZGQ', 'GE.FFAR']
# File containing the clipping information for waveform data
clippings_path: 'data/events/${event_name}/clipping.txt'
# Apply correction factors from station corrections.
apply_correction_factors: true
# Apply correction delays from station corrections.
apply_correction_delays: true
# Extend incomplete seismic traces.
extend_incomplete: false

src/data/init/section_noise_analyser.gronf → src/data/snippets/section_noise_analyser.gronf View File


+ 18
- 0
src/data/snippets/target_gnss.gronf View File

@ -0,0 +1,18 @@
%YAML 1.1
# Target: GNSS target configuration.
- !grond.GNSSCampaignTargetGroup
normalisation_family: gnss_target
path: all
# Manual weight for the GNSS target
weight: 1.0
# The campaigns are identified by their campaign_name.
# Campaigns can be explicitly selected, or the wildcard *all can be used.
gnss_campaigns: ['*all']
misfit_config: !grond.GNSSCampaignMisfitConfig {}
# GF Interpolation
interpolation: multilinear
# GF Store ID
store_id: crust2_ib_static

+ 44
- 0
src/data/snippets/target_insar.gronf View File

@ -0,0 +1,44 @@
%YAML 1.1
# Target: InSAR target configuration.
- !grond.SatelliteTargetGroup
# Normalisation family (see the Grond documentation for how it works).
# Use distinct normalisation families when mixing misfit contributors with
# different magnitude scaling, like e.g. cross-correlation based misfit and
# time-domain Lx norm.
normalisation_family: 'static'
# Just a name used to identify targets from this group. Use dot-separated path
# notation to group related contributors
path: 'insar'
# How to weight contributions from this group in the global misfit
weight: 1.0
# Selector for kite scene ids, '*all' is a wildcard and load all scenes present
kite_scenes: ['*all']
# Subsection on how to fit the traces
misfit_config: !grond.SatelliteMisfitConfig
# Optimise a planar orbital ramp
optimise_orbital_ramp: false
# Parameters for the orbital ramp
ranges:
# Vertical offset in [m]
offset: -0.5 .. 0.5
# Ranges for the East-West and North-South inclination of the ramp
ramp_east: -1e-4 .. 1e-4
ramp_north: -1e-4 .. 1e-4
# How to interpolate the Green's functions (available choices:
# 'nearest_neighbor', 'multilinear'). Choices other than 'nearest_neighbor'
# may require dense GF stores to avoid aliasing artifacts in the forward
# modelling.
interpolation: multilinear
# Name of the GF Store to use
store_id: crust2_ib_static

+ 61
- 0
src/data/snippets/target_waveform.gronf View File

@ -0,0 +1,61 @@
%YAML 1.1
# Target: Waveform target configuration.
- !grond.WaveformTargetGroup
# Normalisation family (see the Grond documentation for how it works).
# Use distinct normalisation families when mixing misfit contributors with
# different magnitude scaling, like e.g. cross-correlation based misfit and
# time-domain Lx norm.
normalisation_family: 'td'
# Just a name used to identify targets from this group. Use dot-separated path
# notation to group related contributors
path: 'td.love'
# Epicentral distance range of stations to be considered in meter
distance_min: 1e3
distance_max: 900e3
# Names of components to be included. Available: N=north, E=east, Z=vertical
# (up), R=radial (away), T=transverse (right)
channels: ['T']
# How to weight contributions from this group in the global misfit
weight: 1.0
# subsection on how to fit the traces
misfit_config: !grond.WaveformMisfitConfig
# Frequency band [Hz] of acausal filter (flat part of frequency taper)
fmin: 0.01
fmax: 0.05
# Factor defining fall-off of frequency taper (zero at fmin/ffactor and
# fmax*ffactor)
ffactor: 1.5
# Time window to include in the data fitting. Times can be defined offset
# to given phase arrivals. E.g. '{stored:P}-600' would mean 600 s
# before arrival of the phase named 'P'. The phase must be defined in the
# travel time tables in the GF store.
tmin: '{stored:any_P}'
tmax: '{vel_surface:2.5}'
# tfade: 120.0
# How to fit the data (available: 'time_domain', 'frequency_domain',
# 'log_frequency_domain', 'absolute', 'envelope', 'cc_max_norm')
domain: 'time_domain'
tautoshift_max: 4.0
autoshift_penalty_max: 0.05
# For L1 norm: 1, L2 norm: 2, etc.
norm_exponent: 1
# How to interpolate the Green's functions (available choices:
# 'nearest_neighbor', 'multilinear'). Choices other than 'nearest_neighbor'
# may require dense GF stores to avoid aliasing artifacts in the forward
# modelling.
interpolation: 'nearest_neighbor'
# Name of the GF Store to use
store_id: 'crust2_j3'

Loading…
Cancel
Save