jenndrei / BayHunter

McMC transdimensional Bayesian inversion of surface wave dispersion and receiver functions
https://jenndrei.github.io/BayHunter
GNU General Public License v3.0
103 stars 43 forks source link

Bug in synthetic dispersion curve save_data() method #10

Open dylanmikesell opened 3 years ago

dylanmikesell commented 3 years ago

We have been using BayHunter for a near-surface study (<100m). We have been using the built-in routine to SynthObs.return_swddata() to compute synthetic dispersion curves for the mean and median models. With one of our data so far, we have run into a tricky little bug. For the mean Vs model, we can compute synthetic curve with no problem; however, we get an error with the median model. This occurs for the Love wave. The model is a thin fast layer over a halfspace. The error is strange because it does not exist on a mac, but does occur on our linux cluster.

$ python write_npy2csv.py 
mean
dict_keys(['rdispph', 'rdispgr', 'ldispph', 'ldispgr'])
ref = rdispph, type(x) = <class 'numpy.ndarray'>
ref = rdispgr, type(x) = <class 'numpy.ndarray'>
ref = ldispph, type(x) = <class 'numpy.ndarray'>
ref = ldispgr, type(x) = <class 'numpy.ndarray'>
median
dict_keys(['rdispph', 'rdispgr', 'ldispph', 'ldispgr'])
ref = rdispph, type(x) = <class 'numpy.ndarray'>
ref = rdispgr, type(x) = <class 'numpy.ndarray'>
ref = ldispph, type(x) = <class 'numpy.float64'>
Traceback (most recent call last):
  File "write_npy2csv.py", line 120, in <module>
    extract_data(depth_int, syn_per, basepath, plot=True)
  File "write_npy2csv.py", line 57, in extract_data
    SynthObs.save_data(syn_disp, outfile=disp_file)
  File "/home/dylanmikesell/anaconda3/lib/python3.7/site-packages/BayHunter/SynthObs.py", line 116, in save_data
    if len(x) > 0: # check if targets exist
TypeError: object of type 'numpy.float64' has no len()

You can see in the last print statement that the ldispph in save_data() is all of a sudden a float64 rather than an ndarray. This does not happen on the mac...type(x) remains an ndarray for this model.

Are there any ideas of what could cause this behavior?