def PyExec(self): # 1. Get the index of the batch reduction index = self.getProperty("RowIndex").value if index == Property.EMPTY_INT: return # 2. Get the state for the index from the PropertyManagerDataService property_manager_service = PropertyManagerService() state = property_manager_service.get_single_state_from_pmds( index_to_retrieve=index) # 3. Get some global settings use_optimizations = self.getProperty("UseOptimizations").value output_mode_as_string = self.getProperty("OutputMode").value output_mode = OutputMode.from_string(output_mode_as_string) plot_results = self.getProperty('PlotResults').value output_graph = self.getProperty('OutputGraph').value # 3. Run the sans_batch script sans_batch = SANSBatchReduction() sans_batch(states=state, use_optimizations=use_optimizations, output_mode=output_mode, plot_results=plot_results, output_graph=output_graph)
def __init__(self, notify_progress, notify_done, notify_error): super(BatchProcessRunner, self).__init__() self.row_processed_signal.connect(notify_progress) self.row_failed_signal.connect(notify_error) self.notify_done = notify_done self.batch_processor = SANSBatchReduction() self._worker = None
def _run_batch_reduction(self, states, use_optimizations=False): batch_reduction_alg = SANSBatchReduction() try: batch_reduction_alg(states, use_optimizations, OutputMode.PublishToADS) did_raise = False except: # noqa did_raise = True self.assertFalse(did_raise)
def __init__(self, notify_progress, notify_done, notify_error): super().__init__() self.notify_done = notify_done self.notify_error = notify_error self.notify_progress = notify_progress self._notify_progress_signal = SignalNotifyProgress() self._notify_progress_signal.signal.connect(notify_progress, QtCore.Qt.QueuedConnection) self.batch_processor = SANSBatchReduction() self._logger = Logger("SANS")
def _run_batch_reduction(self, states, use_optimizations=False): batch_reduction_alg = SANSBatchReduction() batch_reduction_alg(states, use_optimizations, OutputMode.PUBLISH_TO_ADS)
def WavRangeReduction(wav_start=None, wav_end=None, full_trans_wav=None, name_suffix=None, combineDet=None, resetSetup=True, out_fit_settings=None, output_name=None, output_mode=OutputMode.PUBLISH_TO_ADS, use_reduction_mode_as_suffix=False): """ Run reduction from loading the raw data to calculating Q. Its optional arguments allows specifics details to be adjusted, and optionally the old setup is reset at the end. Note if FIT of RESCALE or SHIFT is selected then both REAR and FRONT detectors are both reduced EXCEPT if only the REAR detector is selected to be reduced @param wav_start: the first wavelength to be in the output data @param wav_end: the last wavelength in the output data @param full_trans_wav: if to use a wide wavelength range, the instrument's default wavelength range, for the transmission correction, false by default @param name_suffix: append the created output workspace with this @param combineDet: combineDet can be one of the following: 'rear' (run one reduction for the 'rear' detector data) 'front' (run one reduction for the 'front' detector data, and rescale+shift 'front' data) 'both' (run both the above two reductions) 'merged' (run the same reductions as 'both' and additionally create a merged data workspace) None (run one reduction for whatever detector has been set as the current detector before running this method. If front apply rescale+shift) @param resetSetup: if true reset setup at the end @param out_fit_settings: An output parameter. It is used, specially when resetSetup is True, in order to remember the 'scale and fit' of the fitting algorithm. @param output_name: name of the output workspace/file, if none is specified then one is generated internally. @param output_mode: the way the data should be put out: Can be PublishToADS, SaveToFile or Both @param use_reduction_mode_as_suffix: If true then a second suffix will be used which is based on the reduction mode. @return Name of one of the workspaces created """ print_message('WavRangeReduction(' + str(wav_start) + ', ' + str(wav_end) + ', ' + str(full_trans_wav) + ')') _ = resetSetup _ = out_fit_settings # Set the provided parameters if combineDet is None: reduction_mode = None elif combineDet == 'rear': reduction_mode = ReductionMode.LAB elif combineDet == "front": reduction_mode = ReductionMode.HAB elif combineDet == "merged": reduction_mode = ReductionMode.MERGED elif combineDet == "both": reduction_mode = ReductionMode.ALL else: raise RuntimeError("WavRangeReduction: The combineDet input parameter was given a value of {0}. rear, front," " both, merged and no input are allowed".format(combineDet)) if wav_start is not None: wav_start = float(wav_start) if wav_end is not None: wav_end = float(wav_end) wavelength_command = NParameterCommand(command_id=NParameterCommandId.WAV_RANGE_SETTINGS, values=[wav_start, wav_end, full_trans_wav, reduction_mode]) director.add_command(wavelength_command) # Save options if output_name is not None: director.add_command(NParameterCommand(command_id=NParameterCommandId.USER_SPECIFIED_OUTPUT_NAME, values=[output_name])) if name_suffix is not None: director.add_command(NParameterCommand(command_id=NParameterCommandId.USER_SPECIFIED_OUTPUT_NAME_SUFFIX, values=[name_suffix])) if use_reduction_mode_as_suffix: director.add_command(NParameterCommand(command_id=NParameterCommandId.USE_REDUCTION_MODE_AS_SUFFIX, values=[use_reduction_mode_as_suffix])) # Get the states state = director.process_commands() # Run the reduction batch_alg = SANSBatchReduction() batch_alg(states=[state], use_optimizations=True, output_mode=output_mode) # ----------------------------------------------------------- # Return the name fo the reduced workspace (or WorkspaceGroup) # ----------------------------------------------------------- reduction_mode = state.reduction.reduction_mode is_group = is_part_of_reduced_output_workspace_group(state) if reduction_mode != ReductionMode.ALL: _, output_workspace_base_name = get_output_name(state, reduction_mode, is_group) else: _, output_workspace_base_name_hab = get_output_name(state, ReductionMode.HAB, is_group) _, output_workspace_base_name_lab = get_output_name(state, ReductionMode.LAB, is_group) output_workspace_base_name = [output_workspace_base_name_lab, output_workspace_base_name_hab] return output_workspace_base_name