Browse Source

adding fdsn example

master
lilienka 2 years ago
parent
commit
eecc9a90ba
1 changed files with 68 additions and 0 deletions
  1. +68
    -0
      FDSN-data-download.ipynb

+ 68
- 0
FDSN-data-download.ipynb View File

@@ -0,0 +1,68 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This examples shows how to download restricted waveform data from the geofon database."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pyrocko.fdsn import ws\n",
"from pyrocko import util, io, trace\n",
"\n",
"\n",
"# select time range\n",
"tmin = util.stt('2015-09-16 22:54:33')\n",
"tmax = util.stt('2015-09-17 00:54:33')\n",
"\n",
"# select networkID, StationID, Location, Channel\n",
"# asterisk '*' as wildcard is possible\n",
"selection = [('X9', '*', '*', 'HHZ', tmin, tmax)] \n",
"# Example above: Select restricted network X9, all stations, all locations,\n",
"# vertikal component only, 80Hz\n",
"\n",
"# Read access-token for the restricted network from file \n",
"token=open('token.asc', 'rb').read() # 'rb' required for unicode to byte conversion\n",
"\n",
"# setup a waveform data request\n",
"request_waveform = ws.dataselect(site='geofon',selection=selection,token=token)\n",
"\n",
"# Instead of the token, username and password can be given explicitely via:\n",
"# request_waveform = ws.dataselect(site='geofon',selection=selection,user=user,passwd=passwd)\n",
"# where 'user' and 'passwd' are to be entered as strings.\n",
"\n",
"\n",
"# write the incoming data stream to 'traces.mseed'\n",
"with open('traces.mseed', 'wb') as file: # 'wb' - same reason as 'rb' above\n",
" file.write(request_waveform.read())"
]
}
],
"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.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Loading…
Cancel
Save