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
1.9 KiB

  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Downloading restricted seismic waveform data (FDSN)"
  8. ]
  9. },
  10. {
  11. "cell_type": "markdown",
  12. "metadata": {},
  13. "source": [
  14. "This examples shows how to download restricted waveform data from the geofon database."
  15. ]
  16. },
  17. {
  18. "cell_type": "code",
  19. "execution_count": null,
  20. "metadata": {},
  21. "outputs": [],
  22. "source": [
  23. "from pyrocko.fdsn import ws\n",
  24. "from pyrocko import util, io, trace\n",
  25. "\n",
  26. "# select time range\n",
  27. "tmin = util.stt('2015-09-16 22:54:33')\n",
  28. "tmax = util.stt('2015-09-17 00:54:33')\n",
  29. "\n",
  30. "# select networkID, StationID, Location, Channel\n",
  31. "# use asterisk '*' as wildcard\n",
  32. "selection = [('X9', '*', '*', 'HHZ', tmin, tmax)] \n",
  33. "\n",
  34. "# Read access-token for the restricted network from file as 'rb' for binary\n",
  35. "token=open('token.asc', 'rb').read()\n",
  36. "\n",
  37. "# setup a waveform data request\n",
  38. "request_waveform = ws.dataselect(site='geofon', selection=selection, token=token)\n",
  39. "\n",
  40. "# Alternative method using username and password instead of token:\n",
  41. "# request_waveform = ws.dataselect(site='geofon', selection=selection, user='user', passwd='passwd')\n",
  42. "\n",
  43. "# write the incoming data stream to 'traces.mseed' as 'wb' for binary\n",
  44. "with open('traces.mseed', 'wb') as file:\n",
  45. " file.write(request_waveform.read())"
  46. ]
  47. }
  48. ],
  49. "metadata": {
  50. "kernelspec": {
  51. "display_name": "Python 3",
  52. "language": "python",
  53. "name": "python3"
  54. },
  55. "language_info": {
  56. "codemirror_mode": {
  57. "name": "ipython",
  58. "version": 3
  59. },
  60. "file_extension": ".py",
  61. "mimetype": "text/x-python",
  62. "name": "python",
  63. "nbconvert_exporter": "python",
  64. "pygments_lexer": "ipython3",
  65. "version": "3.5.2"
  66. }
  67. },
  68. "nbformat": 4,
  69. "nbformat_minor": 2
  70. }