UCBerkeleySETI/turbo_seti

plot_event.py tries to plot even when no data has been loaded

Closed this issue · 1 comments

Describe the bug

This is related to UCBerkeleySETI/blimpy#171 .

When plot_candidate_events() is called for a "heavy" file (data size exceeds 1 GB), the make_waterfall_plots() Waterfall instantiations need to be amended to use an appropriate max_load parameter. This can be computed from the file size.

To Reproduce

Steps to reproduce the behavior:

  1. Run plot_event_pipeline() where the data in one of the h5 files in the list exceeds 1 GB.
  2. See error as described in blimpy issue 171.

Expected behavior

No crashes. Data plotted!

My approach:

  • Calculate the max_load parameter required for the specified H5 or Filterbank file.
  • Use max_load in Waterfall instantiation requests.
  • When done with Waterfall objects and grab_data() output (2 arrays), delete them and call Python 3 garbage collection for immediate disposal.

The max_load calculation needs to consider that blimpy makes an internal copy of the data array. So, here is the calculation:

def calc_max_load(arg_path):
    r''' Calculate the max_load parameter value for a subsequent Waterfall instantiation.
    
    Algorithm:
        * A = file size.
        * B = data array size (blimpy currently makes a 2nd copy of the data array)
        * Return ceil(A + B in GB)
    '''
    wf = bl.Waterfall(arg_path, load_data=False)
    data_size = float(wf.header['nchans'] * wf.n_ints_in_file * wf.header['nbits']) / 8.0
    ngbytes = (float(getsize(arg_path)) + data_size) / 1e9
    max_load = np.ceil(ngbytes)
    print('plot_event calc_max_load: max_load={} is required for {}'.format(max_load, arg_path))
    return max_load