d-chambers / Detex

A Python package for subspace detection and waveform similarity clustering
Other
32 stars 6 forks source link

_attachResponse function of getdata raises HTTPError when used with "uuss" setting #28

Open d-chambers opened 8 years ago

d-chambers commented 8 years ago

This happens because the chan parameter passed to _attachResponse is a list of channels. The obspy FDSN get_stations function, however, requires a string that may use wildcards. A quick solution is to loop over the channels and add the inventories to an empty inventory like so:

def _attachResponse(fet, st, start, end, net, sta, loc, chan):
    """
    Function to attach response from inventory or client
    """
    if not fet.removeResponse or fet.inventory is None:
        return st
    if isinstance(fet.inventory, obspy.station.inventory.Inventory):
        st.attach_response(fet.inventory)
    else:
        inv = obspy.station.Inventory([], 'detex')
        for cha in chan:
            inv += fet.inventory.get_stations(starttime=start,
                                          endtime=end,
                                          network=net,
                                          station=sta,
                                          loc=loc,
                                          channel=cha,
                                          level="response")
        st.attach_response(inv)
    return st