From 2deb640b3d489569618c114df19fdce3a6372cc4 Mon Sep 17 00:00:00 2001 From: rasmusthog Date: Tue, 11 Oct 2022 19:57:05 +0200 Subject: [PATCH] Add option to exclude (make region = 0) in diffs --- nafuma/xrd/io.py | 9 +++++++++ nafuma/xrd/plot.py | 1 + 2 files changed, 10 insertions(+) diff --git a/nafuma/xrd/io.py b/nafuma/xrd/io.py index 696699e..f456230 100644 --- a/nafuma/xrd/io.py +++ b/nafuma/xrd/io.py @@ -714,6 +714,15 @@ def read_data(data, options={}, index=0): elif file_extension in['xy', 'xye']: diffractogram, wavelength = read_xy(data=data, options=options, index=index) + + if options['exclude']: + + if not isinstance(options['exclude'], list): + options['exclude'] = [options['exclude']] + + for excl in options['exclude']: + diffractogram['I'].loc[(diffractogram['2th'] > excl[0]) & (diffractogram['2th'] < excl[1])] = 0 + if options['offset'] or options['normalise']: # Make copy of the original intensities before any changes are made through normalisation or offset, to easily revert back if need to update. diff --git a/nafuma/xrd/plot.py b/nafuma/xrd/plot.py index 357cb83..8f6d07c 100644 --- a/nafuma/xrd/plot.py +++ b/nafuma/xrd/plot.py @@ -28,6 +28,7 @@ def plot_diffractogram(data, options={}): 'xunit': '$^{\circ}$', 'yunit': None, 'xlim': None, 'ylim': None, 'normalise': True, + 'exclude': None, 'multiply': 1, # Factor to multiply the normalised data - only used if normalising. 'drawdown': False, 'offset': True,