def show_raw_data(self): for run in self.data_context.current_runs: run_string = run_list_to_string(run) loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][ 'OutputWorkspace'] directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string) if len(loaded_workspace) > 1: # Multi-period data for i, single_ws in enumerate(loaded_workspace): name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1)) single_ws.show(name) else: # Single period data name = directory + get_raw_data_workspace_name(self, run_string) loaded_workspace[0].show(name)
def show_raw_data(self): for run in self.data_context.current_runs: run_string = run_list_to_string(run) loaded_workspace = self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][ 'OutputWorkspace'] directory = get_base_data_directory(self, run_string) + get_raw_data_directory(self, run_string) if len(loaded_workspace) > 1: # Multi-period data for i, single_ws in enumerate(loaded_workspace): name = directory + get_raw_data_workspace_name(self, run_string, period=str(i + 1)) single_ws.show(name) else: # Single period data name = directory + get_raw_data_workspace_name(self, run_string) loaded_workspace[0].show(name)
def getWorkspaceNames(self, use_raw): pair_names = list(self.context.group_pair_context.pair_names) group_names = list(self.context.group_pair_context.group_names) run_numbers = self.context.data_context.current_runs final_options = [] for run in run_numbers: final_options += [ wsName.get_raw_data_workspace_name(self.context, run_list_to_string(run), period=str(period + 1)) + " (PhaseQuad)" for period in range(self.context.data_context.num_periods(run)) ] for name in pair_names: final_options.append( wsName.get_pair_data_workspace_name( self.context, str(name), run_list_to_string(run), not use_raw)) for group_name in group_names: final_options.append( wsName.get_group_asymmetry_name(self.context, str(group_name), run_list_to_string(run), not use_raw)) return final_options
def test_create_workspace_label_dets(self): name = get_raw_data_workspace_name("MUSR", "62260", False, 1, "FD") self.model.set_if_groups(False) self.raw._create_workspace_label = mock.Mock(return_value="det_label") label = self.model._create_workspace_label(name, 3) self.raw._create_workspace_label.assert_called_once_with(name, 3) self.assertEqual(label, "det_label")
def test_create_workspace_label_freq(self): name = get_raw_data_workspace_name("MUSR", "62260", False, 1, "FD") name = get_maxent_workspace_name(name, "by groups") self.model.set_if_groups(True) self.model.reconstructed_data = {0: "fwd", 1: "bwd"} label = self.model._create_workspace_label(name, 0) self.assertEqual(label, "62260 Frequency ;MaxEnt")
def get_ws_names(self, run_string, multi_period, period, detectors: str): name = get_raw_data_workspace_name( self.context.data_context.instrument, run_string, multi_period, period=period, workspace_suffix=self.context.workspace_suffix) lower, upper = self._get_first_and_last_detector_to_plot(detectors) return [name for _ in range(lower, upper)]
def getGroupedWorkspaceNames(self): run_numbers = self.data_context.current_runs runs = [ wsName.get_raw_data_workspace_name( self, run_list_to_string(run_number), period=str(period + 1)) for run_number in run_numbers for period in range(self.data_context.num_periods(run_number))] return runs
def show_raw_data(self): self.ads_observer.observeRename(False) for run in self.data_context.current_runs: with WorkspaceGroupDefinition(): run_string = run_list_to_string(run) loaded_workspace = \ self.data_context._loaded_data.get_data(run=run, instrument=self.data_context.instrument)['workspace'][ 'OutputWorkspace'] loaded_workspace_deadtime_table = self.data_context._loaded_data.get_data( run=run, instrument=self.data_context.instrument )['workspace']['DataDeadTimeTable'] directory = get_base_data_directory(self, run_string) deadtime_name = get_deadtime_data_workspace_name( self.data_context.instrument, str(run[0]), workspace_suffix=self.workspace_suffix) MuonWorkspaceWrapper(loaded_workspace_deadtime_table).show( directory + deadtime_name) self.data_context._loaded_data.get_data( run=run, instrument=self.data_context.instrument )['workspace']['DataDeadTimeTable'] = deadtime_name if len(loaded_workspace) > 1: # Multi-period data for i, single_ws in enumerate(loaded_workspace): name = directory + get_raw_data_workspace_name( self.data_context.instrument, run_string, multi_period=True, period=str(i + 1), workspace_suffix=self.workspace_suffix) single_ws.show(name) else: # Single period data name = directory + get_raw_data_workspace_name( self.data_context.instrument, run_string, multi_period=False, workspace_suffix=self.workspace_suffix) loaded_workspace[0].show(name) self.ads_observer.observeRename(True)
def test_create_workspace_label_dets_reconstructed(self): name = get_raw_data_workspace_name("MUSR", "62260", False, 1, "FD") name = get_maxent_workspace_name(name, "All detectors") name += RECONSTRUCTED_SPECTRA self.model.set_if_groups(False) self.raw._create_workspace_label = mock.Mock(return_value="det_label") label = self.model._create_workspace_label(name, 3) self.raw._create_workspace_label.assert_called_once_with(name, 3) self.assertEqual(label, "det_label" + RECONSTRUCTED_SPECTRA)
def getNPoints(self): run_numbers = self.context.data_context.current_runs ws = [wsName.get_raw_data_workspace_name(self.context, run_list_to_string(run_number)) for run_number in run_numbers] self.N_points = 1 for name in ws: data = mantid.AnalysisDataService.retrieve(name) if self.N_points < len(data.readX(0)): self.N_points = len(data.readX(0)) return self.N_points
def test_create_workspace_label_group_reconstructed(self): name = get_raw_data_workspace_name("MUSR", "62260", False, 1, "FD") name = get_maxent_workspace_name(name, "by groups") name += RECONSTRUCTED_SPECTRA self.model.set_if_groups(True) self.model.reconstructed_data = {0: "fwd", 1: "bwd"} label = self.model._create_workspace_label(name, 0) self.assertEqual(label, "62260 fwd ;MaxEnt" + RECONSTRUCTED_SPECTRA) label = self.model._create_workspace_label(name, 1) self.assertEqual(label, "62260 bwd ;MaxEnt" + RECONSTRUCTED_SPECTRA)
def getGroupedWorkspaceNames(self): run_numbers = self.data_context.current_runs runs = [ wsName.get_raw_data_workspace_name( self.data_context.instrument, run_list_to_string(run_number), self.data_context.is_multi_period(), period=str(period + 1), workspace_suffix=self.workspace_suffix) for run_number in run_numbers for period in range(self.data_context.num_periods(run_number)) ] return runs
def _run_deadtime(self, run_string, output): name = get_raw_data_workspace_name( self.data_context.instrument, run_string, multi_period=False, workspace_suffix=self.workspace_suffix) if isinstance(run_string, str): run = wsName.get_first_run_from_run_string(run_string) dead_time_table = self._corrections_context.current_dead_time_table_name_for_run( self.data_context.instrument, [float(run)]) if dead_time_table: return apply_deadtime(name, output, dead_time_table) return name
def getWorkspaceNames(self, use_raw): pair_names = list(self.context.group_pair_context.pair_names) group_names = list(self.context.group_pair_context.group_names) run_numbers = self.context.data_context.current_runs final_options = [] for run in run_numbers: final_options += [ wsName.get_raw_data_workspace_name(self.context, run_list_to_string(run), period=str(period + 1)) + " (PhaseQuad)" for period in range(self.context.data_context.num_periods(run))] for name in pair_names: final_options.append( wsName.get_pair_data_workspace_name(self.context, str(name), run_list_to_string(run), not use_raw)) for group_name in group_names: final_options.append( wsName.get_group_asymmetry_name(self.context, str(group_name), run_list_to_string(run), not use_raw)) return final_options
def get_parameters_for_maxent_calculation(self): inputs = {} run = self.view.get_run period = self.view.get_period multiperiod = True if self.view.num_periods >1 else False name = get_raw_data_workspace_name(self.context.data_context.instrument, run, multiperiod, period=period, workspace_suffix=self.context.workspace_suffix) inputs['InputWorkspace'] = name if self.view.phase_table != 'Construct' and self.view.phase_table != 'None': inputs['InputPhaseTable'] = self.view.phase_table if self.use_groups: table = self._create_group_table() inputs["GroupTable"] = table dead_time_table_name = self.context.corrections_context.current_dead_time_table_name_for_run( self.context.data_context.instrument, [run]) if dead_time_table_name is not None: inputs['InputDeadTimeTable'] = dead_time_table_name run_float = [float(re.search("[0-9]+", name).group())] inputs['FirstGoodTime'] = self.context.first_good_data(run_float) inputs['LastGoodTime'] = self.context.last_good_data(run_float) inputs['Npts'] = self.view.num_points inputs['InnerIterations'] = self.view.inner_iterations inputs['OuterIterations'] = self.view.outer_iterations inputs['DoublePulse'] = self.view.double_pulse inputs['Factor'] = self.view.lagrange_multiplier inputs['MaxField'] = self.view.maximum_field inputs['DefaultLevel'] = self.view.maximum_entropy_constant inputs['FitDeadTime'] = self.view.fit_dead_times return inputs
def getGroupedWorkspaceNames(self): run_numbers = self.data_context.current_runs runs = [ wsName.get_raw_data_workspace_name(self, run_list_to_string(run_number), period=str(period + 1)) for run_number in run_numbers for period in range(self.data_context.num_periods(run_number))] return runs