def groupbywtm(waves,
               types,
               modes,
               freqs,
               values,
               dvalues=None,
               keepnans=True):
    """group outputs from dispersion by wave, type, modes

        :param waves:   iterable, "R" or "L", Rayleigh or Love
        :param types:   iterable, "C" or "U", phase or group
        :param modes:   iterable, ints, mode numbers
        :param freqs:   iterable, floats, frequencies, Hz
        :param values:  iterable, floats, velocity values, km/s
        :param dvalues: None or iterable, floats, uncertainties of values, km/s
        :param keepnans: bool, by default the nans are removed from the arrays
                         (this occurs especially for overtones below the cut-off period)
        all arrays must be the same length

    groupbywtm demultiplexes these arrays to produce, for each mode
    w (wave key, scalar), t (type key, scalar), m (mode number, scalar), freqs (array), values (array), dvalues (array)
    """
    freqs = np.array(freqs, float)
    types = np.array(list(types), "|S1")
    waves = np.array(list(waves), "|S1")
    modes = np.array(modes, int)
    assert len(waves) == len(types) == len(modes) == len(freqs)
    if dvalues is not None:
        dvalues = np.array(dvalues, float)
        assert len(waves) == len(dvalues)

    w, t, m = munique(waves, types, modes)
    I = np.lexsort((m, t, w))

    for w, t, m in zip(w[I], t[I], m[I]):
        J = (waves == w) & (types == t) & (modes == m)

        if keepnans:
            K = np.ones(len(values[J]), bool)
        else:
            K = ~np.isnan(values[J])

        L = np.argsort(freqs[J][K])

        if dvalues is None:
            yield w, t, m, freqs[J][K][L], values[J][K][L]
        else:
            yield w, t, m, freqs[J][K][L], values[J][K][L], dvalues[J][K][L]
Exemple #2
0
 def wtm(self):
     for w, t, m in zip(*munique(self.data['WAVE'], self.data['TYPE'], self.data['MODE'])):
         yield w, t, m
Exemple #3
0
 def get_all(self):
     for WAVE, TYPE, FLAG, MODE in \
             zip(*munique(self.data['WAVE'], self.data['TYPE'], self.data['FLAG'], self.data['MODE'])):
         yield self.get(mode=MODE, wave=WAVE, type=TYPE, flag=FLAG)