DataAnalysis2022/ObsPy/04_Station_metainformation.ipynb

2 lines
4.5 KiB
Plaintext

{"cells":[{"cell_type":"markdown","metadata":{},"source":["<div style='background-image: url(\"../images/header.svg\") ; padding: 0px ; background-size: cover ; border-radius: 5px ; height: 250px'>\n"," <div style=\"float: right ; margin: 50px ; padding: 20px ; background: rgba(255 , 255 , 255 , 0.7) ; width: 50% ; height: 150px\">\n"," <div style=\"position: relative ; top: 50% ; transform: translatey(-50%)\">\n"," <div style=\"font-size: xx-large ; font-weight: 900 ; color: rgba(0 , 0 , 0 , 0.8) ; line-height: 100%\">ObsPy Tutorial</div>\n"," <div style=\"font-size: large ; padding-top: 20px ; color: rgba(0 , 0 , 0 , 0.5)\">Handling Station Metadata</div>\n"," </div>\n"," </div>\n","</div>"]},{"cell_type":"markdown","metadata":{},"source":["Seismo-Live: http://seismo-live.org\n","\n","##### Authors:\n","* Lion Krischer ([@krischer](https://github.com/krischer))\n","* Tobias Megies ([@megies](https://github.com/megies))\n","---"]},{"cell_type":"markdown","metadata":{},"source":["![](images/obspy_logo_full_524x179px.png)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["%matplotlib inline\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](http://www.fdsn.org/xml/station/)\n","- FDSN StationXML files can be read using **`read_inventory()`**"]},{"cell_type":"code","execution_count":null,"metadata":{},"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","<img src=\"images/Inventory.svg\" width=90%>"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["!head data/station_BFO.xml"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["print(inventory)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["network = inventory[0]\n","print(network)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["station = network[0]\n","print(station)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["channel = station[0]\n","print(channel)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["print(channel.response)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["from obspy import read\n","st = read(\"./data/waveform_PFO.mseed\")\n","print(st)"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["inv = read_inventory(\"./data/station_PFO.xml\", format=\"STATIONXML\")"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["print(st[0].stats)"]},{"cell_type":"markdown","metadata":{},"source":["- 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":{},"outputs":[],"source":["st.plot()\n","st.remove_response(inventory=inv)\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":{},"outputs":[],"source":["st = read(\"./data/waveform_PFO.mseed\")\n","st.remove_response(inventory=inv, 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"]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}},"nbformat":4,"nbformat_minor":2}