From 6eb45772d1947aee7b467cdcfc6e7f8551c1f376 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Jul 2022 17:33:38 +0200 Subject: [PATCH] Fix normalisation issues --- nafuma/xanes/calib.py | 8 +++++--- nafuma/xanes/io.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/nafuma/xanes/calib.py b/nafuma/xanes/calib.py index 84ed070..2c8881e 100644 --- a/nafuma/xanes/calib.py +++ b/nafuma/xanes/calib.py @@ -206,7 +206,7 @@ def pre_edge_subtraction(data: dict, options={}): 'show_plots': False, 'save_plots': False, 'save_folder': './', - 'pre_edge_subtraction_store_data': False + 'pre_edge_subtraction_store_data': True } options = aux.update_options(options=options, required_options=required_options, default_options=default_options) @@ -893,8 +893,10 @@ def normalise(data: dict, options={}): #Finding the normalisation constant ยต_0(E_0), by subtracting the value of the pre-edge-line from the value of the post-edge line at e0 for filename in data['path']: e0_ind = data['post_edge_fit_data'].loc[data['post_edge_fit_data']['ZapEnergy'] == find_nearest(data['post_edge_fit_data']['ZapEnergy'], data['e0_diff'][filename])].index.values[0] + #norm = data['post_edge_fit_data'][filename].iloc[find_nearest(data['post_edge_fit_data'][filename], data['e0'][filename])] - normalisation_constant = data['post_edge_fit_data'][filename].iloc[e0_ind] #- data['pre_edge_fit_data'][filename].iloc[e0_ind] + normalisation_constant = data['post_edge_fit_data'][filename].iloc[e0_ind] - data['pre_edge_fit_data'][filename].iloc[e0_ind] + print(normalisation_constant) normalised_df.insert(1, filename, data['xanes_data'][filename] / normalisation_constant) @@ -967,7 +969,7 @@ def flatten(data:dict, options={}): for filename in data['path']: # Subtract 1 from the _normalised_ post edge fit function - fit_function_diff = data['post_edge_fit_data_norm'][filename] - 1 + fit_function_diff = data['post_edge_fit_data_norm'][filename] - 1 - data['pre_edge_fit_data_norm'][filename] # Set all values from edge position and downwards to 0 so that only data above the edge position will be adjusted fit_function_diff.loc[flattened_df['ZapEnergy'] <= data['e0_diff'][filename]] = 0 diff --git a/nafuma/xanes/io.py b/nafuma/xanes/io.py index a590255..6c4ac1a 100644 --- a/nafuma/xanes/io.py +++ b/nafuma/xanes/io.py @@ -57,7 +57,7 @@ def split_scan_data(data: dict, options={}) -> list: continue # First line after data started with #C - stops data read-in - elif line[0:2] == "#C": + elif line[0:2] == "#C" or line[0:2] == '#S': read_data = False if scan_data: