當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。