Padding a stream or trace retrieved from waveserver

When I read a stream from a winston waveserver using obspy.clients.earthworm.client.Client.get_waveforms, it sometimes cannot get all the data for the requested time period. The stream is therefore smaller than it would be if all the data was available.

Is there a way to get the stream (or a trace from it) that is padded with NaNs where there is missing data?

You could do something like that, but without knowing the use case, I feel like maybe a different approach in your workflow would still be better.

In principle you would convert the data array to a numpy masked array and then extend it at start or end. Extending it at the end would be pretty simple, since the metadata would not need changing. Extending at the front, you would have to manually set the correct new starttime for the data.

You can get an idea for it looking at the resulting stream from the following example:

st = read()
t = st[0].stats.starttime
st.cutout(t+6, t+14)
st.merge(method=0, fill_value=None)

thanks very much. Sometimes I yearn to go back to FORTRAN! :slight_smile:

Really not sure if you’d find implementing a winston waveserver client in Fortran from scratch a lot of fun… :woozy_face: :rofl: