-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cannot read VDIF streams with non-monotonically increasing frame number #13
Comments
Part of making vdif more robust is in https://github.com/mhvk/baseband/tree/vdif-more-robust But that would not work all that well either, or at least be very inefficient. Better might be to read quite a large number of frames at the same time, and then selecting the right frame number. In particular in my
This gives a multi-D header in which one could do |
Looking at this again, I think the best solution would in fact be to read and reorder the file ourselves (using the raw VDIF writer). It might make sense to just document a work-around. |
For really regularly behaved data, an intermediate file reader that does the reordering on the fly is also possible. |
I also have the same issue, so I thought it would be a good idea to post it here. I have 8 threaded vdif files, whose threads are not ordered. This causes baseband to miscalculate the sample shape of the data. I think how baseband currently calculates the number of threads is that it reads one frame at a time, records the thread number, and stops counting after there is a repeated thread number. For instance, If I do the following: In [1]: from baseband import vdif Now if I check the thread ids by repeatedly using the lines I find that the thread ids are: 1, 3, 5, 7, 1. I do find however that threads 0, 2, 4 and 6 pop up later in the scan. I think the first number of frames are only the odd number scans too. I had to read several thousand frames (~ 3000) before I found an even numbered thread. It could also be that even threads appear early in the file too and I am just very unlucky. |
@IMFardz - could you provide a bit more detail: once the even-numbered threads appear, do they have the frame number? I think the trick would be to just start a loop and print only |
Hmm, so I looped through the file using the following for loop: And I think I got something somewhat interesting. For the first 170 frames, it repeats the pattern 1, 3, 5, 7 as follows: I think my best best bet would separate this vdif file into two different vdif files, one with the even threads and another with the odd threads. That would give me two separate vdif files, each with four threads that have ordered thread ids. Let me know if my conclusion makes sense. |
@IMFardz - interestingly different... I think you could indeed just wrote two files. Alternatively, open the file in two readers, one for odd and one for even, and just collect the right frames and write them out to a new file that is properly ordered. |
@mhvk I tried to write a sample script which describes what you just explained. As far as I can tell, I think it is pretty simple and works fine. I think it could be edited pretty easily to serve similar purposes related to this issue. Let me know if you see any glaring issues with this. Thanks! |
@IMFardz - yes, that looks pretty good! Small comments (not functionally important, but to help understanding): opening the files with 'rb' and 'wb' allows you to avoid using Anyway, I think this would be a good one for adding to the documentation! |
@ishengyang, @pharaofranz: taking this out of e-mails to github so we don't forget. Not completely trivial so when this is addressed depends on how urgent it is. Note that I did merge #12, so the legacy headers now do get recognized properly in master.
A Mark 5B file converted to vdif by using
jive5ab
uses a somewhat peculiar ordering of threads and frames:It would be nice to ensure that the stream reader can read this, perhaps by explicitly telling it that there are 8 threads. A possible issue is that with the above ordering, one cannot
seek
a particular frame number into the raw data file, so this may involve more generally addressing that the data file can have gaps or inconsistent ordering.The text was updated successfully, but these errors were encountered: