def show_all_groups(self): self.calculate_all_groups() for run in self._data_context.current_runs: with WorkspaceGroupDefinition(): for group in self._group_pair_context.groups: run_as_string = run_list_to_string(run) group_name = group.name periods = run_list_to_string(group.periods) directory = get_base_data_directory(self, run_as_string) name = get_group_data_workspace_name(self, group_name, run_as_string, periods, rebin=False) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, periods, rebin=False) asym_name_unnorm = get_group_asymmetry_unnorm_name( self, group_name, run_as_string, periods, rebin=False) self.group_pair_context[group_name].show_raw( run, directory + name, directory + asym_name, asym_name_unnorm) if self._do_rebin(): name = get_group_data_workspace_name(self, group_name, run_as_string, periods, rebin=True) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, periods, rebin=True) asym_name_unnorm = get_group_asymmetry_unnorm_name( self, group_name, run_as_string, periods, rebin=True) self.group_pair_context[group_name].show_rebin( run, directory + name, directory + asym_name, asym_name_unnorm)
def show_all_groups(self): self.calculate_all_groups() for run in self._data_context.current_runs: for group_name in self._group_pair_context.group_names: run_as_string = run_list_to_string(run) directory = get_base_data_directory(self, run_as_string) + get_group_data_directory(self, run_as_string) name = get_group_data_workspace_name(self, group_name, run_as_string, rebin=False) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin=False) self.group_pair_context[group_name].show_raw(run, directory + name, directory + asym_name) if self._do_rebin(): name = get_group_data_workspace_name(self, group_name, run_as_string, rebin=True) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin=True) self.group_pair_context[group_name].show_rebin(run, directory + name, directory + asym_name)
def show_group(self, run, group, rebin): run_as_string = run_list_to_string(run) group_name = group.name periods = run_list_to_string(group.periods) directory = get_base_data_directory(self, run_as_string) name = get_group_data_workspace_name(self, group_name, run_as_string, periods, rebin=rebin) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, periods, rebin=rebin) asym_name_unnorm = get_group_asymmetry_unnorm_name(self, group_name, run_as_string, periods, rebin=rebin) if not rebin: self.group_pair_context[group_name].show_raw( run, directory + name, directory + asym_name, asym_name_unnorm) else: self.group_pair_context[group_name].show_rebin( run, directory + name, directory + asym_name, asym_name_unnorm)
def show_all_groups(self): self.calculate_all_groups() for run in self._data_context.current_runs: for group_name in self._group_pair_context.group_names: run_as_string = run_list_to_string(run) directory = get_base_data_directory(self, run_as_string) + get_group_data_directory(self, run_as_string) name = get_group_data_workspace_name(self, group_name, run_as_string, rebin=False) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin=False) self.group_pair_context[group_name].show_raw(run, directory + name, directory + asym_name) if self._do_rebin(): name = get_group_data_workspace_name(self, group_name, run_as_string, rebin=True) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin=True) self.group_pair_context[group_name].show_rebin(run, directory + name, directory + asym_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 _calculate_asymmetry(self, run, group, periods, run_as_string, periods_as_string, rebin): """Calculates the asymmetry workspaces for the given run and group.""" output_name = get_group_asymmetry_name(self, group.name, run_as_string, periods_as_string, rebin=rebin) output_name_unnormalised = get_group_asymmetry_unnorm_name( self, group.name, run_as_string, periods_as_string, rebin=rebin) group_asymmetry, group_asymmetry_unnormalised = estimate_group_asymmetry_data( self, group, run, output_name, output_name_unnormalised, periods) return group_asymmetry, group_asymmetry_unnormalised
def get_workspace_names_for_FFT_analysis(self, use_raw=True): pair_names = list(self.group_pair_context.pair_names) group_names = list(self.group_pair_context.group_names) run_numbers = self.data_context.current_runs workspace_options = [] for run in run_numbers: workspace_options += self.phase_context.get_phase_quad(self.data_context.instrument, run_list_to_string(run)) for name in pair_names: workspace_options.append( wsName.get_pair_data_workspace_name(self, str(name), run_list_to_string(run), not use_raw)) for group_name in group_names: workspace_options.append( wsName.get_group_asymmetry_name(self, str(group_name), run_list_to_string(run), not use_raw)) return workspace_options
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_workspace_names_for_FFT_analysis(self, use_raw=True): pair_names = list(self.group_pair_context.pair_names) group_names = list(self.group_pair_context.group_names) run_numbers = self.data_context.current_runs workspace_options = [] for run in run_numbers: workspace_options += self.phase_context.get_phase_quad(self.data_context.instrument, run_list_to_string(run)) for name in pair_names: workspace_options.append( wsName.get_pair_data_workspace_name(self, str(name), run_list_to_string(run), not use_raw)) for group_name in group_names: workspace_options.append( wsName.get_group_asymmetry_name(self, str(group_name), run_list_to_string(run), not use_raw)) return workspace_options
def calculate_group(self, group_name, run, rebin=False): run_as_string = run_list_to_string(run) name = get_group_data_workspace_name(self, group_name, run_as_string, rebin=rebin) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin=rebin) asym_name_unnorm = get_group_asymmetry_unnorm_name(self, group_name, run_as_string, rebin=rebin) group_workspace = calculate_group_data(self, group_name, run, rebin, name) group_asymmetry, group_asymmetry_unnormalised = estimate_group_asymmetry_data( self, group_name, run, rebin, asym_name, asym_name_unnorm) return group_workspace, group_asymmetry, group_asymmetry_unnormalised
def calculate_group(self, group, run, rebin=False): run_as_string = run_list_to_string(run) periods_as_string = run_list_to_string(group.periods) # A user requirement is that processing can continue if a period is missing from some # of the runs. This filters out periods which are not in a given run. periods = [ period for period in group.periods if period <= self.num_periods(run) ] # If not periods match return nothing here. The caller then needs to handle this gracefully. if not periods: return None, None, None name = get_group_data_workspace_name(self, group.name, run_as_string, periods_as_string, rebin=rebin) asym_name = get_group_asymmetry_name(self, group.name, run_as_string, periods_as_string, rebin=rebin) asym_name_unnorm = get_group_asymmetry_unnorm_name(self, group.name, run_as_string, periods_as_string, rebin=rebin) group_workspace = calculate_group_data(self, group, run, rebin, name, periods) group_asymmetry, group_asymmetry_unnormalised = estimate_group_asymmetry_data( self, group, run, rebin, asym_name, asym_name_unnorm, periods) return group_workspace, group_asymmetry, group_asymmetry_unnormalised
def show_group_data(self, group_name, show=True, rebin=False): for run in self.current_runs: run_as_string = run_list_to_string(run) group_workspace = calculate_group_data(self, group_name, run, rebin) group_asymmetry = estimate_group_asymmetry_data( self, group_name, run, rebin) directory = get_base_data_directory( self, run_as_string) + get_group_data_directory( self, run_as_string) name = get_group_data_workspace_name(self, group_name, run_as_string, rebin) asym_name = get_group_asymmetry_name(self, group_name, run_as_string, rebin) if not rebin: self._groups[group_name]._workspace[str( run)] = MuonWorkspaceWrapper(group_workspace) self._groups[group_name]._asymmetry_estimate[str( run)] = MuonWorkspaceWrapper(group_asymmetry) if show: self._groups[group_name].workspace[str(run)].show( directory + name) self._groups[group_name]._asymmetry_estimate[str( run)].show(directory + asym_name) else: self._groups[group_name]._workspace_rebin[str( run)] = MuonWorkspaceWrapper(group_workspace) self._groups[group_name]._asymmetry_estimate_rebin[str( run)] = MuonWorkspaceWrapper(group_asymmetry) if show: self._groups[group_name]._workspace_rebin[str(run)].show( directory + name) self._groups[group_name]._asymmetry_estimate_rebin[str( run)].show(directory + asym_name)