Skip to content
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

read_header not working with .h5 files #60

Closed
umranhaji opened this issue Oct 11, 2018 · 3 comments
Closed

read_header not working with .h5 files #60

umranhaji opened this issue Oct 11, 2018 · 3 comments

Comments

@umranhaji
Copy link

umranhaji commented Oct 11, 2018

Hi folks,

The older version of blimpy allowed .fil files to have their headers read with the read_header function. Are the .h5 files supposed to be compatible with this function as well? It's not clear from read_header's docstring or from my perusing of the source code for the past several minutes.

I ask because I am getting errors when attempting to use this function on .h5 files. For example, attempting to call read_header on any of the files in bls0:/mnt_bls5/datax3/holding.Lband.692.0001020304050607/ gives me the following error:

/opt/pyve/sci/local/lib/python2.7/site-packages/blimpy/sigproc.pyc in read_header(filename, return_idxs)
    230 
    231         # Check this is a blimpy file
--> 232         keyword, value, idx = read_next_header_keyword(fh)
    233 
    234         try:

/opt/pyve/sci/local/lib/python2.7/site-packages/blimpy/sigproc.pyc in read_next_header_keyword(fh)
    193         return keyword, 0, fh.tell()
    194     else:
--> 195         dtype = header_keyword_types[keyword]
    196         #print dtype
    197         idx = fh.tell()

KeyError: '\r\n\x1a\n\x00\x00\x00\x00\x00\x08\x08\x00\x04\x00\x10\x00'
@telegraphic
Copy link
Contributor

Hey @umranhaji -- h5 files are read with an external library called h5py. You would read the header as:

h = h5py.File(filename)
header = h['data'].attrs.items()

Everything within sigproc.py is solely for reading sigproc-standard filterbanks.

We could / (should?) theoretically provide a high-level read_header() function that worked on both h5 and fil files.

@umranhaji
Copy link
Author

Thanks @telegraphic! And yes, I think a universal blimpy function to read headers would be convenient and appreciated in the future, even if just a combined wrapper around the sigproc and h5py functions.

@telegraphic
Copy link
Contributor

(moved discussion to a new issue labeled as 'enhancement'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants