Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trimming waveforms after fetching from FDSN Client #2298

Merged
merged 5 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ master:
have been deselected due to the default location priorities setting. This
is a pure usability improvement as it has been confusing users
(see #2159).
* make sure that streams fetched via FDSN are properly trimmed to user
requested times if data center serves additional data around the start/end
(see #1887, #2298)
- obspy.io.nordic:
* Add ability to read and write focal mechanisms and moment tensor
information. (see #1924)
Expand Down
1 change: 1 addition & 0 deletions obspy/CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Meschede, Matthias
Michelini, Alberto
Miller, Nathaniel C.
Morgenstern, Bernhard
Murray-Bergquist, Louisa
Nof, Ran Novitsky
Panning, Mark P.
Rapagnani, Giovanni
Expand Down
1 change: 1 addition & 0 deletions obspy/clients/fdsn/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ def get_waveforms(self, network, station, location, channel, starttime,
if attach_response:
self._attach_responses(st)
self._attach_dataselect_url_to_stream(st)
st.trim(starttime, endtime)
return st

def _attach_responses(self, st):
Expand Down
14 changes: 14 additions & 0 deletions obspy/clients/fdsn/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ def test_set_credentials(self):
# queryauth)
self.assertEqual(client.user, user)

def test_trim_stream_after_get_waveform(self):
"""
Tests that stream is properly trimmed to user requested times after
fetching from datacenter, see #1887
"""
c = Client(
service_mappings={'dataselect':
'http://eida.ipgp.fr/fdsnws/dataselect/1'})
starttime = UTCDateTime('2016-11-01T00:00:00')
endtime = UTCDateTime('2016-11-01T00:00:10')
stream = c.get_waveforms('G', 'PEL', '*', 'LHZ', starttime, endtime)
self.assertEqual(starttime, stream[0].stats.starttime)
self.assertEqual(endtime, stream[0].stats.endtime)

def test_service_discovery_iris(self):
"""
Tests the automatic discovery of services with the IRIS endpoint. The
Expand Down