本文整理汇总了Python中mantid.simpleapi.CreateWorkspace.setYUnitLabel方法的典型用法代码示例。如果您正苦于以下问题:Python CreateWorkspace.setYUnitLabel方法的具体用法?Python CreateWorkspace.setYUnitLabel怎么用?Python CreateWorkspace.setYUnitLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.simpleapi.CreateWorkspace
的用法示例。
在下文中一共展示了CreateWorkspace.setYUnitLabel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyExec
# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import setYUnitLabel [as 别名]
#.........这里部分代码省略.........
lambda par_name: lookup(par_name, self.int_vars, 0),
lambda par_name: lookup(par_name, self.float_vars, 0.0),
lambda par_name: lookup(par_name, self.bool_vars, False),
# Callback for logging:
log
)
def write_items_to_file(path, items):
"""Given a path to a file and a list of items, will write the items
to the file, one on each line."""
with open(path, 'w') as f:
for item in items:
f.write(str(item) + "\n")
# Chop the padded outputs back down to the correct size.
output_phases = output_phases[:input_phases_size]
output_deadtimes = output_deadtimes[:input_deadtimes_size]
input_phases = input_phases[:input_phases_size]
input_deadtimes = input_deadtimes[:input_deadtimes_size]
fchan_out = fchan_out[:n_bins]
f_out = f_out[:n_bins]
write_items_to_file(out_phases_file, output_phases)
write_items_to_file(out_deadtimes_file, output_deadtimes)
log_output = "\nDead times in:\n" + str(input_deadtimes) + "\n" +\
"\nDead times out:\n" + str(output_deadtimes) + "\n" +\
"\nPhases in:\n" + str(input_phases) + "\n" +\
"\nPhases out:\n" + str(output_phases) + "\n" + \
"\nGroupings:\n" + str(groupings) + "\n" +\
"\nChi Squared:\n" + str(chi_sq) + "\n" +\
"\nInput variables:\n"
for type_map in self.int_vars, self.float_vars, self.bool_vars:
for name, value in type_map.items():
log_output += str(name) + " = " + str(value) + "\n"
Logger.get("MaxEnt").notice(log_output)
# Generate our own output ws name if the user has not provided one.
out_ws_name = self.getPropertyValue(OUT_WS_PROP)
if out_ws_name == "":
out_ws_name = run_name + "; MaxEnt"
self.setPropertyValue(OUT_WS_PROP, out_ws_name)
out_ws = CreateWorkspace(OutputWorkspace=out_ws_name,
DataX=fchan_out[:n_bins],
DataY=f_out[:n_bins])
self.setProperty(OUT_WS_PROP, out_ws)
# MaxEnt inputs table.
input_table_name = run_name + "; MaxEnt Input"
input_table = CreateEmptyTableWorkspace(OutputWorkspace = input_table_name)
input_table.addColumn("str", "Name")
input_table.addColumn("str", "Value")
inputs = itertools.chain(self.int_vars.items(),
self.float_vars.items(),
self.bool_vars.items())
for name, value in inputs:
input_table.addRow([str(name), str(value)])
# Deadtimes and phases input/output table.
dead_phases_table_name = run_name + "; MaxEnt Deadtimes & Phases"
dead_phases_table = CreateEmptyTableWorkspace(OutputWorkspace = dead_phases_table_name)
for column_name in "Deadtimes In", "Deadtimes Out", "Phases In", "Phases Out":
dead_phases_table.addColumn("double", column_name)
for row in zip(input_deadtimes, output_deadtimes, input_phases, output_phases):
dead_phases_table.addRow(list(map(float, row)))
# Chi-squared output table.
chisq_table_name = run_name + "; MaxEnt Chi^2"
chisq_table = CreateEmptyTableWorkspace(OutputWorkspace = chisq_table_name)
chisq_table.addColumn("int", "Cycle")
for iteration in range(10):
chisq_table.addColumn("double", "Iter " + str(iteration + 1))
for cycle, data in enumerate(chi_sq):
chisq_table.addRow([cycle + 1] + list(map(float,data)))
all_output_ws = [input_table_name,
dead_phases_table_name,
chisq_table_name,
out_ws_name]
# The output workspaces of this algorithm belong in the same groups
# that are created by the muon interface. If the appropriate group
# doesn't exist already then it needs to be created.
if not run_name in mtd:
GroupWorkspaces(InputWorkspaces = all_output_ws,
OutputWorkspace = run_name)
else:
group = mtd[run_name]
for output_ws in all_output_ws:
if not group.contains(output_ws):
group.add(output_ws)
out_ws.getAxis(0).getUnit().setLabel("Field", "G")
out_ws.setYUnitLabel("P(B)")
if INSIDE_MANTIDPLOT:
mantidplot.plotSpectrum(out_ws, 0)