{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

\n", "\n", "

\n", "\n", "

ObsPy Workshop

\n", "
Münster, July 7th & 8th
\n", "\n", "

Data Acquisition and Processing with ObsPy

\n", "\n", "

Handling Station Metadata

\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "from __future__ import print_function\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "plt.style.use('ggplot')\n", "plt.rcParams['figure.figsize'] = 12, 8" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- for station metadata, the de-facto standard of the future (replacing SEED/RESP) is [FDSN StationXML](https://www.fdsn.org/xml/station/)\n", "- FDSN StationXML files can be read using **`read_inventory()`**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from obspy import read_inventory\n", "# real-world StationXML files often deviate from the official schema definition\n", "# therefore file-format autodiscovery sometimes fails and we have to force the file format\n", "inventory = read_inventory(\"./data/station_PFO.xml\", format=\"STATIONXML\")\n", "print(type(inventory))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- the nested ObsPy Inventory class structure (Inventory/Station/Channel/Response/...) is closely modelled after FDSN StationXML\n", "" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "!head data/station_BFO.xml" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(inventory)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "network = inventory[0]\n", "print(network)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "station = network[0]\n", "print(station)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "channel = station[0]\n", "print(channel)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(channel.response)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- for metadata read from StationXML the response information can be attached to the waveform data using the convenience method **`Stream.attach_response()`**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from obspy import read\n", "st = read(\"./data/waveform_PFO.mseed\")\n", "print(st)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "inv = read_inventory(\"./data/station_PFO.xml\", format=\"STATIONXML\")\n", "st.attach_response(inv)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(st[0].stats)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- once attached to the waveform data, the instrument response can be deconvolved from the waveform data using the convenience method **`Stream.remove_response()`**\n", "- evalresp is used internally to calculate the instrument response" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "st.plot()\n", "st.remove_response()\n", "st.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- several options can be used to specify details of the deconvolution (water level, frequency domain prefiltering), output units (velocity/displacement/acceleration), demeaning, tapering and to specify if any response stages should be omitted" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "st = read(\"./data/waveform_PFO.mseed\")\n", "st.attach_response(inv)\n", "st.remove_response(water_level=60, pre_filt=(0.01, 0.02, 8, 10), output=\"DISP\")\n", "st.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- station metadata not present in StationXML yet but in Dataless SEED or RESP files can be used for instrument correction using the `.simulate()` method of Stream/Trace in a similar fashion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Acknowledgements\n", "\n", "Background picture at the very top is from Matthias Meschede." ] } ], "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.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }