def display(self): """ Display the Chromatogram """ self.constrain_zoom("x") display = Display(self.fig, self.ax) self.ax.clear() # Read the TIC from the tic.dat file in the experiment tarfile intensity_array, tic = self.experiment.tic_data # peak_list = load_peaks(os.path.join(ExprDir, "{}_peaks.dat".format(self.experiment.name))) display.plot_tic(tic, label=self.experiment.name, minutes=True) # display.plot_peaks(filtered_peak_list, "Peaks") # display.do_plotting('TIC and PyMS Detected Peaks') # display.do_plotting(f'{self.experiment.name} TIC') display.do_plotting('') x = [time / 60 for time in tic.time_list] self.ax.set_xlim(left=0, right=max(x)) self.ax.set_ylim(bottom=0) self.ax.set_xlabel("Retention Time") self.ax.set_ylabel("Intensity") self.fig.subplots_adjust(left=0.1, bottom=0.125, top=0.9, right=0.97) # figure.tight_layout() self.canvas.draw() self.setup_ylim_refresher(intensity_array, x)
def test_do_plotting_warning(): test_plot = Display() with pytest.warns(UserWarning) as record: test_plot.do_plotting() # check that only one warning was raised assert len(record) == 1 # check that the message matches assert record[0].message.args[0] == """No plots have been created.
def test_Display(): no_args = Display() assert isinstance(no_args.fig, figure.Figure) assert isinstance(no_args.ax, axes.Axes) fig = plt.figure() fig_arg = Display(fig=fig) assert isinstance(fig_arg.fig, figure.Figure) assert isinstance(fig_arg.ax, axes.Axes) assert fig_arg.fig is fig fig = plt.figure() ax = fig.add_subplot(111) both_args = Display(fig=fig, ax=ax) assert isinstance(both_args.fig, figure.Figure) assert isinstance(both_args.ax, axes.Axes) assert both_args.fig is fig assert both_args.ax is ax for obj in [test_tuple, test_list_strs, test_list_ints, test_string, *test_numbers, test_dict]: with pytest.raises(TypeError): Display(fig=obj) with pytest.raises(TypeError): Display(fig=fig, ax=obj) fig = plt.figure() ax = fig.add_subplot(111) with pytest.raises(TypeError): Display(ax, fig)
def test_do_plotting_warning(): test_plot = Display() with pytest.warns(UserWarning) as record: test_plot.do_plotting() # check that only one warning was raised assert len(record) == 1 # check that the message matches args = record[0].message.args # type: ignore expected = """No plots have been created. Please call a plotting function before calling 'do_plotting()'""" assert args[0] == expected
area = peak_sum_area(im, peak) peak.area = area # print some details UID = peak.UID # height as sum of the intensities of the apexing ions height = sum(peak.get_mass_spectrum().mass_spec.tolist()) print(UID + f", {rt:.2f}, {height:.2f}, {peak.area:.2f}") # TIC from raw data tic = data.get_tic() # baseline correction for TIC tic_bc = tophat(tic, struct="1.5m") # Get Ion Chromatograms for all m/z channels n_mz = len(im.get_mass_list()) ic_list = [] for m in range(n_mz): ic_list.append(im.get_ic_at_index(m)) # Create a new display object, this time plot the ICs # and the TIC, as well as the peak list display = Display() display.plot_tic(tic_bc, 'TIC BC') for ic in ic_list: display.plot_ic(ic) display.plot_peaks(new_peak_list, 'Peaks') display.do_plotting('TIC, and PyMassSpec Detected Peaks') display.show_chart()
def test_plot(): fig = plt.figure() ax = fig.add_subplot(111) test_plot = Display(fig, ax) return test_plot