Waveform request

This will dowaload waveforms for one event and will save them in SAC format. ObsPy is required.

Import ObsPy module

In [1]:
from obspy import read
from obspy import UTCDateTime
from obspy import read, read_inventory
from obspy.clients.fdsn import Client
from obspy.io.sac.sactrace import SACTrace

import obspy as ob
print("# obspy version = ",ob.__version__)

# to make directory
import os
# obspy version =  1.2.2

Plot Option

if 1, plotting waveforms etc

In [2]:
plotOPT = 1 # plotting waveforms etc

This example uses USGS. We can use other dataceneter (e.g., NCEDC, IRIS)

In [3]:
#clientEQ = Client("IRIS")
clientEQ = Client("USGS")

Set time window (st, et) and range of magunitude (minmag, maxmag). This example will find the 2018 Mw4.4 Berkeley earthquake with obspy get_events function

In [4]:
#https://earthquake.usgs.gov/earthquakes/eventpage/nc72948801/executive
#M 4.4 - 2km SE of Berkeley, CA
#2018-01-04 10:39:37 (UTC)37.855°N 122.257°W12.3 km depth
        
st = UTCDateTime("2018-01-04T10:39:30")  # 
et = UTCDateTime("2018-01-04T10:39:40")  #
minmag = 4.3
maxmag = 4.5 
  
catalog = clientEQ.get_events(starttime=st , endtime=et,
                            minmagnitude=minmag, maxmagnitude=maxmag)

print(catalog)

if plotOPT:
    _plot = catalog.plot()
1 Event(s) in Catalog:
2018-01-04T10:39:37.730000Z | +37.855, -122.257 | 4.38 mw | manual

Set client (Data Center)

This example will use NCEDC. We can use other dataceneter (e.g., SCEDC, IRIS...)

In [5]:
server_nameOUT = "NCEDC" # data from NCEDC 
#server_nameOUT = "SCEDC" # data from SCEDC 
#server_nameOUT = "IRIS" # data from IRIS 
client = Client(server_nameOUT, timeout=600) # data from NCEDC 

Distance threshold to search for stations

This example will find all stations within 1.0 deg (~111km) from the epicenter

In [6]:
distdeg_from_eq = 1.00 # ~111km from epicenter

Time window

This example will extract data starting from -90s before the origin time and its duration is 5 minutes

In [7]:
pre_tw_sec = 90 # 90 seconds before the origin time
tw_sec = 5*60 # 5 min duration

Which components?

In many cases: HN data are strong-motion data (highest sampling at each station) & HH data are broadband data (highest sampling at each station). This example asks HN? data (strong-motion data) only

In [8]:
com_listOUT = "HN?" # strong-motion
#com_listOUT = "HH?" # broadband 
#com_listOUT = "HH?,HN?" # broadband & strong-motion

Which netowrk (network code)?

This example will use a wildcard. Some examples are BK (Berkeley Seismological Laboratory), NC (USGS-Menlo), CE (CGS), NP (National Ground Motion), PB (PBO). more info. https://www.fdsn.org/networks/

In [9]:
#net_listOUT = "BK,NC,CE,NP,PB" #
net_listOUT = "*" # wildcard (all networks availanle at data center)

Which station (station code)?

Usually this should be a wildcard as we are searching all stations with the distance threhould. but for this example, we already identify which stations are needed

In [10]:
sta_list = "1688,1722,1737,1828,1856,58340,58347,58349,58393,58406,58497,58665,C002,C006,C007,C011,C013,C021,C024,C033,C048,C064,C067,CMC,CNI,CPM,CSL,CSPB,P181,RFSB,VAK"
#sta_list = "VAK" # test
# sta_list = "*" # wildcard

Frequency passband

Which frequency band will be used when the instrument response is corrected? This example uses a 0.5-40 Hz passband

In [11]:
# f1<f2<f3<f4. effective band is between f2 and f3
f1 = 0.1 # 0.1 Hz
f2 = 0.5  # 0.5 Hz
f3 = 40 # 40 Hz
f4 = 50 # 50 Hz

Event information

This example will only read the first event in catalog

In [12]:
event = catalog[0]
origin = event.origins[0]
origin_time = origin.time
evlat = origin.latitude
evlon = origin.longitude
evdp_km = origin.depth / 1000
evmag = event.magnitudes[0].mag

evyearOUT = origin_time.year
evjdayOUT = origin_time.julday
evhourOUT = origin_time.hour
evminOUT = origin_time.minute
evsecOUT = origin_time.second

evid = event.origins[0]['extra']['dataid']['value']

Output directory

Based on event-id and filtering parameter etc. This example will make 2018.004.103937_M4.38_nc72948801_fl0.5_fh40_dist1.0deg

In [13]:
# need for output directory
evyearOUT2 = (str)(evyearOUT)
evjdayOUT2 = (str)(evjdayOUT)
if evjdayOUT < 100:
    evjdayOUT2 = "0"+(str)(evjdayOUT)
        

if evjdayOUT < 10:
    evjdayOUT2 = "00"+(str)(evjdayOUT)
    

evhourOUT2 = (str)(evhourOUT)
if evhourOUT < 10:
    evhourOUT2 = "0"+(str)(evhourOUT)
        

evminOUT2 = (str)(evminOUT)
if evminOUT < 10:
    evminOUT2 = "0"+(str)(evminOUT)


evsecOUT2 = (str)(evsecOUT)
if evsecOUT < 10:
    evsecOUT2 = "0"+(str)(evsecOUT)
        
        


#print("# evyearOUT2 = ",evyearOUT2," evjdayOUT2 = ",evjdayOUT2," evhourOUT2 = ",evhourOUT2," evminOUT2 = ",evminOUT2," evsecOUT2 = ",evsecOUT2)
    
evmseedid = evyearOUT2+"."+evjdayOUT2+"."+evhourOUT2+""+evminOUT2+""+evsecOUT2
#print("# evmseedid = "+evmseedid)

mseedid = evyearOUT2+"."+evjdayOUT2+"."+evhourOUT2+""+evminOUT2+""+evsecOUT2

# name for output directory
pwd_dir = os.getcwd() 
#sacdir= pwd_dir +"/"+ evmseedid +"_M"+(str)(evmag)+"_"+(str)(eventid_ncedc)+"_fl"+(str)(f2)+"_fh"+str(f3)+"_dist"+(str)(distkm_from_eq)+"km"
sacdir= pwd_dir +"/"+ evmseedid +"_M"+(str)(evmag)+"_"+(str)(evid)+"_fl"+(str)(f2)+"_fh"+str(f3)+"_dist"+(str)(distdeg_from_eq)+"deg"
print("# sacdir = ",sacdir)

# create output directory
if not os.path.exists(sacdir):
    os.makedirs(sacdir)
# sacdir =  /Users/taira/work/python_work/2018.004.103937_M4.38_nc72948801_fl0.5_fh40_dist1.0deg

Extracting inventory (instrument response) and channel list based on search parameters

In [14]:
latitude = evlat
longitude = evlon
minradius = 0
maxradius = distdeg_from_eq
starttime = UTCDateTime(origin_time-pre_tw_sec)
endtime = UTCDateTime(origin_time+tw_sec)


invOUT = client.get_stations(network=net_listOUT, station=sta_list, channel=com_listOUT, 
                                starttime=starttime, endtime=endtime,
                                latitude=latitude, longitude=longitude,
                                minradius=minradius, maxradius=maxradius,
                                level="response")

channelOUT = client.get_stations(network=net_listOUT, station=sta_list, channel=com_listOUT, 
                                starttime=starttime, endtime=endtime,
                                latitude=latitude, longitude=longitude,
                                minradius=minradius, maxradius=maxradius,
                                level="channel")
In [15]:
# get station list
ch_listOUT = ""
j2=0
sncl_list = []
for i in range(len(channelOUT)):        
    netOUT = channelOUT[i].code
    #print (inv_ncedc[i].code)
    for ii in range(len(channelOUT[i])):
        #print(ii)
        #print(inv[i][ii].code)    
        staOUT = channelOUT[i][ii].code
        for iii in range(len(channelOUT[i][ii])):
            chaOUT = channelOUT[i][ii][iii].code 
            locOUT = channelOUT[i][ii][iii].location_code
            snclOUT = netOUT+"."+staOUT+"."+locOUT+"."+chaOUT
            #print("# j2 = ",j2," snclOUT = ",snclOUT)
            sncl_list.append(snclOUT)
            j2+=1
            
            

sta_listOUT = ""
j=0
for i in range(len(invOUT)):
    #print (inv_ncedc[i].code)
    for ii in range(len(invOUT[i])):
        #print(ii)
        #print(inv[i][ii].code)
        if j==0:
                sta_listOUT = invOUT[i][ii].code
        else:
                sta_listOUT = sta_listOUT+","+invOUT[i][ii].code
        j+=1
    


print("# sta_listOUT = ",sta_listOUT)
# sta_listOUT =  RFSB,VAK,58340,58347,58349,58393,58406,58497,58665,C002,C006,C007,C011,C013,C021,C024,C033,C048,C064,C067,CMC,CNI,CPM,CSL,CSPB,1688,1722,1737,1828,1856

Extracting waveforms based on station list

In [16]:
# get seismic waveforms nased on station & network lists
stOUT = client.get_waveforms(network=net_listOUT, station=sta_listOUT, channel=com_listOUT, location="*",
                                starttime=starttime, endtime=endtime)

stOUT2 = stOUT.copy()
#st2 = stOUT2.select(network="NC")

# check if data are gappy. short segment (less than 1-sec-long) will be removed. 
for trace in stOUT2:
    nptsOUT = trace.stats.npts
    deltaOUT = trace.stats.delta
    sampHZOUT = 1.0/deltaOUT
    #print("sampHZOUT = ", sampHZOUT, "nptsOUT = ", nptsOUT)    
    if nptsOUT < sampHZOUT:
        stOUT2.remove(trace)

print(stOUT2.__str__(extended=True))
 
90 Trace(s) in Stream:
NP.1688..HNE   | 2018-01-04T10:39:05.170000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 44966 samples
NP.1688..HNN   | 2018-01-04T10:39:05.170000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 44966 samples
NP.1688..HNZ   | 2018-01-04T10:39:05.170000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 44966 samples
NP.1722..HNE   | 2018-01-04T10:39:01.205000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43759 samples
NP.1722..HNN   | 2018-01-04T10:39:01.205000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43759 samples
NP.1722..HNZ   | 2018-01-04T10:39:01.205000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43759 samples
NP.1737..HNE   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.725000Z | 200.0 Hz, 78000 samples
NP.1737..HNN   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.725000Z | 200.0 Hz, 78000 samples
NP.1737..HNZ   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.725000Z | 200.0 Hz, 78000 samples
NP.1828..HNE   | 2018-01-04T10:38:59.805000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44039 samples
NP.1828..HNN   | 2018-01-04T10:38:59.805000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44039 samples
NP.1828..HNZ   | 2018-01-04T10:38:59.805000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44039 samples
NP.1856..HNE   | 2018-01-04T10:39:00.060000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43988 samples
NP.1856..HNN   | 2018-01-04T10:39:00.060000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43988 samples
NP.1856..HNZ   | 2018-01-04T10:39:00.060000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43988 samples
CE.58340..HNE  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58340..HNN  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58340..HNZ  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58347..HNE  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13200 samples
CE.58347..HNN  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13200 samples
CE.58347..HNZ  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13200 samples
CE.58349..HNE  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13400 samples
CE.58349..HNN  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13400 samples
CE.58349..HNZ  | 2018-01-04T10:39:16.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13400 samples
CE.58393..HNE  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58393..HNN  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58393..HNZ  | 2018-01-04T10:39:17.000000Z - 2018-01-04T10:40:21.995000Z | 200.0 Hz, 13000 samples
CE.58406..HNE  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58406..HNN  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58406..HNZ  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58497..HNE  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58497..HNN  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58497..HNZ  | 2018-01-04T10:39:18.000000Z - 2018-01-04T10:40:22.995000Z | 200.0 Hz, 13000 samples
CE.58665..HNE  | 2018-01-04T10:39:21.000000Z - 2018-01-04T10:40:25.995000Z | 200.0 Hz, 13000 samples
CE.58665..HNN  | 2018-01-04T10:39:21.000000Z - 2018-01-04T10:40:25.995000Z | 200.0 Hz, 13000 samples
CE.58665..HNZ  | 2018-01-04T10:39:21.000000Z - 2018-01-04T10:40:25.995000Z | 200.0 Hz, 13000 samples
NC.C002.01.HNE | 2018-01-04T10:39:04.375000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45325 samples
NC.C002.01.HNN | 2018-01-04T10:39:04.375000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45325 samples
NC.C002.01.HNZ | 2018-01-04T10:39:04.375000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 45125 samples
NC.C006.01.HNE | 2018-01-04T10:39:03.705000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 45259 samples
NC.C006.01.HNN | 2018-01-04T10:39:03.705000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45459 samples
NC.C006.01.HNZ | 2018-01-04T10:39:03.705000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45459 samples
NC.C007.01.HNE | 2018-01-04T10:39:00.000000Z - 2018-01-04T10:40:40.995000Z | 200.0 Hz, 20200 samples
NC.C007.01.HNN | 2018-01-04T10:39:00.000000Z - 2018-01-04T10:40:40.995000Z | 200.0 Hz, 20200 samples
NC.C007.01.HNZ | 2018-01-04T10:39:00.000000Z - 2018-01-04T10:40:40.995000Z | 200.0 Hz, 20200 samples
NC.C011.01.HNE | 2018-01-04T10:39:00.075000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43985 samples
NC.C011.01.HNN | 2018-01-04T10:39:00.075000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43985 samples
NC.C011.01.HNZ | 2018-01-04T10:39:00.075000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43985 samples
NC.C013.01.HNE | 2018-01-04T10:39:00.040000Z - 2018-01-04T10:42:40.995000Z | 200.0 Hz, 44192 samples
NC.C013.01.HNN | 2018-01-04T10:39:00.040000Z - 2018-01-04T10:42:40.995000Z | 200.0 Hz, 44192 samples
NC.C013.01.HNZ | 2018-01-04T10:39:00.040000Z - 2018-01-04T10:42:40.995000Z | 200.0 Hz, 44192 samples
NC.C021.01.HNE | 2018-01-04T10:39:02.215000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45757 samples
NC.C021.01.HNN | 2018-01-04T10:39:02.215000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45757 samples
NC.C021.01.HNZ | 2018-01-04T10:39:02.215000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 45557 samples
NC.C024.01.HNE | 2018-01-04T10:39:00.620000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43876 samples
NC.C024.01.HNN | 2018-01-04T10:39:00.620000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43876 samples
NC.C024.01.HNZ | 2018-01-04T10:39:00.620000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43876 samples
NC.C033.01.HNE | 2018-01-04T10:38:59.925000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44015 samples
NC.C033.01.HNN | 2018-01-04T10:38:59.925000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44015 samples
NC.C033.01.HNZ | 2018-01-04T10:38:59.925000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 44015 samples
NC.C048.01.HNE | 2018-01-04T10:39:04.435000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45313 samples
NC.C048.01.HNN | 2018-01-04T10:39:04.435000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45313 samples
NC.C048.01.HNZ | 2018-01-04T10:39:04.435000Z - 2018-01-04T10:42:50.995000Z | 200.0 Hz, 45313 samples
NC.C064.01.HNE | 2018-01-04T10:39:00.180000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43964 samples
NC.C064.01.HNN | 2018-01-04T10:39:00.180000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43964 samples
NC.C064.01.HNZ | 2018-01-04T10:39:00.180000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43964 samples
NC.C067.01.HNE | 2018-01-04T10:39:00.755000Z - 2018-01-04T10:42:39.995000Z | 200.0 Hz, 43849 samples
NC.C067.01.HNN | 2018-01-04T10:39:00.755000Z - 2018-01-04T10:42:41.995000Z | 200.0 Hz, 44249 samples
NC.C067.01.HNZ | 2018-01-04T10:39:00.755000Z - 2018-01-04T10:42:41.995000Z | 200.0 Hz, 44249 samples
NC.CMC.02.HNE  | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CMC.02.HNN  | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CMC.02.HNZ  | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CNI..HNE    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CNI..HNN    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CNI..HNZ    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CPM..HNE    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CPM..HNN    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CPM..HNZ    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSL..HNE    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSL..HNN    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSL..HNZ    | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSPB..HNE   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSPB..HNN   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
NC.CSPB..HNZ   | 2018-01-04T10:38:07.730000Z - 2018-01-04T10:44:37.720000Z | 100.0 Hz, 39000 samples
BK.RFSB.00.HNE | 2018-01-04T10:38:07.738393Z - 2018-01-04T10:44:37.728393Z | 100.0 Hz, 39000 samples
BK.RFSB.00.HNN | 2018-01-04T10:38:07.738393Z - 2018-01-04T10:44:37.728393Z | 100.0 Hz, 39000 samples
BK.RFSB.00.HNZ | 2018-01-04T10:38:07.738393Z - 2018-01-04T10:44:37.728393Z | 100.0 Hz, 39000 samples
BK.VAK.00.HNE  | 2018-01-04T10:38:07.738391Z - 2018-01-04T10:44:37.728391Z | 100.0 Hz, 39000 samples
BK.VAK.00.HNN  | 2018-01-04T10:38:07.738391Z - 2018-01-04T10:44:37.728391Z | 100.0 Hz, 39000 samples
BK.VAK.00.HNZ  | 2018-01-04T10:38:07.738391Z - 2018-01-04T10:44:37.728391Z | 100.0 Hz, 39000 samples

Correcting instrument response

This example will provide ground acceleration (m/s). If velocity data (m/s) is needed -> "ACC", if displacement data (m) is needed -> "DISP"

In [17]:
# remove instrument response
#output_unut = "VEL" # m/s
output_unit = "ACC" # m/s*2
#output_unit = "DISP" # m

stOUT2.remove_response(inventory=invOUT, pre_filt=(f1, f2, f3, f4), output=output_unit)
Out[17]:
90 Trace(s) in Stream:

NP.1688..HNE | 2018-01-04T10:39:05.170000Z - 2018-01-04T10:42:49.995000Z | 200.0 Hz, 44966 samples
...
(88 other traces)
...
BK.VAK.00.HNZ | 2018-01-04T10:38:07.738391Z - 2018-01-04T10:44:37.728391Z | 100.0 Hz, 39000 samples

[Use "print(Stream.__str__(extended=True))" to print all Traces]

Plot one waveform

In [18]:
if plotOPT:
    #_plot = stOUT2.plot()
    _plot = stOUT2[0].plot()

Save waveforms in SAC format

In [19]:
#st2 = stOUT2.select(network="NC",station="N*", location="10")
#print(st2.__str__(extended=True))

#print("# remove_response server_nameOUT = ",server_nameOUT)
#st2.remove_response(inventory=invOUT, 
#                   pre_filt=(f1, f2, f3, f4),
#                   output="VEL")



# save waveforms in SAC format
for i in range(len(stOUT2)):
    #print (st_ncedc2[i])
    sac = SACTrace.from_obspy_trace(stOUT2[i])
    sac.lcalda = True
    
    netOUT = stOUT2[i].stats.network
    comOUT = stOUT2[i].stats.channel
    staOUT = stOUT2[i].stats.station
    locOUT = stOUT2[i].stats.location

    # st_starttime is different from each sacfile, but mseedid is used origin_time - pre_tw_sec
    #st_starttime = st_ncedc2[i].stats.starttime
    #print("# st_starttime = ",st_starttime)
        
    
    stid = netOUT+"."+staOUT+"."+locOUT+"."+comOUT
    print("# staOUT = ",staOUT," netOUT = ",netOUT," comOUT = ",comOUT," locOUT = ",locOUT," stid = ",stid)
    #print("# stid = "+stid)
    sta_coordinate = invOUT.get_coordinates(stid, starttime)
    sac.stla = sta_coordinate['latitude']
    sac.stlo = sta_coordinate['longitude']
    sac.stel = sta_coordinate['elevation']
    sac.evla = evlat
    sac.evlo = evlon
    sac.evdp = evdp_km
     
    sac.kuser0 = "ncss"
    sac.kevnm = (str)(evid)
    sac.mag = evmag
    
    outsacfi = sacdir +"/" + staOUT+"."+netOUT+"."+comOUT+"."+locOUT+".D."+mseedid+"."+(str)(evid)+".sac"
    #print("# outsacfi = "+outsacfi)
    #st_ncedc[i].write(outsacfi, format="SAC")  
    sac.write(outsacfi)  
# staOUT =  1688  netOUT =  NP  comOUT =  HNE  locOUT =    stid =  NP.1688..HNE
# staOUT =  1688  netOUT =  NP  comOUT =  HNN  locOUT =    stid =  NP.1688..HNN
# staOUT =  1688  netOUT =  NP  comOUT =  HNZ  locOUT =    stid =  NP.1688..HNZ
# staOUT =  1722  netOUT =  NP  comOUT =  HNE  locOUT =    stid =  NP.1722..HNE
# staOUT =  1722  netOUT =  NP  comOUT =  HNN  locOUT =    stid =  NP.1722..HNN
# staOUT =  1722  netOUT =  NP  comOUT =  HNZ  locOUT =    stid =  NP.1722..HNZ
# staOUT =  1737  netOUT =  NP  comOUT =  HNE  locOUT =    stid =  NP.1737..HNE
# staOUT =  1737  netOUT =  NP  comOUT =  HNN  locOUT =    stid =  NP.1737..HNN
# staOUT =  1737  netOUT =  NP  comOUT =  HNZ  locOUT =    stid =  NP.1737..HNZ
# staOUT =  1828  netOUT =  NP  comOUT =  HNE  locOUT =    stid =  NP.1828..HNE
# staOUT =  1828  netOUT =  NP  comOUT =  HNN  locOUT =    stid =  NP.1828..HNN
# staOUT =  1828  netOUT =  NP  comOUT =  HNZ  locOUT =    stid =  NP.1828..HNZ
# staOUT =  1856  netOUT =  NP  comOUT =  HNE  locOUT =    stid =  NP.1856..HNE
# staOUT =  1856  netOUT =  NP  comOUT =  HNN  locOUT =    stid =  NP.1856..HNN
# staOUT =  1856  netOUT =  NP  comOUT =  HNZ  locOUT =    stid =  NP.1856..HNZ
# staOUT =  58340  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58340..HNE
# staOUT =  58340  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58340..HNN
# staOUT =  58340  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58340..HNZ
# staOUT =  58347  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58347..HNE
# staOUT =  58347  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58347..HNN
# staOUT =  58347  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58347..HNZ
# staOUT =  58349  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58349..HNE
# staOUT =  58349  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58349..HNN
# staOUT =  58349  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58349..HNZ
# staOUT =  58393  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58393..HNE
# staOUT =  58393  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58393..HNN
# staOUT =  58393  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58393..HNZ
# staOUT =  58406  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58406..HNE
# staOUT =  58406  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58406..HNN
# staOUT =  58406  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58406..HNZ
# staOUT =  58497  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58497..HNE
# staOUT =  58497  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58497..HNN
# staOUT =  58497  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58497..HNZ
# staOUT =  58665  netOUT =  CE  comOUT =  HNE  locOUT =    stid =  CE.58665..HNE
# staOUT =  58665  netOUT =  CE  comOUT =  HNN  locOUT =    stid =  CE.58665..HNN
# staOUT =  58665  netOUT =  CE  comOUT =  HNZ  locOUT =    stid =  CE.58665..HNZ
# staOUT =  C002  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C002.01.HNE
# staOUT =  C002  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C002.01.HNN
# staOUT =  C002  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C002.01.HNZ
# staOUT =  C006  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C006.01.HNE
# staOUT =  C006  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C006.01.HNN
# staOUT =  C006  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C006.01.HNZ
# staOUT =  C007  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C007.01.HNE
# staOUT =  C007  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C007.01.HNN
# staOUT =  C007  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C007.01.HNZ
# staOUT =  C011  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C011.01.HNE
# staOUT =  C011  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C011.01.HNN
# staOUT =  C011  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C011.01.HNZ
# staOUT =  C013  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C013.01.HNE
# staOUT =  C013  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C013.01.HNN
# staOUT =  C013  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C013.01.HNZ
# staOUT =  C021  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C021.01.HNE
# staOUT =  C021  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C021.01.HNN
# staOUT =  C021  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C021.01.HNZ
# staOUT =  C024  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C024.01.HNE
# staOUT =  C024  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C024.01.HNN
# staOUT =  C024  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C024.01.HNZ
# staOUT =  C033  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C033.01.HNE
# staOUT =  C033  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C033.01.HNN
# staOUT =  C033  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C033.01.HNZ
# staOUT =  C048  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C048.01.HNE
# staOUT =  C048  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C048.01.HNN
# staOUT =  C048  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C048.01.HNZ
# staOUT =  C064  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C064.01.HNE
# staOUT =  C064  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C064.01.HNN
# staOUT =  C064  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C064.01.HNZ
# staOUT =  C067  netOUT =  NC  comOUT =  HNE  locOUT =  01  stid =  NC.C067.01.HNE
# staOUT =  C067  netOUT =  NC  comOUT =  HNN  locOUT =  01  stid =  NC.C067.01.HNN
# staOUT =  C067  netOUT =  NC  comOUT =  HNZ  locOUT =  01  stid =  NC.C067.01.HNZ
# staOUT =  CMC  netOUT =  NC  comOUT =  HNE  locOUT =  02  stid =  NC.CMC.02.HNE
# staOUT =  CMC  netOUT =  NC  comOUT =  HNN  locOUT =  02  stid =  NC.CMC.02.HNN
# staOUT =  CMC  netOUT =  NC  comOUT =  HNZ  locOUT =  02  stid =  NC.CMC.02.HNZ
# staOUT =  CNI  netOUT =  NC  comOUT =  HNE  locOUT =    stid =  NC.CNI..HNE
# staOUT =  CNI  netOUT =  NC  comOUT =  HNN  locOUT =    stid =  NC.CNI..HNN
# staOUT =  CNI  netOUT =  NC  comOUT =  HNZ  locOUT =    stid =  NC.CNI..HNZ
# staOUT =  CPM  netOUT =  NC  comOUT =  HNE  locOUT =    stid =  NC.CPM..HNE
# staOUT =  CPM  netOUT =  NC  comOUT =  HNN  locOUT =    stid =  NC.CPM..HNN
# staOUT =  CPM  netOUT =  NC  comOUT =  HNZ  locOUT =    stid =  NC.CPM..HNZ
# staOUT =  CSL  netOUT =  NC  comOUT =  HNE  locOUT =    stid =  NC.CSL..HNE
# staOUT =  CSL  netOUT =  NC  comOUT =  HNN  locOUT =    stid =  NC.CSL..HNN
# staOUT =  CSL  netOUT =  NC  comOUT =  HNZ  locOUT =    stid =  NC.CSL..HNZ
# staOUT =  CSPB  netOUT =  NC  comOUT =  HNE  locOUT =    stid =  NC.CSPB..HNE
# staOUT =  CSPB  netOUT =  NC  comOUT =  HNN  locOUT =    stid =  NC.CSPB..HNN
# staOUT =  CSPB  netOUT =  NC  comOUT =  HNZ  locOUT =    stid =  NC.CSPB..HNZ
# staOUT =  RFSB  netOUT =  BK  comOUT =  HNE  locOUT =  00  stid =  BK.RFSB.00.HNE
# staOUT =  RFSB  netOUT =  BK  comOUT =  HNN  locOUT =  00  stid =  BK.RFSB.00.HNN
# staOUT =  RFSB  netOUT =  BK  comOUT =  HNZ  locOUT =  00  stid =  BK.RFSB.00.HNZ
# staOUT =  VAK  netOUT =  BK  comOUT =  HNE  locOUT =  00  stid =  BK.VAK.00.HNE
# staOUT =  VAK  netOUT =  BK  comOUT =  HNN  locOUT =  00  stid =  BK.VAK.00.HNN
# staOUT =  VAK  netOUT =  BK  comOUT =  HNZ  locOUT =  00  stid =  BK.VAK.00.HNZ
In [ ]:
 
In [ ]: