synthoseis icon indicating copy to clipboard operation
synthoseis copied to clipboard

get_middle_z generates error when xyz_xyz.shape[1] is 0

Open klaas-koster opened this issue 7 months ago • 1 comments

When running the synthoseis-quick-start notebook with the supplied example.json config file, get_middle_z regularly generates an error that random_idx cannot be calculated because xyz_xyz.shape[1] equals 0. The shape of xyz_xyz is (3, 0) when this happens instead of (3, 162) for the faults that do not have a problem.

I haven't yet dug deeper into what causes this situation, but added a check in Faults.py at line 2157 to check for this condition and break out of the loop when it occurs:

                if xyz_xyz.size != 0:
                    random_idx = xyz_xyz[:, np.random.choice(xyz_xyz.shape[1])]
                    print(
                        "   ... Computing fault middle to hang max displacement function"
                    )
                    print("    ... x idx for max displacement  = ", random_idx[0])
                    print("    ... y idx for max displacement  = ", random_idx[1])
                    print("    ... z idx for max displacement  = ", random_idx[2])
                    print(
                        "    ... ellipsoid value  = ",
                        ellipse[random_idx[0], random_idx[1], random_idx[2]],
                    )
                else:
                    print("   ... Break the loop, xyz_xyz.shape[1] = 0")
                    random_idx = []
                    do_it = False
                    break

klaas-koster avatar Jul 10 '24 21:07 klaas-koster