# Problem with obspy.core.stream.Stream.rotate

**URL:** <https://discourse.obspy.org/t/problem-with-obspy-core-stream-stream-rotate/838>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [June 12, 2019, 9:46am UTC](https://discourse.obspy.org/t/problem-with-obspy-core-stream-stream-rotate/838 "2019-06-12T09:46:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohammad\_Raeesi](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@Mohammad\_Raeesi](https://discourse.obspy.org/u/Mohammad_Raeesi)\
**Post date:** [June 12, 2019, 9:46am UTC](https://discourse.obspy.org/t/problem-with-obspy-core-stream-stream-rotate/838/1 "2019-06-12T09:46:38Z")

</div>

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](https://docs.obspy.org/_modules/obspy/core/stream.html#Stream.rotate)

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

```

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

```

```python
Regards,

```

```python
Mohammad

```

---

<div class="post-metadata">

**Author:** ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)\
**Post date:** [June 12, 2019, 2:54pm UTC](https://discourse.obspy.org/t/problem-with-obspy-core-stream-stream-rotate/838/2 "2019-06-12T14:54:37Z")

</div>

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)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for tr in st)  
for net, sta, loc in nsl:  
&nbsp;&nbsp;&nbsp;&nbsp;st\_tmp = st.select(network=net, station=sta, location=loc)  
&nbsp;&nbsp;&nbsp;&nbsp;st\_rotated += st\_tmp.rotate(...)

best,  
T
