Ejemplo n.º 1
0
def test_reader():
    homedir = os.path.dirname(os.path.abspath(__file__))  # where is this script?
    datadir = os.path.abspath(os.path.join(homedir,'..','data'))
    datafile = os.path.join(datadir,'us2000ahv0_phases.xlsx')
    hdr,dataframe = read_phases(datafile)
    assert hdr['id'] == 'us2000ahv0'
    assert dataframe.iloc[0]['Channel'] == 'GI.HUEH.HHZ.--'

    datafile = os.path.join(datadir,'us2000ahv0_phases.csv')
    hdr,dataframe = read_phases(datafile)
    assert hdr['id'] == 'us2000ahv0'
    assert dataframe.iloc[0]['Channel'] == 'GI.HUEH.HHZ.--'

    try:
        read_phases('foo')
    except FileNotFoundError as fnfe:
        pass

    try:
        fname = os.path.abspath(__file__)
        read_phases(fname)
    except Exception as e:
        assert str(e).find('Filenames with extension') > -1
Ejemplo n.º 2
0
def test_reader():
    homedir = os.path.dirname(
        os.path.abspath(__file__))  # where is this script?
    datadir = os.path.abspath(os.path.join(homedir, '..', 'data'))
    datafile = os.path.join(datadir, 'us2000ahv0_phases.xlsx')
    hdr, dataframe = read_phases(datafile)
    assert hdr['id'] == 'us2000ahv0'
    assert dataframe.iloc[0]['Channel'] == 'GI.HUEH.HHZ.--'

    datafile = os.path.join(datadir, 'us2000ahv0_phases.csv')
    hdr, dataframe = read_phases(datafile)
    assert hdr['id'] == 'us2000ahv0'
    assert dataframe.iloc[0]['Channel'] == 'GI.HUEH.HHZ.--'

    try:
        read_phases('foo')
    except FileNotFoundError:
        pass

    try:
        fname = os.path.abspath(__file__)
        read_phases(fname)
    except Exception as e:
        assert str(e).find('Filenames with extension') > -1
Ejemplo n.º 3
0
def test_reader():
    homedir = os.path.dirname(
        os.path.abspath(__file__))  # where is this script?
    datadir = os.path.abspath(os.path.join(homedir, "..", "data"))
    datafile = os.path.join(datadir, "us2000ahv0_phases.xlsx")
    hdr, dataframe = read_phases(datafile)
    assert hdr["id"] == "us2000ahv0"
    assert dataframe.iloc[0]["Channel"] == "GI.HUEH.HHZ.--"

    datafile = os.path.join(datadir, "us2000ahv0_phases.csv")
    hdr, dataframe = read_phases(datafile)
    assert hdr["id"] == "us2000ahv0"
    assert dataframe.iloc[0]["Channel"] == "GI.HUEH.HHZ.--"

    try:
        read_phases("foo")
    except FileNotFoundError:
        pass

    try:
        fname = os.path.abspath(__file__)
        read_phases(fname)
    except Exception as e:
        assert str(e).find("Filenames with extension") > -1
Ejemplo n.º 4
0
    ev_string = year + month + day + hour + minute + second

    # Load picks for this event
    pick_id = df_event.id[ev_num]
    phase_file = cwd + '/Phase_Data/' + pick_id + '_phases.csv'

    if not os.path.exists(phase_file):
        print('The phase file', phase_file,
              'does not exist. Continuing to next event.')
        print(
            '------------------------------------------------------------------'
        )
        continue

    try:
        events, picks = read_phases(phase_file)
    except pd.errors.EmptyDataError:
        print(
            'Phase file did not have any phase data. Continuing on to the next event.'
        )
        print(
            '------------------------------------------------------------------'
        )
        continue

    bulk = []
    for chan_idx1, chan1 in enumerate(picks.Channel):

        network1, station1, channel1, location1 = channel_split(chan1)

        # Check if we have an S-pick
        bulkrow=(networks[x],stations[x],locations[x],channels[x],t1,t2)
        bulk.append(bulkrow)
#        if cntBulk==9:
#            cntBulk=0
#            st = fdsn_client.get_waveforms_bulk(bulk,attach_response=True,debug=True)
#            print(bulk)
#        else:
#            cntBulk +=1

    # Load picks for this event
    picks_folder = cwd+'/Phase_Data/'
    pick_id = df_event.id[ev_num]
    pick_id=pick_id[0:11]
    pick_id_file = picks_folder + pick_id + "_phases.csv"
    #events,picks=phase_reader(pick_id_file)
    events,picks=read_phases(pick_id_file)
    p_indices = [f for f, s in enumerate(picks.Phase) if 'P' in s]
    s_indices = [f for f, s in enumerate(picks.Phase) if 'S' in s]

    # Get all the waveform for this event from IRIS
    st = fdsn_client.get_waveforms_bulk(bulk,attach_response=True,timeout=120,debug=True)
    # Loop over stations
    for st_num in range(len(st)):
        # Need to save the picks in the right order
        stast=st[st_num].stats.station
        indices = [f for f, s in enumerate(picks.Channel) if stast in s]
        use_ind=set(p_indices) & set(indices)
        use_ind_s=set(s_indices) & set(indices)
        # Skip stations that do not have picks
#        if (not use_ind or not use_ind_s):
        if (not use_ind or not use_ind_s ):