obspy.core.stream.Stream.sort
- Stream.sort(keys=['network', 'station', 'location', 'channel', 'starttime', 'endtime'], reverse=False)[source]
Sort the traces in the Stream object.
The traces will be sorted according to the keys list. It will be sorted by the first item first, then by the second and so on. It will always be sorted from low to high and from A to Z.
- Parameters
keys (list, optional) – List containing the values according to which the traces will be sorted. They will be sorted by the first item first and then by the second item and so on. Always available items: ‘network’, ‘station’, ‘channel’, ‘location’, ‘starttime’, ‘endtime’, ‘sampling_rate’, ‘npts’, ‘dataquality’ Defaults to [‘network’, ‘station’, ‘location’, ‘channel’, ‘starttime’, ‘endtime’].
reverse (bool) – Reverts sorting order to descending.
Example
>>> from obspy import read >>> st = read() >>> print(st) 3 Trace(s) in Stream: BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples >>> st.sort() <...Stream object at 0x...> >>> print(st) 3 Trace(s) in Stream: BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples