Fix normalisation issues

This commit is contained in:
rasmusvt 2022-07-06 17:33:38 +02:00
parent 327cef5b51
commit 6eb45772d1
2 changed files with 6 additions and 4 deletions

View file

@ -206,7 +206,7 @@ def pre_edge_subtraction(data: dict, options={}):
'show_plots': False, 'show_plots': False,
'save_plots': False, 'save_plots': False,
'save_folder': './', '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) 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 #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']: 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] 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])] #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) 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']: for filename in data['path']:
# Subtract 1 from the _normalised_ post edge fit function # 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 # 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 fit_function_diff.loc[flattened_df['ZapEnergy'] <= data['e0_diff'][filename]] = 0

View file

@ -57,7 +57,7 @@ def split_scan_data(data: dict, options={}) -> list:
continue continue
# First line after data started with #C - stops data read-in # 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 read_data = False
if scan_data: if scan_data: