Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Jupyter notebook Waveform_demo.ipynb

15 views
Kernel: Anaconda (Python 3) obspy

Retrieving Waveform Data from Various Webservices

There are a couple of different ways to use webservices to download GeoNet data. Here are some examples using the Python Obspy module.

First example is requesting Strong Motion data using FDSN webservices. We remove the instrument response, determine the peak ground acceleration and plot the corrected waveform.

#!/usr/bin/env python from obspy import UTCDateTime from obspy.clients.fdsn import Client as FDSN_Client client = FDSN_Client("GEONET") t = UTCDateTime("2016-09-01T16:37:00.000") st = client.get_waveforms("NZ", "TDHS","20", "?N?", t, t + 300,attach_response=True) pre_filt = (0.005, 0.006, 30.0, 35.0) st.remove_response(output='ACC', pre_filt=pre_filt) st.plot() pga = st.max() print('PGA (HN1) = %f, PGA (HN2) = %f, PGA (HNZ) = %f m/s/s ' % (pga[0],pga[1],pga[2]))
Image in a Jupyter notebook
PGA (HN1) = 1.036797, PGA (HN2) = -1.029480, PGA (HNZ) = -0.363710 m/s/s

Example of retrieving broadband waveform data from the common waveform buffer.

from obspy.clients.neic import Client as CWB_Client client = CWB_Client(host='cwb.geonet.org.nz', port=2061, timeout=30, debug=False) t = UTCDateTime("2016-02-14T00:10:00.000") st = client.get_waveforms("NZ", "MQZ", "10", "HH?", t, t + 500) st.plot()
client = FDSN_Client("GEONET") stime = UTCDateTime("2016-02-13T00:12:00.000") etime = UTCDateTime("2016-02-14T00:12:00.000") singlechannel = client.get_waveforms("NZ", "MRNZ","10", "EHZ", stime, etime) singlechannel.plot(type='dayplot')
Image in a Jupyter notebook
client = FDSN_Client("https://beta-service.geonet.org.nz") #client = FDSN_Client("GeoNet") stime = UTCDateTime("2016-11-13T10:00:00.000") etime = UTCDateTime("2016-11-13T13:00:00.000") st = client.get_waveforms("NZ", "KAIT","*", "BT?", stime, etime) st.plot() print(st)
Image in a Jupyter notebook
6 Trace(s) in Stream: NZ.KAIT.40.BTH | 2016-11-13T10:00:07.069500Z - 2016-11-13T12:59:50.669500Z | 10.0 Hz, 107837 samples NZ.KAIT.41.BTH | 2016-11-13T10:00:01.469500Z - 2016-11-13T12:59:38.369500Z | 10.0 Hz, 107770 samples NZ.KAIT.40.BTT | 2016-11-13T10:00:07.069500Z - 2016-11-13T12:59:50.669500Z | 10.0 Hz, 107837 samples NZ.KAIT.41.BTT | 2016-11-13T10:00:01.469500Z - 2016-11-13T12:59:38.369500Z | 10.0 Hz, 107770 samples NZ.KAIT.40.BTZ | 2016-11-13T10:00:07.069541Z - 2016-11-13T12:59:50.669541Z | 10.0 Hz, 107837 samples NZ.KAIT.41.BTZ | 2016-11-13T10:00:01.469541Z - 2016-11-13T12:59:38.369541Z | 10.0 Hz, 107770 samples