{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\nPlot a Reference CCF\n====================\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# The following two lines are only needed for building this documentation\n# Delete them and run the code in your project folder.\n\nimport os\nif \"SPHINX_DOC_BUILD\" in os.environ:\n os.chdir(r\"C:\\tmp\\msnoise_doc_project\")\n\nimport matplotlib\nmatplotlib.use(\"agg\")\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nfrom pandas.plotting import register_matplotlib_converters\nregister_matplotlib_converters()\n\n\nplt.style.use(\"ggplot\")\n\nfrom msnoise.api import connect, get_results, build_movstack_datelist, get_params, get_t_axis\n\n# connect to the database\ndb = connect()\n\n# Obtain a list of dates between ``start_date`` and ``enddate``\nstart, end, datelist = build_movstack_datelist(db)\n\n# Get the list of parameters from the DB:\nparams = get_params(db)\n\n# Get the time axis for plotting the CCF:\ntaxis = get_t_axis(db)\n\n# Get the results for two station, filter id=1, ZZ component, mov_stack=1 and stack the results:\nn, ccf = get_results(db, \"YA_UV05\", \"YA_UV12\", 1, \"ZZ\", datelist, 1, format=\"stack\", params=params)\n\nplt.figure()\nplt.plot(taxis, ccf)\nplt.title(\"Reference Function\")\nplt.xlabel(\"Lag Time (s)\")\nplt.ylabel(\"Amplitude\")\n\n\n#EOF" ] } ], "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" } }, "nbformat": 4, "nbformat_minor": 0 }