You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

71 lines
2.0 KiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Downloading restricted seismic waveform data (FDSN)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This examples shows how to download restricted waveform data from the Geofon database using a cryptograpghic token. \n",
"A personal file `token.asc` is required for this example."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pyrocko.fdsn import ws\n",
"from pyrocko import util, io, trace\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",
"# use asterisk '*' as wildcard\n",
"selection = [('X9', '*', '*', 'HHZ', tmin, tmax)] \n",
"\n",
"# Read access-token for the restricted network from file as 'rb' for binary\n",
"token=open('token.asc', 'rb').read()\n",
"\n",
"# setup a waveform data request\n",
"request_waveform = ws.dataselect(site='geofon', selection=selection, token=token)\n",
"\n",
"# Alternative method using username and password instead of token:\n",
"# request_waveform = ws.dataselect(site='geofon', selection=selection, user='user', passwd='passwd')\n",
"\n",
"# write the incoming data stream to 'traces.mseed' as 'wb' for binary\n",
"with open('traces.mseed', 'wb') as file:\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.7.3rc1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}