Problem with obspy.core.stream.Stream.rotate

Hi,
It seems to be working properly for the first station in the stream; but, not for the rest. This applies to those rotations that need back-azimuth. The reason is in the following block of “stream.py”:
https://docs.obspy.org/_modules/obspy/core/stream.html#Stream.rotate

 if back_azimuth is None:
            try:
                back_azimuth = self[0].stats.back_azimuth
 

It sets the back-azimuth for all channels in the stream to that of the first channel.

Regards,

Mohammad

I would recommend to just do rotations with Stream objects that only
hold three components for one single instrument.. and it's better to
explicitly provide back_azimuth etc to the rotate method instead of
relying on the "self" lookup magic (we're not really happy about some
magic lookups we put into the code at some point and try to discourage
their use).

st_rotated = Stream()
nsl = set((tr.stats.network, tr.stats.station, tr.stats.location)
          for tr in st)
for net, sta, loc in nsl:
    st_tmp = st.select(network=net, station=sta, location=loc)
    st_rotated += st_tmp.rotate(...)

best,
T