예제 #1
0
def grab_data(scnl, T1, T2, hostname, port, fill_value=0):
	# scnl = list of station names (eg. ['PS4A.EHZ.AV.--','PVV.EHZ.AV.--','PS1A.EHZ.AV.--'])
	# T1 and T2 are start/end obspy UTCDateTimes
	# fill_value can be 0 (default), 'latest', or 'interpolate'
	#
	# returns stream of traces with gaps accounted for
	#
	# print('{} - {}'.format(T1.strftime('%Y.%m.%d %H:%M:%S'),T2.strftime('%Y.%m.%d %H:%M:%S')))
	print('Grabbing data...')

	st=Stream()
	client = Client(hostname, int(port))

	for sta in scnl:
		
		try:
			tr=client.get_waveforms(sta.split('.')[2], sta.split('.')[0],sta.split('.')[3],sta.split('.')[1],
									T1, T2, cleanup=True)
			if len(tr)>1:
				if fill_value==0 or fill_value==None:
					tr.detrend('demean')
					tr.taper(max_percentage=0.01)
				for sub_trace in tr:
					# deal with error when sub-traces have different dtypes
					if sub_trace.data.dtype.name != 'int32':
						sub_trace.data=sub_trace.data.astype('int32')
					if sub_trace.data.dtype!=np.dtype('int32'):
						sub_trace.data=sub_trace.data.astype('int32')
					# deal with rare error when sub-traces have different sample rates
					if sub_trace.stats.sampling_rate!=np.round(sub_trace.stats.sampling_rate):
						sub_trace.stats.sampling_rate=np.round(sub_trace.stats.sampling_rate)
				print('Merging gappy data...')
				tr.merge(fill_value=fill_value)

			# deal where trace length is smaller than expected window length
			if tr[0].stats.endtime - tr[0].stats.starttime < T2 - T1:
				tr.detrend('demean')
				tr.taper(max_percentage=0.01)
		except:
			tr=Stream()
		# if no data, create a blank trace for that channel
		if not tr:
			from obspy import Trace
			from numpy import zeros
			tr=Trace()
			tr.stats['station']=sta.split('.')[0]
			tr.stats['channel']=sta.split('.')[1]
			tr.stats['network']=sta.split('.')[2]
			tr.stats['location']=sta.split('.')[3]
			tr.stats['sampling_rate']=100
			tr.stats['starttime']=T1
			tr.data=zeros(int((T2-T1)*tr.stats['sampling_rate']),dtype='int32')
		st+=tr
	st.trim(T1,T2,pad=True, fill_value=0)
	print('Detrending data...')
	st.detrend('demean')
	return st
예제 #2
0
def get_fdsn_station_day(network,
                         station,
                         channel,
                         time_step=1,
                         nperseg=2560,
                         nfft=2560):

    time_now = UTCDateTime.now()
    time_then = time_now - datetime.timedelta(hours=time_step)

    #client = Client("IRIS")
    client = Client("130.118.86.189", 16022)

    compE = client.get_waveforms(network, station, "--", chn + 'E', time_then,
                                 time_now)[0]
    compN = client.get_waveforms(network, station, "--", chn + 'N', time_then,
                                 time_now)[0]
    compZ = client.get_waveforms(network, station, "--", chn + 'Z', time_then,
                                 time_now)[0]

    Fs = 1 / compE.stats.delta
    array_length = np.min([len(compE.data),
                           len(compN.data),
                           len(compZ.data)]) - 1

    f, t, specE = signal.spectrogram(compE.data[0:array_length],
                                     Fs,
                                     nperseg=nperseg,
                                     nfft=nfft)
    f, t, specN = signal.spectrogram(compN.data[0:array_length],
                                     Fs,
                                     nperseg=nperseg,
                                     nfft=nfft)
    f, t, specZ = signal.spectrogram(compZ.data[0:array_length],
                                     Fs,
                                     nperseg=nperseg,
                                     nfft=nfft)

    t = int(time_then.strftime('%s')) + t
    HVSR = np.log10(((specE * specN)**.5) / specZ)

    return t, f, HVSR
예제 #3
0
def grab_data(server, port, scnl, T1, T2, fill_value=0):
    '''GRAB_DATA Wrapper for ObsPy client.get_waveform()
    
    USAGE
    ------------
    >>> grab_data( server, port, scnl, T1, T2, fill_value=0 )
    >>> grab_data ( 'observatory.org', 16022, 'SEIS.EHZ.US.--',
    ...     UTCDateTime(...), UTCDateTime(...), fill_value=0 )
      
    '''

    from obspy import Stream
    from obspy.clients.earthworm import Client

    st = Stream()
    client = Client(server, port)
    for sta in scnl:
        station = sta.split('.')[0]
        channel = sta.split('.')[1]
        network = sta.split('.')[2]
        location = sta.split('.')[3]
        print(station, channel, network, location, T1, T2)
        try:
            tr = client.get_waveforms(network, station, location, channel, T1,
                                      T2)
            if len(tr) == 0:
                tr = create_trace(sta, T1, T2)
            else:
                if len(tr) > 1:
                    if fill_value == 0 or fill_value == None:
                        tr.detrend('demean')
                        tr.taper(max_percentage=0.01)
                    tr.merge(fill_value=fill_value)
                tr.trim(T1, T2, pad=0)
                tr.detrend('demean')
        except Exception as err:
            print(err)
            print("No data found for " + sta)
            tr = create_trace(sta, T1, T2)
        st += tr
    print(st)
    return st
예제 #4
0
def isrpGetWsData(StzPrms, Ti, Te):
    # ti_str = "20180225_11:00:00"
    # tf_str = "20180225_12:00:00"

    ti = UTCDateTime(Ti)
    tf = UTCDateTime(Te)

    client = Client(StzPrms['WssClient'][0], StzPrms['WssPort'][0], timeout=20)

    Wfrm = Stream()
    for i in range(0, StzPrms['WssChannel'][0]):
        response = client.get_availability(StzPrms['WssNetwork'][0],
                                           StzPrms['StationName'][0],
                                           StzPrms['WssLocation'][0],
                                           'CH' + str(i + 1))
        print(response)
        out = client.get_waveforms(StzPrms['WssNetwork'][0],
                                   StzPrms['StationName'][0],
                                   StzPrms['WssLocation'][0],
                                   'CH' + str(i + 1), ti, tf)
        Wfrm += out

    return Wfrm
예제 #5
0
def init_client(server: str, port: int, from_iris: bool = False, **kwargs):
    """
    Initialize an earthworm client on the given server and port
    :param server: IP address for the machine running earthworm wave server
    :type server: int
    :param port: Port for the earthworm wave server
    :type port: int
    :param **kwargs: Additional kwargs passed to obspy's Client call
    :return: Obspy Client object
    :rtype: Client
    """
    if from_iris:
        client = IRIS_Client('IRIS')
    else:
        client = Client(server, port, **kwargs)
    return client
예제 #6
0
def get_waveforms(client: Client, seed_id: str, starttime: UTCDateTime,
                  endtime: UTCDateTime) -> Stream:
    """
    Retrieve waveforms from earthworm wave server specified by client.
    :param client: Instance of Obspy's Client
    :type client: Client
    :param seed_id: Station name formatted to follow SEED format
    :type seed_id: str
    :param starttime: Start time for data request
    :type starttime: UTCDateTime
    :param endtime: End time for data request
    :type endtime: UTCDateTime
    :return: Obspy stream containing the waveform(s)
    :rtype: Stream
    """
    net, sta, loc, chan = seed_id.split('.')
    st = client.get_waveforms(net, sta, loc, chan, starttime, endtime)
    return st
예제 #7
0
def get_all_Fuego_inf_stations(timestamp):

    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream
    import numpy as np

    station_activity = np.zeros(shape=(0, 3))

    num = 0

    t1 = UTCDateTime(timestamp)  #the format is year:day_of_the_year:month
    t2 = t1 + 24 * 60 * 60 + 1200
    #%%
    sta = 'VF01'  # STATION VF01
    cha = 'HDF'  # CHANNEL - inf
    net = 'XZ'  # Fuego volcano
    loc = ''  # location

    client = Client('138.253.112.23', 16022)

    t1_2s = UTCDateTime(1526774400)
    t2_2s = t1_2s + 2

    st_blank = Stream()
    st_blank = client.get_waveforms(net, sta, loc, cha, t1_2s, t2_2s)
    st_blank.detrend(type='linear')
    st_blank.detrend(type='demean')
    st_blank.filter(type='bandpass', freqmin=0.5, freqmax=5)

    #%% VF01
    try:
        ID = 1
        sta = 'VF01'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st1.detrend(type='linear')
        st1.detrend(type='demean')

        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st1[0].stats.sampling_rate

        if sum(abs(st1[0].data)) > 10 and st1[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st1[0].stats.starttime
            station_activity[num][2] = st1[0].stats.endtime
            num += 1

        else:
            st1 = st_blank

    except:
        st1 = st_blank

#%% VF02
    try:
        ID = 2
        sta = 'VF02'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st2 = Stream()
        st2 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st2.detrend(type='linear')
        st2.detrend(type='demean')

        break_test = st2
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st2[0].stats.sampling_rate

        if sum(abs(st2[0].data)) > 10 and st2[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st2[0].stats.starttime
            station_activity[num][2] = st2[0].stats.endtime
            num += 1

        else:
            st2 = st_blank

    except:
        st2 = st_blank

#%% VF03
    try:
        ID = 3
        sta = 'VF03'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st3 = Stream()
        st3 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st3.detrend(type='linear')
        st3.detrend(type='demean')

        break_test = st3
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st3[0].stats.sampling_rate

        if sum(abs(st3[0].data)) > 10 and st3[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st3[0].stats.starttime
            station_activity[num][2] = st3[0].stats.endtime
            num += 1

        else:
            st3 = st_blank

    except:
        st3 = st_blank

#%% VF04
    try:
        ID = 4
        sta = 'VF04'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st4 = Stream()
        st4 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st4.detrend(type='linear')
        st4.detrend(type='demean')

        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st4[0].stats.sampling_rate

        if sum(abs(st4[0].data)) > 10 and st4[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st4[0].stats.starttime
            station_activity[num][2] = st4[0].stats.endtime
            num += 1

        else:
            st4 = st_blank

    except:
        st4 = st_blank

#%% VF05
    try:
        ID = 5
        sta = 'VF05'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st5 = Stream()
        st5 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st5.detrend(type='linear')
        st5.detrend(type='demean')

        break_test = st5
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st5[0].stats.sampling_rate

        if sum(abs(st5[0].data)) > 10 and st5[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st5[0].stats.starttime
            station_activity[num][2] = st5[0].stats.endtime
            num += 1

        else:
            st5 = st_blank

    except:
        st5 = st_blank

#%% VF06
    try:
        ID = 6
        sta = 'VF06'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'XZ'  # Fuego volcano
        loc = ''  # location,

        st6 = Stream()
        st6 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st6.detrend(type='linear')
        st6.detrend(type='demean')

        break_test = st6
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st6[0].stats.sampling_rate

        if sum(abs(st6[0].data)) > 10 and st6[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st6[0].stats.starttime
            station_activity[num][2] = st6[0].stats.endtime
            num += 1

        else:
            st6 = st_blank

    except:
        st6 = st_blank

#%% FG8

    try:
        ID = 7
        sta = 'FG8'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st7 = Stream()
        st7 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st7.detrend(type='linear')
        st7.detrend(type='demean')

        break_test = st7
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st7[0].stats.sampling_rate

        if sum(abs(st7[0].data)) > 10 and st7[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st7[0].stats.starttime
            station_activity[num][2] = st7[0].stats.endtime
            num += 1

        else:
            st7 = st_blank

    except:
        st7 = st_blank

    try:
        ID = 8
        sta = 'FG8'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st8 = Stream()
        st8 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st8.detrend(type='linear')
        st8.detrend(type='demean')

        break_test = st8
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st8[0].stats.sampling_rate

        if sum(abs(st8[0].data)) > 10 and st8[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st8[0].stats.starttime
            station_activity[num][2] = st8[0].stats.endtime
            num += 1

        else:
            st8 = st_blank

    except:
        st8 = st_blank

    try:
        ID = 9
        sta = 'FG8'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '03'  # location,

        st9 = Stream()
        st9 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st9.detrend(type='linear')
        st9.detrend(type='demean')

        break_test = st9
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st9[0].stats.sampling_rate

        if sum(abs(st9[0].data)) > 10 and st9[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st9[0].stats.starttime
            station_activity[num][2] = st9[0].stats.endtime
            num += 1

        else:
            st9 = st_blank

    except:
        st9 = st_blank

#%% FG10

    try:
        ID = 10
        sta = 'FG10'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st10 = Stream()
        st10 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st10.detrend(type='linear')
        st10.detrend(type='demean')

        break_test = st10
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st10[0].stats.sampling_rate

        if sum(abs(st10[0].data)) > 10 and st10[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st10[0].stats.starttime
            station_activity[num][2] = st10[0].stats.endtime
            num += 1

        else:
            st10 = st_blank

    except:
        st10 = st_blank

    try:
        ID = 11
        sta = 'FG10'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st11 = Stream()
        st11 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st11.detrend(type='linear')
        st11.detrend(type='demean')

        break_test = st11
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st11[0].stats.sampling_rate

        if sum(abs(st11[0].data)) > 10 and st11[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st11[0].stats.starttime
            station_activity[num][2] = st11[0].stats.endtime
            num += 1

        else:
            st11 = st_blank

    except:
        st11 = st_blank

    try:
        ID = 12
        sta = 'FG10'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '03'  # location,

        st12 = Stream()
        st12 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st12.detrend(type='linear')
        st12.detrend(type='demean')

        break_test = st12
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st12[0].stats.sampling_rate

        if sum(abs(st12[0].data)) > 10 and st12[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st12[0].stats.starttime
            station_activity[num][2] = st12[0].stats.endtime
            num += 1

        else:
            st12 = st_blank

    except:
        st12 = st_blank

#%% FG11

    try:
        ID = 13
        sta = 'FG11'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st13 = Stream()
        st13 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st13.detrend(type='linear')
        st13.detrend(type='demean')

        break_test = st13
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st13[0].stats.sampling_rate

        if sum(abs(st13[0].data)) > 10 and st13[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st13[0].stats.starttime
            station_activity[num][2] = st13[0].stats.endtime
            num += 1

        else:
            st13 = st_blank

    except:
        st13 = st_blank

    try:
        ID = 14
        sta = 'FG11'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st14 = Stream()
        st14 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st14.detrend(type='linear')
        st14.detrend(type='demean')

        break_test = st14
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st14[0].stats.sampling_rate

        if sum(abs(st14[0].data)) > 10 and st14[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st14[0].stats.starttime
            station_activity[num][2] = st14[0].stats.endtime
            num += 1

        else:
            st14 = st_blank

    except:
        st14 = st_blank

    try:
        ID = 15
        sta = 'FG11'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '04'  # location,

        st15 = Stream()
        st15 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st15.detrend(type='linear')
        st15.detrend(type='demean')

        break_test = st15
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st15[0].stats.sampling_rate

        if sum(abs(st15[0].data)) > 10 and st15[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st15[0].stats.starttime
            station_activity[num][2] = st15[0].stats.endtime
            num += 1

        else:
            st15 = st_blank

    except:
        st15 = st_blank

    try:
        ID = 16
        sta = 'FG11'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '05'  # location,

        st16 = Stream()
        st16 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st16.detrend(type='linear')
        st16.detrend(type='demean')

        break_test = st16
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st16[0].stats.sampling_rate

        if sum(abs(st16[0].data)) > 10 and st16[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st16[0].stats.starttime
            station_activity[num][2] = st16[0].stats.endtime
            num += 1

        else:
            st16 = st_blank

    except:
        st16 = st_blank

#%% FG12

    try:
        ID = 17
        sta = 'FG12'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st17 = Stream()
        st17 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st17.detrend(type='linear')
        st17.detrend(type='demean')

        break_test = st17
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st17[0].stats.sampling_rate

        if sum(abs(st17[0].data)) > 10 and st17[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st17[0].stats.starttime
            station_activity[num][2] = st17[0].stats.endtime
            num += 1

        else:
            st17 = st_blank

    except:
        st17 = st_blank

    try:
        ID = 18
        sta = 'FG12'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st18 = Stream()
        st18 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st18.detrend(type='linear')
        st18.detrend(type='demean')

        break_test = st18
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st18[0].stats.sampling_rate

        if sum(abs(st18[0].data)) > 10 and st18[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st18[0].stats.starttime
            station_activity[num][2] = st18[0].stats.endtime
            num += 1

        else:
            st18 = st_blank

    except:
        st18 = st_blank

    try:
        ID = 19
        sta = 'FG12'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '03'  # location,

        st19 = Stream()
        st19 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st19.detrend(type='linear')
        st19.detrend(type='demean')

        break_test = st19
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st19[0].stats.sampling_rate

        if sum(abs(st19[0].data)) > 10 and st19[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st19[0].stats.starttime
            station_activity[num][2] = st19[0].stats.endtime
            num += 1

        else:
            st19 = st_blank

    except:
        st19 = st_blank

#%% FG13

    try:
        ID = 20
        sta = 'FG13'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st20 = Stream()
        st20 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st20.detrend(type='linear')
        st20.detrend(type='demean')

        break_test = st20
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st20[0].stats.sampling_rate

        if sum(abs(st20[0].data)) > 10 and st20[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st20[0].stats.starttime
            station_activity[num][2] = st20[0].stats.endtime
            num += 1

        else:
            st20 = st_blank

    except:
        st20 = st_blank

    try:
        ID = 21
        sta = 'FG13'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st21 = Stream()
        st21 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st21.detrend(type='linear')
        st21.detrend(type='demean')

        break_test = st21
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st21[0].stats.sampling_rate

        if sum(abs(st21[0].data)) > 10 and st21[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st21[0].stats.starttime
            station_activity[num][2] = st21[0].stats.endtime
            num += 1

        else:
            st21 = st_blank

    except:
        st21 = st_blank

    try:
        ID = 22
        sta = 'FG13'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '03'  # location,

        st22 = Stream()
        st22 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st22.detrend(type='linear')
        st22.detrend(type='demean')

        break_test = st22
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st22[0].stats.sampling_rate

        if sum(abs(st22[0].data)) > 10 and st22[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st22[0].stats.starttime
            station_activity[num][2] = st22[0].stats.endtime
            num += 1

        else:
            st22 = st_blank

    except:
        st22 = st_blank

#%% FG15

    try:
        ID = 23
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '01'  # location,

        st23 = Stream()
        st23 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st23.detrend(type='linear')
        st23.detrend(type='demean')

        break_test = st23
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st23[0].stats.sampling_rate

        if sum(abs(st23[0].data)) > 10 and st23[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st23[0].stats.starttime
            station_activity[num][2] = st23[0].stats.endtime
            num += 1

        else:
            st23 = st_blank

    except:
        st23 = st_blank

    try:
        ID = 24
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '02'  # location,

        st24 = Stream()
        st24 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st24.detrend(type='linear')
        st24.detrend(type='demean')

        break_test = st24
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st24[0].stats.sampling_rate

        if sum(abs(st24[0].data)) > 10 and st24[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st24[0].stats.starttime
            station_activity[num][2] = st24[0].stats.endtime
            num += 1

        else:
            st24 = st_blank

    except:
        st24 = st_blank

    try:
        ID = 25
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '03'  # location,

        st25 = Stream()
        st25 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st25.detrend(type='linear')
        st25.detrend(type='demean')

        break_test = st25
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st25[0].stats.sampling_rate

        if sum(abs(st25[0].data)) > 10 and st25[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st25[0].stats.starttime
            station_activity[num][2] = st25[0].stats.endtime
            num += 1

        else:
            st25 = st_blank

    except:
        st25 = st_blank

    try:
        ID = 26
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '04'  # location,

        st26 = Stream()
        st26 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st26.detrend(type='linear')
        st26.detrend(type='demean')

        break_test = st26
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st26[0].stats.sampling_rate

        if sum(abs(st26[0].data)) > 10 and st26[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st26[0].stats.starttime
            station_activity[num][2] = st26[0].stats.endtime
            num += 1

        else:
            st26 = st_blank

    except:
        st26 = st_blank

    try:
        ID = 27
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '05'  # location,

        st27 = Stream()
        st27 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st27.detrend(type='linear')
        st27.detrend(type='demean')

        break_test = st27
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st27[0].stats.sampling_rate

        if sum(abs(st27[0].data)) > 10 and st27[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st27[0].stats.starttime
            station_activity[num][2] = st27[0].stats.endtime
            num += 1

        else:
            st27 = st_blank

    except:
        st27 = st_blank

    try:
        ID = 28
        sta = 'FG15'  # STATION VF01
        cha = 'BDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = '06'  # location,

        st28 = Stream()
        st28 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st28.detrend(type='linear')
        st28.detrend(type='demean')

        break_test = st28
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st28[0].stats.sampling_rate

        if sum(abs(st28[0].data)) > 10 and st28[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))
            station_activity[num][0] = ID
            station_activity[num][1] = st28[0].stats.starttime
            station_activity[num][2] = st28[0].stats.endtime
            num += 1

        else:
            st28 = st_blank

    except:
        st28 = st_blank

#%% FV01
    try:
        ID = 29
        sta = 'FV01'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = ''  # location,

        st29 = Stream()
        st29 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st29.detrend(type='linear')
        st29.detrend(type='demean')

        break_test = st29
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st29[0].stats.sampling_rate

        if sum(abs(st29[0].data)) > 10 and st29[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st29[0].stats.starttime
            station_activity[num][2] = st29[0].stats.endtime
            num += 1

        else:
            st29 = st_blank

    except:
        st29 = st_blank

#%% FV02
    try:
        ID = 30
        sta = 'FV02'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = ''  # location,

        st30 = Stream()
        st30 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st30.detrend(type='linear')
        st30.detrend(type='demean')

        break_test = st30
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st30[0].stats.sampling_rate

        if sum(abs(st30[0].data)) > 10 and st30[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st30[0].stats.starttime
            station_activity[num][2] = st30[0].stats.endtime
            num += 1

        else:
            st30 = st_blank

    except:
        st30 = st_blank

#%% FV03
    try:
        ID = 31
        sta = 'FV03'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = ''  # location,

        st31 = Stream()
        st31 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st31.detrend(type='linear')
        st31.detrend(type='demean')

        break_test = st31
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st31[0].stats.sampling_rate

        if sum(abs(st31[0].data)) > 10 and st31[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st31[0].stats.starttime
            station_activity[num][2] = st31[0].stats.endtime
            num += 1

        else:
            st31 = st_blank

    except:
        st31 = st_blank

#%% FV04
    try:
        ID = 32
        sta = 'FV04'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = ''  # location,

        st32 = Stream()
        st32 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st32.detrend(type='linear')
        st32.detrend(type='demean')

        break_test = st32
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st32[0].stats.sampling_rate

        if sum(abs(st32[0].data)) > 10 and st32[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st32[0].stats.starttime
            station_activity[num][2] = st32[0].stats.endtime
            num += 1

        else:
            st32 = st_blank

    except:
        st32 = st_blank

#%% FV08
    try:
        ID = 33
        sta = 'FV08'  # STATION VF01
        cha = 'HDF'  # CHANNEL - inf
        net = 'GI'  # Fuego volcano
        loc = ''  # location,

        st33 = Stream()
        st33 = client.get_waveforms(net, sta, loc, cha, t1, t2)
        st33.detrend(type='linear')
        st33.detrend(type='demean')

        break_test = st33
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        sr = st33[0].stats.sampling_rate

        if sum(abs(st33[0].data)) > 10 and st33[0].stats.npts > 7200 * sr:
            station_activity = np.lib.pad(station_activity, ((0, 1), (0, 0)),
                                          'constant',
                                          constant_values=(0))

            station_activity[num][0] = ID
            station_activity[num][1] = st33[0].stats.starttime
            station_activity[num][2] = st33[0].stats.endtime
            num += 1

        else:
            st33 = st_blank

    except:
        st33 = st_blank

#%%      give all traces and list of active stations

    return (st1, st2, st3, st4, st5, st6, st7, st8, st9, st10, st11, st12,
            st13, st14, st15, st16, st17, st18, st19, st20, st21, st22, st23,
            st24, st25, st26, st27, st28, st29, st30, st31, st32, st33,
            station_activity)
예제 #8
0
 def setUp(self):
     # Monkey patch: set lower default precision of all UTCDateTime objects
     UTCDateTime.DEFAULT_PRECISION = 4
     self.client = Client("pele.ess.washington.edu", 16017, timeout=7)
예제 #9
0
import matplotlib.mlab as mlab
from scipy import integrate
from obspy.clients.earthworm import Client
from obspy import UTCDateTime
from obspy.signal.trigger import classic_sta_lta, recursive_sta_lta
from obspy.signal.trigger import plot_trigger, trigger_onset
from obspy import Stream
from numpy import argmax

#%% Gas rich reference
# STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
sta = 'VF03'  # STATION
cha = 'HDF'  # CHANNEL
net = 'XZ'  #
loc = ''  # location, it depends mostly of which network you are in.
client = Client('138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23

t1r = UTCDateTime(2018, 5, 22, 8, 4,
                  12)  #the format is year:day_of_the_year:month
t2r = t1r + 14
gr_r = Stream()
gr_r = client.get_waveforms(net, sta, loc, cha, t1r, t2r)
gr_r.detrend(type='linear')
gr_r.detrend(type='demean')
sr_r = gr_r[0].stats.sampling_rate
gr_r.filter(type='bandpass', freqmin=0.1, freqmax=(sr_r / 2) - (sr_r / 20))
gr_r.plot(type='relative', color='r', starttime=t1r, endtime=t2r)

#%% Seismic Reference
sta = 'FG8'  # STATION
cha = 'BHZ'  # CHANNEL
예제 #10
0
def get_activity_fuego(day):

    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream
    import numpy as np

    year1 = 2018
    month1 = 3
    day1 = 10
    hour1 = 0
    minute1 = 0
    second1 = 0

    num = 0
    nums = 0
    numa = 0

    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month
    t1 = t0 + day * 24 * 60 * 60
    t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.

    print(UTCDateTime(t1))

    port = '138.253.113.19'  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #%% FG10 seismic
    try:

        sta = 'FG10'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG10s = 1
            num += 1
            nums += 1
        else:
            FG10s = 0

    except:

        FG10s = 0

#%% FG11 Seismic
    try:

        sta = 'FG11'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG11s = 1
            num += 1
            nums += 1
        else:
            FG11s = 0

    except:

        FG11s = 0

#%% FG12 Seismic
    try:

        sta = 'FG12'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '00'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG12s = 1
            num += 1
            nums += 1
        else:
            FG12s = 0

    except:

        FG12s = 0

#%% FG13 Seismic
    try:

        sta = 'FG13'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '00'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG13s = 1
            num += 1
            nums += 1
        else:
            FG13s = 0

    except:

        FG13s = 0

#%% FG14 Seismic
    try:

        sta = 'FG14'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG14s = 1
            num += 1
            nums += 1
        else:
            FG14s = 0

    except:

        FG14s = 0

#%% FG16 Seismic
    try:

        sta = 'FG16'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '00'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG16s = 1
            num += 1
            nums += 1
        else:
            FG16s = 0

    except:

        FG16s = 0

#%% FG8 Seismic
    try:

        sta = 'FG8'  # STATION LB01
        cha = 'BHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '00'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG8s = 1
            num += 1
            nums += 1
        else:
            FG8s = 0

    except:

        FG8s = 0

#%% FG3 Seismic
    try:

        sta = 'FG3'  # STATION LB01
        cha = 'SHZ'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG3s = 1
            num += 1
            nums += 1
        else:
            FG3s = 0

    except:

        FG3s = 0

#%%

#%% FG10 inf
    try:

        sta = 'FG10'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG10_1 = 1
            num += 1
            numa += 1
        else:
            FG10_1 = 0

    except:

        FG10_1 = 0

    try:

        sta = 'FG10'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG10_2 = 1
            num += 1
            numa += 1
        else:
            FG10_2 = 0

    except:

        FG10_2 = 0

    try:

        sta = 'FG10'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '03'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG10_3 = 1
            num += 1
            numa += 1
        else:
            FG10_3 = 0

    except:

        FG10_3 = 0

#%% FG11 inf
    try:

        sta = 'FG11'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG11_1 = 1
            num += 1
            numa += 1
        else:
            FG11_1 = 0

    except:

        FG11_1 = 0

    try:

        sta = 'FG11'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG11_2 = 1
            num += 1
            numa += 1
        else:
            FG11_2 = 0

    except:

        FG11_2 = 0

    try:

        sta = 'FG11'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '04'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG11_4 = 1
            num += 1
            numa += 1
        else:
            FG11_4 = 0

    except:

        FG11_4 = 0

    try:

        sta = 'FG11'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '05'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG11_5 = 1
            num += 1
            numa += 1
        else:
            FG11_5 = 0

    except:

        FG11_5 = 0

#%% FG12 inf
    try:

        sta = 'FG12'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG12_1 = 1
            num += 1
            numa += 1
        else:
            FG12_1 = 0

    except:

        FG12_1 = 0

    try:

        sta = 'FG12'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG12_2 = 1
            num += 1
            numa += 1
        else:
            FG12_2 = 0

    except:

        FG12_2 = 0

    try:

        sta = 'FG12'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '03'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG12_3 = 1
            num += 1
            numa += 1
        else:
            FG12_3 = 0

    except:

        FG12_3 = 0

#%% FG13 inf
    try:

        sta = 'FG13'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG13_1 = 1
            num += 1
            numa += 1
        else:
            FG13_1 = 0

    except:

        FG13_1 = 0

    try:

        sta = 'FG13'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG13_2 = 1
            num += 1
            numa += 1
        else:
            FG13_2 = 0

    except:

        FG13_2 = 0

    try:

        sta = 'FG13'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '03'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG13_3 = 1
            num += 1
            numa += 1
        else:
            FG13_3 = 0

    except:

        FG13_3 = 0

#%% FG15 inf
    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_1 = 1
            num += 1
            numa += 1
        else:
            FG15_1 = 0

    except:

        FG15_1 = 0

    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_2 = 1
            num += 1
            numa += 1
        else:
            FG15_2 = 0

    except:

        FG15_2 = 0

    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '03'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_3 = 1
            num += 1
            numa += 1
        else:
            FG15_3 = 0

    except:

        FG15_3 = 0

    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '04'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_4 = 1
            num += 1
            numa += 1
        else:
            FG15_4 = 0

    except:

        FG15_4 = 0

    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '05'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_5 = 1
            num += 1
            numa += 1
        else:
            FG15_5 = 0

    except:

        FG15_5 = 0

    try:

        sta = 'FG15'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '06'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG15_6 = 1
            num += 1
            numa += 1
        else:
            FG15_6 = 0

    except:

        FG15_6 = 0

#%% FG8 inf
    try:

        sta = 'FG8'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '01'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG8_1 = 1
            num += 1
            numa += 1
        else:
            FG8_1 = 0

    except:

        FG8_1 = 0

    try:

        sta = 'FG8'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '02'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG8_2 = 1
            num += 1
            numa += 1
        else:
            FG8_2 = 0

    except:

        FG8_2 = 0

    try:

        sta = 'FG8'  # STATION LB01
        cha = 'BDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = '03'  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FG8_3 = 1
            num += 1
            numa += 1
        else:
            FG8_3 = 0

    except:

        FG8_3 = 0

#%% FV01 inf
    try:

        sta = 'FV01'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FV01a = 1
            num += 1
            numa += 1
        else:
            FV01a = 0

    except:

        FV01a = 0

#%% FV02 inf
    try:

        sta = 'FV02'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FV02a = 1
            num += 1
            numa += 1
        else:
            FV02a = 0

    except:

        FV02a = 0

#%% FV03 inf
    try:

        sta = 'FV03'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FV03a = 1
            num += 1
            numa += 1
        else:
            FV03a = 0

    except:

        FV03a = 0

#%% FV04 inf
    try:

        sta = 'FV04'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'GI'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            FV04a = 1
            num += 1
            numa += 1
        else:
            FV04a = 0

    except:

        FV04a = 0

#%% VF01 inf
    try:

        sta = 'VF01'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF01a = 1
            num += 1
            numa += 1
        else:
            VF01a = 0

    except:

        VF01a = 0

#%% VF02 inf
    try:

        sta = 'VF02'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF02a = 1
            num += 1
            numa += 1
        else:
            VF02a = 0

    except:

        VF02a = 0

#%% VF03 inf
    try:

        sta = 'VF03'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF03a = 1
            num += 1
            numa += 1
        else:
            VF03a = 0

    except:

        VF03a = 0

#%% VF04 inf
    try:

        sta = 'VF04'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF04a = 1
            num += 1
            numa += 1
        else:
            VF04a = 0

    except:

        VF04a = 0

#%% VF05 inf
    try:

        sta = 'VF05'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF05a = 1
            num += 1
            numa += 1
        else:
            VF05a = 0

    except:

        VF05a = 0

#%% VF06 inf
    try:

        sta = 'VF06'  # STATION LB01
        cha = 'HDF'  # CHANNEL - Vertical
        net = 'XZ'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(port, 16022)
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, loc, cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        if np.mean(abs(st1[0].data)) > 2:

            VF06a = 1
            num += 1
            numa += 1
        else:
            VF06a = 0

    except:

        VF06a = 0

    #%% return all stations

    return (num, nums, numa, FG3s, FG8s, FG10s, FG11s, FG12s, FG13s, FG14s,
            FG16s, FG8_1, FG8_2, FG8_3, FG10_1, FG10_2, FG10_3, FG11_1, FG11_2,
            FG11_4, FG11_5, FG12_1, FG12_2, FG12_3, FG13_1, FG13_2, FG13_3,
            FG15_1, FG15_2, FG15_3, FG15_4, FG15_5, FG15_6, FV01a, FV02a,
            FV03a, FV04a, VF01a, VF02a, VF03a, VF04a, VF05a, VF06a)
예제 #11
0
class ClientTestCase(unittest.TestCase):
    """
    Test cases for obspy.clients.earthworm.client.Client.
    """
    def setUp(self):
        # Monkey patch: set lower default precision of all UTCDateTime objects
        UTCDateTime.DEFAULT_PRECISION = 4
        self.client = Client("pubavo1.wr.usgs.gov", 16022, timeout=30.0)

    def tearDown(self):
        # restore default precision of all UTCDateTime objects
        UTCDateTime.DEFAULT_PRECISION = 6

    @skip_on_network_error
    def test_getWaveform(self):
        """
        Tests get_waveforms method.
        """
        client = self.client
        start = UTCDateTime() - 3600
        end = start + 1.0
        # example 1 -- 1 channel, cleanup
        stream = client.get_waveforms('AV', 'ACH', '', 'EHE', start, end)
        self.assertEqual(len(stream), 1)
        delta = stream[0].stats.delta
        trace = stream[0]
        self.assertEqual(len(trace), 101)
        self.assertTrue(trace.stats.starttime >= start - delta)
        self.assertTrue(trace.stats.starttime <= start + delta)
        self.assertTrue(trace.stats.endtime >= end - delta)
        self.assertTrue(trace.stats.endtime <= end + delta)
        self.assertEqual(trace.stats.network, 'AV')
        self.assertEqual(trace.stats.station, 'ACH')
        self.assertEqual(trace.stats.location, '')
        self.assertEqual(trace.stats.channel, 'EHE')
        # example 2 -- 1 channel, no cleanup
        stream = client.get_waveforms('AV', 'ACH', '', 'EHE', start, end,
                                      cleanup=False)
        self.assertTrue(len(stream) >= 2)
        summed_length = sum(len(tr) for tr in stream)
        self.assertEqual(summed_length, 101)
        self.assertTrue(stream[0].stats.starttime >= start - delta)
        self.assertTrue(stream[0].stats.starttime <= start + delta)
        self.assertTrue(stream[-1].stats.endtime >= end - delta)
        self.assertTrue(stream[-1].stats.endtime <= end + delta)
        for trace in stream:
            self.assertEqual(trace.stats.network, 'AV')
            self.assertEqual(trace.stats.station, 'ACH')
            self.assertEqual(trace.stats.location, '')
            self.assertEqual(trace.stats.channel, 'EHE')
        # example 3 -- component wildcarded with '?'
        stream = client.get_waveforms('AV', 'ACH', '', 'EH?', start, end)
        self.assertEqual(len(stream), 3)
        for trace in stream:
            self.assertEqual(len(trace), 101)
            self.assertTrue(trace.stats.starttime >= start - delta)
            self.assertTrue(trace.stats.starttime <= start + delta)
            self.assertTrue(trace.stats.endtime >= end - delta)
            self.assertTrue(trace.stats.endtime <= end + delta)
            self.assertEqual(trace.stats.network, 'AV')
            self.assertEqual(trace.stats.station, 'ACH')
            self.assertEqual(trace.stats.location, '')
        self.assertEqual(stream[0].stats.channel, 'EHZ')
        self.assertEqual(stream[1].stats.channel, 'EHN')
        self.assertEqual(stream[2].stats.channel, 'EHE')

    @skip_on_network_error
    def test_saveWaveform(self):
        """
        Tests save_waveforms method.
        """
        # initialize client
        client = self.client
        start = UTCDateTime() - 3600
        end = start + 1.0
        with NamedTemporaryFile() as tf:
            testfile = tf.name
            # 1 channel, cleanup (using SLIST to avoid dependencies)
            client.save_waveforms(testfile, 'AV', 'ACH', '', 'EHE', start, end,
                                  format="SLIST")
            stream = read(testfile)
        self.assertEqual(len(stream), 1)
        delta = stream[0].stats.delta
        trace = stream[0]
        self.assertEqual(len(trace), 101)
        self.assertTrue(trace.stats.starttime >= start - delta)
        self.assertTrue(trace.stats.starttime <= start + delta)
        self.assertTrue(trace.stats.endtime >= end - delta)
        self.assertTrue(trace.stats.endtime <= end + delta)
        self.assertEqual(trace.stats.network, 'AV')
        self.assertEqual(trace.stats.station, 'ACH')
        self.assertEqual(trace.stats.location, '')
        self.assertEqual(trace.stats.channel, 'EHE')

    @skip_on_network_error
    def test_availability(self):
        data = self.client.get_availability()
        seeds = ["%s.%s.%s.%s" % (d[0], d[1], d[2], d[3]) for d in data]
        self.assertIn('AV.ACH.--.EHZ', seeds)
예제 #12
0
파일: test_client.py 프로젝트: zurgeg/obspy
 def setUp(self):
     # Monkey patch: set lower default precision of all UTCDateTime objects
     UTCDateTime.DEFAULT_PRECISION = 4
     self.client = Client("pubavo1.wr.usgs.gov", 16022, timeout=30.0)
예제 #13
0
rs1 = 5710
rs2 = 5490
rs3 = 3900
rs4 = 5520
rs5 = 4290
rs6 = 2610

saved = np.zeros(shape=(0, 4))
num = 0
first = 0

#sta = 'LB01' # STATION
#cha = 'HHZ' # CHANNEL
net = 'Z4'  #
loc = ''  # location, it depends mostly of which network you are in.
client = Client('138.253.113.19',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23

#%% read in data
reclen = 512
chunksize = 100000 * reclen  # 100000 = Around 50 MB
with io.open("/Users/william/Documents/scanner/output_data/m32.mseed",
             "rb") as fh:
    #         just month 2
    #with io.open("/Users/william/Documents/scanner/output_data/EXP_all_data_stream_2_month_2.mseed", "rb") as fh:
    while True:
        with io.BytesIO() as buf:
            c = fh.read(chunksize)
            if not c:
                break
            buf.write(c)
            buf.seek(0, 0)
        NET = net['network']
        NETDISP = net['display name']
        all_nets.append(NETDISP)
        all_stations[NETDISP] = []
        for array in net['arrays']:
            STA = array['id']
            STANAME = array['Name']
            all_stations[NETDISP].append(STANAME)

            CHAN = array['channel']

            # LTS alpha parameter - subset size
            ALPHA = array['Alpha']

            logging.info(f'Reading in data from Winston for station {STA}')
            wclient = WClient(config.winston_address, config.winston_port)
            # Get Availability
            try:
                avail = wclient.get_availability(NET, STA, channel=CHAN)
            except Exception:
                logging.error(f"Unable to get location info for station {STA}")
                continue

            locs = [x[2] for x in avail]
            st = Stream()
            for loc in locs:
                try:
                    # Not sure why we can't use a wildcard for loc, but it
                    # doesn't seem to work (at least, not for DLL), so we loop.
                    tr = wclient.get_waveforms(NET,
                                               STA,
예제 #15
0
def get_all_stations(day):

    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream

    year1 = 2014
    month1 = 11
    day1 = 24
    hour1 = 0
    minute1 = 0
    second1 = 0

    num = 12
    lb_num = 6
    #%% LB01
    try:

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st1.detrend(type='linear')
        st1.detrend(type='demean')
        break_test = st1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st1.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st1[0].data)
               ) < 10 or st1[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st1 = Stream()
            st1 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st1.detrend(type='linear')
            st1.detrend(type='demean')
            st1[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st1 = Stream()
        st1 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st1.detrend(type='linear')
        st1.detrend(type='demean')
        st1[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1
#%%    LB02

    try:

        sta = 'LB02'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st2 = Stream()
        st2 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st2.detrend(type='linear')
        st2.detrend(type='demean')
        break_test = st2
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st2.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st2[0].data)
               ) < 10 or st2[0].stats.npts < 7920000 or mid_dat < 0.1:
            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st2 = Stream()
            st2 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st2.detrend(type='linear')
            st2.detrend(type='demean')
            st2[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st2 = Stream()
        st2 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st2.detrend(type='linear')
        st2.detrend(type='demean')
        st2[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1

#%% LB03
    try:

        sta = 'LB03'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st3 = Stream()
        st3 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st3.detrend(type='linear')
        st3.detrend(type='demean')
        break_test = st3
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st3.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st3[0].data)
               ) < 10 or st3[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st3 = Stream()
            st3 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st3.detrend(type='linear')
            st3.detrend(type='demean')
            st3[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st3 = Stream()
        st3 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st3.detrend(type='linear')
        st3.detrend(type='demean')
        st3[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1

#%% LB04
    try:

        sta = 'LB04'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st4 = Stream()
        st4 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st4.detrend(type='linear')
        st4.detrend(type='demean')
        break_test = st4
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st4.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st4[0].data)
               ) < 10 or st4[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st4 = Stream()
            st4 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st4.detrend(type='linear')
            st4.detrend(type='demean')
            st4[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1
    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st4 = Stream()
        st4 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st4.detrend(type='linear')
        st4.detrend(type='demean')
        st4[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1
#%% LB05
    try:

        sta = 'LB05'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st5 = Stream()
        st5 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st5.detrend(type='linear')
        st5.detrend(type='demean')
        break_test = st5
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st5.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st5[0].data)
               ) < 10 or st5[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st5 = Stream()
            st5 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st5.detrend(type='linear')
            st5.detrend(type='demean')
            st5[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st5 = Stream()
        st5 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st5.detrend(type='linear')
        st5.detrend(type='demean')
        st5[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1
#%% LB06
    try:

        sta = 'LB06'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st6 = Stream()
        st6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        st6.detrend(type='linear')
        st6.detrend(type='demean')
        break_test = st6
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = st6.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(st6[0].data)
               ) < 10 or st6[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            st6 = Stream()
            st6 = client.get_waveforms(net, sta, '', cha, t1, t2)

            st6.detrend(type='linear')
            st6.detrend(type='demean')
            st6[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
            lb_num = lb_num - 1
    except:  # give 2 seconds of blank data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st6 = Stream()
        st6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        st6.detrend(type='linear')
        st6.detrend(type='demean')
        st6[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
        lb_num = lb_num - 1

#%% LS01
    try:

        sta = 'LS01'  # STATION LS01
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts1 = Stream()
        sts1 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts1.detrend(type='linear')
        sts1.detrend(type='demean')
        break_test = sts1
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts1.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts1[0].data)
               ) < 10 or sts1[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts1 = Stream()
            sts1 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts1.detrend(type='linear')
            sts1.detrend(type='demean')
            sts1[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts1 = Stream()
        sts1 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts1.detrend(type='linear')
        sts1.detrend(type='demean')
        sts1[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1
#%%    LS02

    try:

        sta = 'LS02'  # STATION LS02
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts2 = Stream()
        sts2 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts2.detrend(type='linear')
        sts2.detrend(type='demean')
        break_test = sts2
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts2.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts2[0].data)
               ) < 10 or sts2[0].stats.npts < 7920000 or mid_dat < 0.1:
            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts2 = Stream()
            sts2 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts2.detrend(type='linear')
            sts2.detrend(type='demean')
            sts2[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts2 = Stream()
        sts2 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts2.detrend(type='linear')
        sts2.detrend(type='demean')
        sts2[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1

#%% LS03
    try:

        sta = 'LS03'  # STATION LS03
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts3 = Stream()
        sts3 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts3.detrend(type='linear')
        sts3.detrend(type='demean')
        break_test = sts3
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts3.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts3[0].data)
               ) < 10 or sts3[0].stats.npts < 7920000 or mid_dat < 0.1 or sts3[
                   0].stats.starttime.timestamp > 1442707190:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts3 = Stream()
            sts3 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts3.detrend(type='linear')
            sts3.detrend(type='demean')
            sts3[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts3 = Stream()
        sts3 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts3.detrend(type='linear')
        sts3.detrend(type='demean')
        sts3[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1

#%% LS04
    try:

        sta = 'LS04'  # STATION LS04
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts4 = Stream()
        sts4 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts4.detrend(type='linear')
        sts4.detrend(type='demean')
        break_test = sts4
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts4.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts4[0].data)
               ) < 10 or sts4[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts4 = Stream()
            sts4 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts4.detrend(type='linear')
            sts4.detrend(type='demean')
            sts4[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1
    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts4 = Stream()
        sts4 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts4.detrend(type='linear')
        sts4.detrend(type='demean')
        sts4[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1

#%% LS05
    try:

        sta = 'LS05'  # STATION LB0S
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts5 = Stream()
        sts5 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts5.detrend(type='linear')
        sts5.detrend(type='demean')
        break_test = sts5
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts5.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts5[0].data)
               ) < 10 or sts5[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts5 = Stream()
            sts5 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts5.detrend(type='linear')
            sts5.detrend(type='demean')
            sts5[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1

    except:  # give 2 seconds of data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts5 = Stream()
        sts5 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts5.detrend(type='linear')
        sts5.detrend(type='demean')
        sts5[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1

#%% LS06
    try:

        sta = 'LS06'  # STATION LS06
        cha = 'EHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts6 = Stream()
        sts6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        sts6.detrend(type='linear')
        sts6.detrend(type='demean')
        break_test = sts6
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)

        sorted_data = sts6.copy()
        sorted_data = abs(sorted_data[0].data)
        sorted_data.sort()
        mid_dat = sorted_data[int(len(sorted_data) / 2)]

        if sum(abs(sts6[0].data)
               ) < 10 or sts6[0].stats.npts < 7920000 or mid_dat < 0.1:

            sta = 'LB01'  # STATION LB01
            cha = 'HHZ'  # CHANNEL - Vertical
            net = 'Z4'  # Santiaguito volcano
            loc = ''  # location, it depends mostly of which network you are in.

            client = Client(
                '138.253.112.23',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
            t0 = UTCDateTime(
                year1, month1, day1, hour1, minute1,
                second1)  #the format is year:day_of_the_year:month
            t1 = t0
            t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
            sts6 = Stream()
            sts6 = client.get_waveforms(net, sta, '', cha, t1, t2)

            sts6.detrend(type='linear')
            sts6.detrend(type='demean')
            sts6[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
            num = num - 1

    except:  # give 2 seconds of blank data instead

        sta = 'LB01'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        sts6 = Stream()
        sts6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        sts6.detrend(type='linear')
        sts6.detrend(type='demean')
        sts6[0].filter("bandpass", freqmin=0.1, freqmax=0.1)
        num = num - 1

    #%% return all stations
    return (st1, st2, st3, st4, st5, st6, sts1, sts2, sts3, sts4, sts5, sts6,
            num, lb_num)  #st7
예제 #16
0
calSeis = 1  # calibration given in counts/m/s
calAcous = 1  # calibration given in counts/Pa

#COORDINATES OF VENT AND STATION
srcCoords = [14.4743, -90.8811]  # Fuego vent
staCoords = [14.43651, -90.83606]  # FG12 location
#staCoords = [14.40677 -90.81859]; % FG13 location

sta = 'FG12'  # STATION
cha1 = 'BHZ'  # CHANNEL
cha2 = 'BDF'  # CHANNEL
net = 'GI'  #
loc1 = '00'  # location, it depends mostly of which network you are in.
loc2 = '02'
client = Client('138.253.113.19',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23

t1 = UTCDateTime(2018, 11, 2, 8, 0, 0)
t2 = UTCDateTime(2018, 11, 2, 10, 0, 0)

st1 = Stream()
st1 = client.get_waveforms(net, sta, loc1, cha1, t1, t2)
tr1 = st1[0]

print("stream 1 in")

sr1 = st1[0].stats.sampling_rate

tr1.detrend(type='linear')
tr1.detrend(type='demean')
tr1.filter(type='bandpass', freqmin=0.5, freqmax=15)
예제 #17
0
def get_LB01z(day):
    year1 = 2014
    month1 = 11
    day1 = 24
    hour1 = 0
    minute1 = 0
    second1 = 0

    from obspy.core import read

    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime

    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    #from scipy.signal import welch
    from obspy import Stream

    # STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
    sta = 'LB01'  # STATION LB01
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    # Corner frequency for high-pass filter
    #    hp_corner = 0.05

    # t1. and t2 are in hours:minutes:seconds
    # Get data from (Liverpool Winston default) wave server between times t1 and t2 for all stations in stalist
    try:
        client = Client(
            '138.253.112.23',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0 + day * 24 * 60 * 60
        t2 = t1 + 23 * 60 * 60 + 59 * 60 + 59.999  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st = Stream()
        st = client.get_waveforms(net, sta, '', cha, t1, t2)

        # st is a stream, we can operate normally as in obspy
        #st.plot(method="full")
        st.detrend(type='linear')
        st.detrend(type='demean')
        break_test = st
        break_test = break_test[0].filter("bandpass", freqmin=1, freqmax=10)
        #st.plot(color='b',starttime=t1, endtime=t2)
    #    print(st)
    except IndexError:
        year1 = 2014
        month1 = 11
        day1 = 24
        hour1 = 0
        minute1 = 0
        second1 = 0

        from obspy.core import read

        from obspy.clients.earthworm import Client
        from obspy import UTCDateTime

        from obspy.clients.earthworm import Client
        from obspy import UTCDateTime
        #from scipy.signal import welch
        from obspy import Stream

        # STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
        sta = 'LB03'  # STATION LB01
        cha = 'HHZ'  # CHANNEL - Vertical
        net = 'Z4'  # Santiaguito volcano
        loc = ''  # location, it depends mostly of which network you are in.

        client = Client(
            '138.253.113.19',
            16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
        t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                         second1)  #the format is year:day_of_the_year:month
        t1 = t0
        t2 = t1 + 2  #UTCDateTime(year2, month2, day2, hour2, minute2, second2) # notice we have here 10 minutes, but we can select our times.
        st = Stream()
        st = client.get_waveforms(net, sta, '', cha, t1, t2)

        st.detrend(type='linear')
        st.detrend(type='demean')
        st[0].filter("bandpass", freqmin=0.1, freqmax=0.1)

    return (st)
예제 #18
0
def stacked_LS_exp(fmi, fma):
    import numpy as np
    import obspy
    from obspy.core import read
    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream
    import matplotlib.pyplot as plt
    #%%

    seisb = Stream()
    stream1 = seisb.copy()
    stream2 = stream1.copy()
    stream3 = stream1.copy()
    stream4 = stream1.copy()
    stream5 = stream1.copy()
    stream6 = stream1.copy()
    stream7 = stream1.copy()
    stream1b = stream1.copy()
    stream2b = stream1.copy()
    stream3b = stream1.copy()
    stream4b = stream1.copy()
    stream5b = stream1.copy()
    stream6b = stream1.copy()
    stream7b = stream1.copy()

    year1 = 2014
    month1 = 11
    day1 = 22
    hour1 = 0
    minute1 = 0
    second1 = 0
    fmin = 0.1
    fmax = 10
    #%% LB01
    sta = 'LS01'  # STATION LB01
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(0, 10, 1):
        if x == 0:
            M = [[2, 37, 16], [4, 44, 34], [20, 21, 25]]
        if x == 1:
            M = [[3, 3, 40], [5, 59, 54], [9, 47, 32], [18, 39, 4]]
        if x == 2:
            M = [[8, 22, 15], [22, 52, 31]]
        if x == 3:
            M = [[1, 49, 10], [2, 25, 57], [7, 38, 37], [8, 56, 5]]
        if x == 4:
            M = [[2, 22, 9], [3, 14, 20], [7, 6, 43], [11, 6, 13]]
        if x == 5:
            M = [[1, 25, 18]]
        if x == 6:
            M = [[3, 21, 26], [4, 20, 18], [7, 7, 37], [12, 42, 54],
                 [22, 16, 3]]
        if x == 7:
            M = [[3, 23, 14], [4, 6, 43], [5, 49, 59]]
        if x == 8:
            M = [[1, 9, 2], [5, 30, 42], [20, 15, 40]]
        if x == 9:
            M = [[5, 27, 21], [10, 13, 51], [22, 1, 42]]

        for i in range(0, len(M), 1):
            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 40
            t2 = t1 + 140
            seis = Stream()
            seis = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc1 = seis[0].slice(starttime=t1 + 30, endtime=t2 - 10)
            trc1.detrend(type='demean')
            trc1.detrend(type='linear')
            stream1.append(trc1)
    #        trc1.plot(type='relative',color='b')

    for x in range(0, len(stream1)):
        trc = stream1[x].normalize()
        stream1b.append(trc)

    stack_norm1 = np.sum([abs(trc.data) for trc in stream1b], axis=0)
    stack_norm1 = stack_norm1 / len(stream1b)

    #    plt.figure(1)
    #    plt.plot(stack_norm1,color='r')
    #    plt.title('LS01 stacked explosion waveform')

    #%% LB02
    sta = 'LS02'  # STATION LB02
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(0, 10, 1):
        if x == 0:
            M = [[2, 37, 15.5]]
        if x == 1:
            M = [[5, 59, 53], [9, 47, 32], [18, 39, 4]]
        if x == 2:
            M = [[13, 11, 9], [22, 52, 30.5]]
        if x == 3:
            M = [[1, 49, 8], [2, 25, 56], [8, 56, 4.5]]
        if x == 4:
            M = [[2, 22, 9], [7, 6, 43], [11, 6, 13]]
        if x == 5:
            M = [[1, 25, 18], [12, 59, 18], [15, 5, 45], [19, 11, 42]]
        if x == 6:
            M = [[4, 20, 17.5], [7, 7, 37]]
        if x == 7:
            M = [[3, 23, 13], [5, 49, 59], [15, 51, 19]]
        if x == 8:
            M = [[12, 31, 4]]  #,[22,27,19]]
        if x == 9:
            M = [[1, 22, 40], [12, 41, 22.5]]

        for i in range(0, len(M), 1):
            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 40
            t2 = t1 + 140
            seis = Stream()
            seis = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc2 = seis[0].slice(starttime=t1 + 30, endtime=t2 - 10)
            trc2.detrend(type='demean')
            trc2.detrend(type='linear')
            stream2.append(trc2)
    #        trc2.plot(type='relative',color='b')

    for x in range(0, len(stream2)):
        trc = stream2[x].normalize()
        stream2b.append(trc)

    stack_norm2 = np.sum([abs(trc.data) for trc in stream2b], axis=0)
    stack_norm2 = stack_norm2 / len(stream2b)

    #    plt.figure(2)
    #    plt.plot(stack_norm2,color='r')
    #    plt.title('LS02 stacked explosion waveform')

    #%% LB03
    sta = 'LS03'  # STATION LB03
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(3, 10, 1):
        if x == 3:
            M = [[2, 25, 58], [7, 38, 37.5], [8, 56, 6], [13, 40, 51.5]]
        if x == 4:
            M = [[2, 22, 11], [3, 14, 21.5], [7, 6, 45], [11, 6, 15]]
        if x == 5:
            M = [[12, 59, 22], [19, 11, 42.5], [21, 33, 9]]
        if x == 6:
            M = [[12, 42, 54], [22, 16, 4]]
        if x == 7:
            M = [[3, 23, 15], [15, 51, 20], [19, 46, 31]]
        if x == 8:
            M = [[1, 9, 3], [5, 30, 42.5], [12, 31, 5], [20, 15, 42],
                 [22, 27, 21]]
        if x == 9:
            M = [[5, 27, 22], [10, 13, 51], [12, 41, 24], [22, 1, 43]]
        for i in range(0, len(M), 1):
            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 40
            t2 = t1 + 140
            seis = Stream()
            seis = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc3 = seis[0].slice(starttime=t1 + 30, endtime=t2 - 10)
            trc3.detrend(type='demean')
            trc3.detrend(type='linear')
            stream3.append(trc3)
    #        trc3.plot(type='relative',color='b')

    for x in range(0, len(stream3)):
        trc = stream3[x].normalize()
        stream3b.append(trc)

    stack_norm3 = np.sum([abs(trc.data) for trc in stream3b], axis=0)
    stack_norm3 = stack_norm3 / len(stream3b)

    #    plt.figure(3)
    #    plt.plot(stack_norm3,color='r')
    #    plt.title('LS03 stacked explosion waveform')
    #
    #%% LB04
    sta = 'LS04'  # STATION LB04
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(3, 10, 1):
        if x == 3:
            M = [[1, 49, 13], [2, 26, 2], [7, 38, 42], [8, 56, 8]]
        if x == 4:
            M = [[2, 22, 15], [3, 14, 25], [7, 6, 48], [11, 6, 19]]
        if x == 5:
            M = [[1, 25, 24]]
        if x == 6:
            M = [[22, 16, 8]]
        if x == 7:
            M = [[3, 23, 19], [19, 46, 35]]
        if x == 8:
            M = [[1, 9, 8], [5, 30, 48], [20, 15, 45], [22, 27, 25]]
        if x == 9:
            M = [[5, 27, 27], [22, 1, 45]]

        for i in range(0, len(M), 1):
            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 40
            t2 = t1 + 140
            seis = Stream()
            seis = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc4 = seis[0].slice(starttime=t1 + 30, endtime=t2 - 10)
            trc4.detrend(type='demean')
            trc4.detrend(type='linear')
            stream4.append(trc4)
    #        trc4.plot(type='relative',color='b')

    for x in range(0, len(stream4)):
        trc = stream4[x].normalize()
        stream4b.append(trc)

    stack_norm4 = np.sum([abs(trc.data) for trc in stream4b], axis=0)
    stack_norm4 = stack_norm4 / len(stream4b)

    #    plt.figure(4)
    #    plt.plot(stack_norm4,color='r')
    #    plt.title('LS04 stacked explosion waveform')

    #%% LB05
    sta = 'LS05'  # STATION LB05
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(6, 10, 1):
        if x == 6:
            M = [[7, 7, 38], [12, 42, 54], [22, 16, 1]]
        if x == 7:
            M = [[3, 23, 15], [4, 6, 45], [5, 50, 2]]
        if x == 8:
            M = [[1, 9, 5], [5, 30, 45], [20, 15, 43], [22, 27, 22]]
        if x == 9:
            M = [[5, 27, 24], [10, 13, 53], [12, 41, 24], [22, 1, 42]]

        for i in range(0, len(M), 1):
            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 40
            t2 = t1 + 140
            seis5 = Stream()
            seis5 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis5[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc5 = seis5[0].slice(starttime=t1 + 30, endtime=t2 - 10)
            trc5.detrend(type='demean')
            trc5.detrend(type='linear')
            stream5.append(trc5)
    #        trc5.plot(type='relative',color='b')

    for x in range(0, len(stream5)):
        trc = stream5[x].normalize()
        stream5b.append(trc)

    stack_norm5 = np.sum([abs(trc.data) for trc in stream5b], axis=0)
    stack_norm5 = stack_norm5 / len(stream5b)

    #    plt.figure(5)
    #    plt.plot(stack_norm5,color='r')
    #    plt.title('LS05 stacked explosion waveform')

    #%% LB06

    # STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
    sta = 'LS06'  # STATION LB01
    cha = 'EHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.112.23',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(2016, 6, 21, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    M = [[16, 2, 38, 8], [4, 42, 5, 22], [5, 14, 34, 22], [6, 43, 16, 33],
         [10, 59, 19, 33], [1, 11, 17, 36]]

    for i in range(0, len(M)):
        h = M[i][0]
        m = M[i][1]
        s = M[i][2]
        d = M[i][3]

        t1 = t0 + d * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 70
        t2 = t1 + 140
        seis6 = Stream()
        seis6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        seis6[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
        trc6 = seis6[0].slice(starttime=t1 + 30, endtime=t2 - 10)
        trc6.detrend(type='demean')
        trc6.detrend(type='linear')
        stream6.append(trc6)
    #    trc6.plot(type='relative',color='b')

    for x in range(0, len(stream6)):
        trc = stream6[x].normalize()
        stream6b.append(trc)

    stack_norm6 = np.sum([abs(trc.data) for trc in stream6b], axis=0)
    stack_norm6 = stack_norm6 / len(stream6)

    #    plt.figure(6)
    #    plt.plot(stack_norm6,color='r')
    #    plt.title('LS06 stacked explosion waveform')

    #%%
    return (stack_norm1, stack_norm2, stack_norm3, stack_norm4, stack_norm5,
            stack_norm6)  #,stack_norm7)
예제 #19
0
파일: plotter.py 프로젝트: wc83/analysis
from obspy import UTCDateTime
#from scipy.signal import welch
from obspy import Stream

# STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
sta1 = 'LB01'  # STATION
sta2 = 'LB02'  # STATION
sta3 = 'LB03'  # STATION
sta4 = 'LB04'  # STATION
sta5 = 'LB05'  # STATION
sta6 = 'LB06'
cha = 'HHZ'  # CHANNEL
net = 'Z4'  #
loc = ''  # location, it depends mostly of which network you are in.

client = Client('138.253.113.19',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
t1 = UTCDateTime(2016, 6, 25, 17, 7,
                 30)  #the format is year:day_of_the_year:month
t2 = t1 + 2 * 60  #+0.01
st1 = Stream()
st1 = client.get_waveforms(net, sta1, '', cha, t1 - 20, t2)

#st1.filter(type='bandpass',freqmin=0.1, freqmax=10)
st1.detrend(type='linear')
st1.detrend(type='demean')
#st.plot(color='b',starttime=t1, endtime=t2)

tr1 = st1[0].slice(starttime=t1, endtime=t2)
st_c1 = calibrate(tr1)
trace1 = st_c1[0].slice(starttime=t1 + 20, endtime=t2)
trace1.detrend(type='linear')
예제 #20
0
    day1[num] = day
    hour1[num] = hour
    minute1[num] = minute
    second1[num] = second

    num += 1

#%%
Energy_trip = np.zeros(shape=(len(events), 2))
Energy_trip[:, 0] = events[:, 0]

#%% get all 2014-2017 data
net = 'Z4'
st_n = Stream()
st_e = Stream()
client = Client('138.253.113.19',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23

for x in range(0, len(events)):

    if Energy_trip[x, 1] == 0:

        t1 = UTCDateTime(events[x] - 10)
        t2 = t1 + 80
        try:
            r = r1
            sta = 'LB01'
            cha1 = 'HHZ'
            cha2 = 'HHE'
            cha3 = 'HHN'

            st_z = client.get_waveforms(net, sta, '', cha1, t1, t2)
예제 #21
0
from obspy import UTCDateTime
#from scipy.signal import welch
from obspy import Stream

# STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES 
sta = 'LB03' # STATION 
cha = 'HHZ' # CHANNEL
net = 'Z4'  # 
loc = ''    # location, it depends mostly of which network you are in. 

# Corner frequency for high-pass filter
#hp_corner = 0.05

# t1. and t2 are in hours:minutes:seconds
# Get data from (Liverpool Winston default) wave server between times t1 and t2 for all stations in stalist      
client = Client('138.253.113.19', 16022) # ip, port - ip's 138.253.113.19 or 138.253.112.23
t1 = UTCDateTime(2017, 3, 21 ,9 ,37, 0) #the format is year:day_of_the_year:month
t2 = t1 + 3*60
st = Stream()
st = client.get_waveforms(net, sta, '', cha, t1 , t2)


st.filter(type='bandpass',freqmin=0.5, freqmax=15)
st.detrend(type='linear')
st.detrend(type='demean')
#st.plot(color='b',starttime=t1+20, endtime=t2)

#peak,cf,bwid50,bwid25=freq_info(st[0].data,t1,t2)
#print(peak,cf,bwid50)

tr=st[0]
예제 #22
0
파일: views.py 프로젝트: diegosauriox/ovdas
def nuevoGetTraza(request):
    id = request.data["eventoMacro"]
    filtrada = request.data["filtrada"]
    cod_event = getAvistamientoByMacroId(id)
    ti = UTCDateTime(getEventoMacroId(id).inicio)
    tf = UTCDateTime(getEventoMacroId(id).fin)

    client = Client("172.16.40.70", 16022, timeout=15)
    fulldata = []
    #INTENTO QUE FUNCIONA DIEGO TRAER TODAS LAS ESTACIONES CON TRAZAS
    for i in range(len(cod_event)):

        volcan = getEstacionByCodeEvent(cod_event[i]["cod_event"])["volcan"]
        estacion = list(cod_event[i]["cod_event"])
        ts = cod_event[i]["t_s"]
        tp = cod_event[i]["t_p"]
        tiempoSstamp = time.mktime(
            datetime.strptime(ts, "%Y-%m-%dT%H:%M:%S.%fZ").timetuple())
        nombreEstacion = estacion[0] + estacion[1] + estacion[2]
        wave = client.get_waveforms('TC', nombreEstacion + "Z", volcan, 'HHZ',
                                    ti, tf)
        tiempos = wave[0].times("timestamp") * 1000
        if (filtrada == 1):
            datos = wave[0].data
        elif (filtrada == 0):
            datos = wave.filter(type='bandpass', freqmin=0.8,
                                freqmax=12)[0].data
        listaF = []
        for i in range(len(datos)):

            listaF.append([tiempos[i], datos[i]])
        fulldata.append([listaF, nombreEstacion, ts, tp])

    ## Aqui obtenemos el paquete de trazas
    wave = client.get_waveforms('TC', 'FREZ', '99', 'HHZ', ti, tf)

    #wave_fil=wave.filter(type='bandpass',freqmin=0.8,freqmax=12)

    ###### Aquí haciamos algo que no recuerdo
    """ INTENTO TRAER FECHAS *FUNCIONA
    for i in range(len(estaciones)):
        try:
            wave=client.get_waveforms('TC',estaciones[i]["estacion_id"]+"Z",estaciones[i]["volcan"]["volcan_id"],'HHZ',ti,tf)
            datos=wave[0].data
            fulldata.append([datos,estaciones[i]["estacion_id"]])
        except:

            print(i)
            
    tiempos=wave[0].times("utcdatetime")    
        
    ts=[]
    tiempos2=wave[0].times("timestamp")*1000
    for tiempo in tiempos:
        d=tiempo.datetime
        ts.append(time.mktime(d.timetuple())*1000)
        
    
    datosF=wave[0].data

    listaF=[]
    for i in range(len(datosF)):
        listaF.append([tiempos2[i],datosF[i]])
 """

    return Response(fulldata, status=status.HTTP_200_OK)
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from scipy import integrate
from obspy.clients.earthworm import Client
from obspy import UTCDateTime
from obspy.signal.trigger import classic_sta_lta, recursive_sta_lta
from obspy.signal.trigger import plot_trigger, trigger_onset
from obspy import Stream
from numpy import argmax

# STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES
sta = 'FG8'  # STATION
cha = 'BHZ'  # CHANNEL
net = 'GI'  #
loc = '00'  # location, it depends mostly of which network you are in.
client = Client('138.253.113.19',
                16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23

#%% reference waveforms

t1 = UTCDateTime(2018, 5, 20, 17, 13,
                 45)  #the format is year:day_of_the_year:month
t2 = t1 + 40
st_ref = Stream()
st_ref = client.get_waveforms(net, sta, loc, cha, t1, t2)
st_ref.detrend(type='linear')
st_ref.detrend(type='demean')
st_ref.filter(type='bandpass', freqmin=12, freqmax=22)
st_ref.plot(color='k', starttime=t1, endtime=t2)

ref_st = st_ref[0].data
예제 #24
0
파일: test_client.py 프로젝트: zurgeg/obspy
class ClientTestCase(unittest.TestCase):
    """
    Test cases for obspy.clients.earthworm.client.Client.
    """
    def setUp(self):
        # Monkey patch: set lower default precision of all UTCDateTime objects
        UTCDateTime.DEFAULT_PRECISION = 4
        self.client = Client("pubavo1.wr.usgs.gov", 16022, timeout=30.0)

    def tearDown(self):
        # restore default precision of all UTCDateTime objects
        UTCDateTime.DEFAULT_PRECISION = 6

    @skip_on_network_error
    def test_get_waveform(self):
        """
        Tests get_waveforms method.
        """
        client = self.client
        start = UTCDateTime() - 3600
        end = start + 1.0
        # example 1 -- 1 channel, cleanup
        stream = client.get_waveforms('AV', 'ACH', '', 'BHE', start, end)
        self.assertEqual(len(stream), 1)
        delta = stream[0].stats.delta
        trace = stream[0]
        self.assertTrue(len(trace) in (50, 51))
        self.assertGreaterEqual(trace.stats.starttime, start - delta)
        self.assertLessEqual(trace.stats.starttime, start + delta)
        self.assertGreaterEqual(trace.stats.endtime, end - delta)
        self.assertLessEqual(trace.stats.endtime, end + delta)
        self.assertEqual(trace.stats.network, 'AV')
        self.assertEqual(trace.stats.station, 'ACH')
        self.assertEqual(trace.stats.location, '')
        self.assertEqual(trace.stats.channel, 'BHE')
        # example 2 -- 1 channel, no cleanup
        stream = client.get_waveforms('AV',
                                      'ACH',
                                      '',
                                      'BHE',
                                      start,
                                      end,
                                      cleanup=False)
        self.assertGreaterEqual(len(stream), 2)
        summed_length = sum(len(tr) for tr in stream)
        self.assertTrue(summed_length in (50, 51))
        self.assertGreaterEqual(stream[0].stats.starttime, start - delta)
        self.assertLessEqual(stream[0].stats.starttime, start + delta)
        self.assertGreaterEqual(stream[-1].stats.endtime, end - delta)
        self.assertLessEqual(stream[-1].stats.endtime, end + delta)
        for trace in stream:
            self.assertEqual(trace.stats.network, 'AV')
            self.assertEqual(trace.stats.station, 'ACH')
            self.assertEqual(trace.stats.location, '')
            self.assertEqual(trace.stats.channel, 'BHE')
        # example 3 -- component wildcarded with '?'
        stream = client.get_waveforms('AV', 'ACH', '', 'BH?', start, end)
        self.assertEqual(len(stream), 3)
        for trace in stream:
            self.assertTrue(len(trace) in (50, 51))
            self.assertGreaterEqual(trace.stats.starttime, start - delta)
            self.assertLessEqual(trace.stats.starttime, start + delta)
            self.assertGreaterEqual(trace.stats.endtime, end - delta)
            self.assertLessEqual(trace.stats.endtime, end + delta)
            self.assertEqual(trace.stats.network, 'AV')
            self.assertEqual(trace.stats.station, 'ACH')
            self.assertEqual(trace.stats.location, '')
        self.assertEqual(stream[0].stats.channel, 'BHZ')
        self.assertEqual(stream[1].stats.channel, 'BHN')
        self.assertEqual(stream[2].stats.channel, 'BHE')

    @skip_on_network_error
    def test_save_waveform(self):
        """
        Tests save_waveforms method.
        """
        # initialize client
        client = self.client
        start = UTCDateTime() - 3600
        end = start + 1.0
        with NamedTemporaryFile() as tf:
            testfile = tf.name
            # 1 channel, cleanup (using SLIST to avoid dependencies)
            client.save_waveforms(testfile,
                                  'AV',
                                  'ACH',
                                  '',
                                  'BHE',
                                  start,
                                  end,
                                  format="SLIST")
            stream = read(testfile)
        self.assertEqual(len(stream), 1)
        delta = stream[0].stats.delta
        trace = stream[0]
        self.assertEqual(len(trace), 51)
        self.assertGreaterEqual(trace.stats.starttime, start - delta)
        self.assertLessEqual(trace.stats.starttime, start + delta)
        self.assertGreaterEqual(trace.stats.endtime, end - delta)
        self.assertLessEqual(trace.stats.endtime, end + delta)
        self.assertEqual(trace.stats.network, 'AV')
        self.assertEqual(trace.stats.station, 'ACH')
        self.assertEqual(trace.stats.location, '')
        self.assertEqual(trace.stats.channel, 'BHE')

    @skip_on_network_error
    def test_availability(self):
        data = self.client.get_availability()
        seeds = ["%s.%s.%s.%s" % (d[0], d[1], d[2], d[3]) for d in data]
        self.assertIn('AV.ACH.--.BHZ', seeds)
예제 #25
0
파일: second.py 프로젝트: wc83/analysis

import obspy
from obspy import read
import numpy as np
from numpy import genfromtxt
import matplotlib.pyplot as plt
from obspy import Stream
from obspy import UTCDateTime
from obspy.clients.earthworm import Client


cha = 'HHZ' # CHANNEL
net = 'Z4'  # 
loc = ''    # location, it depends mostly of which network you are in. 
client = Client('138.253.113.19', 16022) # ip, port - ip's 138.253.113.19 or 138.253.112.23

def second(sta,last_p,cat1):
    
    
    arrival1=last_p
    arrival2=cat1
    print("arrival1",arrival1)
    
    t1 = UTCDateTime(arrival1)-30 #the format is year:day_of_the_year:month
    t2 = t1 + 120
    st1= Stream()
    st1 = client.get_waveforms(net, sta, '', cha, t1 , t2)
    st1.detrend(type='linear')
    st1.detrend(type='demean')
    peak1=max(st1[0].data)
예제 #26
0
 def ew_client(self):
     """Return the earthworn client."""
     ew_client = Client("pubavo1.wr.usgs.gov", 16022, timeout=30.0)
     return ew_client
예제 #27
0
#!/usr/bin/python3

# ObsPy code to get data from Earthworm waveserver on BBShark+RPi
# 2020-Dec-23 J.Beale

from obspy.clients.earthworm import Client
import obspy
from scipy.io import savemat   # for export to Matlab format file
import sys            # for writing file
import numpy as np    # for writing
# ------------------------------------------------------------------

hours = 2  # how many hours of data to export into CSV file
calibration = 1.0   # multiply data by this scale factor

client = Client("192.168.1.227", 16022) # IP and port of EW server
response = client.get_availability('*', '*', channel='EHZ')
print(response)
  
tStart = response[0][4]      # date/time of beginning of data record
tEnd = response[0][5]        # date/time of end of data record
StationName = response[0][1] # eg. 'SHARK'

dur = 60*60*hours  # 60 seconds * 60 minutes * hours

winEnd = tEnd  # fixed end time
winStart = tEnd - dur

print("Requesting " + str(winStart) + " - " + str(winEnd))

startStr = str(winStart)
예제 #28
0
 def setUp(self):
     # Monkey patch: set lower default precision of all UTCDateTime objects
     UTCDateTime.DEFAULT_PRECISION = 4
     self.client = Client("pubavo1.wr.usgs.gov", 16022, timeout=30.0)
예제 #29
0
def stacked_LBz_eq(fmi, fma):
    import numpy as np
    import obspy
    from obspy.core import read
    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream
    import matplotlib.pyplot as plt
    #%%

    seisb = Stream()
    stream1 = seisb.copy()
    stream2 = stream1.copy()
    stream3 = stream1.copy()
    stream4 = stream1.copy()
    stream5 = stream1.copy()
    stream6 = stream1.copy()
    stream7 = stream1.copy()
    stream1b = stream1.copy()
    stream2b = stream1.copy()
    stream3b = stream1.copy()
    stream4b = stream1.copy()
    stream5b = stream1.copy()
    stream6b = stream1.copy()
    stream7b = stream1.copy()

    year1 = 2014
    month1 = 11
    day1 = 24
    hour1 = 0
    minute1 = 0
    second1 = 0
    fmin = fmi
    fmax = fma
    #%% LB01
    sta = 'LB01'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(0, 13, 1):
        if x == 0:
            M = [[1, 57, 18], [8, 30, 14], [18, 42, 56], [18, 59, 57]]
        if x == 1:
            M = [[9, 16, 51], [11, 24, 10], [13, 12, 8]]
        if x == 2:
            M = [[3, 52, 28], [5, 14, 22], [6, 1, 32], [8, 13, 8], [9, 47, 48],
                 [19, 15, 43]]
        if x == 3:
            M = [[6, 50, 47], [8, 4, 14]]
        if x == 4:
            M = [[4, 26, 17]]
        if x == 5:
            M = [[7, 56, 44]]
        if x == 6:
            M = [[12, 47, 4]]
        if x == 7:
            M = [[6, 4, 52], [8, 37, 49], [12, 17, 49], [18, 24, 26]]
        if x == 8:
            M = [[9, 45, 57], [12, 4, 40]]
        if x == 9:
            M = [[0, 4, 49], [10, 34, 41]]
        if x == 10:
            M = [[6, 5, 25], [12, 34, 16], [14, 53, 20], [20, 3, 4]]
        if x == 11:
            M = [[19, 58, 46]]
        if x == 12:
            M = [[8, 59, 48], [14, 25, 20]]

        for i in range(0, len(M), 1):

            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
            t2 = t1 + 90
            seis1 = Stream()
            seis1 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis1[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc1 = seis1[0].slice(starttime=t1 + 10, endtime=t2 - 10)
            trc1.detrend(type='demean')
            trc1.detrend(type='linear')
            stream1.append(trc1)
    #        trc.plot(type='relative',color='b')

    for x in range(0, len(stream1)):
        trc = stream1[x].normalize()
        stream1b.append(trc)

    stack_norm1 = np.sum([abs(trc.data) for trc in stream1b], axis=0)
    stack_norm1 = stack_norm1 / len(stream1b)

    #    plt.figure(1)
    #    plt.plot(stack_norm1,color='r')
    #    plt.title('LB01 stacked earthquake waveform')

    #%% LB02
    sta = 'LB02'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(0, 13, 1):
        if x == 0:
            M = [[1, 57, 18], [8, 30, 14], [18, 42, 55], [18, 59, 58]]
        if x == 1:
            M = [[10, 28, 22]]
        if x == 2:
            M = [[3, 52, 28], [5, 14, 21], [6, 1, 31], [8, 13, 8], [9, 47, 48],
                 [19, 15, 42]]
        if x == 3:
            M = [[6, 50, 47], [12, 23, 45]]
        if x == 4:
            M = [[4, 26, 15]]
        if x == 5:
            M = [[7, 56, 44]]
        if x == 6:
            M = [[12, 47, 2], [12, 55, 0]]
        if x == 7:
            M = [[8, 37, 46], [12, 17, 47]]
        if x == 8:
            M = [[9, 46, 3], [12, 4, 40]]
        if x == 9:
            M = [[0, 4, 49], [10, 34, 41]]
        if x == 10:
            M = [[14, 53, 22], [20, 3, 2]]
        if x == 11:
            M = [[19, 58, 46]]
        if x == 12:
            M = [[8, 59, 48], [14, 25, 20]]

        for i in range(0, len(M), 1):

            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
            t2 = t1 + 90
            seis2 = Stream()
            seis2 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis2[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc2 = seis2[0].slice(starttime=t1 + 10, endtime=t2 - 10)
            trc2.detrend(type='demean')
            trc2.detrend(type='linear')
            stream2.append(trc2)
    #        trc.plot(type='relative',color='b')

    for x in range(0, len(stream2)):
        trc = stream2[x].normalize()
        stream2b.append(trc)

    stack_norm2 = np.sum([abs(trc.data) for trc in stream2b], axis=0)
    stack_norm2 = stack_norm2 / len(stream2b)

    #    plt.figure(2)
    #    plt.plot(stack_norm2,color='r')
    #    plt.title('LB02 stacked earthquake waveform')

    #%% LB03
    sta = 'LB03'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(1, 13, 1):

        if x == 1:
            M = [[5, 6, 46], [9, 16, 52], [11, 24, 10], [13, 12, 9]]
        if x == 2:
            M = [[3, 52, 29], [5, 14, 23], [6, 1, 32], [8, 13, 8], [9, 47, 50],
                 [20, 48, 28]]
        if x == 3:
            M = [[16, 42, 43]]
        if x == 4:
            M = [[8, 56, 14]]
        if x == 5:
            M = [[7, 56, 44], [11, 29, 27], [18, 29, 3]]
        if x == 6:
            M = [[12, 47, 4], [12, 55, 2], [15, 37, 52]]
        if x == 7:
            M = [[8, 37, 49], [12, 17, 49], [18, 24, 26], [22, 52, 27]]
        if x == 8:
            M = [[9, 45, 58]]
        if x == 9:
            M = [[0, 4, 49], [10, 34, 41]]
        if x == 10:
            M = [[12, 34, 17], [14, 53, 22], [19, 29, 32], [20, 3, 4]]
        if x == 11:
            M = [[14, 30, 51], [19, 58, 46]]
        if x == 12:
            M = [[14, 25, 20]]

        for i in range(0, len(M), 1):

            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
            t2 = t1 + 90
            seis3 = Stream()
            seis3 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis3[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc3 = seis3[0].slice(starttime=t1 + 10, endtime=t2 - 10)
            trc3.detrend(type='demean')
            trc3.detrend(type='linear')
            stream3.append(trc3)
    #        trc.plot(type='relative',color='b')

    for x in range(0, len(stream3)):
        trc = stream3[x].normalize()
        stream3b.append(trc)

    stack_norm3 = np.sum([abs(trc.data) for trc in stream3b], axis=0)
    stack_norm3 = stack_norm3 / len(stream3b)

    #    plt.figure(3)
    #    plt.plot(stack_norm3,color='r')
    #    plt.title('LB03 stacked earthquake waveform')

    #%% LB04
    sta = 'LB04'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(1, 13, 1):

        if x == 1:
            M = [[9, 16, 51], [11, 24, 10], [13, 12, 8]]
        if x == 2:
            M = [[3, 52, 28], [5, 14, 22], [6, 1, 32], [8, 13, 8], [9, 47, 48],
                 [19, 15, 43]]
        if x == 3:
            M = [[6, 50, 47], [8, 4, 14]]
        if x == 4:
            M = []
        if x == 5:
            M = [[7, 56, 44]]
        if x == 6:
            M = [[12, 47, 4]]
        if x == 7:
            M = [[6, 4, 52], [8, 37, 49], [12, 17, 49], [18, 24, 26]]
        if x == 8:
            M = [[9, 45, 57], [12, 4, 40]]
        if x == 9:
            M = [[0, 4, 49]]
        if x == 10:
            M = [[6, 5, 25], [12, 34, 16], [14, 53, 22], [20, 3, 4]]
        if x == 11:
            M = [[19, 58, 46]]
        if x == 12:
            M = [[8, 59, 48], [14, 25, 20]]

        for i in range(0, len(M), 1):

            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
            t2 = t1 + 90
            seis4 = Stream()
            seis4 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis4[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc4 = seis4[0].slice(starttime=t1 + 10, endtime=t2 - 10)
            trc4.detrend(type='demean')
            trc4.detrend(type='linear')
            stream4.append(trc4)
    #        trc.plot(type='relative',color='b')

    for x in range(0, len(stream4)):
        trc = stream4[x].normalize()
        stream4b.append(trc)

    stack_norm4 = np.sum([abs(trc.data) for trc in stream4b], axis=0)
    stack_norm4 = stack_norm4 / len(stream4b)

    #    plt.figure(4)
    #    plt.plot(stack_norm4,color='r')
    #    plt.title('LB04 stacked earthquake waveform')

    #%% LB05
    sta = 'LB05'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year1, month1, day1, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    for x in range(2, 12, 1):
        if x == 2:
            M = [[3, 52, 27], [5, 14, 21], [8, 13, 8], [9, 47, 48],
                 [19, 15, 43], [20, 48, 29]]
        if x == 3:
            M = [[6, 50, 47]]
        if x == 4:
            M = [[8, 56, 15]]
        if x == 5:
            M = [[7, 56, 44]]
        if x == 6:
            M = [[12, 47, 3], [12, 55, 0], [15, 37, 52]]
        if x == 7:
            M = [[6, 4, 52], [8, 37, 50], [12, 17, 49], [18, 24, 26]]
        if x == 8:
            M = [[9, 45, 58]]
        if x == 9:
            M = [[0, 4, 50], [10, 34, 41]]
        if x == 10:
            M = [[6, 5, 25], [12, 34, 17], [14, 53, 22], [20, 3, 4]]
        if x == 11:
            M = [[14, 30, 53]]

        for i in range(0, len(M), 1):

            # input time and length of waveform
            h = M[i][0]
            m = M[i][1]
            s = M[i][2]

            #
            t1 = t0 + x * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
            t2 = t1 + 90
            seis5 = Stream()
            seis5 = client.get_waveforms(net, sta, '', cha, t1, t2)

            seis5[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
            trc5 = seis5[0].slice(starttime=t1 + 10, endtime=t2 - 10)
            trc5.detrend(type='demean')
            trc5.detrend(type='linear')
            stream5.append(trc5)
    #        trc.plot(type='relative',color='b')

    for x in range(0, len(stream5)):
        trc = stream5[x].normalize()
        stream5b.append(trc)

    stack_norm5 = np.sum([abs(trc.data) for trc in stream5b], axis=0)
    stack_norm5 = stack_norm5 / len(stream5b)
    #    plt.figure(5)
    #    plt.plot(stack_norm5,color='r')
    #    plt.title('LB05 stacked earthquake waveform')

    #%% LB06
    sta = 'LB06'  # STATION LB02
    cha = 'HHZ'  # CHANNEL - Vertical
    net = 'Z4'  # Santiaguito volcano
    loc = ''  # location, it depends mostly of which network you are in.
    year2 = 2016
    month2 = 6
    day2 = 25

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    t0 = UTCDateTime(year2, month2, day2, hour1, minute1,
                     second1)  #the format is year:day_of_the_year:month

    M = [[2, 28, 10, 0], [10, 23, 54, 2], [21, 43, 19, 2], [1, 18, 53, 4],
         [2, 5, 33, 4], [7, 17, 47, 5], [5, 42, 56, 6], [4, 10, 58, 7],
         [3, 46, 17, 8], [3, 58, 1, 8], [18, 45, 34, 8], [1, 48, 56, 10],
         [7, 36, 19, 12], [8, 26, 4, 12], [2, 32, 32, 14], [18, 30, 4, 15],
         [9, 12, 43, 16], [7, 19, 45, 27], [2, 58, 47, 30]]

    for i in range(0, len(M), 1):

        # input time and length of waveform
        h = M[i][0]
        m = M[i][1]
        s = M[i][2]
        d = M[i][3]
        #
        t1 = t0 + d * 24 * 60 * 60 + h * 60 * 60 + m * 60 + s - 20
        t2 = t1 + 90
        seis6 = Stream()
        seis6 = client.get_waveforms(net, sta, '', cha, t1, t2)

        seis6[0].filter("bandpass", freqmin=fmin, freqmax=fmax)
        trc6 = seis6[0].slice(starttime=t1 + 10, endtime=t2 - 10)
        trc6.detrend(type='demean')
        trc6.detrend(type='linear')
        stream6.append(trc6)
    #        trc6.plot(type='relative',color='b')

    for x in range(0, len(stream6)):
        trc = stream6[x].normalize()
        stream6b.append(trc)

    stack_norm6 = np.sum([abs(trc.data) for trc in stream6b], axis=0)
    stack_norm6 = stack_norm6 / len(stream6b)
    #    plt.figure(6)
    #    plt.plot(stack_norm6,color='r')
    #    plt.title('LB06 stacked earthquake waveform')

    #%% LB07
    #    sta = 'LB07' # STATION LB02
    #    cha = 'HHZ' # CHANNEL - Vertical
    #    net = 'Z4'  # Santiaguito volcano
    #    loc = ''    # location, it depends mostly of which network you are in.
    #
    #    client = Client('138.253.113.19', 16022) # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t0 = UTCDateTime(year2, month2, day2, hour1, minute1, second1) #the format is year:day_of_the_year:month
    #
    #
    #    M=[[21,43,20,2],[1,18,53,4],[5,42,57,6],[4,10,58,7],
    #       [18,45,31,8],[2,58,50,30]]#,[2,5,32,4],[18,30,4,15],[2,32,37,14]]
    #
    #    for i in range(0,len(M),1):
    #
    #        # input time and length of waveform
    #        h=M[i][0]
    #        m=M[i][1]
    #        s=M[i][2]
    #        d=M[i][3]
    #        #
    #        t1 = t0 + d*24*60*60 + h*60*60 + m*60 + s  -50
    #        t2 = t1 +90
    #        seis7 = Stream()
    #        seis7 = client.get_waveforms(net, sta, '', cha, t1 , t2)
    #
    #        seis7[0].filter("bandpass", freqmin=fmin,freqmax=fmax)
    #        trc7 = seis7[0].slice(starttime = t1 + 30  , endtime= t2 - 10)
    #        trc7.detrend(type='demean')
    #        trc7.detrend(type='linear')
    #        stream7.append(trc7)
    #    #    trc7.plot(type='relative',color='b')
    #
    #    for x in range(0,len(stream7)):
    #        trc=stream7[x].normalize()
    #        stream7b.append(trc)
    #
    #
    #    stack_norm7 = np.sum([abs(trc.data) for trc in stream7b], axis=0)
    #    stack_norm7 = stack_norm7/len(stream7b)
    ##    plt.figure(7)
    ##    plt.plot(stack_norm7,color='r')
    ##    plt.title('LB07 stacked earthquake waveform')
    #%%
    return (stack_norm1, stack_norm2, stack_norm3, stack_norm4, stack_norm5,
            stack_norm6)  #,stack_norm7)
예제 #30
0
import scipy.signal as sgn
import matplotlib.pyplot as plt 
import matplotlib.mlab as mlab
from scipy import integrate
from obspy.clients.earthworm import Client
from obspy import UTCDateTime
from obspy.signal.trigger import trigger_onset
#from scipy.signal import welch
from obspy import Stream

# STATION, CHANNEL (DDF --> 400 Hz), NETWWORK AND LOCATION CODES 
sta = 'LB01' # STATION 
cha = 'HHZ' # CHANNEL
net = 'Z4'  # 
loc = ''    # location, it depends mostly of which network you are in. 
client = Client('138.253.112.23', 16022) # ip, port - ip's 138.253.113.19 or 138.253.112.23

t15 = UTCDateTime(2015, 7, 1, 10, 56, 30) #the format is year:day_of_the_year:month
t25 = t15 + 65
st5 = Stream()
st5 = client.get_waveforms(net, sta, '', cha, t15 , t25)
st5.detrend(type='linear')
st5.detrend(type='demean')
st5.filter(type='bandpass',freqmin=1, freqmax=10)
tr5=st5[0].slice(starttime=t15, endtime=t25)
st_c5 = calibrate1(tr5)
print('1/10')

t16 = UTCDateTime(2015, 6, 25, 15, 44, 8) #the format is year:day_of_the_year:month
t26 = t16 + 65
st6 = Stream()
예제 #31
0
def event_mag(t1, a):

    import numpy as np
    from obspy.clients.earthworm import Client
    from obspy import UTCDateTime
    from obspy import Stream
    #%%

    magnitudes = np.zeros(shape=(a, 1))

    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LB01'  # STATION
    cha = 'HHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[0] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LB02'  # STATION
    cha = 'HHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[1] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LB03'  # STATION
    cha = 'HHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[2] = peak2peak

    #%%
    #    NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LB04'  # STATION
    cha = 'HHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[3] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LB05'  # STATION
    cha = 'HHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[4] = peak2peak

    #%%
    #    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    #    sta = 'LB06' # STATION
    #    cha = 'HHZ' # CHANNEL
    #    net = 'Z4'  #
    #
    #    client = Client('138.253.113.19', 16022) # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    #    t2 = t1 + 60*2
    #    st = Stream()
    #    st = client.get_waveforms(net, sta, '', cha, t1-20 , t2)
    #
    #    st.detrend(type='linear')
    #    st.detrend(type='demean')
    #    st.filter(type='bandpass',freqmin=0.25, freqmax=10)
    #    tr=st[0].slice(starttime=t1-20, endtime=t2)
    #    st_c = calibrate1(tr)
    #
    #    peak2peak=max(st_c[0].data)- min(st_c[0].data)
    #    magnitudes[5]=peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS01'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[5] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS02'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[6] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS03'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[7] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS04'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[8] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS05'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[9] = peak2peak

    #%%
    #NEED TO BE CAREFUL FOR INACTIVE STATIONS
    sta = 'LS06'  # STATION
    cha = 'EHZ'  # CHANNEL
    net = 'Z4'  #

    client = Client('138.253.113.19',
                    16022)  # ip, port - ip's 138.253.113.19 or 138.253.112.23
    #    t1 = UTCDateTime(2014, 12, 3, 2, 43, 0) #the format is year:day_of_the_year:month
    t2 = t1 + 60 * 2
    st = Stream()
    st = client.get_waveforms(net, sta, '', cha, t1 - 20, t2)

    st.detrend(type='linear')
    st.detrend(type='demean')
    st.filter(type='bandpass', freqmin=0.25, freqmax=10)
    tr = st[0].slice(starttime=t1 - 20, endtime=t2)
    st_c = calibrate1(tr)

    peak2peak = max(st_c[0].data) - min(st_c[0].data)
    magnitudes[10] = peak2peak

    return (magnitudes)
예제 #32
0
#
# exemplos ObsPy
# https://docs.obspy.org/tutorial/code_snippets/utc_date_time.html#initialization
#
# http://moho.iag.usp.br/rq/
# https://www.facebook.com/sismoUSP/reviews/
# https://www.seiscomp3.org/doc/applications/seedlink.html
#
from obspy.clients.earthworm import Client

client = Client("pubavo1.wr.usgs.gov", 16022)
response = client.get_availability('AV', 'ACH', channel='EHE')
#seismic
A = 1
rhoE = 2500
cE = 2000

consts = 2 * pi * rhoE * cE * (1 / A)

#acoustic
rhoA = 1  #air density (kg/m3) - may need changing slightly
cA = 330  #sound speed (m/s)
norm_P = 0  # 8*1E4 #normal air_pressure (N/m2)

consta = (2 * pi) / (rhoA * cA)

# ip, port - ip's 138.253.113.19 or 138.253.112.23
client = Client('138.253.113.19', 16022)

#%% Infrasound Station Distances

r_FV01 = 7865
r_FV02 = 6965
r_FV03 = 4593
r_FV04 = 2606
r_FV08 = 8017
r_FV11 = 9253

r_VF05 = 9308
r_VF04 = 5762
r_VF01 = 8041
r_VF06 = 7866
r_VF03 = 1088