From 0fb8883d198ac6d57ac9a6dde3f2a6ed32084731 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 23 Mar 2022 14:26:43 +0100 Subject: [PATCH] Add normalisation of diffractograms (default: True= --- beamtime/xrd/io.py | 4 ++++ beamtime/xrd/plot.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 16991a2..fc05654 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -300,6 +300,10 @@ def read_data(data, options={}, index=0): diffractogram, wavelength = read_xy(data=data, options=options, index=index) + if options['normalise']: + diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max() + + diffractogram = translate_wavelengths(data=diffractogram, wavelength=wavelength) return diffractogram, wavelength diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 173da03..d196f2c 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -19,7 +19,7 @@ def plot_diffractogram(data, options={}): data (dict): Must include path = string to diffractogram data, and plot_kind = (recx, beamline, image)''' # Update options - required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', + required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params'] default_options = { @@ -28,6 +28,7 @@ def plot_diffractogram(data, options={}): 'ylabel': 'Intensity', 'xlabel': '2theta', 'xunit': 'deg', 'yunit': 'a.u.', 'xlim': None, 'ylim': None, + 'normalise': True, 'line': True, # whether or not to plot diffractogram as a line plot 'scatter': False, # whether or not to plot individual data points 'reflections_plot': False, # whether to plot reflections as a plot @@ -55,9 +56,12 @@ def plot_diffractogram(data, options={}): for index in range(len(data['path'])): diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index) + data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength + + else: if not isinstance(data['diffractogram'], list): data['diffractogram'] = [data['diffractogram']]