{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Configuration\n", "\n", "To use the command-line scripts provided some configuration values need to be\n", "set. These configuration values are stored in a yaml formatted file. I/O is undertaken using the `rt_eqcorrscan.config.Config`\n", "class.\n", "\n", "Creating a new `Config` object instantiates the object with some simple defaults." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Config(\n", "\trt_match_filter=RTMatchFilterConfig({'client': 'GEONET', 'client_type': 'FDSN', 'seedlink_server_url': 'link.geonet.org.nz', 'n_stations': 10, 'max_distance': 1000.0, 'buffer_capacity': 300.0, 'detect_interval': 120.0, 'plot': True, 'threshold': 0.5, 'threshold_type': 'av_chan_corr', 'trig_int': 2.0, 'local_wave_bank': None}),\n", "\treactor=ReactorConfig({'magnitude_threshold': 6.0, 'rate_threshold': 20.0, 'rate_radius': 0.5}),\n", "\tplot=PlotConfig({'plot_length': 600.0, 'lowcut': 1.0, 'highcut': 10.0}),\n", "\tdatabase_manager=DatabaseManagerConfig({'event_path': '.', 'event_format': 'QUAKEML', 'event_name_structure': '{event_id_end}', 'path_structure': '{year}/{month}/{event_id_end}', 'event_ext': '.xml', 'min_stations': 5}),\n", "\ttemplate=TemplateConfig({'lowcut': 2.0, 'highcut': 15.0, 'filt_order': 4, 'samp_rate': 50.0, 'length': 4.0, 'prepick': 0.2, 'swin': 'all', 'process_len': 300, 'min_snr': 0})\n" ] } ], "source": [ "from rt_eqcorrscan.config import Config\n", "\n", "config = Config()\n", "print(config)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These defaults can be changed, and other parameters added (so that you can write your own scripts and extend the \n", "configuration)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PlotConfig({'plot_length': 200.0, 'lowcut': 1.0, 'highcut': 10.0})\n" ] } ], "source": [ "config.plot.plot_length = 200.0\n", "print(config.plot)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can write these configuration parameters to a file to allow you to store them and read them back in later. You can\n", "also edit the yml file in a text editor." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Config(\n", "\trt_match_filter=RTMatchFilterConfig({'client': 'GEONET', 'client_type': 'FDSN', 'seedlink_server_url': 'link.geonet.org.nz', 'n_stations': 10, 'max_distance': 1000.0, 'buffer_capacity': 300.0, 'detect_interval': 120.0, 'plot': True, 'threshold': 0.5, 'threshold_type': 'av_chan_corr', 'trig_int': 2.0, 'local_wave_bank': None}),\n", "\treactor=ReactorConfig({'magnitude_threshold': 6.0, 'rate_threshold': 20.0, 'rate_radius': 0.5}),\n", "\tplot=PlotConfig({'plot_length': 200.0, 'lowcut': 1.0, 'highcut': 10.0}),\n", "\tdatabase_manager=DatabaseManagerConfig({'event_path': '.', 'event_format': 'QUAKEML', 'event_name_structure': '{event_id_end}', 'path_structure': '{year}/{month}/{event_id_end}', 'event_ext': '.xml', 'min_stations': 5}),\n", "\ttemplate=TemplateConfig({'lowcut': 2.0, 'highcut': 15.0, 'filt_order': 4, 'samp_rate': 50.0, 'length': 4.0, 'prepick': 0.2, 'swin': 'all', 'process_len': 300, 'min_snr': 0})\n" ] } ], "source": [ "config.write(\"basic_config.yml\")\n", "\n", "from rt_eqcorrscan.config import read_config\n", "\n", "config_back = read_config(\"basic_config.yml\")\n", "print(config_back)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "nbformat": 4, "nbformat_minor": 2 }