本文整理汇总了Python中mantid.simpleapi.Load类的典型用法代码示例。如果您正苦于以下问题:Python Load类的具体用法?Python Load怎么用?Python Load使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Load类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_minimal_inputs
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)
开发者ID:AlistairMills,项目名称:mantid,代码行数:27,代码来源:ReflectometryReductionOneAutoTest.py
示例2: test_plus_operator_sums_multiple_set_files_to_give_group
def test_plus_operator_sums_multiple_set_files_to_give_group(self):
summed_data = Load("TSC15352+15353.raw,TSC15352+15354.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(summed_data, WorkspaceGroup))
self.assertEquals(2, summed_data.getNumberOfEntries())
# First group
data = summed_data[0]
self.assertEquals(149, data.getNumberHistograms())
self.assertEquals(24974, data.blocksize())
self.assertAlmostEqual(9.0, data.readX(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(46352.0, data.readY(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(215.29514625276622, data.readE(2)[1], places=DIFF_PLACES)
# Second group
data = summed_data[1]
self.assertEquals(149, data.getNumberHistograms())
self.assertEquals(24974, data.blocksize())
self.assertAlmostEqual(9.0, data.readX(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(35640.0, data.readY(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(188.78559267062727, data.readE(2)[1], places=DIFF_PLACES)
deleted_names = ["TSC15352", "TSC15353", "TSC15354"]
for name in deleted_names:
self.assertTrue(name not in AnalysisDataService)
开发者ID:mantidproject,项目名称:systemtests,代码行数:27,代码来源:LoadTest.py
示例3: beam_center_gravitational_drop
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,代码行数:59,代码来源:hfir_command_interface.py
示例4: do_reduction
def do_reduction(calibration):
# load data
data = Load("HRP39180.RAW")
# copy parameters from calibration to data
CopyInstrumentParameters(calibration, data)
# Now move component on data workspace using a relative move, where that component was a detector in the calibrated workspace
MoveInstrumentComponent(data, DetectorID=1100,X=0.0,Y=0.0,Z=5.0,RelativePosition=True)
return data.getDetector(0).getPos()
开发者ID:nimgould,项目名称:mantid,代码行数:8,代码来源:ReuseExistingCalibration.py
示例5: test_Load_call_with_args_that_do_not_apply_executes_correctly
def test_Load_call_with_args_that_do_not_apply_executes_correctly(self):
try:
raw = Load('IRS21360.raw', SpectrumMax=1, Append=True)
except RuntimeError:
self.fail(
"Load with a filename and extra args should not raise an exception"
)
self.assertEquals(1, raw.getNumberHistograms())
开发者ID:trnielsen,项目名称:mantid,代码行数:8,代码来源:SimpleAPILoadTest.py
示例6: test_extra_properties_passed_to_loader_for_multiple_files
def test_extra_properties_passed_to_loader_for_multiple_files(self):
data = Load("EQSANS_1466_event.nxs,EQSANS_3293_event.nxs", OutputWorkspace = self.wsname,
BankName = "bank1", SingleBankPixelsOnly = False)
self.assertTrue(isinstance(data, WorkspaceGroup))
self.assertEquals(2, data.getNumberOfEntries())
# Test number of events in each
self.assertEquals(740, data[0].getNumberEvents())
self.assertEquals(105666, data[1].getNumberEvents())
开发者ID:liyulun,项目名称:mantid,代码行数:9,代码来源:LoadTest.py
示例7: _create_experimental_data_workspace
def _create_experimental_data_workspace(self):
"""
Loads experimental data into workspaces.
:returns: workspace with experimental data
"""
experimental_wrk = Load(self._experimental_file)
self._set_workspace_units(wrk=experimental_wrk.name())
return experimental_wrk
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:Abins.py
示例8: PyExec
def PyExec(self):
filename = self.getProperty("Filename").value
from mantid.simpleapi import Load
# lifted from script
_tmp = Load(Filename=filename)
_tmp = _tmp.convertUnits(_tmp,Target="Energy")
self.setProperty("OutputWorkspace",_tmp)
_tmp.delete() # Remove temporary reference from MantidPlot view
开发者ID:OwenArnold,项目名称:documents,代码行数:10,代码来源:LoadInEnergy.py
示例9: test_stepped_range_operator_loads_correct_number_of_files
def test_stepped_range_operator_loads_correct_number_of_files(self):
data = Load("TSC15352:15354:2.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(data, WorkspaceGroup))
self.assertEquals(2, data.getNumberOfEntries())
self.assertTrue(isinstance(data[0], MatrixWorkspace))
self.assertTrue(isinstance(data[1], MatrixWorkspace))
# Cursory check that the correct ones were loaded
self.assertTrue("TO96_2" in data[0].getTitle())
self.assertTrue("TO96_4" in data[1].getTitle())
开发者ID:mantidproject,项目名称:systemtests,代码行数:12,代码来源:LoadTest.py
示例10: test_csv_list_with_same_instrument_produces_single_group
def test_csv_list_with_same_instrument_produces_single_group(self):
data = Load("OFFSPEC10791,10792,10793.raw", OutputWorkspace = self.wsname)
self.assertTrue(isinstance(data, WorkspaceGroup))
self.assertEquals(6, data.getNumberOfEntries())
ads_names = ["OFFSPEC00010791_1", "OFFSPEC00010791_2",
"OFFSPEC00010792_1", "OFFSPEC00010792_2",
"OFFSPEC00010793_1", "OFFSPEC00010793_2"]
for name in ads_names:
self.assertTrue(name in AnalysisDataService)
deleted_names = ["OFFSPEC10791", "OFFSPEC10792", "OFFSPEC10793"]
for name in deleted_names:
self.assertTrue(name not in AnalysisDataService)
self.cleanup_names = ads_names
开发者ID:liyulun,项目名称:mantid,代码行数:16,代码来源:LoadTest.py
示例11: test_csv_list_with_different_instrument_produces_single_group
def test_csv_list_with_different_instrument_produces_single_group(self):
# Combine test of different instruments with giving the output name
# the same name as one of the members of the group
self.wsname = "LOQ99631"
data = Load("LOQ99631.RAW, CSP85423.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(data, WorkspaceGroup))
self.assertEquals(3, data.getNumberOfEntries())
ads_names = ["LOQ99631", "CSP85423_1", "CSP85423_2"]
for name in ads_names:
self.assertTrue(name in AnalysisDataService)
deleted_names = ["CSP85423"]
for name in deleted_names:
self.assertTrue(name not in AnalysisDataService)
self.cleanup_names = ads_names
self.wsname = "__LoadTest"
开发者ID:mantidproject,项目名称:systemtests,代码行数:18,代码来源:LoadTest.py
示例12: _run_number_changed
def _run_number_changed(self):
""" Handling event if run number is changed... If it is a valid run number,
the load the meta data
"""
# 1. Form the file
newrunnumberstr = self._content.run_number_edit.text()
instrument = self._instrument_name
eventnxsname = "%s_%s_event.nxs" % (instrument, newrunnumberstr)
msg = str("Load event nexus file %s" % (eventnxsname))
self._content.info_text_browser.setText(msg)
# 2. Load file
metawsname = "%s_%s_meta" % (instrument, newrunnumberstr)
try:
metaws = Load(Filename=str(eventnxsname), OutputWorkspace=str(metawsname), MetaDataOnly=True)
except ValueError:
metaws = None
# 3. Update the log name combo box
if metaws is None:
self._content.info_text_browser.setText(
str("Error! Failed to load data file %s. Current working directory is %s. " % (eventnxsname, os.getcwd())))
else:
self._metaws = metaws
# a) Clear
self._content.log_name_combo.clear()
# b) Get properties
wsrun = metaws.getRun()
ps = wsrun.getProperties()
properties = []
for p in ps:
if p.__class__.__name__ == "FloatTimeSeriesProperty":
if p.size() > 1:
properties.append(p.name)
Logger('FilterSetupWidget').information('{}[{}]'.format(p.name, p.size()))
# ENDFOR p
properties = sorted(properties)
# c) Add
for p in properties:
self._content.log_name_combo.addItem(p)
开发者ID:mantidproject,项目名称:mantid,代码行数:44,代码来源:diffraction_filter_setup.py
示例13: test_plus_operator_for_input_groups
def test_plus_operator_for_input_groups(self):
summed_data = Load("OFFSPEC10791+10792.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(summed_data, WorkspaceGroup))
self.assertEquals(2, summed_data.getNumberOfEntries())
# First group
data = summed_data[0]
self.assertEquals(245, data.getNumberHistograms())
self.assertEquals(5000, data.blocksize())
self.assertAlmostEqual(25.0, data.readX(1)[1], places=DIFF_PLACES)
self.assertAlmostEqual(4.0, data.readY(1)[1], places=DIFF_PLACES)
self.assertAlmostEqual(2.0, data.readE(1)[1], places=DIFF_PLACES)
# Second group
data = summed_data[1]
self.assertEquals(245, data.getNumberHistograms())
self.assertEquals(5000, data.blocksize())
self.assertAlmostEqual(25.0, data.readX(1)[1], places=DIFF_PLACES)
self.assertAlmostEqual(1.0, data.readY(1)[1], places=DIFF_PLACES)
self.assertAlmostEqual(1.0, data.readE(1)[1], places=DIFF_PLACES)
开发者ID:mantidproject,项目名称:systemtests,代码行数:23,代码来源:LoadTest.py
示例14: test_sum_range_operator_with_step_sums_to_single_workspace
def test_sum_range_operator_with_step_sums_to_single_workspace(self):
data = Load("TSC15352-15354:2.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(data, MatrixWorkspace))
self.assertEquals(149, data.getNumberHistograms())
self.assertEquals(24974, data.blocksize())
self.assertAlmostEqual(9.0, data.readX(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(35640.0, data.readY(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(188.78559267062727, data.readE(2)[1], places=DIFF_PLACES)
开发者ID:mantidproject,项目名称:systemtests,代码行数:10,代码来源:LoadTest.py
示例15: test_sum_range_operator_sums_to_single_workspace
def test_sum_range_operator_sums_to_single_workspace(self):
data = Load("TSC15352-15353.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(data, MatrixWorkspace))
self.assertEquals(149, data.getNumberHistograms())
self.assertEquals(24974, data.blocksize())
self.assertAlmostEqual(9.0, data.readX(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(46352.0, data.readY(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(215.29514625276622, data.readE(2)[1], places=DIFF_PLACES)
开发者ID:mantidproject,项目名称:systemtests,代码行数:10,代码来源:LoadTest.py
示例16: runTest
def runTest(self):
self.input_ws = Load(Filename=self.input_ws_path(), OutputWorkspace="input_ws")
gsas_path = self.path_to_gsas()
if not gsas_path:
self.fail("Could not find GSAS-II installation")
self.fitted_peaks_ws, self.lattice_params_table, self.rwp, self.sigma, self.gamma = \
GSASIIRefineFitPeaks(RefinementMethod=self._get_refinement_method(),
InputWorkspace=self.input_ws,
PhaseInfoFiles=self.phase_file_paths(),
InstrumentFile=self.inst_param_file_path(),
PathToGSASII=gsas_path,
SaveGSASIIProjectFile=self._get_gsas_proj_filename(),
MuteGSASII=True,
XMin=10000, XMax=40000,
LatticeParameters=self._LATTICE_PARAM_TBL_NAME,
RefineSigma=True, RefineGamma=True)
开发者ID:DanNixon,项目名称:mantid,代码行数:18,代码来源:GSASIIRefineFitPeaksTest.py
示例17: test_plus_operator_sums_single_set_files
def test_plus_operator_sums_single_set_files(self):
data = Load("TSC15352+15353.raw", OutputWorkspace=self.wsname)
self.assertTrue(isinstance(data, MatrixWorkspace))
self.assertEquals(149, data.getNumberHistograms())
self.assertEquals(24974, data.blocksize())
self.assertAlmostEqual(9.0, data.readX(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(46352.0, data.readY(2)[1], places=DIFF_PLACES)
self.assertAlmostEqual(215.29514625276622, data.readE(2)[1], places=DIFF_PLACES)
deleted_names = ["TSC15352", "TSC15353"]
for name in deleted_names:
self.assertTrue(name not in AnalysisDataService)
开发者ID:mantidproject,项目名称:systemtests,代码行数:14,代码来源:LoadTest.py
示例18: TableWorkspaceDisplayDecoderTest
class TableWorkspaceDisplayDecoderTest(GuiTest):
def setUp(self):
self.ws = Load("SavedTableWorkspace.nxs", OutputWorkspace="ws")
self.decoder = TableWorkspaceDisplayDecoder()
def test_decoder_returns_view(self):
self.assertEqual(self.decoder.decode(TABLEWORKSPACEDISPLAY_DICT).__class__, StatusBarView)
def test_decoder_returns_custom_features(self):
view = self.decoder.decode(TABLEWORKSPACEDISPLAY_DICT)
self.assertEqual(self.ws.name(), view.presenter.model.ws.name())
self.assertEqual(TABLEWORKSPACEDISPLAY_DICT["markedColumns"]["as_y"], view.presenter.model.marked_columns.as_y)
self.assertEqual(TABLEWORKSPACEDISPLAY_DICT["markedColumns"]["as_x"], view.presenter.model.marked_columns.as_x)
self.assertEqual(
TABLEWORKSPACEDISPLAY_DICT["markedColumns"]["as_y_err"][0]["column"],
view.presenter.model.marked_columns.as_y_err[0].column)
self.assertEqual(
TABLEWORKSPACEDISPLAY_DICT["markedColumns"]["as_y_err"][0]["relatedY"],
view.presenter.model.marked_columns.as_y_err[0].related_y_column)
self.assertEqual(
TABLEWORKSPACEDISPLAY_DICT["markedColumns"]["as_y_err"][0]["labelIndex"],
view.presenter.model.marked_columns.as_y_err[0].label_index)
self.assertEqual(1, len(view.presenter.model.marked_columns.as_y_err))
开发者ID:mantidproject,项目名称:mantid,代码行数:23,代码来源:test_tableworkspacedisplay_io.py
示例19: PyExec
def PyExec(self):
from mantid.simpleapi import Load, ConvertUnits, Rebin, DeleteWorkspace
# Load file to workspace
_tmpws = Load(Filename=self.getPropertyValue("Filename"))
# Convert to units to DeltaE
ei = self.getProperty("Ei").value
_tmpws = ConvertUnits(InputWorkspace=_tmpws, Target="DeltaE", EMode="Direct", EFixed=ei)
# Rebin to requested units
bins = self.getProperty("BinParams").value
_tmpws = Rebin(InputWorkspace=_tmpws, Params=bins)
# Create the new output workspace
_summed = WorkspaceFactory.create(_tmpws, NVectors=1)
# Set the X values for the new workspace
_summed.setX(0, _tmpws.readX(0))
# Sum the rows to a single row. Two methods demonstrated:
# ----- 1: Direct workspace access -----
# Uses less memory as it avoids a copy of the data
# readY returns read only array. dataY returns an array we can modify on the new workspace
# note _summed at this point has all its y-values = 0
sumy = _summed.dataY(0) # initialise sumy with zeros
for i in range(_tmpws.getNumberHistograms()):
sumy += _tmpws.readY(i)
# ----- 2: Extract to numpy and sum ----
# Uses more memory as extract copies to data (uncomment to see working)
# yin = __tmpsws.extractY()
# npsum = numpy.sum(yin,axis=0) # Axis 0 = summing down the columns
# and put the data to the workspace
# _summed.setY(0, npsum)
# Store reference outside of algorithm
self.setProperty("OutputWorkspace", _summed)
DeleteWorkspace(_tmpws)
开发者ID:OwenArnold,项目名称:documents,代码行数:41,代码来源:Exercise4_MoreAlgorithms.py
示例20: test_Load_call_with_other_args_executes_correctly
def test_Load_call_with_other_args_executes_correctly(self):
try:
raw = Load("IRS21360.raw", SpectrumMax=1)
except RuntimeError:
self.fail("Load with a filename and extra args should not raise an exception")
self.assertEquals(1, raw.getNumberHistograms())
开发者ID:trnielsen,项目名称:mantid,代码行数:6,代码来源:SimpleAPILoadTest.py
注:本文中的mantid.simpleapi.Load类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论