def command_events(args): def setup(parser): pass parser, options, args = cl_parse('events', args, setup) if len(args) != 1: help_and_die(parser, 'missing arguments') config_path = args[0] try: config = grond.read_config(config_path) for event_name in grond.get_event_names(config): print(event_name) except grond.GrondError as e: die(str(e))
def command_qc_polarization(args): def setup(parser): parser.add_option( '--time-factor-pre', dest='time_factor_pre', type=float, metavar='NUMBER', default=0.5, help='set duration to extract before synthetic P phase arrival, ' 'relative to 1/fmin. fmin is taken from the selected target ' 'group in the config file (default=%default)') parser.add_option( '--time-factor-post', dest='time_factor_post', type=float, metavar='NUMBER', default=0.5, help='set duration to extract after synthetic P phase arrival, ' 'relative to 1/fmin. fmin is taken from the selected target ' 'group in the config file (default=%default)') parser.add_option( '--distance-min', dest='distance_min', type=float, metavar='NUMBER', help='minimum event-station distance [m]') parser.add_option( '--distance-max', dest='distance_max', type=float, metavar='NUMBER', help='maximum event-station distance [m]') parser.add_option( '--depth-min', dest='depth_min', type=float, metavar='NUMBER', help='minimum station depth [m]') parser.add_option( '--depth-max', dest='depth_max', type=float, metavar='NUMBER', help='maximum station depth [m]') parser.add_option( '--picks', dest='picks_filename', metavar='FILENAME', help='add file with P picks in Snuffler marker format') parser.add_option( '--save', dest='output_filename', metavar='FILENAME.FORMAT', help='save output to file FILENAME.FORMAT') parser.add_option( '--dpi', dest='output_dpi', type=float, default=120., metavar='NUMBER', help='DPI setting for raster formats (default=120)') parser, options, args = cl_parse('qc-polarization', args, setup) if len(args) != 3: help_and_die(parser, 'missing arguments') if options.output_filename: import matplotlib matplotlib.use('Agg') import grond.qc config_path, event_name, target_group_path = args try: config = grond.read_config(config_path) except grond.GrondError as e: die(str(e)) ds = config.get_dataset(event_name) engine = config.engine_config.get_engine() nsl_to_time = None if options.picks_filename: markers = marker.load_markers(options.picks_filename) marker.associate_phases_to_events(markers) nsl_to_time = {} for m in markers: if isinstance(m, marker.PhaseMarker): ev = m.get_event() if ev is not None and ev.name == event_name: nsl_to_time[m.one_nslc()[:3]] = m.tmin if not nsl_to_time: help_and_die( parser, 'no markers associated with event "%s" found in file "%s"' % ( event_name, options.picks_filename)) target_group_paths_avail = [] for target_group in config.target_groups: name = target_group.path if name == target_group_path: imc = target_group.misfit_config fmin = imc.fmin fmax = imc.fmax ffactor = imc.ffactor store = engine.get_store(target_group.store_id) timing = '{cake:P|cake:p|cake:P\\|cake:p\\}' grond.qc.polarization( ds, store, timing, fmin=fmin, fmax=fmax, ffactor=ffactor, time_factor_pre=options.time_factor_pre, time_factor_post=options.time_factor_post, distance_min=options.distance_min, distance_max=options.distance_max, depth_min=options.depth_min, depth_max=options.depth_max, nsl_to_time=nsl_to_time, output_filename=options.output_filename, output_dpi=options.output_dpi) return target_group_paths_avail.append(name) die('no target group with path "%s" found. Available: %s' % ( target_group_path, ', '.join(target_group_paths_avail)))