quicknxs.interfaces package
Subpackages
- quicknxs.interfaces.data_handling package
- Submodules
- quicknxs.interfaces.data_handling.data_info module
- quicknxs.interfaces.data_handling.data_manipulation module
- quicknxs.interfaces.data_handling.data_set module
CrossSectionDataCrossSectionData.active_area_xCrossSectionData.active_area_yCrossSectionData.angle_offsetCrossSectionData.collect_info()CrossSectionData.dangleCrossSectionData.dangle0CrossSectionData.det_size_xCrossSectionData.det_size_yCrossSectionData.direct_pixelCrossSectionData.dist_mod_detCrossSectionData.dist_mod_monCrossSectionData.dist_sam_detCrossSectionData.dpixCrossSectionData.drCrossSectionData.event_workspaceCrossSectionData.get_background_vs_TOF()CrossSectionData.get_counts_vs_TOF()CrossSectionData.get_reduction_parameters()CrossSectionData.get_tof_counts_table()CrossSectionData.gisans()CrossSectionData.lambda_centerCrossSectionData.offspec()CrossSectionData.prepare_plot_data()CrossSectionData.process_configuration()CrossSectionData.rCrossSectionData.raw_drCrossSectionData.raw_rCrossSectionData.reflectivity()CrossSectionData.reflectivity_workspaceCrossSectionData.tofCrossSectionData.tofdataCrossSectionData.update_calculated_values()CrossSectionData.update_configuration()CrossSectionData.wavelengthCrossSectionData.wavelength_rangeCrossSectionData.xCrossSectionData.xdataCrossSectionData.xtofCrossSectionData.xyCrossSectionData.yCrossSectionData.ydata
NexusDataNexusData.calculate_gisans()NexusData.calculate_offspec()NexusData.calculate_reflectivity()NexusData.get_highest_cross_section()NexusData.get_q_range()NexusData.get_reflectivity_workspace_group()NexusData.is_direct_beam()NexusData.is_gisans_available()NexusData.is_offspec_available()NexusData.load()NexusData.set_parameter()NexusData.update_calculated_values()NexusData.update_configuration()
NexusMetaDatagetIxyt()
- quicknxs.interfaces.data_handling.filepath module
- quicknxs.interfaces.data_handling.gisans module
- quicknxs.interfaces.data_handling.instrument module
InstrumentInstrument.USE_SLOW_FLIPPER_LOGInstrument.check_direct_beam()Instrument.direct_beam_match()Instrument.dummy_filter_cross_sections()Instrument.file_search_templateInstrument.get_info()Instrument.huber_x_cutInstrument.instrument_dirInstrument.instrument_nameInstrument.integrate_detector()Instrument.legacy_search_templateInstrument.load_data()Instrument.mid_q_value()Instrument.n_x_pixelInstrument.n_y_pixelInstrument.peak_range_offsetInstrument.pixel_widthInstrument.scattering_angle_from_data()Instrument.tolerance
apply_dead_time_correction()get_cross_section_label()get_dead_time_correction()mantid_algorithm_exec()remove_low_event_workspaces()
- quicknxs.interfaces.data_handling.off_specular module
- quicknxs.interfaces.data_handling.peak_finding module
- quicknxs.interfaces.data_handling.processing_workflow module
ProcessingWorkflowProcessingWorkflow.execute()ProcessingWorkflow.get_file_name()ProcessingWorkflow.get_gisans_data()ProcessingWorkflow.get_gisans_slice_output_data()ProcessingWorkflow.get_offspec_data()ProcessingWorkflow.get_output_data()ProcessingWorkflow.get_rebinned_offspec_data()ProcessingWorkflow.get_slice_output_data()ProcessingWorkflow.gisans()ProcessingWorkflow.offspec()ProcessingWorkflow.send_email()ProcessingWorkflow.smooth_offspec()ProcessingWorkflow.specular_reflectivity()ProcessingWorkflow.write_quicknxs()
- quicknxs.interfaces.data_handling.quicknxs_io module
- quicknxs.interfaces.event_handlers package
- Submodules
- quicknxs.interfaces.event_handlers.configuration_handler module
- quicknxs.interfaces.event_handlers.main_handler module
MainHandlerMainHandler.DIRECT_BEAM_TAB_INDEXMainHandler.MAIN_DATA_TAB_INDEXMainHandler.active_channel_changed()MainHandler.active_data_changed()MainHandler.add_direct_beam()MainHandler.add_reflectivity()MainHandler.ask_question()MainHandler.automated_file_selection()MainHandler.check_region_values_changed()MainHandler.clear_direct_beams()MainHandler.clear_reflectivity()MainHandler.compute_gisans_on_change()MainHandler.compute_offspec_on_change()MainHandler.empty_cache()MainHandler.file_loaded()MainHandler.file_open_dialog()MainHandler.file_open_sum_dialog()MainHandler.get_configuration()MainHandler.get_reduction_table_by_index()MainHandler.hide_data_table()MainHandler.hide_run_data()MainHandler.hide_sidebar()MainHandler.initialize_additional_reduction_table()MainHandler.new_progress_reporter()MainHandler.open_file()MainHandler.open_reduced_file_dialog()MainHandler.open_run_number()MainHandler.populate_from_configuration()MainHandler.reduction_tableMainHandler.reduction_table_changed()MainHandler.reduction_table_right_click()MainHandler.reload_all_files()MainHandler.remove_direct_beam()MainHandler.remove_reflectivity()MainHandler.report_message()MainHandler.save_run_data()MainHandler.show_results()MainHandler.stitch_reflectivity()MainHandler.strip_overlap()MainHandler.toggle_final_rebin_global()MainHandler.toggle_final_rebin_run()MainHandler.trim_data_to_normalization()MainHandler.update_calculated_data()MainHandler.update_channel_info()MainHandler.update_daslog()MainHandler.update_direct_beam_table()MainHandler.update_file_list()MainHandler.update_info()MainHandler.update_reduction_table()MainHandler.update_tables()
- quicknxs.interfaces.event_handlers.plot_handler module
PlotHandlerPlotHandler.change_color_scale()PlotHandler.change_offspec_colorscale()PlotHandler.change_region_values()PlotHandler.clip_offspec_colorscale()PlotHandler.connect_plot_events()PlotHandler.control_downPlotHandler.last_eventPlotHandler.plot_mouse_event()PlotHandler.plot_pick_x()PlotHandler.plot_pick_xtof()PlotHandler.plot_pick_xy()PlotHandler.plot_pick_y()PlotHandler.plot_release()PlotHandler.reflPlotHandler.scale_on_plot()
slow_down_events()
- quicknxs.interfaces.event_handlers.progress_reporter module
- quicknxs.interfaces.event_handlers.widgets module
Submodules
quicknxs.interfaces.configuration. module
Application configuration, including reduction options
- class quicknxs.interfaces.configuration.Configuration(settings=None)[source]
Bases:
objectHold reduction options
- DELTA_KZ_VS_QZ = 3
- KZI_VS_KZF = 1
- QX_VS_QZ = 0
- apply_deadtime = False
- bck_offset = 5
- property bck_roi
- deadtime_tof_step = 100
- deadtime_value = 4.2
- do_final_rebin_global = True
- final_rebin_step_global = -0.01
- force_bck_roi = True
- global_stitching = False
- lock_direct_beam_y = False
- property low_res_roi
- nbr_events_min = 100
- normalize_to_unity = True
- paralyzable_deadtime = True
- property peak_roi
- polynomial_stitching = False
- polynomial_stitching_degree = 3
- polynomial_stitching_points = 3
- sample_size = 10
- total_reflectivity_q_cutoff = 0.01
- update_peak_range = False
- use_constant_q = False
- use_low_res_finder = False
- use_peak_finder = False
- use_roi = True
- use_roi_bck = False
- use_tight_bck = False
- wl_bandwidth = 3.2
- quicknxs.interfaces.configuration.get_direct_beam_low_res_roi(data_conf, direct_beam_conf)[source]
Get the direct beam low res ROI either from the data run or from the direct beam depending on the configuration lock_direct_beam_y
- Parameters:
data_conf (Configuration) – Configuration for the data run
direct_beam_conf (Configuration) – Configuration for the direct beam run
- Returns:
The pixel range of the direct beam ROI in the low res direction (y)
- Return type:
[int, int]
quicknxs.interfaces.data_manager module
Data manager. Holds information about the current data location and manages the data cache.
- class quicknxs.interfaces.data_manager.DataManager(current_directory: str)[source]
Bases:
object- MAIN_REDUCTION_LIST_INDEX = 1
- MAX_CACHE = 50
- add_active_to_reduction(peak_index=1)[source]
Add active data set to reduction list
New data sets are always added to the main reduction list. Data sets are added to secondary reduction lists by initializing from the main reduction list (button to add new data tab) or by propagating individual data sets to other tabs (right-click menu).
- Parameters:
peak_index (int) – The index of the peak in peak_reduction_lists
- Returns:
True if the active data set was added to the reduction list, False if it was not added
- Return type:
bool
- add_additional_reduction_list(tab_index: int)[source]
Add reduction list for an additional ROI/peak
- Parameters:
tab_index (int) – Index of the peak in self.peak_reduction_lists
- calculate_reflectivity(configuration=None, active_only=False, nexus_data=None, specular=True)[source]
Calculate reflectivity using the current configuration
- clear_cached_unused_data()[source]
Delete cached files that are not in the reduction list or direct beam list
- clear_direct_beam_list()[source]
Remove all items from the direct beam list, and make sure to remove links to those items in the scattering data sets.
TODO: remove links from scattering data sets.
- copy_nexus_data_to_reduction(nexus_data_to_copy: NexusData, peak_index: int)[source]
Add data set to the reduction list specified by peak_index
- Parameters:
nexus_data_to_copy (NexusData) – Data set to copy
peak_index (int) – Peak (reduction list) to copy data set to
- Returns:
True if the data set was added successfully, otherwise False
- Return type:
bool
- property current_event_files: List[str]
@brief Sorted list of event files in the current directory @details return only file names with pattern ‘event.nxs’ or ‘.nxs.h5’
- property current_file
- property data_sets
Reduced cross sections
- Returns:
dictionary of cross sections
- Return type:
dict
- extract_meta_data(file_path=None)[source]
Return the current q-value at the center of the wavelength range of the current data set. If a file path is provided, the mid q-value will be extracted from that data file.
- find_active_data_id()[source]
Look for the active data in the reduction list. Return the index within the reduction list or none.
- find_active_direct_beam_id()[source]
Look for the active data in the direct beam list. Return the index within the direct beam list or none.
- find_best_direct_beam()[source]
Find the best direct beam in the direct beam list for the active data Returns a run number. Returns True if we have updated the data with a new normalization run.
- find_data_in_direct_beam_list(nexus_data)[source]
Look for the given data in the direct beam list. Return the index within the direct beam list or none. :param NexusData: data set object
- find_data_in_reduction_list(nexus_data)[source]
Look for the given data in the reduction list. Return the index within the reduction list or none. :param NexusData: data set object
- find_run_number_in_reduction_list(run_number: int, reduction_list: list[NexusData])[source]
Look for the given run number in the reduction list.
- Parameters:
run_number (int) – Run number to look for
reduction_list (list[NexusData]) – The reduction list to search
- Returns:
The index in the reduction list or None
- Return type:
int | None
- get_trim_values()[source]
Cut the start and end of the active data set to 5% of its maximum intensity.
- is_active(data_set)[source]
Returns True of the given data set is the active data set. :param NexusData: data set object
- is_gisans_available(active_only=True)[source]
Verify that all data sets and all cross-sections have calculated GISANS data available.
- is_nexus_data_compatible(nexus_data: NexusData, reduction_list: list)[source]
Determine if the data set is compatible with the data sets in the reduction list.
A data set is compatible if the polarization cross-section states matches those of the first run in the reduction list, both the same number of states and the same states.
- is_offspec_available()[source]
Verify that all data sets and all cross-sections have calculated off-specular data available.
- load(file_path: str, configuration: Configuration, force: bool | None = False, update_parameters: bool | None = True, progress: ProgressReporter | None = None) bool[source]
@brief Load one ore more Nexus data files @param file_path: absolute path to one or more files. If more than one, files are concatenated with the merge symbol ‘+’. @param configuration: configuration to use to load the data @param force: it True, existing data in the cache will be replaced by reading from file. @param update_parameters: if True, we will find peak ranges @param progress: aggregator to estimate percent of time allotted to this function @returns True if the data is retrieved from the cache of past loading events
- load_data_from_reduced_file(file_path, configuration=None, progress=None)[source]
Load the information from a reduced file, the load the data. Ask the main event handler to update the UI once we are done. :param str file_path: reduced file to load :param Configuration configuration: configuration to base the loaded data on :param ProgressReporter progress: progress reporter
- load_direct_beam_and_data_files(db_files, data_files, additional_peaks=None, configuration=None, progress=None, force=False, t_0=None)[source]
Load direct beam and data files and add them to the direct beam list and reduction list, respectively
- Parameters:
db_files (list) – List of (run_number, run_file, conf) for direct beam files
data_files (list) – List of (run_number, run_file, conf) for data files
additional_peaks (list | None) – List of (peak_index, run_number, run_file, conf) for data files for additional peaks
configuration (Configuration) – Configuration to base the loaded data on
progress (ProgressReporter) – Progress reporter
force (bool) – If True, ignore cache and force reloading from file
t_0 (float) – Start time for logging data loading time
- property main_reduction_list
Returns the reduction list for the first (mandatory) data tab
- Returns:
The reduction list
- Return type:
list[NexusData]
- rebin_gisans(pol_state, wl_min=0, wl_max=100, qy_npts=50, qz_npts=50, use_pf=False)[source]
Merge all the off-specular reflectivity data and rebin.
- reduce_gisans(progress=None)[source]
Since the specular reflectivity is prominently displayed, it is updated as soon as parameters change. This is not the case for GISANS, which is computed on-demand. This method goes through the data sets in the reduction list and re-calculate the GISANS.
- reduce_offspec(progress=None)[source]
Since the specular reflectivity is prominently displayed, it is updated as soon as parameters change. This is not the case for the off-specular, which is computed on-demand. This method goes through the data sets in the reduction list and re-calculate the off-specular reflectivity.
- property reduction_list
Returns the reduction list for the active data tab
- Returns:
The reduction list
- Return type:
list[NexusData]
- reload_files(configuration=None, progress=None)[source]
Force reload of files in the reduction lists and direct beam list
- remove_additional_reduction_list(tab_index: int)[source]
Remove reduction list for additional ROI/peak
- Parameters:
tab_index (int) – Index of the peak in self.peak_reduction_lists
- remove_from_active_reduction_list(index: int)[source]
Remove item from the active reduction list
- Parameters:
index (int) – Index of the item to remove
- set_active_data_from_direct_beam_list(index)[source]
Set a data set in the direct beam list as the active data set according to its index. :param int index: index in the direct beam list
- set_active_data_from_reduction_list(index)[source]
Set a data set in the reduction list as the active data set according to its index. :param int index: index in the reduction list
- set_active_reduction_list_index(tab_index: int)[source]
Set the active reduction list index
- Parameters:
tab_index (int) – Index of the peak in self.peak_reduction_lists
- set_channel(index)[source]
Set the current channel to the specified index, or zero if it doesn’t exist.
- Parameters:
index (int) – channel index
- Return type:
bool
- stitch_data_sets(normalize_to_unity=True, q_cutoff=0.01, global_stitching=False, poly_degree=None, poly_points=3)[source]
Determine scaling factors for each data set :param bool normalize_to_unity: If True, the reflectivity plateau will be normalized to 1. :param float q_cutoff: critical q-value below which we expect R=1 :param bool global_stitching: If True, use data from all cross-sections to calculate scaling factors :param int poly_degree: if not None, find the scaling factor by simultaneously fitting a polynomial and scaling factor to the curves :param int poly_points: number of additional points on each end of the overlap region to include in the fit
- strip_overlap()[source]
Remove overlapping points in the reflecitviy, cutting always from the lower Qz measurements.
quicknxs.interfaces.main_window module
Main application window
- class quicknxs.interfaces.main_window.MainWindow[source]
Bases:
QMainWindowMain application window
- changeRegionValues()[source]
Called when the reflectivity extraction region has been changed. Sets up a trigger to replot the reflectivity with a delay so a subsequent change can occur without several replots.
- change_active_channel(is_checked)[source]
The overview and reflectivity channel was changed. This updates the run information and plots in the Overview area
The toggled() signal is emitted from both radio buttons whose states were changed, therefore, use the bool value to only perform channel update actions once.
- Parameters:
is_checked (bool) – the state of the radio button that emitted the signal
- change_offspec_colorscale()[source]
Change the intensity limits for the color scale of the off-specular plots
- direct_beam_cell_activated(row, col)[source]
Select a data set when the user double-clicks on a run number (col 0). in the direct beam table. :param int row: row index :param int col: column index
- direct_beam_table_right_click(pos)[source]
Handle right-click on the direct beam table. :param QPoint pos: mouse position
- file_loaded_signal
Signal emitted when a file is loaded.
- file_open_from_list()[source]
Called when a new file is selected from the file list. This is an event call.
- file_open_sum_dialog()[source]
@brief Read a set of congruent file data sets. @details Select a list of event or histogram files, check their metadata is compatible, and read-in.
- getNorm()[source]
TODO: deal with this This is supposed to retrieve the normalization data for the active reflectivity data so that we can normalize the distributions we are plotting. See plotting.plot_xtof and plotting.plot_overview
- global_reflectivity_config_changed()[source]
Perform action upon change in global reflectivity configuration.
- initialize_instrument()[source]
Initialize instrument according to the instrument and saved parameters
- initiate_intensity_plot
Signal to initiate the intensity plot.
- initiate_projection_plot
Signal to initiate the projection plot.
- initiate_reflectivity_plot
Signal to initiate the reflectivity plot.
- match_direct_beam_clicked()[source]
Find the best direct beam run for the activate data set and compute the reflectivity as needed.
- open_deadtime_settings()[source]
Show the dialog for dead-time options. Update global configuration parameters upon closing the dialog.
- plot_manager
Setting auto_change_active = True bypasses execution of: - MainWindow.file_open_from_list() - MainWindow.changeRegionValues() - MainHandler.reduction_table_changed()
- reduceDatasets()[source]
Open a dialog to select reduction options for the current list of reduction items.
- reduction_cell_activated(row, col)[source]
Select a data set when the user double-clicks on a run number (col 0). in the reduction table. :param int row: row index :param int col: column index
- reduction_table_right_click(pos)[source]
Handle right-click on the reduction table. :param QPoint pos: mouse position
- stripOverlap()[source]
Remove overlapping points in the reflecitviy, cutting always from the lower Qz measurements.
- update_gisans_viewer
Signal to update the GISANS viewer.
- update_off_specular_viewer
Signal to update the off-specular viewer.
- update_specular_viewer
Signal to update the specular viewer.
quicknxs.interfaces.plotting module
- class quicknxs.interfaces.plotting.PlotManager(main_window)[source]
Bases:
object- plot_intensity(preserve_lim=False)[source]
Calculate and display the direct beam intensity from the current dataset.
- plot_offspec(recalc=True, crop=False)[source]
Create an offspecular plot for all channels of the datasets in the reduction list. The user can define upper and lower bounds for the plotted intensity and select the coordinates to be either kiz-kfz vs. Qz, Qx vs. Qz or kiz vs. kfz.
- plot_projections(preserve_lim=False)[source]
Create projections of the data on the x and y axes. The x-projection can also be done be means of quantile calculation, which means that the ToF intensities are calculation which are exceeded by a certain number of points. This can be helpful to better separate the specular reflection from bragg-sheets
quicknxs.interfaces.reduction_dialog module
Dialog to select reduction options to choose which outputs are needed and in which formats to write them.
quicknxs.interfaces.result_viewer module
Dialog to show final reduced data.
- class quicknxs.interfaces.result_viewer.ResultViewer(parent, data_manager)[source]
Bases:
QDialogReduction dialog
- default_template = '{instrument}_{numbers}_{peak}_{item}_{state}.{type}'
- update_gisans(crop=False)[source]
Update the results viewer with the latest GISANS calculations :param bool crop: if True, all the plots will be cropped to the ++ cross-section
quicknxs.interfaces.smooth_dialog module
Dialog to let the user select smoothing options This code was taken as-is from QuickNXS v1