Loading sails/modal.py +31 −0 Original line number Diff line number Diff line Loading @@ -862,3 +862,34 @@ def get_cluster_average(clusters, vals): out[..., c] = vals[..., clusters == c].mean(axis=-1) return out def find_pole_pairs(pole_inds, mode_indices): """Find pole pairs within a subset of the poles. Useful for recombining poles into pairs after model-reduction or thresholding. """ # Make sure that we track the modes as pairs of poles where necessary thresh_modes = [] thresh_modes_extracted = [] seen_inds = [] idx = 0 for pole in pole_inds: if pole in seen_inds: continue foundmode = None for mode in mode_indices: if pole in mode: foundmode = mode break if foundmode is None: raise Exception("Could not find pole") for pole in foundmode: seen_inds.append(pole) thresh_modes_extracted.append(idx) idx += 1 thresh_modes.append(foundmode) return thresh_modes Loading
sails/modal.py +31 −0 Original line number Diff line number Diff line Loading @@ -862,3 +862,34 @@ def get_cluster_average(clusters, vals): out[..., c] = vals[..., clusters == c].mean(axis=-1) return out def find_pole_pairs(pole_inds, mode_indices): """Find pole pairs within a subset of the poles. Useful for recombining poles into pairs after model-reduction or thresholding. """ # Make sure that we track the modes as pairs of poles where necessary thresh_modes = [] thresh_modes_extracted = [] seen_inds = [] idx = 0 for pole in pole_inds: if pole in seen_inds: continue foundmode = None for mode in mode_indices: if pole in mode: foundmode = mode break if foundmode is None: raise Exception("Could not find pole") for pole in foundmode: seen_inds.append(pole) thresh_modes_extracted.append(idx) idx += 1 thresh_modes.append(foundmode) return thresh_modes