本文整理汇总了Python中mantid.api.AnalysisDataService.doesExist方法的典型用法代码示例。如果您正苦于以下问题:Python AnalysisDataService.doesExist方法的具体用法?Python AnalysisDataService.doesExist怎么用?Python AnalysisDataService.doesExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.api.AnalysisDataService
的用法示例。
在下文中一共展示了AnalysisDataService.doesExist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cleanup
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def cleanup(self):
if AnalysisDataService.doesExist(self._input_wksp):
DeleteWorkspace(self._input_wksp)
if AnalysisDataService.doesExist(self._output_wksp):
DeleteWorkspace(self._output_wksp)
if AnalysisDataService.doesExist(self._correction_wksp):
DeleteWorkspace(self._correction_wksp)
示例2: _removeWorkspace
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def _removeWorkspace(workspace_name):
"""Remove the workspace with the given name, including any child workspaces if it
is a group. If a corresponding monitors workspace exists, remove that too."""
if AnalysisDataService.doesExist(workspace_name):
workspace = AnalysisDataService.retrieve(workspace_name)
if isinstance(workspace, WorkspaceGroup):
# Remove child workspaces first
while workspace.getNumberOfEntries():
_removeWorkspace(workspace[0].name())
AnalysisDataService.remove(workspace_name)
# If a corresponding monitors workspace also exists, remove that too
if AnalysisDataService.doesExist(_monitorWorkspace(workspace_name)):
_removeWorkspace(_monitorWorkspace(workspace_name))
示例3: __init__
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def __init__(self, exp_number, scan_number_list, matrix_ws_name, scan_spectrum_map, spectrum_scan_map):
"""
initialization
:param exp_number:
:param scan_number_list:
:param matrix_ws_name:
:param scan_spectrum_map:
:param spectrum_scan_map:
"""
# check input
check_integer('Experiment number', exp_number)
check_list('Scan numbers', scan_number_list)
check_string('Workspace2D name', matrix_ws_name)
check_dictionary('Scan number spectrum number mapping', scan_spectrum_map)
check_dictionary('Spectrum number scan number mapping', spectrum_scan_map)
if AnalysisDataService.doesExist(matrix_ws_name) is False:
raise RuntimeError('Workspace {} does not exist.'.format(matrix_ws_name))
# store
self._exp_number = exp_number
self._scan_number_list = scan_number_list[:]
self._matrix_ws_name = matrix_ws_name
self._scan_spectrum_map = scan_spectrum_map
self._spectrum_scan_map = spectrum_scan_map
# TODO - 20180814 - Add pt number, rio name and integration direction for future check!
# others
self._model_ws_name = None
return
示例4: _update_high_q
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def _update_high_q(self, _ws=None):
"""
Update High-Q data set
"""
self._high_q_data = self.update_data(self._content.high_q_combo,
None,
None,
self._content.high_scale_edit)
self._high_q_modified = False
file_in = str(self._content.high_q_combo.lineEdit().text())
if len(file_in.strip()) == 0:
self._high_q_data = None
elif os.path.isfile(file_in) or AnalysisDataService.doesExist(file_in):
self._high_q_data = DataSet(file_in)
try:
self._high_q_data.load(True)
except (AttributeError, ImportError, NameError, TypeError, ValueError, Warning):
self._high_q_data = None
util.set_valid(self._content.high_q_combo.lineEdit(), False)
QtGui.QMessageBox.warning(self, "Error loading file",
"Could not load %s.\nMake sure you pick the XML output from the reduction." % file_in)
return
self._content.high_scale_edit.setText("1.0")
util.set_valid(self._content.high_q_combo.lineEdit(), True)
else:
self._high_q_data = None
util.set_valid(self._content.high_q_combo.lineEdit(), False)
示例5: testCalculateEfficiencyCorretionInvalidStoreADSCheck
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def testCalculateEfficiencyCorretionInvalidStoreADSCheck(self):
self.cleanup()
corr_wksp = CalculateEfficiencyCorrection(
WavelengthRange=self._wavelengths,
Alpha=self._alpha,
StoreInADS=False)
self.assertFalse(AnalysisDataService.doesExist(corr_wksp.name()))
示例6: load_bragg_file
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def load_bragg_file(self, file_name):
"""
Load Bragg diffraction file (including 3-column data file, GSAS file) for Rietveld
"""
# load with different file type
base_file_name = os.path.basename(file_name).lower()
gss_ws_name = os.path.basename(file_name).split('.')[0]
if base_file_name.endswith('.gss') or base_file_name.endswith('.gsa') or base_file_name.endswith('.gda'):
simpleapi.LoadGSS(Filename=file_name,
OutputWorkspace=gss_ws_name)
elif base_file_name.endswith('.nxs'):
simpleapi.LoadNexusProcessed(Filename=file_name, OutputWorkspace=gss_ws_name)
simpleapi.ConvertUnits(InputWorkspace=gss_ws_name, OutputWorkspace=gss_ws_name, EMode='Elastic', Target='TOF')
elif base_file_name.endswith('.dat'):
simpleapi.LoadAscii(Filename=file_name,
OutputWorkspace=gss_ws_name,
Unit='TOF')
else:
raise RuntimeError('File %s is not of a supported type.' % file_name)
self._braggDataList.append(gss_ws_name)
# check
assert AnalysisDataService.doesExist(gss_ws_name)
angle_list = AddieDriver.calculate_bank_angle(gss_ws_name)
return gss_ws_name, angle_list
示例7: edit_matrix_workspace
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def edit_matrix_workspace(sq_name, scale_factor, shift, edited_sq_name=None):
"""
Edit the matrix workspace of S(Q) by scaling and shift
:param sq_name: name of the SofQ workspace
:param scale_factor:
:param shift:
:param edited_sq_name: workspace for the edited S(Q)
:return:
"""
# get the workspace
if AnalysisDataService.doesExist(sq_name) is False:
raise RuntimeError('S(Q) workspace {0} cannot be found in ADS.'.format(sq_name))
if edited_sq_name is not None:
simpleapi.CloneWorkspace(InputWorkspace=sq_name, OutputWorkspace=edited_sq_name)
sq_ws = AnalysisDataService.retrieve(edited_sq_name)
else:
sq_ws = AnalysisDataService.retrieve(sq_name)
# get the vector of Y
sq_ws = sq_ws * scale_factor
sq_ws = sq_ws + shift
if sq_ws.name() != edited_sq_name:
simpleapi.DeleteWorkspace(Workspace=edited_sq_name)
simpleapi.RenameWorkspace(InputWorkspace=sq_ws, OutputWorkspace=edited_sq_name)
assert sq_ws is not None, 'S(Q) workspace cannot be None.'
print('[DB...BAT] S(Q) workspace that is edit is {0}'.format(sq_ws))
示例8: get_weighted_peak_centres
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def get_weighted_peak_centres(self):
""" Get the peak centers found in peak workspace.
Guarantees: the peak centers and its weight (detector counts) are exported
:return: 2-tuple: list of 3-tuple (Qx, Qy, Qz)
list of double (Det_Counts)
"""
# get PeaksWorkspace
if AnalysisDataService.doesExist(self._myPeakWorkspaceName) is False:
raise RuntimeError('PeaksWorkspace %s does ot exit.' % self._myPeakWorkspaceName)
peak_ws = AnalysisDataService.retrieve(self._myPeakWorkspaceName)
# get peak center, peak intensity and etc.
peak_center_list = list()
peak_intensity_list = list()
num_peaks = peak_ws.getNumberPeaks()
for i_peak in xrange(num_peaks):
peak_i = peak_ws.getPeak(i_peak)
center_i = peak_i.getQSampleFrame()
intensity_i = peak_i.getIntensity()
peak_center_list.append((center_i.X(), center_i.Y(), center_i.Z()))
peak_intensity_list.append(intensity_i)
# END-FOR
return peak_center_list, peak_intensity_list
示例9: test_batch_reduction_on_multiperiod_file
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def test_batch_reduction_on_multiperiod_file(self):
# Arrange
# Build the data information
data_builder = get_data_builder(SANSFacility.ISIS)
data_builder.set_sample_scatter("SANS2D0005512")
data_info = data_builder.build()
# Get the rest of the state from the user file
user_file_director = StateDirectorISIS(data_info)
user_file_director.set_user_file("MASKSANS2Doptions.091A")
# Set the reduction mode to LAB
user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB)
state = user_file_director.construct()
# Act
states = [state]
self._run_batch_reduction(states, use_optimizations=False)
# Assert
# We only assert that the expected workspaces exist on the ADS
expected_workspaces = ["5512p1rear_1D_2.0_14.0Phi-45.0_45.0", "5512p2rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p3rear_1D_2.0_14.0Phi-45.0_45.0", "5512p4rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p5rear_1D_2.0_14.0Phi-45.0_45.0", "5512p6rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p7rear_1D_2.0_14.0Phi-45.0_45.0", "5512p8rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p9rear_1D_2.0_14.0Phi-45.0_45.0", "5512p10rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p11rear_1D_2.0_14.0Phi-45.0_45.0", "5512p12rear_1D_2.0_14.0Phi-45.0_45.0",
"5512p13rear_1D_2.0_14.0Phi-45.0_45.0"]
for element in expected_workspaces:
self.assertTrue(AnalysisDataService.doesExist(element))
# Clean up
for element in expected_workspaces:
AnalysisDataService.remove(element)
示例10: retrieve_hkl_from_spice_table
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def retrieve_hkl_from_spice_table(self):
""" Get averaged HKL from SPICE table
HKL will be averaged from SPICE table by assuming the value in SPICE might be right
:return:
"""
# get SPICE table
spice_table_name = get_spice_table_name(self._myExpNumber, self._myScanNumber)
assert AnalysisDataService.doesExist(spice_table_name), 'Spice table for exp %d scan %d cannot be found.' \
'' % (self._myExpNumber, self._myScanNumber)
spice_table_ws = AnalysisDataService.retrieve(spice_table_name)
# get HKL column indexes
h_col_index = spice_table_ws.getColumnNames().index('h')
k_col_index = spice_table_ws.getColumnNames().index('k')
l_col_index = spice_table_ws.getColumnNames().index('l')
# scan each Pt.
hkl = numpy.array([0., 0., 0.])
num_rows = spice_table_ws.rowCount()
for row_index in xrange(num_rows):
mi_h = spice_table_ws.cell(row_index, h_col_index)
mi_k = spice_table_ws.cell(row_index, k_col_index)
mi_l = spice_table_ws.cell(row_index, l_col_index)
hkl += numpy.array([mi_h, mi_k, mi_l])
# END-FOR
self._spiceHKL = hkl/num_rows
return
示例11: _update_high_q
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def _update_high_q(self, ws=None):
"""
Update High-Q data set
"""
self._high_q_data = self.update_data(self._content.high_q_combo,
None,
None,
self._content.high_scale_edit)
self._high_q_modified = False
file = str(self._content.high_q_combo.lineEdit().text())
if len(file.strip())==0:
self._high_q_data = None
elif os.path.isfile(file) or AnalysisDataService.doesExist(file):
self._high_q_data = DataSet(file)
try:
self._high_q_data.load(True)
except:
self._high_q_data = None
util.set_valid(self._content.high_q_combo.lineEdit(), False)
QtGui.QMessageBox.warning(self, "Error loading file", "Could not load %s.\nMake sure you pick the XML output from the reduction." % file)
return
self._content.high_scale_edit.setText("1.0")
npts = self._high_q_data.get_number_of_points()
util.set_valid(self._content.high_q_combo.lineEdit(), True)
else:
self._high_q_data = None
util.set_valid(self._content.high_q_combo.lineEdit(), False)
示例12: testCalculateEfficiencyCorretionStoreADSCheck
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def testCalculateEfficiencyCorretionStoreADSCheck(self):
self.cleanup()
alg_test = run_algorithm("CalculateEfficiencyCorrection",
WavelengthRange=self._wavelengths,
Alpha=self._alpha,
OutputWorkspace=self._output_wksp)
self.assertTrue(alg_test.isExecuted())
self.assertTrue(AnalysisDataService.doesExist(self._output_wksp))
示例13: _display
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def _display(masked_workspace):
if masked_workspace and AnalysisDataService.doesExist(masked_workspace.name()):
if PYQT4:
instrument_win = mantidplot.getInstrumentView(masked_workspace.name())
instrument_win.show()
else:
instrument_win = InstrumentViewPresenter(masked_workspace)
instrument_win.view.show()
示例14: test_that_load_dead_time_from_filename_places_table_in_ADS
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def test_that_load_dead_time_from_filename_places_table_in_ADS(self):
filename = 'MUSR00022725.nsx'
name = utils.load_dead_time_from_filename(filename)
dead_time_table = AnalysisDataService.retrieve(name)
self.assertEqual(name, 'MUSR00022725_deadTimes')
self.assertTrue(AnalysisDataService.doesExist(name))
self.assertTrue(isinstance(dead_time_table, ITableWorkspace))
示例15: _create_sensitivity
# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import doesExist [as 别名]
def _create_sensitivity(self):
if IS_IN_MANTIDPLOT and self.options_callback is not None:
# Get patch information
patch_ws = ""
if AnalysisDataService.doesExist(self.patch_ws):
patch_ws = self.patch_ws
try:
reduction_table_ws = self.options_callback()
patch_output = AnalysisDataService.doesExist(patch_ws)
filename = self._content.sensitivity_file_edit.text()
script = "ComputeSensitivity(Filename='%s',\n" % filename
script += " ReductionProperties='%s',\n" % reduction_table_ws
script += " OutputWorkspace='sensitivity',\n"
script += " PatchWorkspace='%s')\n" % patch_ws
mantidplot.runPythonScript(script, True)
except:
print "Could not compute sensitivity"
print sys.exc_value