def generate_hydra_workspace_multiple_sub_runs(ws_name, sub_run_data_dict): """Generate a multiple sub-run HiDRA workspace Parameters ---------- ws_name sub_run_data_dict Returns ------- pyrs.core.workspaces.HidraWorkspace Test Hidra workspace """ # Create test workspace test_workspace = HidraWorkspace(ws_name) # Sub runs: sub_runs_list = list(sub_run_data_dict.keys()) test_workspace.set_sub_runs(sub_runs_list) # Add diffraction pattern for sub_run_i in sorted(sub_runs_list): vec_x, vec_y = sub_run_data_dict[sub_run_i] test_workspace.set_reduced_diffraction_data(sub_run_i, mask_id=None, two_theta_array=vec_x, intensity_array=vec_y) return test_workspace
def generate_hydra_workspace_single_subrun(peak_profile_type, min_x, max_x, num_x, peak_centers, peak_ranges, peak_intensities): """Generate HiDRAWorkspace for peak fitting test Default: min_x = 75 max_x = 85 num_x = 500 Parameters ---------- peak_profile_type min_x max_x num_x peak_centers peak_ranges peak_intensities Returns ------- pyrs.core.workspaces.HidraWorkspace Test Hidra workspace """ # Create test workspace test_workspace = HidraWorkspace('test') # resolution x_step = (max_x - min_x) / num_x # Generate vector X vec_x = np.arange(num_x) * x_step + min_x # from 75 to 85 degree # Add profile if peak_profile_type.lower() == 'gaussian': test_fitting_function = generate_test_gaussian(vec_x, peak_centers, peak_ranges, peak_intensities) elif peak_profile_type.lower() == 'pseudovoigt': test_fitting_function = generate_test_pseudovoigt( vec_x, peak_centers, peak_ranges, peak_intensities) # peak_range *= 2 # PV requires larger fitting range else: raise NotImplementedError( 'Peak profile {} is not supported to generate testing workspace') vec_y = test_fitting_function['values'] parameters = test_fitting_function['parameters'] # Add background test_background_function = generate_test_background(vec_x, vec_y) vec_y = test_background_function['values'] parameters.append(test_background_function['parameters']) # Print out the test data # for i in range(vec_x.shape[0]): # print('{} {}'.format(vec_x[i], vec_y[i])) # Add diffraction pattern test_workspace.set_sub_runs([1]) test_workspace.set_reduced_diffraction_data(1, mask_id=None, two_theta_array=vec_x, intensity_array=vec_y) return {'workspace': test_workspace, 'parameters': parameters}