GeoNet / help

An issues repo for technical help questions.
6 stars 3 forks source link

Different response for "response" and "channel" levels for FDSN station service #45

Closed calum-chamberlain closed 5 years ago

calum-chamberlain commented 6 years ago

Requesting station information using the obspy FDSN client results in the expected response for level=channel, but returns all channels for all time with level=response.

Consider:

from obspy import UTCDateTime
from obspy.clients.fdsn import Client

client = Client("GEONET")
inv = client.get_stations(
    network="NZ", station="RPZ", location="10", channel="HHZ",
    starttime=UTCDateTime(2010, 8, 20), 
    endtime=UTCDateTime(2010, 8, 21), level='channel')
assert len(inv[0][0].channels) == 1
# Passes
inv = client.get_stations(
    network="NZ", station="RPZ", location="10", channel="HHZ",
    starttime=UTCDateTime(2010, 8, 20), 
    endtime=UTCDateTime(2010, 8, 21), level='response')
assert len(inv[0][0].channels) == 1

The second assert Fails because four channels are returned, which extend beyond the period requested.

nbalfour commented 6 years ago

Thanks for drawing our attention to this.

I have checked using the URL query, such as: https://service.geonet.org.nz/fdsnws/station/1/query?network=NZ&station=RPZ&location=10&channel=HHZ&starttime=2010-08-20T00:00:00.000&endtime=2010-08-21T00:00:00.0000&level=response

And the query above returned all time periods for the channel, like you said it did with obspy. It should only return the response that is valid for the time period requested.

I will ask one of the team to look into this issue and if there was a reason it was implemented this way. If not, we will correct it so that it only returns the response or responses valid for the time period requested.

calum-chamberlain commented 6 years ago

:tada: Thanks @nbalfour. Just in case anyone stumbles across this and needs a work around, Inventory objects have a .select() method, so you can get rid of extraneous information if you need to:

from obspy import UTCDateTime
from obspy.clients.fdsn import Client

client = Client("GEONET")
inv = client.get_stations(
    network="NZ", station="RPZ", location="10", channel="HHZ",
    starttime=UTCDateTime(2010, 8, 20), 
    endtime=UTCDateTime(2010, 8, 21), level='response')
inv = inv.select(starttime=UTCDateTime(2010, 8, 20), endtime=UTCDateTime(2010, 8, 21))
salichon commented 6 years ago

thanks for this ! I had to have a work around using obspy (creating an array of responses) to select the right time periods ... the "starttime/endtime" naming was not helping to understand.