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.

72 lines
2.0KB

  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 using a cryptograpghic token. \n",
  15. "A personal file `token.asc` is required for this example."
  16. ]
  17. },
  18. {
  19. "cell_type": "code",
  20. "execution_count": null,
  21. "metadata": {},
  22. "outputs": [],
  23. "source": [
  24. "from pyrocko.fdsn import ws\n",
  25. "from pyrocko import util, io, trace\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. "# use asterisk '*' as wildcard\n",
  33. "selection = [('X9', '*', '*', 'HHZ', tmin, tmax)] \n",
  34. "\n",
  35. "# Read access-token for the restricted network from file as 'rb' for binary\n",
  36. "token=open('token.asc', 'rb').read()\n",
  37. "\n",
  38. "# setup a waveform data request\n",
  39. "request_waveform = ws.dataselect(site='geofon', selection=selection, token=token)\n",
  40. "\n",
  41. "# Alternative method using username and password instead of token:\n",
  42. "# request_waveform = ws.dataselect(site='geofon', selection=selection, user='user', passwd='passwd')\n",
  43. "\n",
  44. "# write the incoming data stream to 'traces.mseed' as 'wb' for binary\n",
  45. "with open('traces.mseed', 'wb') as file:\n",
  46. " file.write(request_waveform.read())"
  47. ]
  48. }
  49. ],
  50. "metadata": {
  51. "kernelspec": {
  52. "display_name": "Python 3",
  53. "language": "python",
  54. "name": "python3"
  55. },
  56. "language_info": {
  57. "codemirror_mode": {
  58. "name": "ipython",
  59. "version": 3
  60. },
  61. "file_extension": ".py",
  62. "mimetype": "text/x-python",
  63. "name": "python",
  64. "nbconvert_exporter": "python",
  65. "pygments_lexer": "ipython3",
  66. "version": "3.7.3rc1"
  67. }
  68. },
  69. "nbformat": 4,
  70. "nbformat_minor": 2
  71. }