def export(self, overwrite=False): """ Export the (ideally) whole project to disk :param overwrite: if specified, then any existing files with same name will be rewritten :return: """ # create workspace directory self.create_workspace_directory() print '[INFO] Saving {0} MDEventWorkspaces to {1}.'.format(len(self._wsList), self._wsDir) # save MDs for ws_name in self._wsList: md_file_name = os.path.join(self._wsDir, ws_name + '.nxs') if overwrite or not os.path.exists(md_file_name): try: mantidsimple.SaveMD(InputWorkspace=ws_name, Filename=md_file_name) except RuntimeError as run_err: print '[ERROR] Unable to save {0} due to RuntimeError {1}.'.format(ws_name, run_err) except Exception as arb_err: print '[ERROR] Unable to save {0} due to arbitrary exception {1}.'.format(ws_name, arb_err) # END-IF # END-FOR (ws_name) with open(self._projectPath, 'w') as pickle_file: pickle.dump(self._variableDict, pickle_file, pickle.HIGHEST_PROTOCOL) pickle.dump(self._wsList, pickle_file, pickle.HIGHEST_PROTOCOL) return
def export(self, overwrite=False): """ Export the (ideally) whole project to disk :param overwrite: if specified, then any existing files with same name will be rewritten :return: """ self.create_workspace_directory() # save MDs for ws_name in self._wsList: md_file_name = os.path.join(self._wsDir, ws_name + '.nxs') if overwrite or os.path.exists(md_file_name): mantidsimple.SaveMD(InputWorkspace=ws_name, Filename=md_file_name) with open(self._projectPath, 'w') as pickle_file: pickle.dump(self._variableDict, pickle_file, pickle.HIGHEST_PROTOCOL) pickle.dump(self._wsList, pickle_file, pickle.HIGHEST_PROTOCOL) return
filename = 'fe_demo_30.sqw' ws_in = 'fe_demo_30' # Load an SQW file and internally convert to a Multidimensional event workspace (MDEW) if not mantid.mtd.doesExist(ws_in): mantid.LoadSQW(filename, OutputWorkspace=ws_in) # Bin the workspace in an axis aligned manner. Creates a Histogrammed MD workspace. mantid.BinMD(InputWorkspace=ws_in, OutputWorkspace='binned_axis_aligned', AxisAligned=True, AlignedDim0='Q_\\zeta,-1.5,5,100', AlignedDim1='Q_\\xi,-6,6,100', AlignedDim2='Q_\\eta,-6,6,100', AlignedDim3='E,0,150,30') # Bin the workpace using a coordinate transformation to rotate the output.. Creates a Histogrammed MD workspace. mantid.BinMD(InputWorkspace=ws_in, OutputWorkspace='binned_rotated', AxisAligned=False, BasisVector0='Qx,Ang,1,0.5,0,0,1,100', BasisVector1='Qy,Ang,-0.5,1,0,0,1,100', BasisVector2='Qz,Ang,0,0,1.25,0,1,100', Origin='0,0,0,0') # Save the MDEW workspace in the MDEW nexus format. mantid.SaveMD(ws_in, Filename='MDEW_fe_demo_30.nxs') # Could reload the MDEW at this point.