Skip to content

megaplot.py fails with numpy 2

Attempting to run megaplot.py in an environment with numpy 2 causes an error [ref]:

Traceback (most recent call last):
  File "/builds/computing/conda/envs/igwn-py311-testing/bin/megaplot.py", line 2666, in <module>
    axwinner = get_axes(jobName, postDir, ifoList, mod, time, RUN_FLAGS)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/computing/conda/envs/igwn-py311-testing/bin/megaplot.py", line 276, in get_axes
    snr_t = snrfunctime(median_waveform)
                        ^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'median_waveform' where it is not associated with a value

This is because the get_waveform function is failing, but that failure is being ignored. The getwaveformfunction is failing because it is trying to usenumpy.recfromtxt` which was removed in 2.0.0.

I think this code needs to be updated to use numpy.genfromtxt instead.