NeuXtalViz.presenters package#

Submodules#

NeuXtalVizPresenter: Presenter class for connecting the view and model in NeuXtalViz.

This module defines the NeuXtalVizPresenter class, which acts as the mediator between the user interface (view) and the underlying data/model logic. It handles user actions, updates the view based on model state, and manages status/progress reporting for the main visualization window.

Classes#

NeuXtalVizPresenter

Presenter for the main visualization window, connecting view events to model logic and updating the UI accordingly.

class NeuXtalVizPresenter(view, model)[source]#

Bases: object

Presenter for the main visualization window in NeuXtalViz.

Connects user interface events to model logic, updates the view based on model state, and manages status and progress reporting.

Methods

azimuth_view_left()

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()

Rotate the camera right (azimuth) by the configured step angle.

calculate_camera_parameters()

Compute and display the camera's roll, elevation, and azimuth in the view.

change_lattice()

Enable or disable reciprocal lattice display in the view.

elevate_view_down()

Tilt the camera down by the configured step angle.

elevate_view_up()

Tilt the camera up by the configured step angle.

rotate_view_ccw()

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()

Roll the view clockwise about the viewing axis.

save_screenshot()

Save a screenshot of the current view to a file.

stop_processing(stop_event)

Check if a stop has been requested.

stop_workers()

Stop all running workers and update UI.

update_complete([status])

Indicate completion to the user and reset progress.

update_invalid()

Indicate invalid parameters to the user and reset progress.

update_oriented_lattice()

Update the oriented lattice parameter display in the view.

update_processing([status, progress])

Indicate processing state to the user and update progress.

update_progress(progress)

Update progress step in the view.

update_status(status)

Update status information in the view.

update_stopped()

Indicate that processing was stopped by the user.

view_ab()

Set the view to the c* direction (real lattice).

view_ab_star()

Set the view to the c-axis direction (reciprocal lattice).

view_bc()

Set the view to the a* direction (real lattice).

view_bc_star()

Set the view to the a-axis direction (reciprocal lattice).

view_ca()

Set the view to the b* direction (real lattice).

view_ca_star()

Set the view to the b-axis direction (reciprocal lattice).

view_manual()

Set the view to a manually specified axis direction.

view_up_manual()

Set the view's up direction to a manually specified axis.

azimuth_view_left()[source]#

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()[source]#

Rotate the camera right (azimuth) by the configured step angle.

calculate_camera_parameters()[source]#

Compute and display the camera’s roll, elevation, and azimuth in the view.

change_lattice()[source]#

Enable or disable reciprocal lattice display in the view.

elevate_view_down()[source]#

Tilt the camera down by the configured step angle.

elevate_view_up()[source]#

Tilt the camera up by the configured step angle.

rotate_view_ccw()[source]#

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()[source]#

Roll the view clockwise about the viewing axis.

save_screenshot()[source]#

Save a screenshot of the current view to a file.

static stop_processing(stop_event)[source]#

Check if a stop has been requested.

Convenience method for worker tasks to check if they should terminate early.

Parameters:
stop_eventthreading.Event or None

The stop event to check.

Returns:
stopbool

True if stop was requested, False otherwise.

stop_workers()[source]#

Stop all running workers and update UI.

update_complete(status='Complete!')[source]#

Indicate completion to the user and reset progress.

Parameters:
statusstr, optional

Completion message (default is “Complete!”).

update_invalid()[source]#

Indicate invalid parameters to the user and reset progress.

update_oriented_lattice()[source]#

Update the oriented lattice parameter display in the view.

update_processing(status='Processing...', progress=1)[source]#

Indicate processing state to the user and update progress.

Parameters:
statusstr, optional

Processing message (default is “Processing…”).

progressint, optional

Progress step or value (default is 1).

update_progress(progress)[source]#

Update progress step in the view.

Parameters:
progressint, str

Progress step or value.

update_status(status)[source]#

Update status information in the view.

Parameters:
statusstr

Status message to display.

update_stopped()[source]#

Indicate that processing was stopped by the user.

view_ab()[source]#

Set the view to the c* direction (real lattice).

view_ab_star()[source]#

Set the view to the c-axis direction (reciprocal lattice).

view_bc()[source]#

Set the view to the a* direction (real lattice).

view_bc_star()[source]#

Set the view to the a-axis direction (reciprocal lattice).

view_ca()[source]#

Set the view to the b* direction (real lattice).

view_ca_star()[source]#

Set the view to the b-axis direction (reciprocal lattice).

view_manual()[source]#

Set the view to a manually specified axis direction.

view_up_manual()[source]#

Set the view’s up direction to a manually specified axis.

class CrystalStructure(view, model)[source]#

Bases: NeuXtalVizPresenter

Presenter for the crystal structure tool.

Connects the crystal structure view’s signals to model-driven actions for editing lattice parameters, atom sites, and space group settings, calculating structure factors and hkl equivalents, and loading/saving crystal structure files.

Parameters:
viewNeuXtalViz.views.crystal_structure_tools.CrystalStructureView

View for the crystal structure tool.

modelNeuXtalViz.models.crystal_structure_tools.CrystalStructure

Model for the crystal structure tool.

Methods

azimuth_view_left()

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()

Rotate the camera right (azimuth) by the configured step angle.

calculate_F2()

Start calculation of F2 factors using a worker thread.

calculate_F2_complete(result)

Complete F2 calculation and update the view with results.

calculate_F2_process(progress[, stop_event, ...])

Worker task that generates unique reflections and structure factors.

calculate_absorption()

Start prediction of per-reflection transmission/absorption using a worker thread.

calculate_absorption_complete(result)

Complete absorption prediction and update the view with results.

calculate_absorption_process(progress[, ...])

Worker task that predicts per-reflection transmission/absorption.

calculate_camera_parameters()

Compute and display the camera's roll, elevation, and azimuth in the view.

calculate_hkl()

Start calculation of hkl equivalents using a worker thread.

calculate_hkl_complete(result)

Complete hkl calculation and update the view with results.

calculate_hkl_process(progress[, ...])

Worker task that calculates symmetry equivalents of a reflection.

change_lattice()

Enable or disable reciprocal lattice display in the view.

elevate_view_down()

Tilt the camera down by the configured step angle.

elevate_view_up()

Tilt the camera up by the configured step angle.

generate_groups()

Generate space groups for the selected crystal system and update the view.

generate_settings()

Generate settings for the selected space group and update the view.

highlight_row()

Highlight the selected atom row in the view.

load_CIF()

Load a CIF file and update the crystal structure in the view and model.

rotate_view_ccw()

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()

Roll the view clockwise about the viewing axis.

save_INS()

Save the current crystal structure to an INS file.

save_screenshot()

Save a screenshot of the current view to a file.

select_isotope()

Select an isotope and show the periodic table dialog.

set_atom_table()

Set the atom table in the view and update atoms.

stop_processing(stop_event)

Check if a stop has been requested.

stop_workers()

Stop all running workers and update UI.

update_atoms()

Update atom positions and related information in the view.

update_complete([status])

Indicate completion to the user and reset progress.

update_invalid()

Indicate invalid parameters to the user and reset progress.

update_oriented_lattice()

Update the oriented lattice parameter display in the view.

update_parameters()

Update lattice parameters and atom positions in the view.

update_processing([status, progress])

Indicate processing state to the user and update progress.

update_progress(progress)

Update progress step in the view.

update_selection(data)

Update the selected isotope and atom table in the view.

update_status(status)

Update status information in the view.

update_stopped()

Indicate that processing was stopped by the user.

view_ab()

Set the view to the c* direction (real lattice).

view_ab_star()

Set the view to the c-axis direction (reciprocal lattice).

view_bc()

Set the view to the a* direction (real lattice).

view_bc_star()

Set the view to the a-axis direction (reciprocal lattice).

view_ca()

Set the view to the b* direction (real lattice).

view_ca_star()

Set the view to the b-axis direction (reciprocal lattice).

view_manual()

Set the view to a manually specified axis direction.

view_up_manual()

Set the view's up direction to a manually specified axis.

calculate_F2()[source]#

Start calculation of F2 factors using a worker thread.

Parameters:
None
calculate_F2_complete(result)[source]#

Complete F2 calculation and update the view with results.

Parameters:
resulttuple or None

Result from F2 calculation.

calculate_F2_process(progress, stop_event=None, d_min=None, params=None)[source]#

Worker task that generates unique reflections and structure factors.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

d_minfloat, optional

Minimum d-spacing to generate reflections for. If None, it is derived from params (default None).

paramstuple, optional

Lattice constants used to derive d_min when it is not given, and to validate that the calculation should proceed (default None).

Returns:
hklsnumpy.ndarray or None

Array of unique HKL indices, or None if stopped or invalid.

dsnumpy.ndarray or None

Array of d-spacings corresponding to hkls.

F2snumpy.ndarray or None

Array of squared structure factors corresponding to hkls.

calculate_absorption()[source]#

Start prediction of per-reflection transmission/absorption using a worker thread.

Parameters:
None
calculate_absorption_complete(result)[source]#

Complete absorption prediction and update the view with results.

Parameters:
resulttuple or None

Result from calculate_absorption_process().

calculate_absorption_process(progress, stop_event=None, d_min=None, wavelength=None, shape_params=None, sample_vectors=None, shape_vectors=None)[source]#

Worker task that predicts per-reflection transmission/absorption.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

d_minfloat, optional

Minimum d-spacing to generate reflections for. If None, it is derived from the lattice constants, the same way as the Factors tab’s calculate_F2_process.

wavelengthfloat, optional

Incident wavelength, in Angstrom.

shape_paramslist of float, optional

Ellipsoid thickness, width, and height, in mm.

sample_vectorstuple of (list, list) or None, optional

Sample U/V vectors defining the crystal’s own orientation.

shape_vectorstuple of (list, list) or None, optional

Shape U/V vectors orienting the shape mesh.

Returns:
hklsnumpy.ndarray or None

Miller indices, sorted by d-spacing then h, k, l, or None if stopped, invalid, or no reflection was reachable.

dsnumpy.ndarray or None

d-spacing per reflection.

Tsnumpy.ndarray or None

Transmission per reflection.

Tbarsnumpy.ndarray or None

Absorption-weighted path length (cm) per reflection.

abs_dictdict or None

Absorption/scattering parameters, from the model’s get_absorption_dict.

meshnumpy.ndarray or None

Sample shape mesh, from the model’s sample_mesh.

Tnumpy.ndarray or None

a*/b*/c* orientation matrix, from the model’s get_transform_from_UB, for drawing the axes arrows attached to the sample.

r_incidentfloat or None

Sample radius (cm) along the incident beam direction, from the model’s get_incident_path_length.

calculate_hkl()[source]#

Start calculation of hkl equivalents using a worker thread.

Parameters:
None
calculate_hkl_complete(result)[source]#

Complete hkl calculation and update the view with results.

Parameters:
resulttuple or None

Result from hkl calculation.

calculate_hkl_process(progress, stop_event=None, hkl=None)[source]#

Worker task that calculates symmetry equivalents of a reflection.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

hkltuple, optional

Miller indices (h, k, l) of the reflection to calculate equivalents for (default None).

Returns:
hklslist of V3D or None

Symmetry-equivalent HKL reflections, or None if stopped or invalid.

dfloat or None

d-spacing of the reflection.

F2float or None

Squared structure factor of the reflection.

generate_groups()[source]#

Generate space groups for the selected crystal system and update the view.

Parameters:
None
generate_settings()[source]#

Generate settings for the selected space group and update the view.

Parameters:
None
highlight_row()[source]#

Highlight the selected atom row in the view.

Parameters:
None
load_CIF()[source]#

Load a CIF file and update the crystal structure in the view and model.

Parameters:
None
save_INS()[source]#

Save the current crystal structure to an INS file.

Parameters:
None
select_isotope()[source]#

Select an isotope and show the periodic table dialog.

Parameters:
None
set_atom_table()[source]#

Set the atom table in the view and update atoms.

Parameters:
None
update_atoms()[source]#

Update atom positions and related information in the view.

Parameters:
None
update_parameters()[source]#

Update lattice parameters and atom positions in the view.

Parameters:
None
update_selection(data)[source]#

Update the selected isotope and atom table in the view.

Parameters:
dataobject

Selected isotope data.

class Experiment(view, model)[source]#

Bases: NeuXtalVizPresenter

Presenter for the experiment planner in NeuXtalViz.

Connects the experiment-planner view’s signals to model logic for goniometer/instrument setup, peak coverage calculation and visualization, plane/mesh scan generation, coverage optimization, and experiment plan save/load.

Methods

add_orientation()

Launch a background worker to add a manually entered orientation.

add_orientation_complete(result)

Add the newly calculated orientation as a row in the plan table.

add_orientation_process(progress[, ...])

Worker task: predict reflections for a manually entered orientation.

add_settings()

Launch a background worker to recompute peaks for all plan rows.

add_settings_complete(result)

Refresh the peaks table after recomputing all plan row settings.

add_settings_process(progress[, stop_event, ...])

Worker task: recompute peaks for every orientation in the plan.

azimuth_view_left()

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()

Rotate the camera right (azimuth) by the configured step angle.

calculate_camera_parameters()

Compute and display the camera's roll, elevation, and azimuth in the view.

calculate_double()

Launch a background worker to calculate simultaneous coverage of two reflections.

calculate_double_complete(result)

Plot the simultaneous two-reflection coverage on the instrument view.

calculate_double_process(progress[, ...])

Worker task: compute detector coverage for two simultaneous reflections.

calculate_harmonics()

Plot harmonic reflections overlapping the selected peak(s).

calculate_plane()

Launch a background worker to preview coverage of a scattering plane.

calculate_plane_process(progress[, ...])

Worker task: preview the coverage slice for a scattering plane.

calculate_single()

Calculate peak coverage for the first (primary) input HKL.

calculate_single_alt()

Calculate peak coverage for the second (alternate) input HKL.

calculate_single_complete(result)

Plot the single-reflection coverage on the instrument view.

calculate_single_hkl()

Launch a background worker to calculate a single reflection's detector coverage across all goniometer settings.

calculate_single_process(progress[, ...])

Worker task: compute detector coverage for a single reflection.

change_lattice()

Enable or disable reciprocal lattice display in the view.

convert_mesh_to_hkl()

Recompute coverage from the mesh-scan angles and slice to HKL.

convert_plan_to_hkl()

Recompute coverage from the plan's orientations and slice to HKL.

convert_to_hkl()

Launch a background worker to compute/re-slice HKL coverage.

convert_to_hkl_complete(result)

Update the slice view with the newly computed HKL coverage.

convert_to_hkl_process(progress[, ...])

Worker task: compute or re-slice the HKL coverage for a plan.

create_instrument()

Initialize the instrument workspace with the current view settings.

delete_angles()

Launch a background worker to delete the selected orientations.

delete_angles_complete(rows)

Remove the deleted orientation rows from the plan table.

delete_angles_process(progress[, ...])

Worker task: delete orientation rows from the model.

elevate_view_down()

Tilt the camera down by the configured step angle.

elevate_view_up()

Tilt the camera up by the configured step angle.

get_normal()

Get the one-hot slice-normal vector for the selected slice plane.

highlight_peak()

Update the Laue plot for the peak selected in the peaks table.

load_UB()

Load UB matrix from file and update the view and model.

load_detector()

Load detector calibration file and set it in the view.

load_experiment()

Load a previously saved experiment plan and sample from Nexus.

load_goniometer()

Load goniometer calibration file and set it in the view.

load_mask()

Load detector mask file and set it in the view.

lookup_angle(gamma, nu)

Look up and display the goniometer setting nearest a clicked instrument-view detector position.

mesh_scan()

Launch a background worker to add orientations from a mesh scan.

mesh_scan_complete(result)

Add the mesh-scan orientations as rows in the plan table.

mesh_scan_process(progress[, stop_event, ...])

Worker task: predict reflections for each orientation in a mesh of goniometer settings.

move_orientation_down()

Move the selected orientation down one row in the plan table.

move_orientation_up()

Move the selected orientation up one row in the plan table.

optimize_coverage()

Launch a background worker to optimize coverage via CrystalPlan.

optimize_coverage_complete(result)

Add the CrystalPlan-optimized orientations as rows in the plan table.

optimize_coverage_process(progress[, ...])

Worker task: optimize orientation coverage with a genetic algorithm.

plane_scan()

Launch a background worker to add orientations spanning a plane.

plane_scan_complete(result)

Add the plane-scan orientations as rows in the plan table.

plane_scan_process(progress[, stop_event, ...])

Worker task: add orientations spanning a scattering plane.

reslice()

Re-slice the existing coverage without rebuilding the footprint.

rotate_view_ccw()

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()

Roll the view clockwise about the viewing axis.

save_CSV()

Save the active plan rows to a CSV file and copy it to the instrument PC.

save_experiment()

Save the full experiment plan and sample to a Nexus file.

save_screenshot()

Save a screenshot of the current view to a file.

select_peak(gamma, nu)

Select and highlight the peak nearest a clicked Laue-plot position.

show_instrument()

Launch a background worker to render the instrument geometry.

show_instrument_complete(result)

Add the computed instrument geometry to the 3D view.

show_instrument_process(progress[, ...])

Worker task: initialize the instrument and extract its geometry.

stop_processing(stop_event)

Check if a stop has been requested.

stop_workers()

Stop all running workers and update UI.

switch_centering()

Re-visualize the coverage when the lattice centering changes.

switch_crystal()

Update available point groups when the crystal system changes.

switch_group()

Update available lattice centerings when the point group changes.

switch_instrument()

Switch instrument and update all related view parameters.

update_complete([status])

Indicate completion to the user and reset progress.

update_goniometer()

Refresh the goniometer/motor tables for the selected mode.

update_hkl_limits()

Recompute and display HKL limits from the current d-min and UB.

update_invalid()

Indicate invalid parameters to the user and reset progress.

update_oriented_lattice()

Update the oriented lattice parameter display in the view.

update_peaks([visualize])

Refresh the peaks table and Laue plot for the selected orientation.

update_plan()

Push the current view state into the model's plan and sample.

update_processing([status, progress])

Indicate processing state to the user and update progress.

update_progress(progress)

Update progress step in the view.

update_status(status)

Update status information in the view.

update_stopped()

Indicate that processing was stopped by the user.

update_wavelength()

Update the derived wavelength display from the minimum wavelength.

view_ab()

Set the view to the c* direction (real lattice).

view_ab_star()

Set the view to the c-axis direction (reciprocal lattice).

view_bc()

Set the view to the a* direction (real lattice).

view_bc_star()

Set the view to the a-axis direction (reciprocal lattice).

view_ca()

Set the view to the b* direction (real lattice).

view_ca_star()

Set the view to the b-axis direction (reciprocal lattice).

view_manual()

Set the view to a manually specified axis direction.

view_up_manual()

Set the view's up direction to a manually specified axis.

visualize()

Recompute statistics and coverage, and refresh the plots.

add_orientation()[source]#

Launch a background worker to add a manually entered orientation.

Slot for the “Add” button. Gathers the manually entered angles and current instrument settings from the view and runs add_orientation_process() in a worker thread, updating the plan table via add_orientation_complete() when finished.

add_orientation_complete(result)[source]#

Add the newly calculated orientation as a row in the plan table.

Parameters:
resulttuple or None

(angles, all_angles, free_angles) from add_orientation_process(), giving the full per-axis angle setting, the names of all goniometer axes, and the names of the free (variable) axes, or None if no orientation was added.

add_orientation_process(progress, stop_event=None, angles=None, free_angles=None, all_angles=None, wavelength=None, d_min=None, rows=None)[source]#

Worker task: predict reflections for a manually entered orientation.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

angleslist of float, optional

Full per-axis goniometer angle setting.

free_angleslist of str, optional

Names of the goniometer axes that are free (variable).

all_angleslist of str, optional

Names of all goniometer axes.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

d_minfloat, optional

Minimum d-spacing (Angstrom).

rowsint, optional

Row index at which to add the new orientation’s predicted peaks workspace.

Returns:
angles, all_angles, free_anglestuple or None

The same angles, all_angles, and free_angles passed in, if reflections were predicted, or None if angles was empty.

add_settings()[source]#

Launch a background worker to recompute peaks for all plan rows.

Slot for the “Reset” button, and called after loading an experiment. Gathers the per-row angle settings and current instrument settings from the view and runs add_settings_process() in a worker thread, updating the peaks table via add_settings_complete() when finished.

add_settings_complete(result)[source]#

Refresh the peaks table after recomputing all plan row settings.

Parameters:
resultint or None

Number of rows processed, as returned by add_settings_process(), or None if the worker was stopped early.

add_settings_process(progress, stop_event=None, wavelength=None, d_min=None, rows=None, instrument=None, mode=None, limits=None, instr_motors=None, cal=None, gon=None, mask=None, angle_settings=None)[source]#

Worker task: recompute peaks for every orientation in the plan.

Clears the combined peaks workspace and, for each plan row, combines its free-axis angle settings with the fixed-limit angles and predicts peaks for the resulting orientation.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

d_minfloat, optional

Minimum d-spacing (Angstrom).

rowsint, optional

Number of plan rows to recompute.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

angle_settingslist, optional

Per-row free-axis angle values, one entry per plan row.

Returns:
rowsint or None

The same rows passed in, if processing completed, or None if the worker was stopped early.

calculate_double()[source]#

Launch a background worker to calculate simultaneous coverage of two reflections.

Slot for the “Calculate Double” button. Gathers the two input HKLs, wavelength, symmetry, and instrument settings from the view and runs calculate_double_process() in a worker thread, plotting the result via calculate_double_complete() when finished.

calculate_double_complete(result)[source]#

Plot the simultaneous two-reflection coverage on the instrument view.

Parameters:
resulttuple or None

(gamma_1, nu_1, lamda_1, d_1, gamma_2, nu_2, lamda_2, d_2) from calculate_double_process(), giving the detector gamma/nu angles (degrees), wavelength, and d-spacing (Angstrom) for the first and second reflection at each matching goniometer setting, or None if the calculation was cancelled or invalid.

calculate_double_process(progress, stop_event=None, hkl_1=None, hkl_2=None, wavelength=None, equiv=None, pg=None, instrument=None, mode=None, limits=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: compute detector coverage for two simultaneous reflections.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

hkl_1array-like, optional

Miller index of the first reflection.

hkl_2array-like, optional

Miller index of the second reflection.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

equivbool, optional

Whether to include symmetry-equivalent HKLs in the search.

pgstr, optional

Point group symbol used to generate symmetry equivalents.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
gamma_1, nu_1, lamda_1, d_1ndarray

Detector gamma/nu angles (degrees), wavelength (Angstrom), and d-spacing (Angstrom) for the first reflection.

gamma_2, nu_2, lamda_2, d_2ndarray

Same quantities for the second reflection, at goniometer settings where both reflections are simultaneously visible. The full 8-tuple is None instead if either HKL is missing, no UB matrix is loaded, or the worker was stopped early.

calculate_harmonics()[source]#

Plot harmonic reflections overlapping the selected peak(s).

Slot for the view’s harm_ready signal, emitted when the instrument plot is updated. Computes and plots harmonics for the primary reflection and, if present, the alternate (simultaneous) reflection.

calculate_plane()[source]#

Launch a background worker to preview coverage of a scattering plane.

Slot for the “Calculate Plane” button. No-op if a previous HKL-conversion/plane calculation is still running (guarded by convert_idle). Gathers the plane’s HKL vectors, projection, slice, and instrument settings from the view and runs calculate_plane_process() in a worker thread, updating the slice view via convert_to_hkl_complete() when finished.

calculate_plane_process(progress, stop_event=None, hkl_1=None, hkl_2=None, max_deg=None, n_steps=None, instrument=None, mode=None, limits=None, proj=None, value=None, thickness=None, d_min=None, symm=None, point_group=None, wavelength=None, norm=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: preview the coverage slice for a scattering plane.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

hkl_1, hkl_2array-like, optional

Miller-index vectors defining the scattering plane.

max_degfloat, optional

Maximum rotation angle (degrees) to scan about the plane normal.

n_stepsint, optional

Number of steps to scan over max_deg.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

projarray-like, optional

Flattened 3x3 HKL projection matrix.

valuefloat, optional

Slice position along the slice normal.

thicknessfloat, optional

Slice half-thickness.

d_minfloat, optional

Minimum d-spacing (Angstrom).

symmbool, optional

Whether to apply point-group symmetry when computing coverage.

point_groupstr, optional

Point group symbol used when symm is True.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

normlist of int, optional

One-hot vector selecting the slice normal axis.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
resultdict or None

Slice dictionary from model.calculate_rotations (with keys such as "x", "y", "signal", "transform") for the requested plane, or None if the HKL vectors, projection, or other parameters are invalid, no plane orientations were found, or the worker was stopped early.

calculate_single()[source]#

Calculate peak coverage for the first (primary) input HKL.

Slot for the “Calculate Single” button. Selects the primary HKL input and delegates to calculate_single_hkl().

calculate_single_alt()[source]#

Calculate peak coverage for the second (alternate) input HKL.

Slot for the alternate “Calculate Single” button. Selects the alternate HKL input and delegates to calculate_single_hkl().

calculate_single_complete(result)[source]#

Plot the single-reflection coverage on the instrument view.

Parameters:
resulttuple or None

(gamma, nu, lamda, d) from calculate_single_process(), giving the detector gamma/nu angles (degrees), wavelength, and d-spacing (Angstrom) of the matching goniometer settings, or None if the calculation was cancelled or invalid.

calculate_single_hkl()[source]#

Launch a background worker to calculate a single reflection’s detector coverage across all goniometer settings.

Gathers the HKL, wavelength, symmetry, and instrument settings from the view and runs calculate_single_process() in a worker thread, plotting the result via calculate_single_complete() when finished.

calculate_single_process(progress, stop_event=None, hkl_1=None, hkl_2=None, wavelength=None, equiv=None, pg=None, instrument=None, mode=None, limits=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: compute detector coverage for a single reflection.

Uses hkl_1 unless alt_hkl is set, in which case hkl_2 is used.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

hkl_1array-like, optional

Primary Miller index input.

hkl_2array-like, optional

Alternate Miller index input.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

equivbool, optional

Whether to include symmetry-equivalent HKLs in the search.

pgstr, optional

Point group symbol used to generate symmetry equivalents.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
gamma, nu, lamda, dndarray or None

Detector gamma/nu angles (degrees), wavelength (Angstrom), and d-spacing (Angstrom) of matching goniometer settings, or None if the HKL is invalid, no UB matrix is loaded, or the worker was stopped early.

convert_mesh_to_hkl()[source]#

Recompute coverage from the mesh-scan angles and slice to HKL.

Slot for the “Convert Mesh” button. Sets the presenter to use the mesh-angle grid (rather than the plan’s discrete orientations) as the source of goniometer settings, then delegates to convert_to_hkl().

convert_plan_to_hkl()[source]#

Recompute coverage from the plan’s orientations and slice to HKL.

Slot for the “Convert Plan” button. Sets the presenter to use the discrete orientations in the plan table (rather than the mesh-angle grid) as the source of goniometer settings, then delegates to convert_to_hkl().

convert_to_hkl()[source]#

Launch a background worker to compute/re-slice HKL coverage.

No-op if a previous HKL-conversion is still running (guarded by convert_idle). Gathers the projection, slice, and instrument settings from the view, along with either the mesh angles or the plan angles depending on mesh, and runs convert_to_hkl_process() in a worker thread, updating the slice view via convert_to_hkl_complete() when finished.

convert_to_hkl_complete(result)[source]#

Update the slice view with the newly computed HKL coverage.

Parameters:
resultdict or None

Slice dictionary from convert_to_hkl_process(), or None if the conversion was invalid or produced no coverage.

convert_to_hkl_process(progress, stop_event=None, instrument=None, mode=None, proj=None, value=None, thickness=None, d_min=None, symm=None, point_group=None, norm=None, angles=None, wavelength=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: compute or re-slice the HKL coverage for a plan.

If slice_only is set, re-slices the most recently computed coverage without recomputing the footprint (see reslice()). Otherwise, initializes the instrument, builds the footprint, and computes the coverage for angles (either a mesh grid or a list of plan orientations, depending on mesh), then slices it onto the requested HKL plane.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

projarray-like, optional

Flattened 3x3 HKL projection matrix.

valuefloat, optional

Slice position along the slice normal.

thicknessfloat, optional

Slice half-thickness.

d_minfloat, optional

Minimum d-spacing (Angstrom).

symmbool, optional

Whether to apply point-group symmetry when computing coverage.

point_groupstr, optional

Point group symbol used when symm is True.

normlist of int, optional

One-hot vector selecting the slice normal axis.

anglesarray-like, optional

Either a list of goniometer angle tuples (plan orientations) or (limits, ns) describing a mesh grid, depending on mesh.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
resultdict or None

Slice dictionary from model.calculate_rotations or model.reslice_last (with keys such as "x", "y", "signal", "transform"), or None if the parameters or projection are invalid, no angles were provided, there is no coverage to reslice, or the worker was stopped early.

create_instrument()[source]#

Initialize the instrument workspace with the current view settings.

Reads the instrument, motors, and calibration/mask files from the view and initializes the model’s instrument workspace synchronously (not run in a background worker).

delete_angles()[source]#

Launch a background worker to delete the selected orientations.

Slot for the “Delete” button. Gathers the rows selected for deletion from the view and runs delete_angles_process() in a worker thread, updating the view via delete_angles_complete() when finished.

delete_angles_complete(rows)[source]#

Remove the deleted orientation rows from the plan table.

Parameters:
rowslist of int or None

Row indices that were deleted, as returned by delete_angles_process(), or None if no rows were selected.

delete_angles_process(progress, stop_event=None, rows=None)[source]#

Worker task: delete orientation rows from the model.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

rowslist of int, optional

Row indices to delete.

Returns:
rowslist of int or None

The same rows passed in, if deletion was performed, or None if no rows were selected.

get_normal()[source]#

Get the one-hot slice-normal vector for the selected slice plane.

Returns:
normlist of int

One-hot vector selecting which of the projection basis vectors (U, V, W) is the slice normal: [0, 0, 1] for “Axis 1/2”, [0, 1, 0] for “Axis 1/3”, or [1, 0, 0] for “Axis 2/3”.

highlight_peak()[source]#

Update the Laue plot for the peak selected in the peaks table.

Slot for the peaks table’s itemSelectionChanged signal.

load_UB()[source]#

Load UB matrix from file and update the view and model.

load_detector()[source]#

Load detector calibration file and set it in the view.

load_experiment()[source]#

Load a previously saved experiment plan and sample from Nexus.

Slot for the “Load Experiment” button. Prompts for a source file (defaulting to the current instrument’s directory) and, if one is selected, restores the instrument, goniometer mode, wavelength, d-min, goniometer limits, motor values, calibration and mask files, crystal system, point group, lattice centering, and plan table rows from the file, then re-adds the restored settings via add_settings() and remembers the file’s directory as the default for future dialogs. No-op if the file dialog is cancelled.

load_goniometer()[source]#

Load goniometer calibration file and set it in the view.

load_mask()[source]#

Load detector mask file and set it in the view.

lookup_angle(gamma, nu)[source]#

Look up and display the goniometer setting nearest a clicked instrument-view detector position.

Slot for the view’s roi_ready signal, emitted with the (gamma, nu) coordinates of a mouse click on the instrument coverage plot.

Parameters:
gammafloat

Detector gamma angle (degrees) of the clicked position.

nufloat

Detector nu angle (degrees) of the clicked position.

mesh_scan()[source]#

Launch a background worker to add orientations from a mesh scan.

Slot for the “Mesh Scan” button. Gathers the mesh axis limits and step counts along with the current instrument settings from the view and runs mesh_scan_process() in a worker thread, updating the plan table via mesh_scan_complete() when finished.

mesh_scan_complete(result)[source]#

Add the mesh-scan orientations as rows in the plan table.

Parameters:
resultlist of ndarray or None

Per-orientation free-axis angle values from mesh_scan_process(), or None if the mesh scan was cancelled or invalid.

mesh_scan_process(progress, stop_event=None, mesh_angles=None, free_angles=None, all_angles=None, wavelength=None, d_min=None, rows=None, instrument=None, mode=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: predict reflections for each orientation in a mesh of goniometer settings.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

mesh_anglestuple, optional

(limits, ns) – per-axis [min, max] angle limits and number of steps to sample for each goniometer axis.

free_angleslist of str, optional

Names of the goniometer axes that are free (variable).

all_angleslist of str, optional

Names of all goniometer axes.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

d_minfloat, optional

Minimum d-spacing (Angstrom).

rowsint, optional

Row index at which to start adding the new orientations’ predicted peaks workspaces.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
angleslist of ndarray or None

Per-orientation free-axis angle values, one entry per mesh grid point, or None if mesh_angles was not provided or the worker was stopped early.

move_orientation_down()[source]#

Move the selected orientation down one row in the plan table.

Slot for the “Move Down” button. Swaps the selected orientation with the one below it, in both the model and the view, then refreshes the peaks table without a full re-visualization.

move_orientation_up()[source]#

Move the selected orientation up one row in the plan table.

Slot for the “Move Up” button. Swaps the selected orientation with the one above it, in both the model and the view, then refreshes the peaks table without a full re-visualization.

optimize_coverage()[source]#

Launch a background worker to optimize coverage via CrystalPlan.

Slot for the “Optimize” button. Gathers the symmetry, coverage, and instrument settings from the view and runs optimize_coverage_process() (a genetic-algorithm search over orientations) in a worker thread, updating the plan table via optimize_coverage_complete() when finished.

optimize_coverage_complete(result)[source]#

Add the CrystalPlan-optimized orientations as rows in the plan table.

Parameters:
resultlist of ndarray or None

Per-orientation free-axis angle values from optimize_coverage_process(), or None if no UB matrix was loaded or the optimization was cancelled.

optimize_coverage_process(progress, stop_event=None, point_group=None, lattice_centering=None, use=None, opt=None, d_min=None, wavelength=None, n_orient=None, instrument=None, mode=None, limits=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: optimize orientation coverage with a genetic algorithm.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

point_groupstr, optional

Point group symbol.

lattice_centeringstr, optional

Lattice centering symbol.

uselist of bool, optional

Per-row flag indicating whether that plan orientation should be included in the optimization.

optlist of bool, optional

Per-row flag indicating whether that plan orientation is free to be optimized.

d_minfloat, optional

Minimum d-spacing (Angstrom).

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

n_orientint, optional

Number of orientations to optimize.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
valueslist or None

Best per-orientation goniometer settings found by the genetic algorithm (see CrystalPlan.optimize), or None if no UB matrix is loaded or the worker was stopped early.

plane_scan()[source]#

Launch a background worker to add orientations spanning a plane.

Slot for the “Add Plane” button. Gathers the plane’s HKL vectors, scan range, and current instrument settings from the view and runs plane_scan_process() in a worker thread, updating the plan table via plane_scan_complete() when finished.

plane_scan_complete(result)[source]#

Add the plane-scan orientations as rows in the plan table.

Parameters:
resultlist of ndarray or None

Per-orientation free-axis angle values from plane_scan_process(), or None if the plane scan was cancelled or invalid.

plane_scan_process(progress, stop_event=None, hkl_1=None, hkl_2=None, max_deg=None, n_steps=None, free_angles=None, all_angles=None, wavelength=None, d_min=None, rows=None, instrument=None, mode=None, limits=None, instr_motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: add orientations spanning a scattering plane.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

hkl_1, hkl_2array-like, optional

Miller-index vectors defining the scattering plane.

max_degfloat, optional

Maximum rotation angle (degrees) to scan about the plane normal.

n_stepsint, optional

Number of steps to scan over max_deg.

free_angleslist of str, optional

Names of the goniometer axes that are free (variable).

all_angleslist of str, optional

Names of all goniometer axes.

wavelength2-tuple of float, optional

Minimum and maximum wavelength (Angstrom).

d_minfloat, optional

Minimum d-spacing (Angstrom).

rowsint, optional

Row-number offset at which to start adding the new orientations’ predicted peaks.

instrumentstr, optional

Instrument identifier.

modestr, optional

Goniometer mode name.

limitssequence of (float, float), optional

Per-axis (min, max) goniometer angle limits, in degrees.

instr_motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
angleslist of ndarray or None

Per-orientation free-axis angle values, one entry per selected plane orientation, or None if the HKL vectors are invalid, no plane orientations were found, or the worker was stopped early.

reslice()[source]#

Re-slice the existing coverage without rebuilding the footprint.

save_CSV()[source]#

Save the active plan rows to a CSV file and copy it to the instrument PC.

Slot for the “Save CSV” button. Prompts for a destination file, updates the model’s plan/sample from the current view state, writes the active (used) rows to CSV, and copies the file to the instrument PC share if applicable (see model.copy_to_instrument_pc()). No-op if the file dialog is cancelled.

save_experiment()[source]#

Save the full experiment plan and sample to a Nexus file.

Slot for the “Save Experiment” button. Prompts for a destination file (defaulting to the current instrument’s directory), updates the model’s plan/sample from the current view state, saves them to Nexus, and remembers the file’s directory as the default for future dialogs. No-op if the file dialog is cancelled.

select_peak(gamma, nu)[source]#

Select and highlight the peak nearest a clicked Laue-plot position.

Slot for the view’s sel_ready signal, emitted with the (gamma, nu) coordinates of a mouse click on the Laue plot.

Parameters:
gammafloat

Detector gamma angle (degrees) of the clicked position.

nufloat

Detector nu angle (degrees) of the clicked position.

show_instrument()[source]#

Launch a background worker to render the instrument geometry.

Slot for the “Show Instrument” button. Gathers the current instrument/motor/calibration settings from the view and runs show_instrument_process() in a worker thread, updating the view with the result via show_instrument_complete() and refreshing the HKL limits when finished.

show_instrument_complete(result)[source]#

Add the computed instrument geometry to the 3D view.

Parameters:
resultdict or None

Instrument mesh dictionary from show_instrument_process() (as returned by model.extract_instrument_view), or None if the calculation was cancelled or failed.

show_instrument_process(progress, stop_event=None, instrument=None, motors=None, cal=None, gon=None, mask=None)[source]#

Worker task: initialize the instrument and extract its geometry.

Parameters:
progresscallable

Callback progress(status, percent) used to report status messages and progress percentage back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that the worker should stop early.

instrumentstr, optional

Instrument identifier.

motorslist, optional

Auxiliary motor (name, value) settings.

calstr, optional

Detector calibration file path.

gonstr, optional

Goniometer calibration file path.

maskstr, optional

Detector mask file path.

Returns:
inst_dictdict or None

Instrument mesh dictionary with "points", "faces", and "radius" keys, or None if the worker was stopped early.

switch_centering()[source]#

Re-visualize the coverage when the lattice centering changes.

Slot for the lattice centering combo box’s activation signal.

switch_crystal()[source]#

Update available point groups when the crystal system changes.

Slot for the crystal system combo box’s activation signal. Fetches the point groups compatible with the selected crystal system, updates the view, and refreshes the lattice centering list via switch_group().

switch_group()[source]#

Update available lattice centerings when the point group changes.

Slot for the point group combo box’s activation signal. Fetches the lattice centerings compatible with the selected point group, updates the view, and triggers a re-visualization.

switch_instrument()[source]#

Switch instrument and update all related view parameters.

update_goniometer()[source]#

Refresh the goniometer/motor tables for the selected mode.

Slot for the goniometer mode combo box’s activation signal.

update_hkl_limits()[source]#

Recompute and display HKL limits from the current d-min and UB.

Slot for the d-min line edit’s editingFinished signal (and called after loading a UB matrix). Does nothing if no d-min is set or no UB matrix has been loaded.

update_peaks(visualize=True)[source]#

Refresh the peaks table and Laue plot for the selected orientation.

Slot for the orientations combo box’s activated signal, and called directly (with visualize=False) after orientations are added, deleted, reordered, or reconfigured.

Parameters:
visualizebool, optional

If True (default), also trigger a full coverage re-visualization via visualize().

update_plan()[source]#

Push the current view state into the model’s plan and sample.

Gathers the full plan table, instrument/goniometer settings, UB matrix, and crystal symmetry from the view and passes them to model.create_plan(), model.create_sample(), model.update_sample(), and model.update_goniometer_motors() so they are recorded on the plan/sample workspaces before saving. Called by save_CSV() and save_experiment().

update_wavelength()[source]#

Update the derived wavelength display from the minimum wavelength.

Slot for the minimum wavelength line edit’s editingFinished signal.

visualize()[source]#

Recompute statistics and coverage, and refresh the plots.

Slot connected to several view signals (combined-peaks checkbox, color scheme, lattice centering, point group, visualization-ready) and called after orientations are added, deleted, or reconfigured. No-op if a previous visualization is still running (guarded by draw_idle). Computes completeness/redundancy statistics and, if a UB matrix is loaded, the reciprocal-space coverage point cloud, then updates the corresponding plots in the view.

PeriodicTable and Atom: Presenter classes for the periodic table and atom selection dialogs in NeuXtalViz.

This module defines the PeriodicTable and Atom presenter classes, which mediate between the periodic table/atom selection views and their underlying models, handling isotope selection and propagating the selected atom data back to the calling view/model.

Classes#

PeriodicTable

Presenter for the periodic table dialog, launching atom selection and updating the selection in the calling view/model.

Atom

Presenter for the atom/isotope selection dialog, updating displayed atom and neutron parameters as the isotope selection changes.

class Atom(view, model)[source]#

Bases: object

Presenter for the atom/isotope selection dialog in NeuXtalViz.

Connects the atom dialog view to its model, populating the available isotopes and updating the displayed atom/neutron parameters as the selection changes.

Methods

set_info()

Set atom parameters in the view using the selected isotope.

set_isotope()

Set the selected isotope and close the dialog.

set_info()[source]#

Set atom parameters in the view using the selected isotope.

Parameters:
None
set_isotope()[source]#

Set the selected isotope and close the dialog.

Parameters:
None
class PeriodicTable(view, model)[source]#

Bases: object

Presenter for the periodic table dialog in NeuXtalViz.

Connects the periodic table view to its model, launching the atom selection dialog and propagating the selected isotope back to the caller’s view/model.

Methods

connect_atom_model_view(atom)

Connect the atom model and view for the selected atom.

show_atom_dialog(atom)

Show the atom selection dialog for the given atom.

update_selection(data)

Update the atom selection in the model and view.

connect_atom_model_view(atom)[source]#

Connect the atom model and view for the selected atom.

Parameters:
atomobject

Atom identifier or data.

show_atom_dialog(atom)[source]#

Show the atom selection dialog for the given atom.

Parameters:
atomobject

Atom identifier or data.

update_selection(data)[source]#

Update the atom selection in the model and view.

Parameters:
dataobject

Selected atom data.

class UB(view, model)[source]#

Bases: NeuXtalVizPresenter

Presenter for the UB-matrix determination and refinement tools.

Mediates between the UB tools view and model: wires the view’s Qt signals to presenter handlers, converts UI events into model calls, and pushes model results back to the view. Covers Q-space conversion, peak finding/indexing/integration, UB matrix determination/transformation/refinement, lattice/cell selection, instrument and slice visualization, and peak alignment/clustering.

Methods

add_highlight_1()

Add the currently selected peak as the first highlighted peak.

add_highlight_2()

Add the currently selected peak as the second highlighted peak.

add_peak()

Add a peak at the current detector position to the model.

add_slice_peak(h, k, l)

Add a peak at the given hkl position from the slice view.

azimuth_view_left()

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()

Rotate the camera right (azimuth) by the configured step angle.

calculate_alignment()

Calculate observed-vs-predicted Q vectors for goniometer alignment.

calculate_alignment_complete(result)

Handle completion of the alignment-calculation worker.

calculate_alignment_process([progress, ...])

Worker task that computes observed-vs-predicted Q vectors for goniometer alignment.

calculate_camera_parameters()

Compute and display the camera's roll, elevation, and azimuth in the view.

calculate_highlight()

Calculate the angle between the two highlighted peaks.

calculate_hkl()

Compute the detector position corresponding to a given hkl.

calculate_peaks()

Calculate d-spacings and the interplanar angle for two entered hkl values.

change_lattice()

Enable or disable reciprocal lattice display in the view.

cluster()

Cluster peak hkl offsets to detect satellite modulation vectors.

cluster_complete(result)

Handle completion of the peak-clustering worker.

cluster_process([progress, stop_event, params])

Worker task that clusters peak positions using DBSCAN.

convert_Q([force_reload])

Load raw event/histogram data and convert it to Q-space in a background worker.

convert_Q_complete(result)

Handle the result of the Q-space conversion worker.

convert_Q_process([progress, stop_event, ...])

Worker task that loads, calibrates, and converts data to Q-space.

convert_Q_reload()

Reconvert data to Q-space, forcing a reload of already-loaded runs.

convert_to_hkl()

Redraw the HKL slice from the current Q-sample data.

convert_to_hkl_complete(result)

Handle completion of the HKL-slice conversion worker.

convert_to_hkl_process([progress, ...])

Worker task that computes an HKL slice from Q-sample data.

delete_peak()

Delete the currently selected peak(s) from the model.

elevate_view_down()

Tilt the camera down by the configured step angle.

elevate_view_up()

Tilt the camera up by the configured step angle.

filter_peaks()

Filter the peaks table by a variable, comparison operator, and value.

filter_peaks_complete(result)

Handle completion of the peak-filtering worker.

filter_peaks_process([progress, stop_event, ...])

Worker task that filters the peaks table.

find_conventional()

Determine the UB matrix from known lattice parameters.

find_conventional_complete([result])

Handle completion of the conventional-cell UB worker.

find_conventional_process([progress, ...])

Worker task that determines the UB matrix from lattice parameters.

find_niggli()

Determine the UB matrix from a Niggli (reduced primitive) cell.

find_niggli_complete(result)

Handle completion of the Niggli-cell UB worker.

find_niggli_process([progress, stop_event, ...])

Worker task that determines the UB matrix from a Niggli cell.

find_peaks()

Search for peaks in Q-space in a background worker.

find_peaks_complete(result)

Handle completion of the peak-finding worker.

find_peaks_process([progress, stop_event, ...])

Worker task that finds peaks and optionally removes peaks from known contaminant phases.

get_clim_method()

Get the color-limit clipping method for the slice view.

get_modulation_info()

Gather modulation-vector and satellite-indexing settings from the view.

get_normal()

Get the slice normal vector for the selected axis pair.

get_vlim_method()

Get the color-limit clipping method for the instrument view.

hand_index_fractional()

Recompute integer (h,k,l,m,n,p) indices from a manually edited fractional hkl and update the selected peak and view.

hand_index_integer()

Recompute a fractional hkl from manually edited integer (h,k,l,m,n,p) indices and update the selected peak and view.

handle_data_combo_change()

Handle selection of a new run in the data list combo box.

highlight_cell()

Sync the selected cell-table row to the form-number field.

highlight_peak()

Highlight the peak(s) selected in the peaks table.

index_peaks()

Index the peaks table against the current UB matrix.

index_peaks_complete(result)

Handle completion of the peak-indexing worker.

index_peaks_process([progress, stop_event, ...])

Worker task that indexes the peaks table.

integrate_peaks()

Integrate peak intensities in Q-space.

integrate_peaks_complete(result)

Handle completion of the peak-integration worker.

integrate_peaks_process([progress, ...])

Worker task that integrates peak intensities.

lattice_transform()

Populate the symmetry-operation choices for the selected lattice system.

load_Q()

Load a Q-sample workspace from a file selected by the user.

load_UB()

Load a UB matrix from a file selected by the user.

load_detector_calibration()

Prompt for and set a detector calibration file.

load_goniometer_calibration()

Prompt for and set a goniometer calibration file.

load_peaks()

Load a peaks table from a file selected by the user.

load_tube_calibration()

Prompt for and set a tube calibration file.

predict_peaks()

Predict peak positions from the UB matrix and lattice centering.

predict_peaks_complete(result)

Handle completion of the peak-prediction worker.

predict_peaks_process([progress, ...])

Worker task that predicts peak positions from the UB matrix.

refine_UB()

Refine the UB matrix using the selected refinement option.

refine_UB_complete(result)

Handle completion of the UB-refinement worker.

refine_UB_process([progress, stop_event, ...])

Worker task that refines the UB matrix.

refresh_peak_views()

Refresh the peaks table and alignment run list in the view.

reslice()

Redraw the HKL slice if sliced data already exists.

rotate_view_ccw()

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()

Roll the view clockwise about the viewing axis.

save_Q()

Save the current Q-sample workspace to a file selected by the user.

save_UB()

Save the current UB matrix to a file selected by the user.

save_peaks()

Save the current peaks table to a file selected by the user.

save_roi_mask()

Save a detector mask XML file for the current instrument-view ROI.

save_screenshot()

Save a screenshot of the current view to a file.

select_cell()

Transform to the conventional cell selected in the cell table.

select_cell_complete(result)

Handle completion of the cell-selection worker.

select_cell_process([progress, stop_event, ...])

Worker task that transforms the lattice to a conventional cell.

set_UB()

Set the UB matrix manually from lattice constants and sample directions.

set_UB_from_scattering_plane()

Determine the UB matrix from a scattering plane and lattice constants.

set_UB_from_scattering_plane_complete([result])

Handle completion of the scattering-plane UB worker.

set_UB_from_scattering_plane_process([...])

Worker task that determines the UB matrix from a scattering plane.

show_cells()

List possible conventional cells compatible with the current Niggli cell.

show_cells_complete(result)

Handle completion of the possible-cells worker.

show_cells_process([progress, stop_event, ...])

Worker task that lists possible conventional cells.

stop_processing(stop_event)

Check if a stop has been requested.

stop_workers()

Stop all running workers and update UI.

switch_instrument()

Refresh instrument-dependent view state after the instrument selection changes.

symmetry_transform()

Display the transform matrix for the selected symmetry operation.

transform_UB()

Apply a lattice transformation matrix to the UB matrix.

transform_UB_complete(result)

Handle completion of the UB-transformation worker.

transform_UB_process([progress, stop_event, ...])

Worker task that applies a lattice transformation to the UB matrix.

undo_filter_peaks()

Restore the peaks table to its state before the last filter operation.

undo_filter_peaks_complete(result)

Handle completion of the undo-filter worker.

undo_filter_peaks_process([progress, stop_event])

Worker task that restores the peaks table from the filter-peaks backup.

update_check_hkl()

Recompute and display the hkl corresponding to the current ROI scan position.

update_complete([status])

Indicate completion to the user and reset progress.

update_cvals()

Update the slice colorbar limits from the view's vmin/vmax line-edit values.

update_data_status()

Refresh the Q/peaks/UB status indicators and undo-filter availability in the view.

update_find_distance()

Update the find peaks d-spacing in the view from the distance (Q) value.

update_find_spacing()

Update the find peaks distance (Q) in the view from the d-spacing value.

update_inst_cvals()

Update the instrument view colorbar limits from the view's vmin/vmax line-edit values.

update_instrument_clim()

Refresh the instrument display using the current color limits.

update_instrument_display()

Redraw the instrument view display using the cached signal.

update_instrument_view()

Recompute and redraw the instrument detector view in a background worker.

update_instrument_view_autoscaled()

Refresh the instrument view, clearing manual color limits when auto-limits are enabled.

update_instrument_view_complete(result)

Handle the result of the instrument view computation worker.

update_instrument_view_process([progress, ...])

Worker task that computes the instrument detector view and ROI.

update_invalid()

Indicate invalid parameters to the user and reset progress.

update_lattice_info()

Refresh the lattice constants and sample-direction displays in the view from the current UB matrix.

update_oriented_lattice()

Update the oriented lattice parameter display in the view.

update_processing([status, progress])

Indicate processing state to the user and update progress.

update_progress(progress)

Update progress step in the view.

update_roi()

Recompute and redraw the region-of-interest (ROI) view.

update_run_goniometer()

Update the displayed goniometer setting for the selected run.

update_scan()

Recompute and redraw the ROI scan (integrated profile) view.

update_slice_clim()

Refresh the slice display using the current color limits.

update_slice_display()

Redraw the HKL slice display using the cached signal.

update_slice_extent()

Update the slice slider range for the selected projection and axis pair.

update_status(status)

Update status information in the view.

update_stopped()

Indicate that processing was stopped by the user.

update_wavelength()

Sync the minimum wavelength value into the wavelength display.

view_ab()

Set the view to the c* direction (real lattice).

view_ab_star()

Set the view to the c-axis direction (reciprocal lattice).

view_bc()

Set the view to the a* direction (real lattice).

view_bc_star()

Set the view to the a-axis direction (reciprocal lattice).

view_ca()

Set the view to the b* direction (real lattice).

view_ca_star()

Set the view to the b-axis direction (reciprocal lattice).

view_manual()

Set the view to a manually specified axis direction.

view_up_manual()

Set the view's up direction to a manually specified axis.

visualize()

Refresh the 3D Q-space visualization and dependent UI state.

add_highlight_1()[source]#

Add the currently selected peak as the first highlighted peak.

Connected to the first “Add Highlighted” button signal. Looks up the peak selected in the peaks table and, if found, adds it to the view as highlighted peak 1.

add_highlight_2()[source]#

Add the currently selected peak as the second highlighted peak.

Connected to the second “Add Highlighted” button signal. Looks up the peak selected in the peaks table and, if found, adds it to the view as highlighted peak 2.

add_peak()[source]#

Add a peak at the current detector position to the model.

Connected to the “add peak” button signal. Reads the selected run, horizontal/vertical detector coordinates, and diffraction (e.g. time-of-flight or wavelength) value from the view, adds the corresponding peak via the model, and refreshes the visualization.

add_slice_peak(h, k, l)[source]#

Add a peak at the given hkl position from the slice view.

Connected to the view’s slice_ready signal, emitted when the user picks a point on the HKL slice plot.

Parameters:
hfloat

H index of the selected slice position.

kfloat

K index of the selected slice position.

lfloat

L index of the selected slice position.

calculate_alignment()[source]#

Calculate observed-vs-predicted Q vectors for goniometer alignment.

Connected to the “calculate alignment” button signal. Gathers the selected run number and goniometer tilt angles from the view, then dispatches calculate_alignment_process to a worker thread whose completion renders the alignment comparison.

calculate_alignment_complete(result)[source]#

Handle completion of the alignment-calculation worker.

Parameters:
resultdict or None

Alignment information dictionary returned by calculate_alignment_process, or None if the calculation did not succeed. If present, the alignment comparison view is refreshed.

calculate_alignment_process(progress=None, stop_event=None, run_number=None, tilts=None)[source]#

Worker task that computes observed-vs-predicted Q vectors for goniometer alignment.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

run_numberint or None, optional

Run number to select peaks from, or None if the input field is invalid.

tiltstuple or None, optional

Goniometer tilt angles (yaw, pitch, roll) in degrees, or None if the input fields are invalid.

Returns:
resultdict

Alignment information dictionary from the model, returned only if peaks and a UB matrix are present, the parameters are valid, and indexed peaks exist for the selected run.

calculate_highlight()[source]#

Calculate the angle between the two highlighted peaks.

Connected to the highlighted-peaks “Calculate” button signal. Reads the Q vectors of the two highlighted peaks from the view and, if both are set, updates the angle display.

calculate_hkl()[source]#

Compute the detector position corresponding to a given hkl.

Connected to the “check hkl” signal. Reads the selected run and target hkl from the view, asks the model for the diffraction value and horizontal/vertical detector coordinates for that hkl, and updates the corresponding view fields and instrument display.

calculate_peaks()[source]#

Calculate d-spacings and the interplanar angle for two entered hkl values.

Connected to the hkl-calculation “Calculate” button signal. Reads the two hkl values and lattice constants from the view and, if the lattice constants are valid, updates the d-spacing/angle display.

cluster()[source]#

Cluster peak hkl offsets to detect satellite modulation vectors.

Connected to the “cluster” button signal. Gathers the DBSCAN (eps, min_samples) parameters from the view, then dispatches cluster_process to a worker thread whose completion renders the cluster peaks and populates the cluster table.

cluster_complete(result)[source]#

Handle completion of the peak-clustering worker.

Parameters:
resultdict or None

Updated cluster peak information dictionary returned by cluster_process, or None if clustering did not succeed. If present, the 3D cluster view and cluster table are refreshed.

cluster_process(progress=None, stop_event=None, params=None)[source]#

Worker task that clusters peak positions using DBSCAN.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

paramstuple or None, optional

(eps, min_samples) DBSCAN parameters as returned by the view, or None if the input fields are invalid.

Returns:
peak_infodict

Updated cluster peak information dictionary from the model, returned only if clustering succeeds.

convert_Q(force_reload=False)[source]#

Load raw event/histogram data and convert it to Q-space in a background worker.

Connected to the “convert Q” button signal. Gathers the instrument, wavelength, calibration files, IPTS/run/experiment numbers, Lorentz-correction flag, time-stop cutoff, and minimum d-spacing from the view, then dispatches convert_Q_process to a worker thread whose result updates the run list and triggers a visualization refresh.

Parameters:
force_reloadbool, optional

Whether to force reloading/reconverting data that has already been loaded (default is False). True when invoked via convert_Q_reload.

convert_Q_complete(result)[source]#

Handle the result of the Q-space conversion worker.

Parameters:
resultdict or None

Dictionary with keys "runs" (list of loaded/converted run workspace names) and "mono" (whether the data is monochromatic), or None if conversion failed or produced no output.

convert_Q_process(progress=None, stop_event=None, instrument=None, wavelength=None, tube_cal=None, det_cal=None, gon_cal=None, IPTS=None, runs=None, exp=None, lorentz=None, time_stop=None, d_min=None, force_reload=False)[source]#

Worker task that loads, calibrates, and converts data to Q-space.

Parameters:
progresscallable or None

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None

Event used to signal that processing should stop early.

instrumentstr or None

Instrument name.

wavelengthfloat, tuple, or None

Incident wavelength (or wavelength band for time-of-flight instruments).

tube_calstr or None

Path to a tube calibration file.

det_calstr or None

Path to a detector calibration file.

gon_calstr or None

Path to a goniometer calibration file.

IPTSint or None

IPTS proposal number.

runsstr or None

Run number(s) to load.

expint or None

Experiment number (required for DEMAND).

lorentzbool or None

Whether to apply the Lorentz correction during conversion.

time_stopfloat or None

Time cutoff used to filter events during loading.

d_minfloat or None

Minimum d-spacing used when converting data to Q-space.

force_reloadbool, optional

Whether to force reloading/reconverting already-loaded data (default is False).

Returns:
resultdict or None

Dictionary with keys "mono" (bool, whether the data is monochromatic) and "runs" (int, number of loaded workspaces), or None if processing was stopped, the required data files do not exist, or the input parameters are invalid.

convert_Q_reload()[source]#

Reconvert data to Q-space, forcing a reload of already-loaded runs.

Connected to the “reload/reconvert Q” button signal.

convert_to_hkl()[source]#

Redraw the HKL slice from the current Q-sample data.

Connected to the “Convert” button signal for HKL conversion. No-ops if a slice update is already in progress. Gathers the projection matrix, slice position/thickness/width, slice normal, color-limit method, and display-scaling parameters from the view, then dispatches convert_to_hkl_process to a worker thread whose completion updates the slice display.

convert_to_hkl_complete(result)[source]#

Handle completion of the HKL-slice conversion worker.

Parameters:
resultdict or None

Slice information dictionary returned by convert_to_hkl_process, or None if the slice could not be computed. If present, its “signal” array is cached and the slice display is updated.

convert_to_hkl_process(progress=None, stop_event=None, proj=None, value=None, thickness=None, width=None, norm=None, clim_method=None, slice_scale=None, slice_auto_limits=None, vmin=None, vmax=None)[source]#

Worker task that computes an HKL slice from Q-sample data.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

projarray_like or None, optional

Projection matrix (9 values reshaped to 3x3) whose rows define the U, V, W basis vectors, or None if the input fields are invalid.

valuefloat or None, optional

Position along the slice normal at which to slice.

thicknessfloat or None, optional

Thickness of the slice.

widthfloat or None, optional

Width of the output histogram bins.

normlist or None, optional

Normal vector for the slice, as returned by get_normal.

clim_methodstr or None, optional

Color-limit clipping method, as returned by get_clim_method.

slice_scalestr or None, optional

Display scaling for the slice (“linear” or “log”).

slice_auto_limitsbool or None, optional

Whether to automatically compute display limits.

vmin, vmaxfloat or None, optional

Manual display limits, used when slice_auto_limits is False.

Returns:
slice_histodict

Slice information dictionary (extents, bins, transform, signal, and resolved display limits), returned only if the projection is valid and slice data is available.

delete_peak()[source]#

Delete the currently selected peak(s) from the model.

Connected to the “delete peak” button signal. Removes the highlighted peak rows from the model’s peaks table, clears the selection in the view, and refreshes the visualization.

filter_peaks()[source]#

Filter the peaks table by a variable, comparison operator, and value.

Connected to the “filter peaks” button signal. Gathers the filter variable, comparison operator, and threshold value from the view, then dispatches filter_peaks_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

filter_peaks_complete(result)[source]#

Handle completion of the peak-filtering worker.

Parameters:
resultNone

Unused; filter_peaks_process reports progress but does not return a value.

filter_peaks_process(progress=None, stop_event=None, name=None, operator=None, value=None)[source]#

Worker task that filters the peaks table.

Snapshots the current peaks table before filtering so the operation can be undone.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

namestr or None, optional

Name of the peak variable to filter on.

operatorstr or None, optional

Comparison operator used to filter peaks.

valuefloat or None, optional

Threshold value peaks are compared against, or None if the input field is invalid.

find_conventional()[source]#

Determine the UB matrix from known lattice parameters.

Connected to the “find conventional cell” button signal. Gathers the lattice constants and indexing tolerance from the view, then dispatches find_conventional_process to a worker thread whose completion refreshes the data status and visualization.

find_conventional_complete(result=None)[source]#

Handle completion of the conventional-cell UB worker.

Parameters:
resultNone, optional

Unused; find_conventional_process reports progress but does not return a value.

find_conventional_process(progress=None, stop_event=None, params=None, tol=None)[source]#

Worker task that determines the UB matrix from lattice parameters.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

paramstuple or None, optional

Lattice constants (a, b, c, alpha, beta, gamma) as returned by the view, or None if the input fields are invalid.

tolfloat or None, optional

Indexing tolerance, or None if the input field is invalid.

find_niggli()[source]#

Determine the UB matrix from a Niggli (reduced primitive) cell.

Connected to the “find niggli cell” button signal. Gathers the minimum/maximum lattice constants and indexing tolerance from the view, then dispatches find_niggli_process to a worker thread whose completion lists the possible conventional cells and refreshes the visualization.

find_niggli_complete(result)[source]#

Handle completion of the Niggli-cell UB worker.

Parameters:
resultNone

Unused; find_niggli_process reports progress but does not return a value.

find_niggli_process(progress=None, stop_event=None, params=None, tol=None)[source]#

Worker task that determines the UB matrix from a Niggli cell.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

paramstuple or None, optional

(min_d, max_d) minimum and maximum lattice constants as returned by the view, or None if the input fields are invalid.

tolfloat or None, optional

Indexing tolerance, or None if the input field is invalid.

find_peaks()[source]#

Search for peaks in Q-space in a background worker.

Connected to the “find peaks” button signal. Gathers the minimum Q, maximum d-spacing, peak-finding parameters, edge exclusion, peak width, and contamination-avoidance flags (aluminum/copper/iron) from the view, then dispatches find_peaks_process to a worker thread whose completion copies the resulting peaks into the UB and refreshes the visualization.

find_peaks_complete(result)[source]#

Handle completion of the peak-finding worker.

Parameters:
resultNone

Unused; find_peaks_process reports progress but does not return a value.

find_peaks_process(progress=None, stop_event=None, Q_min=None, d_max=None, params=None, edge=None, peak_width=None, no_al=None, no_cu=None, no_fe=None)[source]#

Worker task that finds peaks and optionally removes peaks from known contaminant phases.

Parameters:
progresscallable or None

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None

Event used to signal that processing should stop early.

Q_minfloat or None

Minimum |Q| distance between peaks used for peak finding.

d_maxfloat or None

Maximum d-spacing considered for contamination avoidance.

paramstuple or None

Peak-finding parameters passed to the model’s find_peaks.

edgeint or float or None

Number of pixels/bins to exclude from the detector edge.

peak_widthfloat or None

Peak width used for contamination avoidance.

no_albool or None

Whether to remove peaks matching aluminum contamination.

no_cubool or None

Whether to remove peaks matching copper contamination.

no_febool or None

Whether to remove peaks matching iron contamination.

get_clim_method()[source]#

Get the color-limit clipping method for the slice view.

Returns:
methodstr or None

"normal" for mean +/- 3 standard deviations, "boxplot" for the interquartile-range method, or None if neither is selected (no clipping).

get_modulation_info()[source]#

Gather modulation-vector and satellite-indexing settings from the view.

Returns:
mod_vec_1, mod_vec_2, mod_vec_3list

Modulation offset vectors [dh, dk, dl].

max_orderint

Maximum satellite order, 0 if the max-order/cross-terms input is invalid.

cross_termsbool

Whether to include modulation cross terms, False if the max-order/cross-terms input is invalid.

get_normal()[source]#

Get the slice normal vector for the selected axis pair.

Returns:
normlist

Unit normal vector [1, 0, 0], [0, 1, 0], or [0, 0, 1] corresponding to the “Axis 2/3”, “Axis 1/3”, or “Axis 1/2” slice-plane selection, respectively.

get_vlim_method()[source]#

Get the color-limit clipping method for the instrument view.

Returns:
methodstr or None

"normal" for mean +/- 3 standard deviations, "boxplot" for the interquartile-range method, or None if neither is selected (no clipping).

hand_index_fractional()[source]#

Recompute integer (h,k,l,m,n,p) indices from a manually edited fractional hkl and update the selected peak and view.

Connected to the h/k/l fractional index line edit signals. Reads the modulation vectors, the current hkl/integer-hkl/mnp indices, and the selected peak row from the view; if all are available, recalculates the integer indices, stores them on the selected peak in the model, and updates the peaks table and index fields in the view.

hand_index_integer()[source]#

Recompute a fractional hkl from manually edited integer (h,k,l,m,n,p) indices and update the selected peak and view.

Connected to the integer h/k/l/m/n/p index line edit signals. Reads the modulation vectors, the current hkl/integer-hkl/mnp indices, and the selected peak row from the view; if all are available, recalculates the fractional hkl, stores it on the selected peak in the model, and updates the peaks table and index fields in the view.

handle_data_combo_change()[source]#

Handle selection of a new run in the data list combo box.

Connected to the view’s data-list combo box signal. Invalidates the cached instrument signal so the instrument view is recomputed from scratch, then refreshes the (auto-scaled) instrument view.

highlight_cell()[source]#

Sync the selected cell-table row to the form-number field.

Connected to the cell table’s selection-changed signal. Reads the form number of the currently selected row and writes it into the form-number input field.

highlight_peak()[source]#

Highlight the peak(s) selected in the peaks table.

Connected to the peaks table’s selection-changed signal. If one or more rows are selected, looks up the first selected peak, updates the peak-information display, highlights all selected peaks in the 3D view, and centers the view on the first peak’s position. Clears the highlight if no rows are selected.

index_peaks()[source]#

Index the peaks table against the current UB matrix.

Connected to the “index peaks” button signal. Gathers modulation info, indexing tolerances, whether to index satellite peaks, and whether to round hkl values from the view, then dispatches index_peaks_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

index_peaks_complete(result)[source]#

Handle completion of the peak-indexing worker.

Parameters:
resultNone

Unused; index_peaks_process reports progress but does not return a value.

index_peaks_process(progress=None, stop_event=None, mod_info=None, params=None, sat=None, round_hkl=None)[source]#

Worker task that indexes the peaks table.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

mod_infotuple or None, optional

(mod_vec_1, mod_vec_2, mod_vec_3, max_order, cross_terms) as returned by get_modulation_info.

paramstuple or None, optional

(tol, sat_tol) indexing and satellite-indexing tolerances, or None if the input fields are invalid.

satbool or None, optional

Whether to index satellite peaks; if False, max_order is forced to 0.

round_hklbool or None, optional

Whether to round indexed hkl values to integers.

integrate_peaks()[source]#

Integrate peak intensities in Q-space.

Connected to the “integrate peaks” button signal. Gathers the integration radius/background factors, whether to use ellipsoidal integration, and whether to centroid peaks first from the view, then dispatches integrate_peaks_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

integrate_peaks_complete(result)[source]#

Handle completion of the peak-integration worker.

Parameters:
resultNone

Unused; integrate_peaks_process reports progress but does not return a value.

integrate_peaks_process(progress=None, stop_event=None, params=None, ellipsoid=None, centroid=None)[source]#

Worker task that integrates peak intensities.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

paramstuple or None, optional

(rad, inner_factor, outer_factor) integration radius and background shell factors, or None if the input fields are invalid.

ellipsoidbool or None, optional

Whether to use ellipsoidal (True) or spherical (False) integration regions.

centroidbool or None, optional

Whether to shift peak positions to their centroid before integrating (spherical method only).

lattice_transform()[source]#

Populate the symmetry-operation choices for the selected lattice system.

Connected to the lattice-system combo box signal. Generates the lattice transforms compatible with the selected lattice system, updates the symmetry-operation combo box with their symbols, and applies the currently selected symmetry transform.

load_Q()[source]#

Load a Q-sample workspace from a file selected by the user.

Connected to the “Load Q” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, loads it into the model, updates the minimum d-spacing, wavelength, and instrument selection fields in the view, refreshes the lattice information, and redraws the visualization.

load_UB()[source]#

Load a UB matrix from a file selected by the user.

Connected to the “Load UB” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, loads it into the model and updates the transform display in the view.

load_detector_calibration()[source]#

Prompt for and set a detector calibration file.

Connected to the “Browse” button signal for the detector calibration field. Opens a file dialog rooted at the instrument’s calibration directory and, if a file is chosen, writes its path into the view.

load_goniometer_calibration()[source]#

Prompt for and set a goniometer calibration file.

Connected to the “Browse” button signal for the goniometer calibration field. Opens a file dialog rooted at the instrument’s calibration directory and, if a file is chosen, writes its path into the view.

load_peaks()[source]#

Load a peaks table from a file selected by the user.

Connected to the “Load Peaks” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, loads it into the model and refreshes the peaks table and 3D peak views.

load_tube_calibration()[source]#

Prompt for and set a tube calibration file.

Connected to the “Browse” button signal for the tube calibration field. Opens a file dialog rooted at the instrument’s calibration directory and, if a file is chosen, writes its path into the view.

predict_peaks()[source]#

Predict peak positions from the UB matrix and lattice centering.

Connected to the “predict peaks” button signal. Gathers modulation info, lattice centering, wavelength band, d-spacing/edge parameters, and whether to predict satellite peaks from the view, then dispatches predict_peaks_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

predict_peaks_complete(result)[source]#

Handle completion of the peak-prediction worker.

Parameters:
resultNone

Unused; predict_peaks_process reports progress but does not return a value.

predict_peaks_process(progress=None, stop_event=None, mod_info=None, centering=None, wavelength=None, params=None, predict_sat=None, edge=None)[source]#

Worker task that predicts peak positions from the UB matrix.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

mod_infotuple or None, optional

(mod_vec_1, mod_vec_2, mod_vec_3, max_order, cross_terms) as returned by get_modulation_info.

centeringstr or None, optional

Lattice centering symbol used to apply reflection conditions.

wavelengthtuple or None, optional

(lamda_min, lamda_max) wavelength band in angstroms, or None if the input fields are invalid.

paramstuple or None, optional

(d_min, sat_d_min) minimum d-spacing for fundamental and satellite peaks, or None if the input fields are invalid.

predict_satbool or None, optional

Whether to also predict satellite peak positions.

edgeint or float or None, optional

Number of pixels/bins to exclude from the detector edge.

refine_UB()[source]#

Refine the UB matrix using the selected refinement option.

Connected to the “optimize UB” button signal. Gathers the lattice constants, refinement tolerance, and refinement option (e.g. constrained/unconstrained/lattice-system-constrained) from the view, then dispatches refine_UB_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

refine_UB_complete(result)[source]#

Handle completion of the UB-refinement worker.

Parameters:
resultNone

Unused; refine_UB_process reports progress but does not return a value.

refine_UB_process(progress=None, stop_event=None, params=None, tol=None, option=None)[source]#

Worker task that refines the UB matrix.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

paramstuple or None, optional

Lattice constants (a, b, c, alpha, beta, gamma), used only when option is "Constrained", or None if the input fields are invalid.

tolfloat or None, optional

Indexing tolerance, or None if the input field is invalid.

optionstr or None, optional

Refinement option: "Constrained" to refine orientation only from params, "Unconstrained" to refine the UB without lattice-system constraints, or a lattice system name to refine the UB with that lattice-system constraint.

refresh_peak_views()[source]#

Refresh the peaks table and alignment run list in the view.

Pulls the current peak information from the model (or an empty list if there are no peaks) and pushes it to the peaks table and the alignment run selector in the view.

reslice()[source]#

Redraw the HKL slice if sliced data already exists.

Connected to the slice-position/thickness/width field and slider signals.

save_Q()[source]#

Save the current Q-sample workspace to a file selected by the user.

Connected to the “Save Q” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, saves the Q-sample workspace there.

save_UB()[source]#

Save the current UB matrix to a file selected by the user.

Connected to the “Save UB” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, saves the UB matrix there.

save_peaks()[source]#

Save the current peaks table to a file selected by the user.

Connected to the “Save Peaks” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, saves the peaks table there.

save_roi_mask()[source]#

Save a detector mask XML file for the current instrument-view ROI.

Connected to the “Save ROI Mask” button signal. Opens a file dialog rooted at the instrument’s shared directory and, if a file is chosen, saves the mask there and reports the outcome message to the view.

select_cell()[source]#

Transform to the conventional cell selected in the cell table.

Connected to the cell-selection button signal. Gathers the form number and indexing tolerance from the view, then dispatches select_cell_process to a worker thread whose completion refreshes the visualization.

select_cell_complete(result)[source]#

Handle completion of the cell-selection worker.

Parameters:
resultNone

Unused; select_cell_process reports progress but does not return a value.

select_cell_process(progress=None, stop_event=None, form=None, tol=None)[source]#

Worker task that transforms the lattice to a conventional cell.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

formint or None, optional

Conventional cell form number, or None if the input field is invalid.

tolfloat or None, optional

Indexing tolerance, or None if the input field is invalid.

set_UB()[source]#

Set the UB matrix manually from lattice constants and sample directions.

Connected to the “Set UB” button signal. Reads the lattice constants and sample directions from the view and, if both are valid, sets the UB matrix on the model and refreshes the data status, lattice information, and oriented-lattice display.

set_UB_from_scattering_plane()[source]#

Determine the UB matrix from a scattering plane and lattice constants.

Connected to the “Search U from Scattering Plane” button signal. Gathers the lattice constants and scattering-plane sample directions from the view, then dispatches set_UB_from_scattering_plane_process to a worker thread whose completion refreshes the data status and visualization.

set_UB_from_scattering_plane_complete(result=None)[source]#

Handle completion of the scattering-plane UB worker.

Parameters:
resultbool or None, optional

True if set_UB_from_scattering_plane_process succeeded, otherwise None.

set_UB_from_scattering_plane_process(progress=None, stop_event=None, constants=None, directions=None)[source]#

Worker task that determines the UB matrix from a scattering plane.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

constantslist or None, optional

Lattice constants and angles [a, b, c, alpha, beta, gamma], or None if the input fields are invalid.

directionslist or None, optional

Two non-parallel vectors [u1, u2, u3, v1, v2, v3] defining the scattering plane, or None if the input fields are invalid.

Returns:
successbool

True if the UB matrix was determined successfully, returned only on success.

show_cells()[source]#

List possible conventional cells compatible with the current Niggli cell.

Gathers the maximum scalar error tolerance from the view, then dispatches show_cells_process to a worker thread whose completion populates the cell table and refreshes the visualization.

show_cells_complete(result)[source]#

Handle completion of the possible-cells worker.

Parameters:
resultlist or None

Possible conventional cells returned by show_cells_process, or None if the operation could not be performed.

show_cells_process(progress=None, stop_event=None, scalar=None)[source]#

Worker task that lists possible conventional cells.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

scalarfloat or None, optional

Maximum scalar error tolerance, or None if the input field is invalid.

Returns:
cellslist

Possible conventional cells found, returned only if peaks and a UB matrix are present and scalar is valid.

switch_instrument()[source]#

Refresh instrument-dependent view state after the instrument selection changes.

Connected to the instrument combo box signal. Updates the wavelength, clears run information, sets the goniometer axes and default minimum d-spacing fields for the newly selected instrument.

symmetry_transform()[source]#

Display the transform matrix for the selected symmetry operation.

Connected to the symmetry-operation combo box signal. Regenerates the lattice transforms for the selected lattice system and, if the selected symmetry symbol is among them, writes the corresponding transform matrix into the view.

transform_UB()[source]#

Apply a lattice transformation matrix to the UB matrix.

Connected to the “Transform” button signal. Gathers the transform matrix and indexing tolerance from the view, then dispatches transform_UB_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

transform_UB_complete(result)[source]#

Handle completion of the UB-transformation worker.

Parameters:
resultNone

Unused; transform_UB_process reports progress but does not return a value.

transform_UB_process(progress=None, stop_event=None, params=None, tol=None)[source]#

Worker task that applies a lattice transformation to the UB matrix.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

params3x3 array-like or None, optional

Transform matrix to apply to the hkl values, or None if the input fields are invalid.

tolfloat or None, optional

Indexing tolerance, or None if the input field is invalid.

undo_filter_peaks()[source]#

Restore the peaks table to its state before the last filter operation.

Connected to the “undo filter” button signal. Dispatches undo_filter_peaks_process to a worker thread whose completion copies the resulting UB back from the peaks and refreshes the visualization.

undo_filter_peaks_complete(result)[source]#

Handle completion of the undo-filter worker.

Parameters:
resultNone

Unused; undo_filter_peaks_process reports progress but does not return a value.

undo_filter_peaks_process(progress=None, stop_event=None)[source]#

Worker task that restores the peaks table from the filter-peaks backup.

Parameters:
progresscallable or None, optional

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None, optional

Event used to signal that processing should stop early.

update_check_hkl()[source]#

Recompute and display the hkl corresponding to the current ROI scan position.

Connected to the view’s scan_ready signal, emitted after the scan plot has been redrawn.

update_cvals()[source]#

Update the slice colorbar limits from the view’s vmin/vmax line-edit values.

Connected to the slice view’s vmin/vmax line-edit signals. Manually editing either value disables automatic color limits. Adjusts the lower limit upward when it is non-positive and the slice scale is logarithmic.

update_data_status()[source]#

Refresh the Q/peaks/UB status indicators and undo-filter availability in the view.

Checks whether the expected data files exist for the current instrument/IPTS/run(s)/experiment selection and updates the Q-data, peaks, and UB status indicators, as well as whether the “undo filter peaks” action is enabled.

update_find_distance()[source]#

Update the find peaks d-spacing in the view from the distance (Q) value.

Connected to the find-peaks distance (Q) line edit signal.

update_find_spacing()[source]#

Update the find peaks distance (Q) in the view from the d-spacing value.

Connected to the find-peaks d-spacing line edit signal.

update_inst_cvals()[source]#

Update the instrument view colorbar limits from the view’s vmin/vmax line-edit values.

Connected to the instrument view’s vmin/vmax line-edit signals. Manually editing either value disables automatic color limits. Adjusts the lower limit upward when it is non-positive and the instrument scale is logarithmic.

update_instrument_clim()[source]#

Refresh the instrument display using the current color limits.

Connected to the instrument view’s vlim-combo signal. Selecting a method re-enables automatic color limits.

update_instrument_display()[source]#

Redraw the instrument view display using the cached signal.

Connected to the instrument scale/colormap/colorbar combo box and auto-limits signals. If no signal is cached yet, triggers a full instrument view recomputation instead. Otherwise resolves the display limits and updates the view’s colormap, scale, and color limits.

update_instrument_view()[source]#

Recompute and redraw the instrument detector view in a background worker.

Connected to the d_min/d_max range signals (and invoked after Q conversion, run selection, and hkl lookups). No-ops if a prior instrument view computation is still in flight. Gathers the selected run, d-spacing range, horizontal/vertical position and ROI, diffraction value, and display-limit settings from the view, then dispatches update_instrument_view_process to a worker thread.

update_instrument_view_autoscaled()[source]#

Refresh the instrument view, clearing manual color limits when auto-limits are enabled.

Connected to the instrument view’s vlim-combo signal. If auto-limits are enabled, clears the manual vmin/vmax line edits (blocking their signals while doing so), then redraws the instrument display from the cached signal, or recomputes the instrument view if no cache is available.

update_instrument_view_complete(result)[source]#

Handle the result of the instrument view computation worker.

Parameters:
resulttuple or None

Tuple of (inst_view, roi_view) dictionaries as produced by the model’s inst_view/roi_view state, or None if the computation was stopped or the parameters were invalid. inst_view["img"] is cached for redisplaying without recomputation.

update_instrument_view_process(progress=None, stop_event=None, ind=None, d_min=None, d_max=None, horz=None, vert=None, horz_roi=None, vert_roi=None, val=None, vlim_method=None, instrument_scale=None, instrument_auto_limits=None, inst_vmin=None, inst_vmax=None)[source]#

Worker task that computes the instrument detector view and ROI.

Parameters:
progresscallable or None

Callback progress(message, percent) used to report status back to the view.

stop_eventthreading.Event or None

Event used to signal that processing should stop early.

indint or None

Index of the selected run in the data list.

d_minfloat or None

Minimum d-spacing to include in the instrument view.

d_maxfloat or None

Maximum d-spacing to include in the instrument view.

horzfloat or None

Horizontal detector coordinate for the ROI center.

vertfloat or None

Vertical detector coordinate for the ROI center.

horz_roifloat or None

Horizontal ROI half-width.

vert_roifloat or None

Vertical ROI half-width.

valfloat or None

Diffraction (time-of-flight/wavelength) value for the ROI.

vlim_methodstr or None

Clipping method used to resolve display color limits.

instrument_scalestr or None

Display scale ("log" or "linear") for the instrument view.

instrument_auto_limitsbool or None

Whether display limits should be automatically computed.

inst_vminfloat or None

Manually-set lower display limit.

inst_vmaxfloat or None

Manually-set upper display limit.

Returns:
inst_viewdict

The model’s instrument view data (image, extents, and resolved display limits).

roi_viewdict

The model’s extracted region-of-interest data, or None if processing was stopped or the parameters were invalid.

update_lattice_info()[source]#

Refresh the lattice constants and sample-direction displays in the view from the current UB matrix.

update_roi()[source]#

Recompute and redraw the region-of-interest (ROI) view.

Connected to the horizontal/vertical position and ROI-width line edit signals. No-ops while an instrument view computation is in flight. Extracts the ROI from the model using the current horizontal/vertical position and widths, updates the ROI view, and refreshes the checked hkl display.

update_run_goniometer()[source]#

Update the displayed goniometer setting for the selected run.

update_scan()[source]#

Recompute and redraw the ROI scan (integrated profile) view.

Connected to the view’s roi_ready signal, emitted after the ROI plot has been redrawn. No-ops while an instrument view computation is in flight. Extracts the ROI from the model and updates the scan view and checked hkl display.

update_slice_clim()[source]#

Refresh the slice display using the current color limits.

Connected to the slice view’s color-limit method combo box. Selecting a method re-enables automatic color limits.

update_slice_display()[source]#

Redraw the HKL slice display using the cached signal.

Connected to the slice scale/colormap/colorbar combo box and auto-limits signals. If no signal is cached yet, triggers a full reslice instead. Otherwise resolves the display limits and updates the view’s colormap, scale, and color limits.

update_slice_extent()[source]#

Update the slice slider range for the selected projection and axis pair.

Connected to the slice axis-pair combo box signal. Validates the projection matrix and, if valid, computes the extent along the slice normal and reconfigures the slice slider’s range.

update_wavelength()[source]#

Sync the minimum wavelength value into the wavelength display.

Connected to editing-finished on the minimum wavelength field.

visualize()[source]#

Refresh the 3D Q-space visualization and dependent UI state.

Called after data-modifying operations complete (e.g. Q conversion, peak finding/indexing/integration, UB determination). No-ops if there is no Q data or a visualization update is already in progress. Updates the data status, redraws the Q-space volume, refreshes UB/lattice information if a UB matrix is set, and refreshes the peaks table.

class VolumeSlicer(view, model)[source]#

Bases: NeuXtalVizPresenter

Presenter for the volume slicer tool.

Connects the volume slicer view’s signals to model-driven actions for loading a NeXus MDHisto workspace and interactively slicing and cutting through the resulting volume, including managing display/color limits and saving slices and cuts.

Parameters:
viewNeuXtalViz.views.volume_slicer.VolumeSlicerView

View for the volume slicer tool.

modelNeuXtalViz.models.volume_slicer.VolumeSlicer

Model for the volume slicer tool.

Methods

activate_workspace()

Make the workspace combo's current selection the active workspace.

activate_workspace_complete(result)

Refresh lattice/display state after a new workspace is activated.

azimuth_view_left()

Rotate the camera left (azimuth) by the configured step angle.

azimuth_view_right()

Rotate the camera right (azimuth) by the configured step angle.

calculate_camera_parameters()

Compute and display the camera's roll, elevation, and azimuth in the view.

calculate_pdf()

Run the pad/FFT stage, producing a 3D-ΔPDF result.

calculate_pdf_complete(result)

Refresh the workspace list after a 3D-ΔPDF calculation completes.

change_lattice()

Enable or disable reciprocal lattice display in the view.

combine_workspaces()

Compute a * ws_a - b * ws_b from the arithmetic panel's inputs.

cut_data()

Cut the sliced volume on a worker thread if not already cutting.

cut_data_complete(result)

Complete cut calculation and update the view with the result.

cut_data_process(progress[, stop_event, ...])

Worker task that computes a 1D cut through the sliced volume.

delete_workspace()

Delete the workspace currently selected in the management list.

elevate_view_down()

Tilt the camera down by the configured step angle.

elevate_view_up()

Tilt the camera up by the configured step angle.

get_axis()

Get the axis vector for the currently selected line cut.

get_clim_method()

Get the color-limit clipping method for the 3D volume display.

get_normal()

Get the normal vector for the currently selected slice plane.

get_vlim_method()

Get the color-limit clipping method for the 2D slice display.

load_NXS()

Prompt for a NeXus file and a workspace name, then load it on a worker thread.

load_NXS_complete(result)

Complete NeXus file loading by refreshing the oriented lattice display.

load_NXS_process(progress[, stop_event])

Worker task that loads a NeXus MDHisto workspace.

load_bond_cif()

Prompt for a CIF file and load it for the bond-network viewer.

load_bond_cif_complete(result)

Populate the atom-site table after a CIF finishes loading.

plot_bond_network()

Build the supercell bond network and draw it in the 3D view.

plot_bond_network_complete(result)

Chain a second worker to sample ΔPDF correlations, then draw.

redraw_data([reset])

Redraw the 3D volume on a worker thread if not already drawing.

redraw_data_complete(result)

Complete volume redraw and update the view with the new histogram.

redraw_data_process(progress[, stop_event, ...])

Worker task that prepares the 3D volume histogram for display.

refresh_workspace_lists()

Refresh the workspace combo(s) and management list from the model.

rename_workspace()

Rename the workspace currently selected in the management list.

rotate_view_ccw()

Roll the view counter‑clockwise about the viewing axis.

rotate_view_cw()

Roll the view clockwise about the viewing axis.

run_blur()

NaN-Gaussian-blur the selected workspace.

run_blur_complete(result)

Refresh the workspace list after a blur completes.

run_bragg_punch()

Punch out Bragg-reflection outliers and remove the low-Q region.

run_bragg_punch_complete(result)

Refresh the workspace list after a Bragg punch completes.

run_karen()

Remove Bragg-peak outliers from the selected workspace with KAREN.

run_karen_complete(result)

Refresh the workspace list after a KAREN filter completes.

sample_bond_correlations_complete(result)

Draw the bond network, colored by sampled ΔPDF correlation.

save_cut()

Prompt for a filename and save the current cut, if one exists.

save_screenshot()

Save a screenshot of the current view to a file.

save_slice()

Prompt for a filename and save the current slice, if one exists.

save_workspace()

Save the workspace currently selected in the management list.

slice_data()

Slice the volume on a worker thread if not already slicing.

slice_data_complete(result)

Complete slice calculation and update the view with the result.

slice_data_process(progress[, stop_event, ...])

Worker task that computes a 2D slice through the loaded volume.

stop_processing(stop_event)

Check if a stop has been requested.

stop_workers()

Stop all running workers and update UI.

update_complete([status])

Indicate completion to the user and reset progress.

update_cut()

Cut the loaded volume if a histogram workspace is available.

update_cut_value()

Update the cut using the current cut value.

update_cvals()

Update colorbar value limits in the view based on user input.

update_invalid()

Indicate invalid parameters to the user and reset progress.

update_lims()

Update slice and cut limits in the view based on input.

update_oriented_lattice()

Update the oriented lattice parameter display in the view.

update_pdf_space_groups()

Repopulate the space-group combo for the selected crystal system.

update_processing([status, progress])

Indicate processing state to the user and update progress.

update_progress(progress)

Update progress step in the view.

update_slice()

Slice the loaded volume if a histogram workspace is available.

update_slice_clim()

Refresh the slice display using the current color limit settings.

update_slice_display()

Update the slice display's colormap, scale, and value limits.

update_slice_value()

Redraw the volume without resetting the current slice/cut view.

update_status(status)

Update status information in the view.

update_stopped()

Indicate that processing was stopped by the user.

update_vmax()

Handle editing of the colorbar maximum field.

update_vmin()

Handle editing of the colorbar minimum field.

update_volume()

Redraw the volume and reset the slice/cut view.

view_ab()

Set the view to the c* direction (real lattice).

view_ab_star()

Set the view to the c-axis direction (reciprocal lattice).

view_bc()

Set the view to the a* direction (real lattice).

view_bc_star()

Set the view to the a-axis direction (reciprocal lattice).

view_ca()

Set the view to the b* direction (real lattice).

view_ca_star()

Set the view to the b-axis direction (reciprocal lattice).

view_manual()

Set the view to a manually specified axis direction.

view_up_manual()

Set the view's up direction to a manually specified axis.

activate_workspace()[source]#

Make the workspace combo’s current selection the active workspace.

Runs on a worker thread, since activation clones and re-downsamples the workspace for the 3D view (potentially slow for large volumes), then redraws the volume/slice/cut.

Parameters:
None
activate_workspace_complete(result)[source]#

Refresh lattice/display state after a new workspace is activated.

For a real-space (delta-PDF) workspace, defaults the colormap to “Diverging” and checks “Symmetric about Zero” – these remain normal, user-overridable controls afterward.

Parameters:
resultobject

Return value of model.activate_workspace (unused).

calculate_pdf()[source]#

Run the pad/FFT stage, producing a 3D-ΔPDF result.

Runs on a worker thread. Typically run on the output of run_blur, though any registered workspace may be selected directly – see VolumeSlicerModel.calculate_pdf.

Parameters:
None
calculate_pdf_complete(result)[source]#

Refresh the workspace list after a 3D-ΔPDF calculation completes.

Parameters:
resultstr or None

Display name of the 3D-ΔPDF result, or None if the worker was stopped or the inputs were invalid.

combine_workspaces()[source]#

Compute a * ws_a - b * ws_b from the arithmetic panel’s inputs.

Shows an error dialog (without raising) if the two workspaces don’t share common binning, or if any input is missing/invalid.

Parameters:
None
cut_data()[source]#

Cut the sliced volume on a worker thread if not already cutting.

Parameters:
None
cut_data_complete(result)[source]#

Complete cut calculation and update the view with the result.

Parameters:
resultdict or None

Cut information dictionary from cut_data_process, or None if the worker was stopped or the parameters were invalid.

cut_data_process(progress, stop_event=None, axis=None, cut_value=None, cut_thick=None)[source]#

Worker task that computes a 1D cut through the sliced volume.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

axisarray-like, optional

Axis along which to cut (default None).

cut_valuefloat, optional

Position along the axis to cut (default None).

cut_thickfloat, optional

Thickness of the cut (default None).

Returns:
cut_histodict or None

Cut information dictionary, or None if stopped, the volume is not sliced, or cut_value/cut_thick are missing.

delete_workspace()[source]#

Delete the workspace currently selected in the management list.

Prompts for confirmation first.

Parameters:
None
get_axis()[source]#

Get the axis vector for the currently selected line cut.

Derived from the in-plane directions of get_normal, with the component corresponding to the selected cut axis zeroed out.

Returns:
axislist of int

Axis vector with a single non-zero component identifying the in-plane direction being cut along.

get_clim_method()[source]#

Get the color-limit clipping method for the 3D volume display.

Returns:
methodstr or None

‘normal’ for mean +/- 3 sigma, ‘boxplot’ for quartile-based IQR clipping, or None for no clipping.

get_normal()[source]#

Get the normal vector for the currently selected slice plane.

Returns:
normlist of int

Unit normal vector, e.g. [0, 0, 1] for “Axis 1/2”, [0, -1, 0] for “Axis 1/3”, or [1, 0, 0] otherwise.

get_vlim_method()[source]#

Get the color-limit clipping method for the 2D slice display.

Returns:
methodstr or None

‘normal’ for mean +/- 3 sigma, ‘boxplot’ for quartile-based IQR clipping, or None for no clipping.

load_NXS()[source]#

Prompt for a NeXus file and a workspace name, then load it on a worker thread.

Parameters:
None
load_NXS_complete(result)[source]#

Complete NeXus file loading by refreshing the oriented lattice display.

Parameters:
resultobject

Result returned by load_NXS_process (unused).

load_NXS_process(progress, stop_event=None)[source]#

Worker task that loads a NeXus MDHisto workspace.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

load_bond_cif()[source]#

Prompt for a CIF file and load it for the bond-network viewer.

Runs on a worker thread (symmetry expansion of every site can take a moment for a large asymmetric unit). On success, populates the atom-site table – the bond network itself is only (re)built when “Plot Bond Network” is clicked.

Parameters:
None
load_bond_cif_complete(result)[source]#

Populate the atom-site table after a CIF finishes loading.

Parameters:
resultlist of dict or None

Sites returned by VolumeSlicerModel.load_bond_cif, or None if the worker was stopped.

plot_bond_network()[source]#

Build the supercell bond network and draw it in the 3D view.

Runs on a worker thread (the pairwise-distance search can be slow for a large supercell) – see VolumeSlicerModel.build_bond_network.

Parameters:
None
plot_bond_network_complete(result)[source]#

Chain a second worker to sample ΔPDF correlations, then draw.

Keeps the (potentially slow) supercell build and the ΔPDF sampling as two separately inspectable/progress-reported steps, rather than drawing immediately.

Parameters:
resultdict or None

Geometry dictionary from VolumeSlicerModel.build_bond_network, or None if the worker was stopped.

redraw_data(reset=True)[source]#

Redraw the 3D volume on a worker thread if not already drawing.

Parameters:
resetbool, optional

Whether to reset the current slice/cut view before redrawing (default True).

redraw_data_complete(result)[source]#

Complete volume redraw and update the view with the new histogram.

Parameters:
resulttuple or None

Tuple of (histo, normal, norm, value, trans) from redraw_data_process, or None if the worker was stopped or the parameters were invalid.

redraw_data_process(progress, stop_event=None, norm=None, clim_method=None, slice_value=None, symmetric_zero=False)[source]#

Worker task that prepares the 3D volume histogram for display.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

normarray-like, optional

Normal vector for the current slice plane (default None).

clim_methodstr or None, optional

Color-limit clipping method passed to the model’s calculate_clim (default None).

slice_valuefloat, optional

Position along the normal for the current slice plane (default None).

symmetric_zerobool, optional

If True, force the 3D volume’s color/opacity limits to be symmetric about zero (default False) – needed for the “Linear Symmetric”/”Sigmoid Symmetric”/”Geometric Symmetric” opacity mappings, whose zero-opacity point sits at the midpoint of the clim range: without this, that midpoint generally isn’t at the data’s true zero, since none of the clim methods (Min/Max, mean +/- 3 sigma, IQR) are otherwise zero-aware.

Returns:
histodict

Histogram information dictionary with clipped signal data.

normalnumpy.ndarray

Negated normal plane vector from the model.

normarray-like

Normal vector for the current slice plane, as passed in.

slice_valuefloat

Position along the normal for the current slice plane, as passed in.

transformnumpy.ndarray

Transform matrix from the model.

refresh_workspace_lists()[source]#

Refresh the workspace combo(s) and management list from the model.

Parameters:
None
rename_workspace()[source]#

Rename the workspace currently selected in the management list.

Prompts for a new display name.

Parameters:
None
run_blur()[source]#

NaN-Gaussian-blur the selected workspace.

Runs on a worker thread. Typically run on the output of run_bragg_punch, though any registered workspace may be selected directly – see VolumeSlicerModel.run_blur.

Parameters:
None
run_blur_complete(result)[source]#

Refresh the workspace list after a blur completes.

Parameters:
resultstr or None

Display name of the blurred workspace, or None if the worker was stopped or the inputs were invalid.

run_bragg_punch()[source]#

Punch out Bragg-reflection outliers and remove the low-Q region.

Runs on a worker thread (the per-reflection loop can be slow). Produces a new, separately inspectable reciprocal-space workspace – see VolumeSlicerModel.run_bragg_punch.

Parameters:
None
run_bragg_punch_complete(result)[source]#

Refresh the workspace list after a Bragg punch completes.

Parameters:
resultstr or None

Display name of the punched workspace, or None if the worker was stopped or the inputs were invalid.

run_karen()[source]#

Remove Bragg-peak outliers from the selected workspace with KAREN.

Runs on a worker thread. An alternative to run_bragg_punch + run_blur – see VolumeSlicerModel.run_karen.

Parameters:
None
run_karen_complete(result)[source]#

Refresh the workspace list after a KAREN filter completes.

Parameters:
resultstr or None

Display name of the filtered workspace, or None if the worker was stopped or the inputs were invalid.

sample_bond_correlations_complete(result)[source]#

Draw the bond network, colored by sampled ΔPDF correlation.

Parameters:
resultndarray or None

Signed ΔPDF value per bond from VolumeSlicerModel.sample_bond_correlations, or None if the selected workspace isn’t a registered real-space result (or the worker was stopped) – either way, the bond network is still drawn, just without correlation coloring.

save_cut()[source]#

Prompt for a filename and save the current cut, if one exists.

Parameters:
None
save_slice()[source]#

Prompt for a filename and save the current slice, if one exists.

Parameters:
None
save_workspace()[source]#

Save the workspace currently selected in the management list.

Prompts for a destination file, pre-filled with the workspace’s display name.

Parameters:
None
slice_data()[source]#

Slice the volume on a worker thread if not already slicing.

Parameters:
None
slice_data_complete(result)[source]#

Complete slice calculation and update the view with the result.

Caches the sliced signal for later use by update_slice_display.

Parameters:
resultdict or None

Slice information dictionary from slice_data_process, or None if the worker was stopped or the parameters were invalid.

slice_data_process(progress, stop_event=None, norm=None, thick=None, value=None, vlim_method=None, scale=None, auto_limits=None, vmin=None, vmax=None, symmetric_zero=False)[source]#

Worker task that computes a 2D slice through the loaded volume.

Intended to run on a background worker thread, reporting progress and checking for a stop request between steps.

Parameters:
progresscallable

Callback invoked as progress(status, value) to report status text and percent complete.

stop_eventthreading.Event, optional

Event used to signal that the worker should stop early (default None).

normarray-like, optional

Normal vector for the slicing direction (default None).

thickfloat, optional

Thickness of the slice (default None).

valuefloat, optional

Position along the normal to slice (default None).

vlim_methodstr or None, optional

Color-limit clipping method used to resolve display limits (default None).

scalestr, optional

Display scale, either ‘log’ or ‘linear’ (default None).

auto_limitsbool, optional

Whether automatic limit calculation is enabled (default None).

vminfloat, optional

User-supplied lower display limit, if any (default None).

vmaxfloat, optional

User-supplied upper display limit, if any (default None).

Returns:
slice_histodict or None

Slice information dictionary with resolved vmin/vmax display limits, or None if stopped, the histogram is not loaded, or thick/value are missing.

update_cut()[source]#

Cut the loaded volume if a histogram workspace is available.

Parameters:
None
update_cut_value()[source]#

Update the cut using the current cut value.

Parameters:
None
update_cvals()[source]#

Update colorbar value limits in the view based on user input.

Uses vmin, vmax from the view and sets colorbar limits if valid. Manually editing either value disables automatic color limits.

Parameters:
None
update_lims()[source]#

Update slice and cut limits in the view based on input.

Uses xmin/max, ymin/max and sets slice/cut limits if valid.

Parameters:
None
update_pdf_space_groups()[source]#

Repopulate the space-group combo for the selected crystal system.

Connected to the crystal-system combo. Reuses CrystalStructureModel’s (static) space-group generation rather than duplicating it.

Parameters:
None
update_slice()[source]#

Slice the loaded volume if a histogram workspace is available.

Parameters:
None
update_slice_clim()[source]#

Refresh the slice display using the current color limit settings.

Connected to the slice view’s color-limit method combo box. Selecting a method re-enables automatic color limits.

Parameters:
None
update_slice_display()[source]#

Update the slice display’s colormap, scale, and value limits.

If no slice signal is cached yet, triggers a slice update instead.

Parameters:
None
update_slice_value()[source]#

Redraw the volume without resetting the current slice/cut view.

Parameters:
None
update_vmax()[source]#

Handle editing of the colorbar maximum field.

If “Symmetric About Zero” is enabled, forces the minimum field to the negative of the edited maximum before applying it.

Parameters:
None
update_vmin()[source]#

Handle editing of the colorbar minimum field.

If “Symmetric About Zero” is enabled, forces the maximum field to the negative of the edited minimum before applying it.

Parameters:
None
update_volume()[source]#

Redraw the volume and reset the slice/cut view.

Parameters:
None