UCBerkeleySETI / blimpy

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

Waterfall from existing data array + header dict combo currently broken (`setup_freqs()` missing) #264

Closed Sofysicist closed 2 years ago

Sofysicist commented 2 years ago

I was trying to use the header_dict + data_array method for creating a Waterfall object, and it looks like it refers to a function that is no longer in the waterfall.py file (_self.setup_freqs()). This functionality would be useful (for me, and hopefully others!) if it was brought back, because I'd like to identify RFI-heavy channels with AOFLAGGER, modify the blimpy data array, and visualize the modified array with blimpy plotting tools.

https://github.com/UCBerkeleySETI/blimpy/blob/18a81317920d4ffb239760b06301ff632ae38044/blimpy/waterfall.py#L116

Any help tracking down that original function would be appreciated - I can't seem to find it anywhere else in the repo at a glance

texadactyl commented 2 years ago

@Sofysicist

I went all the way back to blimpy version 1.3.4 (earliest release) i.e. https://github.com/UCBerkeleySETI/blimpy/tree/1.3.4 The last commit for version 1.3.4 was on Nov 29, 2018.

The _setup_freqs function referenced in the Waterfall object is an inherited function from a "Filterbank" object defined in an obsolete filterbank.py source file. When the latter was scheduled for obsolesence as part of a large reorganisation, several of its functions were moved to waterfall.py and elsewhere. It appears that _setup_freqs was left out somehow. And, it might have been left out because it didn't match what the reference in Waterfall needed (guessing). If so, that code in Waterfall should have been removed.

The current Waterfall instantiation (__init__) could use some additional diagnostic code.

So, the desired function seems to be to instantiate a new Waterfall object given a metadata (header) dict object and a complete data matrix as opposed to getting this from a file. This should be new code that is equivalent to the "if filename" section preceding it. Agree?

texadactyl commented 2 years ago

Anyone reading this issue should not be distracted by the _setup_freqs function that is defined in the Reader object of the blimpy/io/base_reader.py source file. Unfortunately, blimpy has some function names that are repeated at multiple levels and perform different functions.

texadactyl commented 2 years ago

@Sofysicist My question about this issue still needs resolution. I want to make sure that (a) I interpreted your request correctly and (b) this proposed capability is still of interest.

Sofysicist commented 2 years ago

Agree with your definition of the desired function here, thanks. I actually just ran into a need for this functionality again (making a waterfall object from an existing data array and header dictionary), so it is definitely still-of-interest!

texadactyl commented 2 years ago

@Sofysicist

I was thinking about a simple interface to produce a blimpy Waterfall object. Inspiration came from https://github.com/UCBerkeleySETI/turboseti_stream/blob/main/turboseti_stream/doppler_finder.py, the Gnu Radio project of Summer 2021.

However, on second thought, we will go with a single Waterfall class with the existing parameters (simpler). I'll make it work with the supplied data matrix and metadata (header dict).

What are you planning to do with the Waterfall object? Plot? Save it to an .h5 file or .fil file?

texadactyl commented 2 years ago

@Sofysicist Ready for testing: blimpy 2.1.1.

texadactyl commented 2 years ago

@Sofysicist Reminder that blimpy 2.1.3 is ready for testing.