UCBerkeleySETI / blimpy

Breakthrough Listen I/O Methods for Python
https://blimpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
46 stars 40 forks source link

Add support for filterbank/hdf5 files with names that don't end in .fil or .h5 #26

Closed mattlebofsky closed 5 years ago

mattlebofsky commented 6 years ago

Currently blimpy errors out (in a confusing manner) if the filename doesn't end in .fil or .h5, even if it's a filterbank or hdf5 file. Maybe have a filetype command switch?

telegraphic commented 6 years ago

This should be supported already?

The relevant code in filterbank.py is:

        if filename:
            self.filename = filename
            if HAS_HDF5:
                if h5py.is_hdf5(filename):
                    self.read_hdf5(filename, f_start, f_stop, t_start, t_stop, load_data)
                else:
                    self.read_filterbank(filename, f_start, f_stop, t_start, t_stop, load_data)
            else:
self.read_filterbank(filename, f_start, f_stop, t_start, t_stop, load_data)
telegraphic commented 6 years ago

Ah ok, waterfall won't support this as it has special file readers. I think this is the code that needs a mod: https://github.com/UCBerkeleySETI/blimpy/blob/master/blimpy/file_wrapper.py#L1062

jeenriquez commented 6 years ago

I think this is supported now. Matt could you check?

mattlebofsky commented 6 years ago

If you are doing something basic like, say, watutil, it works. Regardless of the suffix it figures out the file format. However! It's still a little buggy with fil2h5. If you have a filterbank file called "test.blah" and you do:

fil2h5 test.blah

It just overwrites the filterbank file "test.blah" with an hdf5 file called "test.blah." Not expected or correct behavior. I imagine this is due to some incorrect search and replace logic somewhere.

But at least it isn't erroring out!

jeenriquez commented 6 years ago

Great detective work! I think I have fixed, this, could you check again?

mattlebofsky commented 6 years ago

Well.... the fil2h5/h52fil now work.

BUT now watutil doesn't work. Doing something simple like watutil test.fil gives me the error unrecognized arguments: test.fil

jeenriquez commented 6 years ago

Ok, should have fixed this now. Let me know if you agree!

telegraphic commented 5 years ago

Looks like this is resolved, closing :door: