本文整理汇总了Python中mantid.api.FileFinder.getFullPath方法的典型用法代码示例。如果您正苦于以下问题:Python FileFinder.getFullPath方法的具体用法?Python FileFinder.getFullPath怎么用?Python FileFinder.getFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.api.FileFinder
的用法示例。
在下文中一共展示了FileFinder.getFullPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def _run(self):
'''Defines the workflow for the test'''
self.tolerance = 1e-3
self.samples = [sample[:-4] for sample in self.samples]
# Load files into Mantid
for sample in self.samples:
LoadNexus(sample, OutputWorkspace=sample)
LoadNexus(FileFinder.getFullPath(self.resolution), OutputWorkspace=self.resolution)
_, iqt_ws = TransformToIqt(SampleWorkspace=self.samples[0],
ResolutionWorkspace=self.resolution,
EnergyMin=self.e_min,
EnergyMax=self.e_max,
BinReductionFactor=self.num_bins,
DryRun=False,
NumberOfIterations=200)
# Test IqtFit Sequential
iqtfitSeq_ws, params, fit_group = IqtFitSequential(InputWorkspace=iqt_ws, Function=self.func,
StartX=self.startx, EndX=self.endx,
SpecMin=0, SpecMax=self.spec_max)
self.result_names = [iqt_ws.name(),
iqtfitSeq_ws[0].name()]
# Remove workspaces from Mantid
for sample in self.samples:
DeleteWorkspace(sample)
DeleteWorkspace(params)
DeleteWorkspace(fit_group)
DeleteWorkspace(self.resolution)
示例2: _create_peaks_workspace
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def _create_peaks_workspace(self):
"""Create a dummy peaks workspace"""
path = FileFinder.getFullPath("IDFs_for_UNIT_TESTING/MINITOPAZ_Definition.xml")
inst = LoadEmptyInstrument(Filename=path)
ws = CreatePeaksWorkspace(inst, 0)
DeleteWorkspace(inst)
SetUB(ws, 1, 1, 1, 90, 90, 90)
# Add a bunch of random peaks that happen to fall on the
# detetor bank defined in the IDF
center_q = np.array([-5.1302,2.5651,3.71809])
qs = []
for i in np.arange(0, 1, 0.1):
for j in np.arange(-0.5, 0, 0.1):
q = center_q.copy()
q[1] += j
q[2] += i
qs.append(q)
# Add the peaks to the PeaksWorkspace with dummy values for intensity,
# Sigma, and HKL
for q in qs:
peak = ws.createPeak(q)
peak.setIntensity(100)
peak.setSigmaIntensity(10)
peak.setHKL(1, 1, 1)
ws.addPeak(peak)
return ws
示例3: cleanup
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def cleanup(self):
Files = ["TOPAZ_3132.hkl",
"TOPAZ_3132FFT.hkl"]
for file in Files:
absfile = FileFinder.getFullPath(file)
if os.path.exists(absfile):
os.remove(absfile)
return True
示例4: find_data
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def find_data(file, instrument='', allow_multiple=False):
"""
Finds a file path for the specified data set, which can either be:
- a run number
- an absolute path
- a file name
@param file: file name or part of a file name
@param instrument: if supplied, FindNeXus will be tried as a last resort
"""
# First, assume a file name
file = str(file).strip()
# If we allow multiple files, users may use ; as a separator,
# which is incompatible with the FileFinder
n_files = 1
if allow_multiple:
file=file.replace(';',',')
toks = file.split(',')
n_files = len(toks)
instrument = str(instrument)
file_path = FileFinder.getFullPath(file)
if os.path.isfile(file_path):
return file_path
# Second, assume a run number and pass the instrument name as a hint
try:
# FileFinder doesn't like dashes...
instrument=instrument.replace('-','')
f = FileFinder.findRuns(instrument+file)
if os.path.isfile(f[0]):
if allow_multiple:
# Mantid returns its own list object type, so make a real list out if it
if len(f)==n_files:
return [i for i in f]
else:
return f[0]
except:
# FileFinder couldn't make sense of the the supplied information
pass
# Third, assume a run number, without instrument name to take care of list of full paths
try:
f = FileFinder.findRuns(file)
if os.path.isfile(f[0]):
if allow_multiple:
# Mantid returns its own list object type, so make a real list out if it
if len(f)==n_files:
return [i for i in f]
else:
return f[0]
except:
# FileFinder couldn't make sense of the the supplied information
pass
# If we didn't find anything, raise an exception
Logger('find_data').error("\n\nCould not find a file for %s: check your reduction parameters\n\n" % str(file))
raise RuntimeError("Could not find a file for %s" % str(file))
示例5: do_cleanup
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def do_cleanup():
Files = ["PG3_9829.gsa",
"PG3_9829.py",
"PG3_9830.gsa",
"PG3_9830.py"]
for file in Files:
absfile = FileFinder.getFullPath(file)
if os.path.exists(absfile):
os.remove(absfile)
return True
示例6: do_cleanup
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def do_cleanup():
Files = ["BioSANS_test_data_reduction.log",
"BioSANS_test_data_Iq.xml",
"BioSANS_test_data_Iq.txt",
"BioSANS_test_data_Iqxy.dat"]
for filename in Files:
absfile = FileFinder.getFullPath(filename)
if os.path.exists(absfile):
os.remove(absfile)
return True
示例7: runTest
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def runTest(self):
UseCompatibilityMode()
SANS2D()
Set1D()
Detector("rear-detector")
MaskFile('MASKSANS2Doptions.091A')
Gravity(True)
csv_file = FileFinder.getFullPath('SANS2D_periodTests.csv')
BatchReduce(csv_file, 'nxs', plotresults=False, saveAlgs={'SaveCanSAS1D': 'xml', 'SaveNexus': 'nxs'})
os.remove(os.path.join(config['defaultsave.directory'], '5512p7_SANS2DBatch.xml'))
示例8: runTest
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def runTest(self):
UseCompatibilityMode()
SANS2D()
Set1D()
Detector("rear-detector")
MaskFile('MASKSANS2Doptions.091A')
Gravity(True)
csv_file = FileFinder.getFullPath('SANS2D_multiPeriodTests.csv')
BatchReduce(csv_file, 'nxs', saveAlgs={})
self.reduced = '5512_SANS2DBatch'
示例9: __init__
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def __init__(self):
ISISIndirectInelasticConvFit.__init__(self)
self.sample = 'osi97935_graphite002_red.nxs'
self.resolution = FileFinder.getFullPath('osi97935_graphite002_res.nxs')
#ConvFit fit function
self.func = 'name=LinearBackground,A0=0,A1=0;(composite=Convolution,FixResolution=true,NumDeriv=true;'\
'name=Resolution,Workspace=\"%s\";name=Lorentzian,Amplitude=2,PeakCentre=0,FWHM=0.05)' % self.resolution
self.startx = -0.2
self.endx = 0.2
self.bg = 'Fit Linear'
self.spectra_min = 0
self.spectra_max = 41
self.ties = False
self.result_names = ['osi97935_graphite002_conv_1LFitL_s0_to_41_Result']
示例10: __verifyRequiredFile
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def __verifyRequiredFile(self, filename):
'''Return True if the specified file name is findable by Mantid.'''
from mantid.api import FileFinder
# simple way is just getFullPath which never uses archive search
if os.path.exists(FileFinder.getFullPath(filename)):
return True
# try full findRuns which will use archive search if it is turned on
try:
candidates = FileFinder.findRuns(filename)
for item in candidates:
if os.path.exists(item):
return True
except RuntimeError, e:
return False
示例11: do_cleanup
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def do_cleanup():
Files = ["PG3_9829.getn",
"PG3_9829.gsa",
"PG3_9829.py",
'sum_PG3_9829.gsa',
'sum_PG3_9829.py',
"PG3_9830.gsa",
"PG3_9830.py",
"PG3_4844-1.dat",
"PG3_4844.getn",
"PG3_4844.gsa",
"PG3_4844.py",
"PG3_4866.gsa"]
for filename in Files:
absfile = FileFinder.getFullPath(filename)
if os.path.exists(absfile):
os.remove(absfile)
return True
示例12: runTest
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def runTest(self):
UseCompatibilityMode()
LOQ()
Detector("main-detector-bank")
csv_file = FileFinder.getFullPath('batch_input.csv')
Set1D()
MaskFile('MASK.094AA')
Gravity(True)
BatchReduce(csv_file, 'raw', plotresults=False, saveAlgs={'SaveCanSAS1D': 'xml', 'SaveNexus': 'nxs'})
LoadNexus(Filename='54433sans.nxs', OutputWorkspace='result')
Plus(LHSWorkspace='result', RHSWorkspace='99630sanotrans', OutputWorkspace= 'result')
os.remove(os.path.join(config['defaultsave.directory'],'54433sans.nxs'))
os.remove(os.path.join(config['defaultsave.directory'],'99630sanotrans.nxs'))
os.remove(os.path.join(config['defaultsave.directory'],'54433sans.xml'))
os.remove(os.path.join(config['defaultsave.directory'],'99630sanotrans.xml'))
示例13: import
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
#pylint: disable=invalid-name,attribute-defined-outside-init
"""
The tests here are ports from the original SANS2DReductionGUI.py test suite. Not all tests can be ported since they
include details about the ReductionSingleton
"""
from __future__ import (absolute_import, division, print_function)
import systemtesting
from mantid.kernel import (config)
from mantid.api import (FileFinder)
from mantid.simpleapi import RenameWorkspace
from sans.command_interface.ISISCommandInterface import (BatchReduce, SANS2D, MaskFile, AssignSample, AssignCan,
TransmissionSample, TransmissionCan, WavRangeReduction,
UseCompatibilityMode, FindBeamCentre)
MASKFILE = FileFinder.getFullPath('MaskSANS2DReductionGUI.txt')
BATCHFILE = FileFinder.getFullPath('sans2d_reduction_gui_batch.csv')
class SANS2DMinimalBatchReductionTest_V2(systemtesting.MantidSystemTest):
"""Minimal script to perform full reduction in batch mode
"""
def __init__(self):
super(SANS2DMinimalBatchReductionTest_V2, self).__init__()
config['default.instrument'] = 'SANS2D'
self.tolerance_is_rel_err = True
self.tolerance = 1.0e-2
def runTest(self):
UseCompatibilityMode()
SANS2D()
示例14: ISISPowderDiffraction
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
# pylint: disable=no-init
from mantid.api import FileFinder
from mantid.simpleapi import *
from mantid import config
import os.path
import stresstesting
import sys
F_DIR = FileFinder.getFullPath("PowderISIS")
sys.path.append(F_DIR)
import cry_ini
import cry_focus
class ISISPowderDiffraction(stresstesting.MantidStressTest):
def requiredFiles(self):
return set(["hrp39191.raw", "hrp39187.raw", "hrp43022.raw", "hrpd/test/GrpOff/hrpd_new_072_01.cal",
"hrpd/test/GrpOff/hrpd_new_072_01_corr.cal", "hrpd/test/cycle_09_2/Calibration/van_s1_old-0.nxs",
"hrpd/test/cycle_09_2/Calibration/van_s1_old-1.nxs",
"hrpd/test/cycle_09_2/Calibration/van_s1_old-2.nxs", "hrpd/test/cycle_09_2/tester/mtd.pref"])
def _clean_up_files(self, filenames, directories):
try:
for file in filenames:
path = os.path.join(directories[0], file)
os.remove(path)
except OSError, ose:
print 'could not delete generated file : ', ose.filename
def runTest(self):
dirs = config['datasearch.directories'].split(';')
示例15: setUp
# 需要导入模块: from mantid.api import FileFinder [as 别名]
# 或者: from mantid.api.FileFinder import getFullPath [as 别名]
def setUp(self):
self._function = 'Voigt'
self._parameter_file = FileFinder.getFullPath("IP0005.par")
self._calibrated_params = self.load_ip_file()
self._mode = 'FoilOut'
self._energy_estimates = np.array([ENERGY_ESTIMATE])