Rotate function

Dear all,

I am struggling with the rotate function of ObsPy.

I have a Stream with 3 Traces - one for each channel. The channels are labeleld HHZ, HH2 and HH3:

3 Trace(s) in Stream:
Z3.A333A.00.HH2 | 2017-12-12T07:46:39.165000Z - 2017-12-12T07:46:41.155000Z | 100.0 Hz, 200 samples
Z3.A333A.00.HH3 | 2017-12-12T07:46:39.165000Z - 2017-12-12T07:46:41.155000Z | 100.0 Hz, 200 samples
Z3.A333A.00.HHZ | 2017-12-12T07:46:39.165000Z - 2017-12-12T07:46:41.155000Z | 100.0 Hz, 200 samples

Channels are 2+3 instead of N+E because the sensor is not pointing to the North. Now I want to rotate this Stream such that I actually do get ZNE data. I have the inventory file with the correct orientation specified. Still, I cannot get my data rotated.

If I use only

stream.rotate(method=’->ZNE’, inventory=inv)
or
stream._rotate_to_zne(inv)

it doesn’t do anything. No error message either. Certainly the data is not rotated. I figured I should indicate the components, since my channels are not Z12 or 123. So I tried specifying the components:

First of all I now wonder if the order of the channels matter and if they relate to the order of Traces in the Stream? Anyways, whatever order I chose, I end up with an error message:

stream.rotate(method=’->ZNE’, inventory=inv, components=‘Z23’)
or
stream._rotate_to_zne(inv, components=‘23Z’)

-> IndexError: list index out of range

The error occurs in this part of the function code:

to be used in rotation

3294 st = self.select(network=network, station=station, location=location)
-> 3295 st = (st.select(channel=channels[0]) + st.select(channel=channels[1]) +
3296 st.select(channel=channels[2]))
3297 # remove the original unrotated traces from the stream

This makes me wonder if there is maybe a bug in the function and that rearranging the Traces doesn’t work correctly? Or do I mess it up by not setting the right channel order?

Any help is much appreciated.

Thank you very much,
Florian

Dear Florian,

this code snipped works for me… a bit clumsy but it works

sz1 ist the 3 component stream…

sz1.reverse()
for tr in sz1:
for channel in inv[0].stations[0].channels:
if tr.stats.channel == channel.code:
tr.stats.align = AttribDict(dict(azimuth=channel.azimuth,
dip=channel.dip))
print tr.stats.align
break

z,n,e = rotate2zne(sz1[0].data,sz1[0].stats.align.azimuth,sz1[0].stats.align.dip,
sz1[1].data,sz1[1].stats.align.azimuth,sz1[1].stats.align.dip,
sz1[2].data,sz1[2].stats.align.azimuth,sz1[2].stats.align.dip)

sz1[0].data = z
sz1[0].stats.channel = “HHZ”
sz1[1].data = n
sz1[1].stats.channel = “HHN”
sz1[2].data = e
sz1[2].stats.channel = “HHE”

Best Jo

Hi Florian,

what you did should work, I think:

stream.rotate(method='->ZNE', inventory=inv, components='Z23')

Ordering of Traces should not matter at all.

So if that doesn't work, please open an issue with a self-contained
example (including the data to reproduce the issue).

cheers,
T

Hi Florian,

we stumbled over this topic again, actually it turns out that the call
was not as expected internally, "components" is expected to be a
list/tuple of sets of component codes to combine during rotation, so the
appropriate call would be:

stream.rotate(method='->ZNE', inventory=inv, components=['Z23'])

Maybe we should internally catch this special case of a single set of
component codes..

cheers,
T