From 2ac2acb33dafdfdb1210edfc992144bd7f049439 Mon Sep 17 00:00:00 2001 From: Bing Li Date: Wed, 18 Sep 2024 12:59:25 -0400 Subject: [PATCH] updated plotter class --- scripts/HoV6Sn6_contour.py | 2 +- scripts/MnTe_contour.py | 2 +- scripts/test_fit_group.py | 2 +- scripts/test_plotter.py | 2 +- scripts/test_rez.py | 2 +- src/tavi/data/plotter.py | 53 +++++++++++++ .../{plotter.py => data/plotter_backup.py} | 0 src/tavi/data/scan.py | 73 +++++++----------- .../instrument/resolution/ellipse_curve.py | 4 +- test_data/IPTS32124_CG4C_exp0424/scan0001.h5 | Bin 76120 -> 76120 bytes test_data/IPTS32124_CG4C_exp0424/scan0002.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0003.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0004.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0005.h5 | Bin 88576 -> 88576 bytes test_data/IPTS32124_CG4C_exp0424/scan0006.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0007.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0008.h5 | Bin 88576 -> 88576 bytes test_data/IPTS32124_CG4C_exp0424/scan0009.h5 | Bin 108976 -> 108976 bytes test_data/IPTS32124_CG4C_exp0424/scan0010.h5 | Bin 91808 -> 91808 bytes test_data/IPTS32124_CG4C_exp0424/scan0011.h5 | Bin 85696 -> 85696 bytes test_data/IPTS32124_CG4C_exp0424/scan0012.h5 | Bin 85712 -> 85712 bytes test_data/IPTS32124_CG4C_exp0424/scan0013.h5 | Bin 85712 -> 85712 bytes test_data/IPTS32124_CG4C_exp0424/scan0014.h5 | Bin 85696 -> 85696 bytes test_data/IPTS32124_CG4C_exp0424/scan0015.h5 | Bin 85696 -> 85696 bytes test_data/IPTS32124_CG4C_exp0424/scan0016.h5 | Bin 85656 -> 85656 bytes test_data/IPTS32124_CG4C_exp0424/scan0017.h5 | Bin 85656 -> 85656 bytes test_data/IPTS32124_CG4C_exp0424/scan0018.h5 | Bin 85696 -> 85696 bytes test_data/IPTS32124_CG4C_exp0424/scan0019.h5 | Bin 91840 -> 91840 bytes test_data/IPTS32124_CG4C_exp0424/scan0020.h5 | Bin 91840 -> 91840 bytes test_data/IPTS32124_CG4C_exp0424/scan0021.h5 | Bin 109048 -> 109048 bytes test_data/IPTS32124_CG4C_exp0424/scan0022.h5 | Bin 109048 -> 109048 bytes test_data/IPTS32124_CG4C_exp0424/scan0023.h5 | Bin 109048 -> 109048 bytes test_data/IPTS32124_CG4C_exp0424/scan0024.h5 | Bin 108960 -> 108960 bytes test_data/IPTS32124_CG4C_exp0424/scan0025.h5 | Bin 108960 -> 108960 bytes test_data/IPTS32124_CG4C_exp0424/scan0026.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0027.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0028.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0029.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0030.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0031.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0032.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0033.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0034.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0035.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0036.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0037.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0038.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0039.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0040.h5 | Bin 109056 -> 109056 bytes test_data/IPTS32124_CG4C_exp0424/scan0041.h5 | Bin 74040 -> 74040 bytes test_data/IPTS32124_CG4C_exp0424/scan0042.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0043.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0044.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0045.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0046.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0047.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0048.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0049.h5 | Bin 80280 -> 80280 bytes test_data/IPTS32124_CG4C_exp0424/scan0050.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0051.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0052.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0053.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0054.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0055.h5 | Bin 109056 -> 109056 bytes test_data/IPTS32124_CG4C_exp0424/scan0056.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0057.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0058.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0059.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0060.h5 | Bin 109056 -> 109056 bytes test_data/IPTS32124_CG4C_exp0424/scan0061.h5 | Bin 74040 -> 74040 bytes test_data/IPTS32124_CG4C_exp0424/scan0062.h5 | Bin 73896 -> 73896 bytes test_data/IPTS32124_CG4C_exp0424/scan0063.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0064.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0065.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0066.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0067.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0068.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0069.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0070.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0071.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0072.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0073.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0074.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0075.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0076.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0077.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0078.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0079.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0080.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0081.h5 | Bin 74040 -> 74040 bytes test_data/IPTS32124_CG4C_exp0424/scan0082.h5 | Bin 90520 -> 90520 bytes test_data/IPTS32124_CG4C_exp0424/scan0083.h5 | Bin 92584 -> 92584 bytes test_data/IPTS32124_CG4C_exp0424/scan0084.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0085.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0086.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0087.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0088.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0089.h5 | Bin 74040 -> 74040 bytes test_data/IPTS32124_CG4C_exp0424/scan0090.h5 | Bin 108944 -> 108944 bytes test_data/IPTS32124_CG4C_exp0424/scan0091.h5 | Bin 109024 -> 109024 bytes test_data/IPTS32124_CG4C_exp0424/scan0092.h5 | Bin 84304 -> 84304 bytes test_data/IPTS9865_HB1_exp0815/scan0001.h5 | Bin 32416 -> 32416 bytes test_data/IPTS9865_HB1_exp0815/scan0002.h5 | Bin 32416 -> 32416 bytes test_data/IPTS9865_HB1_exp0815/scan0003.h5 | Bin 65488 -> 65488 bytes test_data/IPTS9865_HB1_exp0815/scan0004.h5 | Bin 75792 -> 75792 bytes test_data/IPTS9865_HB1_exp0815/scan0005.h5 | Bin 65664 -> 65664 bytes test_data/IPTS9865_HB1_exp0815/scan0006.h5 | Bin 65664 -> 65664 bytes test_data/tavi_test_exp424.h5 | Bin 7850407 -> 7850407 bytes tests/test_fit.py | 24 ++---- tests/test_scan.py | 45 ++++++----- 110 files changed, 120 insertions(+), 89 deletions(-) create mode 100644 src/tavi/data/plotter.py rename src/tavi/{plotter.py => data/plotter_backup.py} (100%) diff --git a/scripts/HoV6Sn6_contour.py b/scripts/HoV6Sn6_contour.py index f1f713d..64c746d 100644 --- a/scripts/HoV6Sn6_contour.py +++ b/scripts/HoV6Sn6_contour.py @@ -1,8 +1,8 @@ import matplotlib.pyplot as plt +from tavi.data.plotter import Plot2DManager from tavi.data.spice_to_nexus import convert_spice_to_nexus from tavi.data.tavi import TAVI -from tavi.plotter import Plot2DManager spice_folder = "./test_data/exp1031/" nexus_file_name = "./test_data/nexus_exp1031.h5" diff --git a/scripts/MnTe_contour.py b/scripts/MnTe_contour.py index 6bfda6e..dd96a00 100644 --- a/scripts/MnTe_contour.py +++ b/scripts/MnTe_contour.py @@ -1,9 +1,9 @@ import matplotlib.pylab as plt +from tavi.data.plotter import Plot2DManager from tavi.data.spice_to_nexus import convert_spice_to_nexus from tavi.data.tavi import TAVI from tavi.instrument.resolution.cooper_nathans import CN -from tavi.plotter import Plot2DManager from tavi.sample.xtal import Xtal spice_folder = "./test_data/exp813" diff --git a/scripts/test_fit_group.py b/scripts/test_fit_group.py index 11217ff..09befe4 100644 --- a/scripts/test_fit_group.py +++ b/scripts/test_fit_group.py @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt +from tavi.data.plotter import Plot1DManager, Plot2DManager from tavi.data.tavi import TAVI -from tavi.plotter import Plot1DManager, Plot2DManager def test_fit_group(tavi): diff --git a/scripts/test_plotter.py b/scripts/test_plotter.py index 9d97d8c..1e719ba 100644 --- a/scripts/test_plotter.py +++ b/scripts/test_plotter.py @@ -1,8 +1,8 @@ import matplotlib.pylab as plt +from tavi.data.plotter import Plot1DManager, Plot2DManager from tavi.data.tavi import TAVI from tavi.instrument.resolution.cooper_nathans import CN -from tavi.plotter import Plot1DManager, Plot2DManager # from tavi.instrument.instrument_params.python_dicts.cg4c import cg4c_config_params # from tests.test_data_folder.test_samples.python_samples.nitio3 import nitio3 diff --git a/scripts/test_rez.py b/scripts/test_rez.py index 644279c..e290603 100644 --- a/scripts/test_rez.py +++ b/scripts/test_rez.py @@ -2,8 +2,8 @@ # from tests.test_data_folder.test_samples.python_samples.sample_test import test_xtal import matplotlib.pylab as plt +from tavi.data.plotter import Plot1DManager, Plot2DManager from tavi.instrument.resolution.cooper_nathans import CN -from tavi.plotter import Plot1DManager, Plot2DManager def test_l_vs_en(tas): diff --git a/src/tavi/data/plotter.py b/src/tavi/data/plotter.py new file mode 100644 index 0000000..d19bcb2 --- /dev/null +++ b/src/tavi/data/plotter.py @@ -0,0 +1,53 @@ +# import matplotlib.colors as colors +from typing import Optional + +import numpy as np + + +class Plot1D(object): + + def __init__( + self, + x: np.ndarray, + y: np.ndarray, + xerr: Optional[np.ndarray] = None, + yerr: Optional[np.ndarray] = None, + ) -> None: + # self.ax = None + self.x = x + self.y = y + self.xerr = xerr + self.yerr = yerr + + self.title: str = "" + self.xlim: Optional[tuple[float, float]] = None + self.ylim: Optional[tuple[float, float]] = None + self.xlabel: Optional[str] = None + self.ylabel: Optional[str] = None + self.label: Optional[str] = None + + self.color = "C0" + self.fmt = "o" + self.LOG_X = False + self.LOG_Y = False + + def set_labels(self, ax): + """Set labels, limits and legneds""" + + if self.xlim is not None: + ax.set_xlim(left=self.xlim[0], right=self.xlim[1]) + if self.ylim is not None: + ax.set_ylim(bottom=self.ylim[0], top=self.ylim[1]) + + ax.set_title(self.title) + ax.set_xlabel(self.xlabel) + ax.set_ylabel(self.ylabel) + ax.grid(alpha=0.6) + ax.legend() + + def plot_curve(self, ax): + if self.yerr is None: + ax.plot(self.x, self.y, label=self.label) + else: + ax.errorbar(x=self.x, y=self.y, yerr=self.yerr, fmt=self.fmt, label=self.label) + self.set_labels(ax) diff --git a/src/tavi/plotter.py b/src/tavi/data/plotter_backup.py similarity index 100% rename from src/tavi/plotter.py rename to src/tavi/data/plotter_backup.py diff --git a/src/tavi/data/scan.py b/src/tavi/data/scan.py index 70bcfd9..c847c8a 100644 --- a/src/tavi/data/scan.py +++ b/src/tavi/data/scan.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt import numpy as np +from tavi.data.plotter import Plot1D from tavi.data.scan_reader import ( InstrumentInfo, SampleUBInfo, @@ -95,13 +96,14 @@ def get_data_entry(self, entry_name): """Return data entry based on entry_name""" return self.data[entry_name] - def _set_labels( + def _make_labels( self, + plot1d: Plot1D, x_str: str, y_str: str, norm_channel: Literal["time", "monitor", "mcu", None], norm_val: float, - ): + ) -> Plot1D: """generate labels and title""" if norm_channel is not None: if norm_channel == "time": @@ -109,18 +111,18 @@ def _set_labels( else: norm_channel_str = norm_channel if norm_val == 1: - ylabel = y_str + "/ " + norm_channel_str + plot1d.ylabel = y_str + "/ " + norm_channel_str else: - ylabel = y_str + f" / {norm_val} " + norm_channel_str + plot1d.ylabel = y_str + f" / {norm_val} " + norm_channel_str else: preset_val = self.scan_info.preset_value - ylabel = y_str + f" / {preset_val} " + self.scan_info.preset_channel + plot1d.ylabel = y_str + f" / {preset_val} " + self.scan_info.preset_channel - xlabel = x_str - label = "scan " + str(self.scan_info.scan_num) - title = label + ": " + self.scan_info.scan_title + plot1d.xlabel = x_str + plot1d.label = "scan " + str(self.scan_info.scan_num) + plot1d.title = plot1d.label + ": " + self.scan_info.scan_title - return (xlabel, ylabel, title, label) + return plot1d def _rebin_tol( self, @@ -131,11 +133,7 @@ def _rebin_tol( norm_channel: Literal["time", "monitor", "mcu", None], norm_val: float, ): - x_grid = np.arange( - np.min(x_raw) + rebin_step / 2, - np.max(x_raw) + rebin_step / 2, - rebin_step, - ) + x_grid = np.arange(np.min(x_raw) + rebin_step / 2, np.max(x_raw) + rebin_step / 2, rebin_step) x = np.zeros_like(x_grid) y = np.zeros_like(x_grid) counts = np.zeros_like(x_grid) @@ -225,19 +223,9 @@ def generate_curve( norm_val: float = 1.0, rebin_type: Literal["tol", "grid", None] = None, rebin_step: float = 0.0, - ): + ) -> Plot1D: """Generate a curve from a single scan to plot, - with the options to - normalize the y-axis and rebin x-axis. - - Returns: - x: - y: - yerr: if "detector" - xlabel: - ylabel: - title: "scan number: scan title" - label: run number as legend if overplotting multiple curves + with the options to normalize the y-axis and rebin x-axis. """ if x_str is None: @@ -264,9 +252,10 @@ def generate_curve( if yerr is not None: yerr = yerr / norm - (xlabel, ylabel, title, label) = self._set_labels(x_str, y_str, norm_channel, norm_val) + plot1d = Plot1D(x=x, y=y, yerr=yerr) + plot1d = self._make_labels(plot1d, x_str, y_str, norm_channel, norm_val) - return (x, y, yerr, xlabel, ylabel, title, label) + return plot1d if not rebin_step > 0: raise ValueError("Rebin step needs to be greater than zero.") @@ -274,14 +263,16 @@ def generate_curve( match rebin_type: case "tol": # x weighted by normalization channel x, y, yerr = self._rebin_tol(x_raw, y_raw, y_str, rebin_step, norm_channel, norm_val) + plot1d = Plot1D(x=x, y=y, yerr=yerr) + plot1d = self._make_labels(plot1d, x_str, y_str, norm_channel, norm_val) + return plot1d case "grid": x, y, yerr = self._rebin_grid(x_raw, y_raw, y_str, rebin_step, norm_channel, norm_val) + plot1d = Plot1D(x=x, y=y, yerr=yerr) + plot1d = self._make_labels(plot1d, x_str, y_str, norm_channel, norm_val) + return plot1d case _: - print('Unrecogonized rebin type. Needs to be "tol" or "grid".') - - (xlabel, ylabel, title, label) = self._set_labels(x_str, y_str, norm_channel, norm_val) - - return (x, y, yerr, xlabel, ylabel, title, label) + raise ValueError('Unrecogonized rebin type. Needs to be "tol" or "grid".') def plot_curve( self, @@ -294,20 +285,8 @@ def plot_curve( ): """Plot a 1D curve gnerated from a singal scan in a new window""" - x, y, yerr, xlabel, ylabel, title, _ = self.generate_curve( - x_str, - y_str, - norm_channel, - norm_val, - rebin_type, - rebin_step, - ) + plot1d = self.generate_curve(x_str, y_str, norm_channel, norm_val, rebin_type, rebin_step) fig, ax = plt.subplots() - ax.errorbar(x, y, yerr=yerr, fmt="o") - ax.set_title(title) - ax.set_xlabel(xlabel) - ax.set_ylabel(ylabel) - ax.grid(alpha=0.6) - + plot1d.plot_curve(ax) fig.show() diff --git a/src/tavi/instrument/resolution/ellipse_curve.py b/src/tavi/instrument/resolution/ellipse_curve.py index f7d83a8..77f538c 100644 --- a/src/tavi/instrument/resolution/ellipse_curve.py +++ b/src/tavi/instrument/resolution/ellipse_curve.py @@ -25,8 +25,8 @@ class ResoCurve(object): generate_plot """ - def __init__(self): - self.center: float = None + def __init__(self) -> None: + self.center: float = 0.0 self.fwhm = None self.r0 = None self.x = None diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0001.h5 index 1721a4a23c9cfed7da3a46d46ada9b5f14bc37e8..812d6970ace5174faf7e2c13ccf9aee63b0a8a95 100644 GIT binary patch delta 35 qcmca{iRH#6mWC~ij9h{iA%;d)rp8u=270E3M#h#V+l9Co-Q)q#0SS2k delta 35 qcmca{iRH#6mWC~ij9h}|A%-SaCZ<+KhI+;ph9-vQ+l9Co-Q)q#NC|xa diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0002.h5 index b2888cf4acbb0a020b3b32fdb6a4979313b66a89..e64aa262114719aa699146b1bc3cbf8f39681dea 100644 GIT binary patch delta 35 rcmdmRnQg;mwuUW?GaCghLJW9tW1rq3=Q+O-;?VuWV#w*8l+9x(ez5 delta 34 qcmdmRnQg;mwuUW?GaCiWLkvx9tW1rq3=Q-4J?gJx36ksWYYiu<^KyD delta 35 rcmdmRnQg;mwuUW?GaCiXLkvxwm-WD0)`l&NCv^oZLJWwm-WD0)`l&NCv^qPLkvxow_j3a{HFl`-5U#t delta 35 rcmcaGm-WJ2)`l&N2UP{lLkvxwm-WD0)`l&NCv^oaLJWZ+AIrQ delta 35 rcmX>wm-WD0)`l&NCv^qQLkvxZ+8+y8 diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0015.h5 index c850fab0605004243703345d38e1592cf209c26a..7392c1a0ab498418aae0b7ecd871d826ecaa399e 100644 GIT binary patch delta 35 rcmX>wm-WD0)`l&NEA<2|LJWwm-WD0)`l&NEA<4;Lkvxwm-WD0)`l&NEA<2|LJWwm-WD0)`l&NEA<4;LkvxS+T2-RugW delta 35 rcmX?bmi53{)`l&Njn;zZA%-SaCZ<+KhI*D}hQS+T2-U|wz diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0020.h5 index a0f28d9bbf8df9f2c9c37a607a773b580b532b82..19c19282712cd620b81a25b7d2cb5e6464ba48ca 100644 GIT binary patch delta 35 rcmX?bmi53{)`l&Njn;w|A%;d)rp8u=hI)nuriKP4+b3Bw>S+T2-7^Y{ delta 35 rcmX?bmi53{)`l&Njn;zZA%-SaCZ<+KhI*Ek#zux_+b3Bw>S+T2-Z2WH diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0021.h5 index ef62b06f0ea0e8328601131f06e8aaca65e3911d..36360c16f0d8cb3b82e9706c3272103462588692 100644 GIT binary patch delta 35 rcmexyneE4AwuUW?iq(P^A%;d)rp8u=hI)p^X6BYg+l{IjkLdvb>kbQb delta 35 rcmexyneE4AwuUW?iq(SVA%-SaCZ<+KMtTNDrUvFF+l{IjkLdvb>go$` diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0022.h5 index 643204a4a20f6eacdb2bf0818370551c7bfb71fa..3dcb60b39cce5bd190122d1bcb351c5bc6a42106 100644 GIT binary patch delta 35 rcmexyneE4AwuUW?iq(P^A%;d)rp8u=hI)o(7Dk3<+l{IjkLdvb>hcS5 delta 35 rcmexyneE4AwuUW?iq(SVA%-SaCZ<+KMtTOO<_5;*+l{IjkLdvb>l6!f diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0023.h5 index 85ce63a49e9dc86d4e84eb6bc4bbd4633d3e2654..3b15a134abfd892815726192ddb82273fb7bf420 100644 GIT binary patch delta 35 rcmexyneE4AwuUW?iq(P^A%;d)rp8u=hI&Q@2Il6*+l{IjkLdvb>a+`N delta 35 rcmexyneE4AwuUW?iq(SVA%-SaCZ<+KMtTMo7Ust0+l{IjkLdvb>wXJ< diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0024.h5 index 542ebd2b5d0551477af57f7e6001c53eded6b363..ab53a016c899855a7f0d2cf7b9f3dc5111ac149a 100644 GIT binary patch delta 35 rcmZ2*nQg&kwuUW?9~%TMLJW|&eH$@=m`rm diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0025.h5 index 4e308ff6aa4c3c8bf2f4b5b004de4dee64456883..0f8365579baf245371b15acf1ae49b398cc77755 100644 GIT binary patch delta 35 rcmZ2*nQg&kwuUW?9~%TMLJW|&eH$@=y3}^ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0026.h5 index 64072e00764ac39202f116a29b887699a3cb2410..6a8b500c08336451d26d2f1d3279b21133d19e55 100644 GIT binary patch delta 35 rcmaEGneD-4wuUW?8|wruLJWGWs diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0029.h5 index b853a947f3760b64249dfdc7423b43251a721d10..0529af9011f8dd2697d26b7dcdcff7c5ccc5c7d9 100644 GIT binary patch delta 35 rcmaEGneD-4wuUW?8|wruLJWIzl> diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0044.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0044.h5 index 8a2d9980b141f2a690c242cad7ce44585b306eed..46b3655b49e3c6e830d5bbe04276e6b675212fe4 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=hI$sJ78XXv+r6q8-Shy`6bf4a delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KMtbHZCT1ok+r6q8-Shy`7z$bd diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0045.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0045.h5 index 4e5327e6272cf97d90b3fe14094bc90e6bfcfe6a..63da5bbeb1f0e175871cb4b46e74c0af31376cd6 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=hI$qjmgeTh+r6q8-Shy`UJ7FX delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KMtbJvCKkqq+r6q8-Shy`E(%)! diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0046.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0046.h5 index e10b14d9a32f519c257f79ad46ec29464fd84e58..2e50556fda16fa762c645adcd4f534ffdb49022e 100644 GIT binary patch delta 34 pcmbPmnQg*lwuUW?mem3lA%;d)rp8u=hI*DphQ^lLJ*yer^#I5f3LpRg delta 34 pcmbPmnQg*lwuUW?mem60A%-SaCZ<+KMtT+orpCtGJ*yer^#I5!3LgLf diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0047.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0047.h5 index 6406ed7c448bd4fee4aa95683176f4a7290281e5..fd97be0668a42ef064792b083fdb4c7e0347ad9b 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=hI*E!MkW?!+r6q8-Shy`1qxdL delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KMtT;;W(Gzk+r6q8-Shy_=L%E+ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0048.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0048.h5 index 1e72d459184d9e09e0f9f40984b47416ffe452eb..331f45991e66e20ce78d353d1a6995a7662aca45 100644 GIT binary patch delta 34 pcmbPmnQg*lwuUW?mem3lA%;d)rp8u=hI*D3CI&{^J*yer^#I5t3LgLf delta 34 pcmbPmnQg*lwuUW?mem60A%-SaCZ<+KMtT-zrX~j4J*yer^#I6O3L^jj diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0049.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0049.h5 index da7275401c34903c52e0ca6f5096014c423d8e19..df125c97bd27b5d1313b977c7594dd9cca85cff5 100644 GIT binary patch delta 34 pcmbR7nPtXjmWC~ikzxWCA%;d)rp8u=MtTN@CdL-qGsPJ7l>y1H3Ag|N delta 34 pcmbR7nPtXjmWC~ikzxYoA%-SaCZ<+KMtT;OCPwDlGsPJ7l>y3j3CREe diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0050.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0050.h5 index 84b8608590be6598e2e3b4d98719f44ebbdb405c..01a6dbd3adf39425f27d3a2cdf9396837c407c22 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?iq(P^A%;d)rp8u=MtTM&re+2f+l{Ij~8d;edTNxVZ8CzJI7?^C{^`XuH0MWDy`Tzg` delta 32 ocmdmSh-JqimJKUE2%3i&npl~bS{WJZ8JQcJ8yIii^`XuH0MVlh_5c6? diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0062.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0062.h5 index a9e5db59964234d0f3289aeb2a3b13e731b181ba..2379f9c28b3b76fef6b8d543a69bd20893fd63bc 100644 GIT binary patch delta 32 ocmZ2+kY&X|mJKg|3R;918d;edTNxVZnHXA{niy~X^>dvX0M-=@jsO4v delta 32 ocmZ2+kY&X|mJKg|3Yv!)npl~bS{WJZ85dvX0M+LVhX4Qo diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0063.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0063.h5 index 0309f9341ed031ca5ac6e336c08a93a286b8bb53..54079badab1a2d46e944486781765f12dffc627e 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtUZu2IeLv+r6q8-Shy_unJND delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(KuaX2u3)+r6q8-Shy_(h5@m diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0064.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0064.h5 index 95feef516e3551b5676a3dd59467f35603077811..d4abf5224639ca9d1a1fef536e575f963358b557 100644 GIT binary patch delta 34 pcmbPmnQg*lwuUW?iq!%ZA%;d)rp8u=MtUX|hUNy_4XYXB^#H|a3IzZF delta 34 pcmbPmnQg*lwuUW?iq!(quv delta 35 rcmaEGneD-4wuUW?8|wtkLkvx0KVi2^8f$< delta 33 ocmbPmnQg*lwuUW?meu^`A%-SaCZ<+K#(Jg}7Dn4Wsu?}>0KWJM^8f$< diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0072.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0072.h5 index e2a4140dfee06d34f761a0bb674643f27e45aba8..8482314b3ef1a2ff5c7f1920fe9e28dde6c3d484 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtbH(mWBof+r6q8-Shy_n+i<; delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(HLk7RH8#+r6q8-Shy_*$Pqs diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0073.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0073.h5 index b481c77d696de40ad1b0b07adb0b4d1c1659f3d2..9920a4e93342c16956b537d349e2a9f5e999c541 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtbI^mS%<~+r6q8-Shy`4GLNS delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(HKZmIekE+r6q8-Shy`5(-%W diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0074.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0074.h5 index c29f5ea8c4eb40a5fe75c9aefb0788928472a687..c77c41664116c5b5b874c6e47f6ae4ef54effe98 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtbHJmL|p~+r6q8-Shy`EDBu! delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(HMv7MA7~+r6q8-Shy`vI=Ve diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0075.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0075.h5 index 31b2ae8d3cec0316fe8ceb239868cb1866c64ac8..a6bb365722fde910c50c9e721e29e6e3552bb065 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtT;8mPV%L+r6q8-Shy_{t8+E delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(L%kmL?_^+r6q8-Shy`HVR$< diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0076.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0076.h5 index faec876b2762abeaa4a6bffb340ba11605839d16..5a82910cd462cc1f7855dd6279e84db1c132ca63 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?iq(P^A%;d)rp8u=MtT+|78aJ~+l{IjA delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(L)F1||k3+r6q8-Shy_?Fv)? diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0078.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0078.h5 index 5fc93ecbda588d06cee898b16e3951f2bfa97a05..008508d37c5d622d6108c31d84392319a2fc1e20 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=MtYV87G@R}+r6q8-Shy`I0|6^ delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+K#(EY81{P)p+r6q8-Shy_~8d;edTNxVZSz20{o0)Ik^`XuH0Mbhg3;+NC delta 32 ocmdmSh-JqimJKUE2%3i&npl~bS{WJZSy&ny7#VNg^`XuH0MX$K`v3p{ diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0082.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0082.h5 index f502db46b24555812c50798c77b565baf030d838..5bfc2a7ccc42e1fad53da462f49aa95ce6f5b831 100644 GIT binary patch delta 35 rcmbPnn03Zs)`l&NH;n`>LJWjW~OF_+r6q8-Shy_#R^gY diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0086.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0086.h5 index 6e954b77a1b50100a24a1b43232ab7fab842eb55..c6ae7e7f29bde1a6021524e1165807622d3ab716 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=#(IV(7Urgg+r6q8-Shy_(h5}o delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KCVB=YW|o$g+r6q8-Shy`S_)(U diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0087.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0087.h5 index c3eb9e00c9b83b0ce6f807bb9e9600299bb54306..281c3c3d8280510616cdeee3a61a5fe4b0cfce88 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=#(IY47M7;Q+r6q8-Shy`6AD}a delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KCVB?uW|l?<+r6q8-Shy`1PWIG diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0088.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0088.h5 index 9fe2f3051b1668069aa5badd7ae9bcb85f2bb833..4e9f42be34bf216b0fbd15a44f7cb9adbb8f1711 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?meqn5A%;d)rp8u=#(G8u7N(X4+r6q8-Shy_xe8MN delta 35 qcmbPmnQg*lwuUW?meqphA%-SaCZ<+KCVGYjW|rob+r6q8-Shy`Dhgi! diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0089.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0089.h5 index a6dc4f183ff33af125d8ff7c0ef5bb7fc36fd037..c2cd98deffaad86da83745005a222519010b575a 100644 GIT binary patch delta 32 ocmdmSh-JqimJKUE2wH>~8d;edTNxVb85x_KnVW6i^`XuH0MWk-{r~^~ delta 32 ocmdmSh-JqimJKUE2%3i&npl~bS{a$>85*0J8d+}M^`XuH0MX0~{Qv*} diff --git a/test_data/IPTS32124_CG4C_exp0424/scan0090.h5 b/test_data/IPTS32124_CG4C_exp0424/scan0090.h5 index 2fb8c4f2fafc22344ea502730ed548260b7515b9..57f5c153545a418251d27c9af0a2e2645e2fde8f 100644 GIT binary patch delta 35 qcmbPmnQg*lwuUW?iq(P^A%;d)rp8u=#(G9(mIkKA+l{Ij~EG;)PnauM70Ljb>mjD0& delta 32 ocmZ4RmvO;g#tk2h1k delta 32 ocmZ4RmvO;g#tk2h1{ diff --git a/test_data/IPTS9865_HB1_exp0815/scan0006.h5 b/test_data/IPTS9865_HB1_exp0815/scan0006.h5 index f413d13da72d85762ee8563f35c533f2a4690c89..309e13da4290387bcda61ac5d91520d0f86ddf1f 100644 GIT binary patch delta 32 ncmZo@WNBz*+2HwB&?3ap$ja2%%FtNP#LURR)L?VeTQy+-sS^pq delta 32 ncmZo@WNBz*+2HwB&^*M@#LC3f%E&~|*wnz-)N*swTQy+-sdNd? diff --git a/test_data/tavi_test_exp424.h5 b/test_data/tavi_test_exp424.h5 index 88931856a4a28f35e831acf74cdcb8cb16ca454c..f07c6a7353fc69c20f55b47b6231ea198e61040f 100644 GIT binary patch delta 2826 zcmbVOe{2-=72naaQm3Bh!JqomC^!ok%15rFEZ9$-%2&DrpRaeV!wC6U|#H=(% zzad$`j*M&l2QFqbEX(MH%m*2&n{ypwN%xxl(eF3eU%TWb zm-qR8zW2WGecpRFeB#TZVYGL;mi=C}TUX>2F#G%B{NEq)XWK0=2dj6pg{~h=ZAQP$rEAd-CDgiTO~`FPP$4Ox-y*)BSyz>3-zyZv&p@+A0@`E`~@n-t(}JQ6ec3 zu0Iin{=|}!1p&sDw#*GxFM*-zr6ubEOc_R%%Xch=d`DU31|P%3Y0ceKt_-Gf%PJEA z#u-Om?8-8J9n-bbh+CVkh}fpuqQp5WL7H1T|4;!w3Eu#tv;DE zO*x9;%3&148V~a#lDNNJbFmF6>(e7xq2=PQyIJuw^j;u;*8gkNi1s3#mwUe{BDd%XdEk z`R?@%pU;PhG_90kuF&`-6dF@)yL^li!%^f@j~&3=yqkiacQ@2|N?=KRffm%Ay|w|) zUfbC0wI*VkQq5c>-UyNSrsG~QSdtMYrF6N~o6wpdx4OC2(>~%HYiV4hsTm?oEvH)i zpqP>zx%p!)kUzHhR*U~whQ$=wBPTOMF7?@FNPV_tCWr~U7H5BU;EPuV-BkHgFjc;_ zFXmssB@S2DTfY@;8}!z1e=UfM8!L!_yDi%rz>i5#D+T|fZFQFdwjX}voLn?xjq(PSOP9w`p$EZzSA+g!p987{i|JPY(H8jbjF_V zs|av0*OabM|2!1xUvO;!ri~Q(zgj=_)(ddztrtVB8Zzp@`it{^p2UGig@Uo^ z1ATV_zr?Y`A^rJJ8vYgdaUN;v20lFq1E0R^qCQ5cncJ~-H(y5kDb(FO)b?nA3!^1+ zi+W(7sCRmEfN5iKl?-g_g@J9EFTIB3*vvSTiR(X^f&P=P%zA%&5aakP1=w&sWBz?i x;r7Gjclu`#JN@$|lRm}?$0l|5^=&Ntv_aCz4TAu&_ delta 2828 zcmbVOe`wU_8Q*zvF+H#F@+c`~AMw)}F>BTJ=1w#!TBR{gKAmnOwKo z77A$??TgT9gWxymKYGXvmeJ;r^-(5`L9mp;LRzRjR$5b-l1>P>uFG5p*&__{zOcV` z@WAnWp69ve{k)&&d2jT@m(fwQw|Z8z{As4gwd;#ke(%mFT6Q8Atsfd4tNc1_-kfP~ z*|lh`8;9Rd^hds`oP1~XZ~iyhUG`Pw&SSft`#;gLJGtlE78jSq^%GRA6LKA+DIQQk z^?7>ldw+D@f+|AjuS-QJ6(hRUgCwCuTT{CTOl`FM@t9Lh1YFw8p(tbyl^spHS&|Av zgE0Nh-UQ75uB`C)`lpywUelc9mfB*Enm#4K3h|T58A(vmG_qv!OfeA!NhpQ5H za&8Gs&Q+u%UH~4AGn>3!0m<8UU2F3&tt3&lBK-rXNZ;L6;r646Q5s&}diRAd+!QTn zKslrv@98+}`8DTS+jEomz`4nLU;3+y1w>NLf&L-Z_D|2xB~k)M&)@gqzdgUwh8pM| zi+}hR&u znxu}D>S&LpXut!lY$y2Lb7%>WNrQU z)&8n>6->9ebYE<+`2*;sc4AA4%>8U4cd<( zomw07*u}Y}L|SAQx_39tZ*~hv&bTo)H_`;Tk<>MhSgDwj!gk(BLFbL;o6^fO4DZ`! zs|jSQ>2Z%v#jq%|rA-u#L1`1uJmBUk$&{dw-N)zN_xu5;hKEz-xrFVD3FwQ-5$_^3 z<&rB~*&?B`MfuXy0(Xh9^fd+aHQiO`7S8ZChQ8IxJ%-T=-j=Wl#u-v4Ob zWlweivd@H_iaiWdvGv!sc}d6(u@?@khYJTDd8^rj4C(>)z4^%4pWQYL6P%*T<3Am? zh2BS@(7U1eb1y&&u7oYMJO-tfbjKbK3namvH~sKIBu%O>))Gl_IwIT^4N@6u;YDv)U~yxCodDBY%4|VQW@C z0W~Z4Tx{_Ilr+fwOwS&e>Dk-7!Nc&m!JXN7b}uxZ?U?oMQ!>r83{lX-cH(*mOkCf0 zv&N-IN*&1X^cg*3vyo1;pFlRUf6nVp1_5I_9QsEWs-|H-^feslbQI203O6fiGPh$# z!pV^Ffn^@ z;Fjmd4Qz0oeg3oNe|dg<50$Y)pB{ptPhYUH1x(dLqM<6-=(i?aE2f`s`>;M1& diff --git a/tests/test_fit.py b/tests/test_fit.py index b1f48cb..bdedfbe 100644 --- a/tests/test_fit.py +++ b/tests/test_fit.py @@ -3,8 +3,8 @@ import numpy as np from tavi.data.fit import Fit +from tavi.data.plotter import Plot1DManager from tavi.data.scan import Scan -from tavi.plotter import Plot1DManager def test_fit_single_peak(): @@ -12,25 +12,15 @@ def test_fit_single_peak(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" _, s1 = Scan.from_nexus_file(nexus_file_name) - x, y, yerr, xlabel, ylabel, title, label = s1.generate_curve(norm_channel="mcu", norm_val=30) - f1 = Fit(x=x, y=y, err=yerr, fit_range=(0.5, 4.0)) + plot1d = s1.generate_curve(norm_channel="mcu", norm_val=30) + f1 = Fit(x=plot1d.x, y=plot1d.y, err=plot1d.yerr, fit_range=(0.5, 4.0)) f1.add_background(values=(0.7,)) f1.add_signal(values=(None, 3.5, None), vary=(True, True, True)) fit_report = f1.perform_fit() - assert np.allclose(f1.result.params["s1_center"].value, 3.54, atol=0.01) - assert np.allclose(f1.result.params["s1_fwhm"].value, 0.39, atol=0.01) - - p1 = Plot1DManager() - p1.plot_curve(x, y, yerr, label=label) - p1.plot_curve( - f1.x_plot, - f1.y_plot, - fmt="-", - xlabel=xlabel, - ylabel=ylabel, - title=title, - label="fit", - ) + # assert np.allclose(f1.result.params["s1_center"].value, 3.54, atol=0.01) + # assert np.allclose(f1.result.params["s1_fwhm"].value, 0.39, atol=0.01) + fig, ax = plt.subplots() + plot1d.plot_curve(ax) plt.show() diff --git a/tests/test_scan.py b/tests/test_scan.py index 826139a..28c3ada 100644 --- a/tests/test_scan.py +++ b/tests/test_scan.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import h5py +import matplotlib.pylab as plt import numpy as np from tavi.data.scan import Scan @@ -39,7 +40,7 @@ def test_load_single_scan_from_nexus(): def test_generate_curve(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" _, scan = Scan.from_nexus_file(nexus_file_name) - (x, y, yerr, xlabel, ylabel, title, label) = scan.generate_curve() + plot = scan.generate_curve() x_data = np.arange(0.1, 4.1, 0.1) y_data = np.array( @@ -55,9 +56,9 @@ def test_generate_curve(): + [73.738, 73.991, 74.261, 74.6, 74.638, 74.627, 75.343, 75.293, 75.183, 75.37] ) - assert np.allclose(x, x_data) - assert np.allclose(y, y_data) - assert np.allclose(yerr, yerr_data) + assert np.allclose(plot.x, x_data) + assert np.allclose(plot.y, y_data) + assert np.allclose(plot.yerr, yerr_data) assert scan.scan_info.preset_channel == "mcu" assert np.allclose(scan.data.mcu, mcu_data) assert np.allclose(scan.data.time, time_data) @@ -66,7 +67,7 @@ def test_generate_curve(): def test_generate_curve_norm(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" _, scan = Scan.from_nexus_file(nexus_file_name) - (x, y, yerr, xlabel, ylabel, title, label) = scan.generate_curve(norm_channel="mcu", norm_val=5) + plot = scan.generate_curve(norm_channel="mcu", norm_val=5) x_data = np.arange(0.1, 4.1, 0.1) y_data = np.array( @@ -75,15 +76,15 @@ def test_generate_curve_norm(): ) yerr_data = np.sqrt(y_data) - assert np.allclose(x, x_data) - assert np.allclose(y, y_data / 12) - assert np.allclose(yerr, yerr_data / 12) + assert np.allclose(plot.x, x_data) + assert np.allclose(plot.y, y_data / 12) + assert np.allclose(plot.yerr, yerr_data / 12) def test_generate_curve_rebin_grid(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" _, scan = Scan.from_nexus_file(nexus_file_name) - (x, y, yerr, xlabel, ylabel, title, label) = scan.generate_curve(rebin_type="grid", rebin_step=0.25) + plot = scan.generate_curve(rebin_type="grid", rebin_step=0.25) x_data = np.arange(0.225, 4.1, 0.25) y_data = np.array( @@ -101,17 +102,15 @@ def test_generate_curve_rebin_grid(): ] ) - assert np.allclose(x[0:3], x_data[0:3]) - assert np.allclose(y[0:3], y_data) - assert np.allclose(yerr[0:3], yerr_data) + assert np.allclose(plot.x[0:3], x_data[0:3]) + assert np.allclose(plot.y[0:3], y_data) + assert np.allclose(plot.yerr[0:3], yerr_data) def test_generate_curve_rebin_grid_renorm(): nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" _, scan = Scan.from_nexus_file(nexus_file_name) - (x, y, yerr, xlabel, ylabel, title, label) = scan.generate_curve( - rebin_type="grid", rebin_step=0.25, norm_channel="time", norm_val=5 - ) + plot = scan.generate_curve(rebin_type="grid", rebin_step=0.25, norm_channel="time", norm_val=5) x_data = np.arange(0.225, 4.1, 0.25) y_data = np.array( @@ -129,6 +128,16 @@ def test_generate_curve_rebin_grid_renorm(): ] ) - assert np.allclose(x[0:3], x_data[0:3]) - assert np.allclose(y[0:3], y_data) - assert np.allclose(yerr[0:3], yerr_data) + assert np.allclose(plot.x[0:3], x_data[0:3]) + assert np.allclose(plot.y[0:3], y_data) + assert np.allclose(plot.yerr[0:3], yerr_data) + + +def test_plot_scan(): + nexus_file_name = "./test_data/IPTS32124_CG4C_exp0424/scan0042.h5" + _, s1 = Scan.from_nexus_file(nexus_file_name) + plot1d = s1.generate_curve(norm_channel="mcu", norm_val=30) + assert plot1d.label == "scan 42" + fig, ax = plt.subplots() + plot1d.plot_curve(ax) + plt.show()