Translate relfections to heatmap x-coords
This commit is contained in:
parent
dd7f2d9dea
commit
6372603324
2 changed files with 49 additions and 30 deletions
|
|
@ -80,6 +80,8 @@ def plot_diffractogram(data, options={}):
|
|||
|
||||
# Generate heatmap data
|
||||
data['heatmap'], data['heatmap_xticks'], data['heatmap_xticklabels'] = generate_heatmap(data=data, options=options)
|
||||
options['heatmap_loaded'] = True
|
||||
|
||||
if options['heatmap']:
|
||||
options['xlim'] = options['heatmap_xlim']
|
||||
|
||||
|
|
@ -163,16 +165,16 @@ def plot_diffractogram(data, options={}):
|
|||
options['xlim'] = ax.get_xlim()
|
||||
options['to_wavelength'] = data['wavelength'][0]
|
||||
|
||||
for reference, axis in zip(options['reflections_data'], ref_axes):
|
||||
plot_reflection_table(data=reference, ax=axis, options=options)
|
||||
for reflections_params, axis in zip(options['reflections_data'], ref_axes):
|
||||
plot_reflection_table(data=data, reflections_params=reflections_params, ax=axis, options=options)
|
||||
|
||||
# Print the reflection indices. By default, the wavelength of the first diffractogram will be used for this.
|
||||
if options['reflections_indices'] and options['reflections_data']:
|
||||
options['xlim'] = ax.get_xlim()
|
||||
options['to_wavelength'] = data['wavelength'][0]
|
||||
|
||||
for reference in options['reflections_data']:
|
||||
plot_reflection_indices(data=reference, ax=indices_ax, options=options)
|
||||
for reflections_params in options['reflections_data']:
|
||||
plot_reflection_indices(data=data, reflections_params=reflections_params, ax=indices_ax, options=options)
|
||||
|
||||
|
||||
if options['interactive_session_active']:
|
||||
|
|
@ -533,7 +535,7 @@ def update_widgets(data, options):
|
|||
|
||||
|
||||
|
||||
def plot_reflection_indices(data, ax, options={}):
|
||||
def plot_reflection_indices(data, reflections_params, ax, options={}):
|
||||
''' Print reflection indices from output generated by VESTA.
|
||||
|
||||
Required contents of data:
|
||||
|
|
@ -547,20 +549,21 @@ def plot_reflection_indices(data, ax, options={}):
|
|||
'hide_indices': False
|
||||
}
|
||||
|
||||
data = aux.update_options(options=data, required_options=required_options, default_options=default_options)
|
||||
reflections_params = aux.update_options(options=reflections_params, required_options=required_options, default_options=default_options)
|
||||
|
||||
if not data['hide_indices']:
|
||||
reflection_table = xrd.io.load_reflection_table(data=data, options=options)
|
||||
if not reflections_params['hide_indices']:
|
||||
reflection_table = xrd.io.load_reflection_table(data=data, reflections_params=reflections_params, options=options)
|
||||
|
||||
if data['reflection_indices'] > 0:
|
||||
if reflections_params['reflection_indices'] > 0:
|
||||
|
||||
# Get the data['reflection_indices'] number of highest reflections within the subrange options['xlim']
|
||||
reflection_indices = reflection_table.loc[(reflection_table[options['x_vals']] > options['xlim'][0]) & (reflection_table[options['x_vals']] < options['xlim'][1])].nlargest(options['reflection_indices'], 'I')
|
||||
x_vals = 'heatmap' if options['heatmap'] else options['x_vals']
|
||||
reflection_indices = reflection_table.loc[(reflection_table[x_vals] > options['xlim'][0]) & (reflection_table[x_vals] < options['xlim'][1])].nlargest(options['reflection_indices'], 'I')
|
||||
|
||||
# Plot the indices
|
||||
for i in range(data['reflection_indices']):
|
||||
for i in range(reflections_params['reflection_indices']):
|
||||
if reflection_indices.shape[0] > i:
|
||||
ax.text(s=f'({reflection_indices["h"].iloc[i]} {reflection_indices["k"].iloc[i]} {reflection_indices["l"].iloc[i]})', x=reflection_indices[options['x_vals']].iloc[i], y=0, fontsize=2.5, rotation=90, va='bottom', ha='center', c=data['text_colour'])
|
||||
ax.text(s=f'({reflection_indices["h"].iloc[i]} {reflection_indices["k"].iloc[i]} {reflection_indices["l"].iloc[i]})', x=reflection_indices[x_vals].iloc[i], y=0, fontsize=2.5, rotation=90, va='bottom', ha='center', c=reflections_params['text_colour'])
|
||||
|
||||
|
||||
if options['xlim']:
|
||||
|
|
@ -571,7 +574,7 @@ def plot_reflection_indices(data, ax, options={}):
|
|||
|
||||
return
|
||||
|
||||
def plot_reflection_table(data, ax=None, options={}):
|
||||
def plot_reflection_table(data, reflections_params, ax=None, options={}):
|
||||
''' Plots a reflection table from output generated by VESTA.
|
||||
|
||||
Required contents of data:
|
||||
|
|
@ -590,15 +593,15 @@ def plot_reflection_table(data, ax=None, options={}):
|
|||
}
|
||||
|
||||
if 'colour' in data.keys():
|
||||
options['reflections_colour'] = data['colour']
|
||||
if 'min_alpha' in data.keys():
|
||||
options['min_alpha'] = data['min_alpha']
|
||||
if 'reflection_indices' in data.keys():
|
||||
options['reflection_indices'] = data['reflection_indices']
|
||||
if 'label' in data.keys():
|
||||
options['label'] = data['label']
|
||||
if 'wavelength' in data.keys():
|
||||
options['wavelength'] = data['wavelength']
|
||||
options['reflections_colour'] = reflections_params['colour']
|
||||
if 'min_alpha' in reflections_params.keys():
|
||||
options['min_alpha'] = reflections_params['min_alpha']
|
||||
if 'reflection_indices' in reflections_params.keys():
|
||||
options['reflection_indices'] = reflections_params['reflection_indices']
|
||||
if 'label' in reflections_params.keys():
|
||||
options['label'] = reflections_params['label']
|
||||
if 'wavelength' in reflections_params.keys():
|
||||
options['wavelength'] = reflections_params['wavelength']
|
||||
|
||||
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
||||
|
||||
|
|
@ -606,9 +609,10 @@ def plot_reflection_table(data, ax=None, options={}):
|
|||
if not ax:
|
||||
_, ax = btp.prepare_plot(options)
|
||||
|
||||
reflection_table = xrd.io.load_reflection_table(data=data, options=options)
|
||||
x_vals = 'heatmap' if options['heatmap'] else options['x_vals']
|
||||
|
||||
reflections, intensities = reflection_table[options['x_vals']], reflection_table['I']
|
||||
reflection_table = xrd.io.load_reflection_table(data=data, reflections_params=reflections_params, options=options)
|
||||
reflections, intensities = reflection_table[x_vals], reflection_table['I']
|
||||
|
||||
|
||||
|
||||
|
|
@ -638,7 +642,7 @@ def plot_reflection_table(data, ax=None, options={}):
|
|||
xlim_range = ax.get_xlim()[1] - ax.get_xlim()[0]
|
||||
ylim_avg = (ax.get_ylim()[0]+ax.get_ylim()[1])/2
|
||||
|
||||
ax.text(s=data['label'], x=(ax.get_xlim()[0]-0.01*xlim_range), y=ylim_avg, ha = 'right', va = 'center')
|
||||
ax.text(s=reflections_params['label'], x=(ax.get_xlim()[0]-0.01*xlim_range), y=ylim_avg, ha = 'right', va = 'center')
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue