Ejemplo n.º 1
0
 def test_peak_reference_indices_group(self):
     indices = sp.spectra_peak_indices(self.spectra, 0.5)
     flat_indices = np.hstack(indices)
     groups = sp.index_groups(flat_indices, 1)
     print(groups)
     reference_indices = sp.peak_reference_indices_group(groups[0])
     print(reference_indices)
Ejemplo n.º 2
0
 def test_realign_indices(self):
     indices = sp.spectra_peak_indices(self.spectra, 0.5)
     s = sp.realign_indices(self.spectra, indices)
     x = np.unique([i[0][0] for i in s])
     sum_before = sp.spectra_sum(self.spectra)
     sum_after = sp.spectra_sum(s)
     nptest.assert_equal(x[0], self.spectra[0][0][18])
Ejemplo n.º 3
0
    def test_width_peak_indices(self):
        indices = sp.spectra_peak_indices(self.spectra, 0.5)
        flat_indices = list(np.hstack(indices))
        flat_indices += [18 for i in range(10)]

        reference_indices = sp.peak_reference_indices(flat_indices)
        indices_to_width = sp.width_peak_indices(reference_indices,
                                                 flat_indices)
        nptest.assert_equal(indices_to_width[18], 3.0)
Ejemplo n.º 4
0
def plot_peak_selected(spectra, realigned_spectra):
    spectra_max_before = sp.spectra_max(spectra)
    #spectra_max_after = sp.spectra_max(realigned_spectra)
    indices_spectra_max = sp.peak_indices(spectra_max_before, prominence)

    full_indices = sp.spectra_peak_indices(spectra, prominence)
    small_indices = sp.peak_reference_indices_groups(full_indices)

    print(len(small_indices), " ", len(indices_spectra_max))

    print(len(realigned_spectra[0][0]))
    plt.plot(spectra[0][0], spectra_max_before, realigned_spectra[0][0], np.array(spectra_max_before)[small_indices], ".")
    plt.show()
Ejemplo n.º 5
0
 def test_index_groups(self):
     indices = sp.spectra_peak_indices(self.spectra, 0.5)
     flat_indices = np.hstack(indices)
     groups = sp.index_groups(flat_indices, 1)
     print(groups)
Ejemplo n.º 6
0
 def test_peak_reference_indices(self):
     indices = sp.spectra_peak_indices(self.spectra, 0.5)
     flat_indices = list(np.hstack(indices))
     flat_indices += [18 for i in range(10)]
     reference_indices = sp.peak_reference_indices(flat_indices)
     nptest.assert_array_equal(reference_indices, [18])
Ejemplo n.º 7
0
 def test_spectra_peak_indices(self):
     indices = sp.spectra_peak_indices(self.spectra, 0.5)
     flat_indices = np.hstack(indices)
     unique = np.unique(flat_indices)
     nptest.assert_array_equal(unique, [16, 18, 20])