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.
 
 

76 lines
2.1 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. "\n",
  27. "# select time range\n",
  28. "tmin = util.stt('2015-09-16 22:54:33')\n",
  29. "tmax = util.stt('2015-09-17 00:54:33')\n",
  30. "\n",
  31. "# select networkID, StationID, Location, Channel\n",
  32. "# asterisk '*' as wildcard is possible\n",
  33. "selection = [('X9', '*', '*', 'HHZ', tmin, tmax)] \n",
  34. "# Example above: Select restricted network X9, all stations, all locations,\n",
  35. "# vertikal component only, 80Hz\n",
  36. "\n",
  37. "# Read access-token for the restricted network from file \n",
  38. "token=open('token.asc', 'rb').read() # 'rb' required for unicode to byte conversion\n",
  39. "\n",
  40. "# setup a waveform data request\n",
  41. "request_waveform = ws.dataselect(site='geofon',selection=selection,token=token)\n",
  42. "\n",
  43. "# Instead of the token, username and password can be given explicitely via:\n",
  44. "# request_waveform = ws.dataselect(site='geofon',selection=selection,user=user,passwd=passwd)\n",
  45. "# where 'user' and 'passwd' are to be entered as strings.\n",
  46. "\n",
  47. "\n",
  48. "# write the incoming data stream to 'traces.mseed'\n",
  49. "with open('traces.mseed', 'wb') as file: # 'wb' - same reason as 'rb' above\n",
  50. " file.write(request_waveform.read())"
  51. ]
  52. }
  53. ],
  54. "metadata": {
  55. "kernelspec": {
  56. "display_name": "Python 3",
  57. "language": "python",
  58. "name": "python3"
  59. },
  60. "language_info": {
  61. "codemirror_mode": {
  62. "name": "ipython",
  63. "version": 3
  64. },
  65. "file_extension": ".py",
  66. "mimetype": "text/x-python",
  67. "name": "python",
  68. "nbconvert_exporter": "python",
  69. "pygments_lexer": "ipython3",
  70. "version": "3.5.2"
  71. }
  72. },
  73. "nbformat": 4,
  74. "nbformat_minor": 2
  75. }