当前位置: 首页>>代码示例>>Python>>正文


Python Load.run方法代码示例

本文整理汇总了Python中mantid.simpleapi.Load.run方法的典型用法代码示例。如果您正苦于以下问题:Python Load.run方法的具体用法?Python Load.run怎么用?Python Load.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.simpleapi.Load的用法示例。


在下文中一共展示了Load.run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: beam_center_gravitational_drop

# 需要导入模块: from mantid.simpleapi import Load [as 别名]
# 或者: from mantid.simpleapi.Load import run [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
开发者ID:mantidproject,项目名称:mantid,代码行数:61,代码来源:hfir_command_interface.py

示例2: range

# 需要导入模块: from mantid.simpleapi import Load [as 别名]
# 或者: from mantid.simpleapi.Load import run [as 别名]
    if ts < running_times[0] or ts > running_times[-1]:
        return False
    running = True
    for i in range(len(running_times) - 1):
        print "ts={}, rt(i)={}, rt(i+1)={}".format(ts,  running_times[i], running_times[i+1])
        if (ts >= running_times[i]) and (ts < running_times[i+1]):
            running = running_values[i]
            print "found ",i, running
            break
    return running

# ----------------------------------------------------------------------------------------------------------------------


w = Load('/mnt/data1/source/github/mantidproject/mantid/builds/debug/ExternalData/Testing/Data/SystemTest/LARMOR/LARMOR00000063.nxs')
r = w.run()
run_start = dt.datetime.strptime(str(r.startTime()).strip(), ISO_TIMESTAMP_FORMAT)

dae_beam_current = r.getLogData('dae_beam_current')
# running log is series of boolean values indicating run status
running_log = w.run().getLogData('running')
running_times = []
for t in running_log.times:
    running_times.append(to_datetime_iso(t))

# create times as offset from run_start
uamps_times, uamps_values = dae_beam_current.times, dae_beam_current.value
delta_t, uamps_datetime = [], []
for t in uamps_times:
    t1, t2 = run_start, to_datetime_iso(t)
    uamps_datetime.append(t2)
开发者ID:martyngigg,项目名称:plotting-evaluation,代码行数:33,代码来源:sample_log_plots.py


注:本文中的mantid.simpleapi.Load.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。