Can Stream.slide be disordered?

Dear obspy experts,

I wonder if the slide windows of obspy.core.stream.Stream.slide can be randomly output?Normally it will follow the time order:

I tried the python module random.shuffle and it didn’t work.

Cheers

Ming

Hi Ming,

currently not and I’m not sure such a feature would be generically useful enough to justify inclusion into ObsPy.

Given how short the slide() method actually is, you could just make a copy of it and add a shuffle() call after the windows have been retrieved:

Also note that the slide() method internally uses slice() which only creates views on the existing data and thus they barely uses any memory. You could therefore just get all the windows and shuffle afterwards, e.g.

windows = [tr for tr in st.slide(…)]

random.shuffle(windows)

for windowed_st in windows: …

Cheers!

Lion

Hi Lion,

Thank you for the detailed answer,it perfectly works for my situation!

Cheers
Ming