Add interactive offset_y
This commit is contained in:
parent
c637bdce6a
commit
f504c7dd69
2 changed files with 25 additions and 6 deletions
|
|
@ -341,11 +341,13 @@ 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()
|
||||
|
||||
|
||||
if options['offset']:
|
||||
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.
|
||||
diffractogram['I_org'] = diffractogram['I']
|
||||
diffractogram['2th_org'] = diffractogram['2th']
|
||||
|
||||
diffractogram = apply_offset(diffractogram, wavelength, index, options)
|
||||
|
||||
|
||||
|
|
@ -355,13 +357,21 @@ def read_data(data, options={}, index=0):
|
|||
|
||||
|
||||
def apply_offset(diffractogram, wavelength, index, options):
|
||||
|
||||
options['current_offset_y'] = options['offset_y']
|
||||
options['current_offset_x'] = options['offset_x']
|
||||
|
||||
#Apply offset along y-axis
|
||||
diffractogram['I_org'] = diffractogram['I'] # make copy of original intensities
|
||||
diffractogram['I'] = diffractogram['I_org'] # Reset intensities
|
||||
|
||||
if options['normalise']:
|
||||
diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max()
|
||||
|
||||
diffractogram['I'] = diffractogram['I'] + index*options['offset_y']
|
||||
|
||||
# Apply offset along x-axis
|
||||
relative_shift = (wavelength / 1.54059)*options['offset_x'] # Adjusts the offset-factor to account for wavelength, so that offset_x given is given in 2th_cuka-units
|
||||
diffractogram['2th_org'] = diffractogram['2th']
|
||||
diffractogram['2th'] = diffractogram['2th_org']
|
||||
diffractogram['2th'] = diffractogram['2th'] + index*relative_shift
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,13 @@ def plot_diffractogram(data, options={}):
|
|||
options['xlim'] = [diffractogram[options['x_vals']].min(), diffractogram[options['x_vals']].max()]
|
||||
|
||||
|
||||
if options['interactive_session_active']:
|
||||
if options['offset']:
|
||||
if (options['offset_x'] != options['current_offset_x']) or (options['offset_y'] != options['current_offset_y']):
|
||||
for i, (diff, wl) in enumerate(zip(data['diffractogram'], data['wavelength'])):
|
||||
xrd.io.apply_offset(diff, wl, i, options)
|
||||
|
||||
|
||||
# Start inteactive session with ipywidgets. Disables options['interactive'] in order for the interactive loop to not start another interactive session
|
||||
if options['interactive']:
|
||||
options['interactive'] = False
|
||||
|
|
@ -156,7 +163,9 @@ def plot_diffractogram(data, options={}):
|
|||
if options['interactive_session_active']:
|
||||
btp.update_widgets(options=options)
|
||||
|
||||
xrd.io.up
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return diffractogram, fig, ax
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue