New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reftek mass position channels #2678
Conversation
So, if I understand correctly this actually does two very different things
Otherwise this looks good to me, especially since existing tests pass and you have a test for the new case. todos:
The part about taking into account the number of samples in each packet / empty space at end could be considered a bug fix, I guess. So we could think about putting it into |
Hi Tobias, |
Thanks @MaevaP !
Rebase from the current master and push.... I could have sworn there used to be a button for this @megies ;
Ugh, yes, floats are such a pain. Sometimes decimal comes to the rescue. Not a clean way to solve the printing problem as |
Thank you for the feedback @dsentinel. |
if we wanna be super clean, we could check |
Just the ordering in contributors, and if you're comfortable with that please |
Hi Tobias, |
For git rebase you want to specify the base branch, so e.g. |
…(sampling_rate=0.1Hz and 16 encoding)
…ling_rate is now a float
…ng representations of Reftek object and Packets
…sentations, and changed bytes_ to be static
Update name ordering in contributors file
Co-authored-by: dsentinel <lloyd@passcal.nmt.edu>
add some comments, easier to read code
I took over for the (hopefully) last iteration of changes, since I don't want this to stay dangling for too long, as it's hard to come back to stuff like this after a while. If CI goes green I'd appreciate a final review @dsentinel |
Awesome! Thanks for taking over and addressing that quickly. All these changes make sense and are an improvement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Merge as is, or minor changes.
@@ -314,15 +310,38 @@ def to_stream(self, network="", location="", component_codes=None, | |||
sample_data = _unpack_C0_C2_data(packets_, | |||
encoding) | |||
elif encoding in ('16', '32'): | |||
dtype = {'16': np.int16, '32': np.int32}[encoding] | |||
# rt130 stores in big endian | |||
dtype = {'16': '>i2', '32': '>i4'}[encoding] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
sample_data = sample_data.flatten().view(dtype) | ||
# switch endianness, rt130 stores in big endian | ||
sample_data = sample_data.byteswap() | ||
sample_data = sample_data.view(dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit strange to take a view of a variable that is being overwritten by itself. I think astype
would be cleaner, but there's a chance of a copy, the conditions which are vague from the docs so this is fine with me.
Co-authored-by: dsentinel <lloyd@passcal.nmt.edu>
thanks for the PR @MaevaP good stuff! 🎉 |
@MaevaP if you can be asked, it would be nice to test if it also works if the half-full packet is in the middle of the contiguous packet list. You happen to have real data with a half-full packet that is contiguously followed by some other packets? I noticed in the test, that the half-full packet is at the end, so the test case is lacking a bit |
@megies That's a good point. |
I think it'd be worth it, yes. I'm not using these numpy function on a daily basis, and we are cutting out some parts of a contiguous array and just return a view, so I'm wondering if that cuts it, especially if we run something that is working on the C pointers from numpy afterwards.. or if we need to make a copy after the cutting out middle parts to be safe.. I have things in mind like #192, #193 or #1704 |
What does this PR do?
Reftek mass position channel data are '16' encoded and have a sampling rate of 0.1 Hz.
This PR modifies section of the obspy.io.reftek.core routines that deal with upacking data with '16' and '32' encodings to account for number of samples in each data packet.
This PR also changes the type of EH_PAYLOAD['sampling_rate'] from int to float in the obspy.io.reftek.packet module.
Why was it initiated? Any relevant Issues?
This PR was initiated to provide read support for Reftek 130 mass position channel data.
PR Checklist
master
for new features,maintenance_...
for bug fixesJust remove the space in the following string after the + sign: "+ DOCS"
(e.g.
clients.fdsn,clients.arclink
) after the colon in the following magic string: "+TESTS:"(you can also add "ALL" to just simply run all tests across all modules)
CHANGELOG.txt
.CONTRIBUTORS.txt
.