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.
 
 

69 lines
2.0 KiB

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