根据obspy Catalog申请连续波形数据

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from datetime import timedelta
  5.  
  6. from obspy.clients.fdsn import Client as fdsnClient
  7. from obspy import UTCDateTime
  8. from HinetPy import Client, win32
  9.  
  10.  
  11. fdsnclient = fdsnClient('IRIS')
  12. starttime = UTCDateTime("2005-01-01")
  13. endtime = UTCDateTime("2005-01-03")
  14. catalog = fdsnclient.get_events(starttime=starttime, endtime=endtime,
  15. minmagnitude=6, catalog="ISC")
  16.  
  17. client = Client("username", "password")
  18. for event in catalog: # loop over events
  19. origin = event.origins[0].time.datetime
  20. starttime = origin + timedelta(hours=9) # deal with TimeZone issue
  21. outdir = origin.strftime("%Y%m%d%H%M")
  22.  
  23. # skip if outdir already exists to avoid overwrite
  24. if os.path.exits(ourdir):
  25. continue
  26.  
  27. data, ctable = client.get_continuous_waveform('0101', starttime, 20, outdir=outdir)
  28. win32.extract_sac(data, ctable, outdir=outdir, with_pz=True)