def _attenuate_workspace(output_file_paths, attenuated_ws, attenuation_filepath): # Clone a workspace which is not attenuated no_att = output_file_paths["output_name"] + "_noatten" mantid.CloneWorkspace(InputWorkspace=attenuated_ws, OutputWorkspace=no_att) return pearl_algs.attenuate_workspace( attenuation_file_path=attenuation_filepath, ws_to_correct=attenuated_ws)
def _focus_mode_trans(output_file_paths, attenuation_filepath, calibrated_spectra): summed_ws = mantid.MergeRuns(InputWorkspaces=calibrated_spectra[:9]) xList = summed_ws.readX(0) summed_ws = mantid.CropWorkspace(InputWorkspace=summed_ws, XMin=xList[1], Xmax=xList[-2]) summed_ws = mantid.Scale(InputWorkspace=summed_ws, Factor=0.111111111111111) if attenuation_filepath: summed_ws = pearl_algs.attenuate_workspace( attenuation_file_path=attenuation_filepath, ws_to_correct=summed_ws) summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws, Target="TOF") mantid.SaveGSS(InputWorkspace=summed_ws, Filename=output_file_paths["gss_filename"], Append=False, Bank=1) mantid.SaveFocusedXYE(InputWorkspace=summed_ws, Filename=output_file_paths["tof_xye_filename"], Append=False, IncludeHeader=False) summed_ws = mantid.ConvertUnits(InputWorkspace=summed_ws, Target="dSpacing") # Rename to user friendly name: summed_ws_name = output_file_paths["output_name"] + "_mods1-9" summed_ws = mantid.RenameWorkspace(InputWorkspace=summed_ws, OutputWorkspace=summed_ws_name) mantid.SaveFocusedXYE(InputWorkspace=summed_ws, Filename=output_file_paths["dspacing_xye_filename"], Append=False, IncludeHeader=False) mantid.SaveNexus(InputWorkspace=summed_ws, Filename=output_file_paths["nxs_filename"], Append=False) output_list = [summed_ws] for i in range(0, 9): workspace_name = output_file_paths["output_name"] + "_mod" + str(i + 1) to_save = mantid.ConvertUnits(InputWorkspace=calibrated_spectra[i], Target="dSpacing", OutputWorkspace=workspace_name) output_list.append(to_save) mantid.SaveNexus(Filename=output_file_paths["nxs_filename"], InputWorkspace=to_save, Append=True) return output_list
def _focus_mode_all(output_file_paths, processed_spectra, attenuation_filepath): summed_spectra_name = output_file_paths["output_name"] + "_mods1-9" summed_spectra = mantid.MergeRuns(InputWorkspaces=processed_spectra[:9], OutputWorkspace=summed_spectra_name) xList = summed_spectra.readX(0) summed_spectra = mantid.CropWorkspace(InputWorkspace=summed_spectra, XMin=xList[1], Xmax=xList[-2], OutputWorkspace=summed_spectra_name) summed_spectra = mantid.Scale(InputWorkspace=summed_spectra, Factor=0.111111111111111, OutputWorkspace=summed_spectra_name) if attenuation_filepath: summed_spectra = pearl_algs.attenuate_workspace( attenuation_file_path=attenuation_filepath, ws_to_correct=summed_spectra) summed_spectra = mantid.ConvertUnits(InputWorkspace=summed_spectra, Target="TOF", OutputWorkspace=summed_spectra_name) mantid.SaveGSS(InputWorkspace=summed_spectra, Filename=output_file_paths["gss_filename"], Append=False, Bank=1) mantid.SaveFocusedXYE(InputWorkspace=summed_spectra_name, Filename=output_file_paths["tof_xye_filename"], Append=False, IncludeHeader=False) summed_spectra = mantid.ConvertUnits(InputWorkspace=summed_spectra, Target="dSpacing", OutputWorkspace=summed_spectra_name) mantid.SaveNexus(Filename=output_file_paths["nxs_filename"], InputWorkspace=summed_spectra, Append=False) output_list = [summed_spectra] for i in range(0, 5): spectra_index = (i + 9) # Compensate for 0 based index ws_to_save = processed_spectra[ spectra_index] # Save out workspaces 10/11/12 output_name = output_file_paths["output_name"] + "_mod" + str( spectra_index + 1) ws_to_save = mantid.ConvertUnits(InputWorkspace=ws_to_save, OutputWorkspace=ws_to_save, Target="TOF") mantid.SaveGSS(InputWorkspace=ws_to_save, Filename=output_file_paths["gss_filename"], Append=True, Bank=i + 2) splits = output_file_paths["tof_xye_filename"].split(".") tof_xye_name = splits[0] + "-" + str(i + 10) + "." + splits[1] mantid.SaveFocusedXYE(InputWorkspace=ws_to_save, Filename=tof_xye_name, Append=False, IncludeHeader=False) ws_to_save = mantid.ConvertUnits(InputWorkspace=ws_to_save, OutputWorkspace=output_name, Target="dSpacing") mantid.SaveNexus(Filename=output_file_paths["nxs_filename"], InputWorkspace=ws_to_save, Append=True) output_list.append(ws_to_save) return output_list
def _attenuate_workspace(output_file_paths, attenuated_ws, attenuation_filepath): # Clone a workspace which is not attenuated no_att = output_file_paths["output_name"] + "_noatten" mantid.CloneWorkspace(InputWorkspace=attenuated_ws, OutputWorkspace=no_att) return pearl_algs.attenuate_workspace(attenuation_file_path=attenuation_filepath, ws_to_correct=attenuated_ws)