本文整理汇总了Python中mantid.simpleapi.Load.getInstrument方法的典型用法代码示例。如果您正苦于以下问题:Python Load.getInstrument方法的具体用法?Python Load.getInstrument怎么用?Python Load.getInstrument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.simpleapi.Load
的用法示例。
在下文中一共展示了Load.getInstrument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_minimal_inputs
# 需要导入模块: from mantid.simpleapi import Load [as 别名]
# 或者: from mantid.simpleapi.Load import getInstrument [as 别名]
def test_minimal_inputs(self):
in_ws = Load('INTER00013460.nxs', OutputWorkspace="13460")
trans1 = Load('INTER00013463.nxs', OutputWorkspace="trans1")
inst = trans1.getInstrument()
out_ws, out_wsl_lam, thetafinal = ReflectometryReductionOneAuto(InputWorkspace=in_ws, AnalysisMode="PointDetectorAnalysis"
,OutputWorkspace="InQ", OutputWorkspaceWavelength="InLam")
history = out_ws.getHistory()
alg = history.lastAlgorithm()
'''
Here we are checking that the applied values (passed to CreateTransmissionWorkspace come from the instrument parameters.
'''
self.assertEqual(inst.getNumberParameter("LambdaMin")[0], alg.getProperty("WavelengthMin").value)
self.assertEqual(inst.getNumberParameter("LambdaMax")[0], alg.getProperty("WavelengthMax").value)
self.assertEqual(inst.getNumberParameter("MonitorBackgroundMin")[0], alg.getProperty("MonitorBackgroundWavelengthMin").value)
self.assertEqual(inst.getNumberParameter("MonitorBackgroundMax")[0], alg.getProperty("MonitorBackgroundWavelengthMax").value)
self.assertEqual(inst.getNumberParameter("MonitorIntegralMin")[0], alg.getProperty("MonitorIntegrationWavelengthMin").value)
self.assertEqual(inst.getNumberParameter("MonitorIntegralMax")[0], alg.getProperty("MonitorIntegrationWavelengthMax").value)
self.assertEqual(inst.getNumberParameter("I0MonitorIndex")[0], alg.getProperty("I0MonitorIndex").value)
self.assertEqual(inst.getNumberParameter("PointDetectorStart")[0], float(alg.getProperty("ProcessingInstructions").value.split(',')[0]))
self.assertEqual(inst.getNumberParameter("PointDetectorStop")[0], float(alg.getProperty("ProcessingInstructions").value.split(',')[1]))
DeleteWorkspace(in_ws)
DeleteWorkspace(trans1)
示例2: beam_center_gravitational_drop
# 需要导入模块: from mantid.simpleapi import Load [as 别名]
# 或者: from mantid.simpleapi.Load import getInstrument [as 别名]
def beam_center_gravitational_drop(beam_center_file, sdd=1.13):
'''
This method is used for correcting for gravitational drop
@param beam_center_file :: file where the beam center was found
@param sdd :: sample detector distance to apply the beam center
'''
def calculate_neutron_drop(path_length, wavelength):
'''
Calculate the gravitational drop of the neutrons
path_length in meters
wavelength in Angstrom
'''
wavelength *= 1e-10
neutron_mass = 1.674927211e-27
gravity = 9.80665
h_planck = 6.62606896e-34
l_2 = (gravity * neutron_mass**2 / (2.0 * h_planck**2 )) * path_length**2
return wavelength**2 * l_2
# Get beam center used in the previous reduction
pm = mantid.PropertyManagerDataService[ReductionSingleton().property_manager]
beam_center_x = pm['LatestBeamCenterX'].value
beam_center_y = pm['LatestBeamCenterY'].value
Logger("CommandInterface").information("Beam Center before: [%.2f, %.2f] pixels" % (beam_center_x, beam_center_y))
try:
# check if the workspace still exists
wsname = "__beam_finder_" + os.path.splitext(beam_center_file)[0]
ws = mantid.mtd[wsname]
Logger("CommandInterface").debug("Using Workspace: %s." % (wsname))
except KeyError:
# Let's try loading the file. For some reason the beamcenter ws is not there...
try:
ws = Load(beam_center_file)
Logger("CommandInterface").debug("Using filename %s." % (beam_center_file))
except IOError:
Logger("CommandInterface").error("Cannot read input file %s." % beam_center_file)
return
i = ws.getInstrument()
y_pixel_size_mm = i.getNumberParameter('y-pixel-size')[0]
Logger("CommandInterface").debug("Y Pixel size = %.2f mm" % y_pixel_size_mm)
y_pixel_size = y_pixel_size_mm * 1e-3 # In meters
distance_detector1 = i.getComponentByName("detector1").getPos()[2]
path_length = distance_detector1 - sdd
Logger("CommandInterface").debug("SDD detector1 = %.3f meters. SDD for wing = %.3f meters." % (distance_detector1, sdd))
Logger("CommandInterface").debug("Path length for gravitational drop = %.3f meters." % (path_length))
r = ws.run()
wavelength = r.getProperty("wavelength").value
Logger("CommandInterface").debug("Wavelength = %.2f A." % (wavelength))
drop = calculate_neutron_drop(path_length, wavelength)
Logger("CommandInterface").debug("Gravitational drop = %.6f meters." % (drop))
# 1 pixel -> y_pixel_size
# x pixel -> drop
drop_in_pixels = drop / y_pixel_size
new_beam_center_y = beam_center_y + drop_in_pixels
Logger("CommandInterface").information("Beam Center after: [%.2f, %.2f] pixels" % (beam_center_x, new_beam_center_y))
return beam_center_x, new_beam_center_y