本文整理汇总了Python中mantid.api.WorkspaceFactory.createTable方法的典型用法代码示例。如果您正苦于以下问题:Python WorkspaceFactory.createTable方法的具体用法?Python WorkspaceFactory.createTable怎么用?Python WorkspaceFactory.createTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.api.WorkspaceFactory
的用法示例。
在下文中一共展示了WorkspaceFactory.createTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyExec
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def PyExec(self):
""" Main Execution Body
"""
# 1. Setup output workspaces
paramWS = WorkspaceFactory.createTable()
self.setProperty("InstrumentParameterWorkspace", paramWS)
hklWS = WorkspaceFactory.createTable()
self.setProperty("BraggPeakParameterWorkspace", hklWS)
# 2. Get Other Properties
instrument = self.getProperty("Instrument")
reflectionfilename = self.getPropertyValue("ReflectionsFile")
irffilename = self.getPropertyValue("FullprofParameterFile")
# 3. Import reflections list
hkldict = self.importFullProfHKLFile(reflectionfilename)
hkllist = sorted(hkldict.keys())
if _OUTPUTLEVEL == "INFORMATION":
for hkl in hkllist:
print "Import Peak (%d, %d, %d): FWHM = %f" % (hkl[0], hkl[1], hkl[2], hkldict[hkl]["FWHM"])
# 4. Import parameter file (.irf)
peakparamsdict = self.parseFullprofPeakProfileFile(irffilename)
# 5. Set up the table workspaces
self.createPeakParameterWorkspace(peakparamsdict, paramWS)
self.createReflectionWorkspace(hkldict, hklWS)
return
示例2: PyExec
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def PyExec(self):
""" Main Execution Body
"""
# 1. Get Input properties
inppeakws = self.getProperty("BraggPeakParameterWorkspace").value
inpzscows = self.getProperty("ZscoreWorkspace").value
minpeakheight = float(self.getPropertyValue("MinimumPeakHeight"))
zscorefilterstr = self.getPropertyValue("ZscoreFilter")
print "Input: PeakParameterWorkspace = %s; ZscoreWorkspace = %s" % (inppeakws.name, inpzscows.name)
print " Minimum peak height = %f" % (minpeakheight)
print " Zscore filter: %s" % (zscorefilterstr)
# 3. Parse Zscore table and peak parameters
self.mPeaks = {}
zscoredict = self.parseBraggPeakParameterTable(inpzscows)
self.mPeaks = self.parseBraggPeakParameterTable(inppeakws)
# 4. Filter by peak height
self.filterByPeakHeight(minpeakheight)
# 5. Filter by zscore
zscorefilterdict = self.parseZscoreFilter(zscorefilterstr)
self.filterByZscore(zscoredict, zscorefilterdict)
# 6. Generate the output
paramWS = WorkspaceFactory.createTable()
self.genBraggPeakParameterWorkspace(paramWS)
self.setProperty("OutputBraggPeakParameterWorkspace", paramWS)
return
示例3: test_table_is_resized_correctly
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_table_is_resized_correctly(self):
table = WorkspaceFactory.createTable()
self.assertEquals(len(table), 0)
table.setRowCount(5)
self.assertEquals(len(table), 5)
self.assertTrue(table.addColumn(type="int",name="index"))
self.assertEquals(table.columnCount(), 1)
示例4: test_adding_table_data_using_numpy
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_adding_table_data_using_numpy(self):
table = WorkspaceFactory.createTable()
table.addColumn(type="int",name="index")
self.assertEquals(table.columnCount(), 1)
table.addColumn(type="int",name="value")
self.assertEquals(table.columnCount(), 2)
nextrow = [1, 10]
values32 = numpy.array(nextrow).astype(numpy.int32)
values64 = numpy.array(nextrow).astype(numpy.int64)
table.addRow(values32)
self.assertEquals(len(table), 1)
insertedrow = table.row(0)
self.assertEquals(1, insertedrow['index'])
self.assertEquals(10, insertedrow['value'])
table.addRow(values64)
self.assertEquals(len(table), 2)
insertedrow = table.row(1)
self.assertEquals(1, insertedrow['index'])
self.assertEquals(10, insertedrow['value'])
incorrect_type = numpy.array(['1', '10'])
self.assertRaises(TypeError, table.addRow, incorrect_type)
示例5: _loadFullprofPrfFile
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def _loadFullprofPrfFile(self, prffilename):
""" Load Fullprof .prf file
"""
# 1. Parse the file to dictionary
infodict, data = self._parseFullprofPrfFile(prffilename)
# 2. Export information to table file
tablews = WorkspaceFactory.createTable()
tablews.addColumn("str", "Name")
tablews.addColumn("double", "Value")
for parname in infodict.keys():
parvalue = infodict[parname]
tablews.addRow([parname, parvalue])
# 3. Export the data workspace
datasize = len(data)
print "Data Size = ", datasize
dataws = WorkspaceFactory.create("Workspace2D", 4, datasize, datasize)
for i in xrange(datasize):
for j in xrange(4):
dataws.dataX(j)[i] = data[i][0]
dataws.dataY(j)[i] = data[i][j+1]
dataws.dataE(j)[i] = 1.0
return (tablews, dataws)
示例6: _create_test_table
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def _create_test_table(self):
table = WorkspaceFactory.createTable()
table.addColumn(type="int", name="index")
table.addColumn(type="str", name="name")
table.addRow([0, "1"])
table.addRow([0, "2"])
table.addRow([0, "3"])
return table
示例7: _create_test_table
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def _create_test_table(self):
table = WorkspaceFactory.createTable()
table.addColumn(type='int', name='index')
table.addColumn(type='str', name='name')
table.addRow([0,'1'])
table.addRow([0,'2'])
table.addRow([0,'3'])
return table
示例8: test_set_and_extract_v3d_columns
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_set_and_extract_v3d_columns(self):
from mantid.kernel import V3D
table = WorkspaceFactory.createTable()
table.addColumn(type='V3D', name='pos')
table.addRow([V3D(1,1,1)])
self.assertEquals(V3D(1,1,1), table.cell(0, 0))
示例9: test_set_and_extract_boolean_columns
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_set_and_extract_boolean_columns(self):
table = WorkspaceFactory.createTable()
table.addColumn(type='bool', name='yes_no')
table.addRow([True])
table.addRow([False])
self.assertTrue(table.cell(0, 0))
self.assertFalse(table.cell(1, 0))
示例10: test_set_and_extract_vector_columns
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_set_and_extract_vector_columns(self):
table = WorkspaceFactory.createTable()
table.addColumn(type='vector_int', name='values')
# Settings from general Python list
table.addRow([ [1,2,3,4,5] ])
# Setting from numpy array
table.addRow([ numpy.array([6,7,8,9,10]) ])
self.assertTrue( numpy.array_equal( table.cell(0,0), numpy.array([1,2,3,4,5]) ) )
self.assertTrue( numpy.array_equal( table.cell(1,0), numpy.array([6,7,8,9,10]) ) )
示例11: test_adding_table_data_using_list
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_adding_table_data_using_list(self):
table = WorkspaceFactory.createTable()
table.addColumn(type="int",name="index")
self.assertEquals(table.columnCount(), 1)
table.addColumn(type="str",name="value")
self.assertEquals(table.columnCount(), 2)
nextrow = {'index':1, 'value':'10'}
values = nextrow.values()
table.addRow(nextrow)
self.assertEquals(len(table), 1)
insertedrow = table.row(0)
self.assertEquals(insertedrow, nextrow)
insertedrow = table.row(0)
self.assertEquals(insertedrow, nextrow)
示例12: test_adding_table_data_using_dictionary
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_adding_table_data_using_dictionary(self):
table = WorkspaceFactory.createTable()
table.addColumn(type="int",name="index")
self.assertEquals(table.columnCount(), 1)
table.addColumn(type="str",name="value")
self.assertEquals(table.columnCount(), 2)
nextrow = {'index':1, 'value':'10'}
table.addRow(nextrow)
self.assertEquals(len(table), 1)
insertedrow = table.row(0)
self.assertEquals(insertedrow, nextrow)
incorrect_type = {'index':1, 'value':10}
self.assertRaises(ValueError, table.addRow, incorrect_type)
示例13: test_adding_table_data_using_list
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_adding_table_data_using_list(self):
table = WorkspaceFactory.createTable()
table.addColumn(type="int",name="index")
self.assertEquals(table.columnCount(), 1)
table.addColumn(type="str",name="value")
self.assertEquals(table.columnCount(), 2)
values = [1, '10']
table.addRow(values)
self.assertEquals(len(table), 1)
insertedrow = table.row(0)
self.assertEquals(1, insertedrow['index'])
self.assertEquals('10', insertedrow['value'])
incorrect_type = [1, 10]
self.assertRaises(TypeError, table.addRow, incorrect_type)
示例14: test_pickle_table_workspace
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_pickle_table_workspace(self):
from mantid.kernel import V3D
import pickle
table = WorkspaceFactory.createTable()
table.addColumn(type="int",name="index")
table.addColumn(type="str",name="value")
table.addColumn(type="V3D",name="position")
values = (1, '10', V3D(0, 0, 1))
table.addRow(values)
values = (2, '100', V3D(1, 0, 0))
table.addRow(values)
p = pickle.dumps(table)
table2 = pickle.loads(p)
self.assertEqual(table.toDict(), table2.toDict())
示例15: test_set_and_extract_plot_types
# 需要导入模块: from mantid.api import WorkspaceFactory [as 别名]
# 或者: from mantid.api.WorkspaceFactory import createTable [as 别名]
def test_set_and_extract_plot_types(self):
table = WorkspaceFactory.createTable()
table.addColumn("int", "index")
table.addColumn("int", "value", 3)
self.assertEquals(table.columnCount(), 2)
self.assertEquals(table.getPlotType(0), -1000) # default plot type
self.assertEquals(table.getPlotType(1), 3)
table.setPlotType(0, 1)
table.setPlotType("value", 2)
self.assertEquals(table.getPlotType("index"), 1)
self.assertEquals(table.getPlotType("value"), 2)
table.addRow([1, 2])
table.addRow([3, 4])
self.assertEquals(table.rowCount(), 2)