本文整理汇总了Python中mantid.logger.information函数的典型用法代码示例。如果您正苦于以下问题:Python information函数的具体用法?Python information怎么用?Python information使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了information函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _calculate_energy
def _calculate_energy(self, monitor_ws, grouped_ws, red_ws):
"""
Convert the input run to energy transfer
@param monitor_ws :: name of the monitor workspace to divide by
@param grouped_ws :: name of workspace with the detectors grouped
@param red_ws :: name to call the reduced workspace
"""
x_range = self._monitor_range(monitor_ws)
Scale(InputWorkspace=monitor_ws, OutputWorkspace=monitor_ws, Factor=0.001, Operation='Multiply')
CropWorkspace(InputWorkspace=monitor_ws, OutputWorkspace=monitor_ws, Xmin=x_range[0], XMax=x_range[1])
ScaleX(InputWorkspace=monitor_ws, OutputWorkspace=monitor_ws, Factor=-x_range[0], Operation='Add')
CropWorkspace(InputWorkspace=grouped_ws, OutputWorkspace=grouped_ws, Xmin=x_range[0], XMax=x_range[1])
ScaleX(InputWorkspace=grouped_ws, OutputWorkspace=grouped_ws, Factor=-x_range[0], Operation='Add')
Divide(LHSWorkspace=grouped_ws, RHSWorkspace=monitor_ws, OutputWorkspace=grouped_ws)
formula = self._energy_range(grouped_ws)
ConvertAxisByFormula(InputWorkspace=grouped_ws, OutputWorkspace=red_ws, Axis='X', Formula=formula,
AxisTitle='Energy transfer', AxisUnits='meV')
xnew = mtd[red_ws].readX(0) # energy array
logger.information('Energy range : %f to %f' % (xnew[0], xnew[-1]))
DeleteWorkspace(grouped_ws)
DeleteWorkspace(monitor_ws)
示例2: _get_spectra_index
def _get_spectra_index(self, input_ws):
"""
Gets the index of the two monitors and first detector for the current instrument configurtion.
Assumes monitors are named monitor1 and monitor2
"""
instrument = mtd[input_ws].getInstrument()
try:
analyser = instrument.getStringParameter('analyser')[0]
detector_1_idx = instrument.getComponentByName(analyser)[0].getID() - 1
logger.information('Got index of first detector for analyser %s: %d' % (analyser, detector_1_idx))
except IndexError:
detector_1_idx = 2
logger.warning('Could not determine index of first detetcor, using default value.')
try:
monitor_1_idx = self._get_detector_spectrum_index(input_ws, instrument.getComponentByName('monitor1').getID())
monitor_2 = instrument.getComponentByName('monitor2')
if monitor_2 is not None:
monitor_2_idx = self._get_detector_spectrum_index(input_ws, monitor_2.getID())
else:
monitor_2_idx = None
logger.information('Got index of monitors: %d, %s' % (monitor_1_idx, str(monitor_2_idx)))
except IndexError:
monitor_1_idx = 0
monitor_2_idx = 1
logger.warning('Could not determine index of monitors, using default values.')
return monitor_1_idx, monitor_2_idx, detector_1_idx
示例3: PyExec
def PyExec(self):
self._setup()
ws_basename = str(self._sample_ws_in)
self._trans_mon(ws_basename, 'Sam', self._sample_ws_in)
self._trans_mon(ws_basename, 'Can', self._can_ws_in)
# Generate workspace names
sam_ws = ws_basename + '_Sam'
can_ws = ws_basename + '_Can'
trans_ws = ws_basename + '_Trans'
# Divide sample and can workspaces
Divide(LHSWorkspace=sam_ws, RHSWorkspace=can_ws, OutputWorkspace=trans_ws)
trans = numpy.average(mtd[trans_ws].readY(0))
logger.information('Average Transmission: ' + str(trans))
AddSampleLog(Workspace=trans_ws, LogName='can_workspace', LogType='String', LogText=self._can_ws_in)
# Group workspaces
group = sam_ws + ',' + can_ws + ',' + trans_ws
GroupWorkspaces(InputWorkspaces=group, OutputWorkspace=self._out_ws)
self.setProperty('OutputWorkspace', self._out_ws)
示例4: ReadWidthFile
def ReadWidthFile(readWidth,widthFile,numSampleGroups):
widthY = []
widthE = []
if readWidth:
logger.information('Width file is ' + widthFile)
# read ascii based width file
try:
wfPath = FileFinder.getFullPath(widthFile)
handle = open(wfPath, 'r')
asc = []
for line in handle:
line = line.rstrip()
asc.append(line)
handle.close()
except Exception, e:
raise ValueError('Failed to read width file')
numLines = len(asc)
if numLines == 0:
raise ValueError('No groups in width file')
if numLines != numSampleGroups: # check that no. groups are the same
error = 'Width groups (' +str(numLines) + ') not = Sample (' +str(numSampleGroups) +')'
raise ValueError(error)
示例5: load_files
def load_files(data_files, ipf_filename, spec_min, spec_max, sum_files=False, load_logs=True, load_opts=None):
"""
Loads a set of files and extracts just the spectra we care about (i.e. detector range and monitor).
@param data_files List of data file names
@param ipf_filename File path/name for the instrument parameter file to load
@param spec_min Minimum spectra ID to load
@param spec_max Maximum spectra ID to load
@param sum_files Sum loaded files
@param load_logs Load log files when loading runs
@param load_opts Additional options to be passed to load algorithm
@return List of loaded workspace names and flag indicating chopped data
"""
workspace_names, chopped_data = _load_files(data_files, ipf_filename, spec_min, spec_max, load_logs, load_opts)
# Sum files if needed
if sum_files and len(data_files) > 1:
if chopped_data:
workspace_names = sum_chopped_runs(workspace_names)
else:
workspace_names = sum_regular_runs(workspace_names)
logger.information('Summed workspace names: %s' % (str(workspace_names)))
return workspace_names, chopped_data
示例6: _generate_UBList
def _generate_UBList(self):
CreateSingleValuedWorkspace(OutputWorkspace='__ub')
LoadIsawUB('__ub',self.getProperty("UBMatrix").value)
ub=mtd['__ub'].sample().getOrientedLattice().getUB().copy()
DeleteWorkspace(Workspace='__ub')
symOps = self.getProperty("SymmetryOps").value
if symOps:
try:
symOps = SpaceGroupFactory.subscribedSpaceGroupSymbols(int(symOps))[0]
except ValueError:
pass
if SpaceGroupFactory.isSubscribedSymbol(symOps):
symOps = SpaceGroupFactory.createSpaceGroup(symOps).getSymmetryOperations()
else:
symOps = SymmetryOperationFactory.createSymOps(symOps)
logger.information('Using symmetries: '+str([sym.getIdentifier() for sym in symOps]))
ub_list=[]
for sym in symOps:
UBtrans = np.zeros((3,3))
UBtrans[0] = sym.transformHKL([1,0,0])
UBtrans[1] = sym.transformHKL([0,1,0])
UBtrans[2] = sym.transformHKL([0,0,1])
UBtrans=np.matrix(UBtrans.T)
ub_list.append(ub*UBtrans)
return ub_list
else:
return [ub]
示例7: ReadIbackGroup
def ReadIbackGroup(a,first): #read Ascii block of spectrum values
x = []
y = []
e = []
next = first
line1 = a[next]
next += 1
val = ExtractInt(a[next])
n1 = val[0]
ngrp = val[2]
if line1.startswith('S'):
error = ''
else:
error = 'NOT an S block starting at line ' +str(first)
logger.information('ERROR *** ' + error)
sys.exit(error)
next += 1
next,Ival = Iblock(a,next)
for m in range(0, len(Ival)):
x.append(float(m))
yy = float(Ival[m])
y.append(yy)
ee = math.sqrt(yy)
e.append(ee)
return next,x,y,e #values of x,y,e as lists
示例8: _read_width_file
def _read_width_file(self, readWidth, widthFile, numSampleGroups):
widthY, widthE = [], []
if readWidth:
logger.information('Width file is ' + widthFile)
# read ascii based width file
try:
wfPath = s_api.FileFinder.getFullPath(widthFile)
handle = open(wfPath, 'r')
asc = []
for line in handle:
line = line.rstrip()
asc.append(line)
handle.close()
except Exception:
raise ValueError('Failed to read width file')
numLines = len(asc)
if numLines == 0:
raise ValueError('No groups in width file')
if numLines != numSampleGroups: # check that no. groups are the same
raise ValueError('Width groups (' + str(numLines) + ') not = Sample (' + str(numSampleGroups) + ')')
else:
# no file: just use constant values
widthY = np.zeros(numSampleGroups)
widthE = np.zeros(numSampleGroups)
# pad for Fortran call
widthY = PadArray(widthY, 51)
widthE = PadArray(widthE, 51)
return widthY, widthE
示例9: process_monitor_efficiency
def process_monitor_efficiency(workspace_name):
"""
Process monitor efficiency for a given workspace.
@param workspace_name Name of workspace to process monitor for
"""
from mantid.simpleapi import OneMinusExponentialCor
monitor_workspace_name = workspace_name + '_mon'
instrument = mtd[workspace_name].getInstrument()
try:
area = instrument.getNumberParameter('Workflow.Monitor1-Area')[0]
thickness = instrument.getNumberParameter('Workflow.Monitor1-Thickness')[0]
attenuation = instrument.getNumberParameter('Workflow.Monitor1-Attenuation')[0]
except IndexError:
raise ValueError('Cannot get monitor details form parameter file')
if area == -1 or thickness == -1 or attenuation == -1:
logger.information('For workspace %s, skipping monitor efficiency' % workspace_name)
return
OneMinusExponentialCor(InputWorkspace=monitor_workspace_name,
OutputWorkspace=monitor_workspace_name,
C=attenuation * thickness,
C1=area)
示例10: Iblock
def Iblock(a,first): #read Ascii block of Integers
line1 = a[first]
line2 = a[first+1]
val = ExtractInt(line2)
numb = val[0]
lines=numb/10
last = numb-10*lines
if line1.startswith('I'):
error = ''
else:
error = 'NOT an I block starting at line ' +str(first)
logger.information('ERROR *** ' + error)
sys.exit(error)
ival = []
for m in range(0, lines):
mm = first+2+m
val = ExtractInt(a[mm])
for n in range(0, 10):
ival.append(val[n])
mm += 1
val = ExtractInt(a[mm])
for n in range(0, last):
ival.append(val[n])
mm += 1
return mm,ival #values as list
示例11: CheckAnalysers
def CheckAnalysers(in1WS,in2WS):
'''Check workspaces have identical analysers and reflections
Args:
@param in1WS - first 2D workspace
@param in2WS - second 2D workspace
Returns:
@return None
Raises:
@exception Valuerror - workspaces have different analysers
@exception Valuerror - workspaces have different reflections
'''
ws1 = mtd[in1WS]
a1 = ws1.getInstrument().getStringParameter('analyser')[0]
r1 = ws1.getInstrument().getStringParameter('reflection')[0]
ws2 = mtd[in2WS]
a2 = ws2.getInstrument().getStringParameter('analyser')[0]
r2 = ws2.getInstrument().getStringParameter('reflection')[0]
if a1 != a2:
raise ValueError('Workspace '+in1WS+' and '+in2WS+' have different analysers')
elif r1 != r2:
raise ValueError('Workspace '+in1WS+' and '+in2WS+' have different reflections')
else:
logger.information('Analyser is '+a1+r1)
示例12: chop_workspace
def chop_workspace(workspace, monitor_index):
"""
Chops the specified workspace if its maximum x-value exceeds its instrument
parameter, 'Workflow.ChopDataIfGreaterThan'.
:param workspace: The workspace to chop
:param monitor_index: The index of the monitor spectra in the workspace.
:return: A tuple of the list of output workspace names and a boolean
specifying whether the workspace was chopped.
"""
from mantid.simpleapi import ChopData
workspace_name = workspace.getName()
# Chop data if required
try:
chop_threshold = workspace.getInstrument().getNumberParameter('Workflow.ChopDataIfGreaterThan')[0]
x_max = workspace.readX(0)[-1]
chopped_data = x_max > chop_threshold
except IndexError:
logger.warning("Chop threshold not found in instrument parameters")
chopped_data = False
logger.information('Workspace {0} need data chop: {1}'.format(workspace_name, str(chopped_data)))
if chopped_data:
ChopData(InputWorkspace=workspace,
OutputWorkspace=workspace_name,
MonitorWorkspaceIndex=monitor_index,
IntegrationRangeLower=5000.0,
IntegrationRangeUpper=10000.0,
NChops=5)
return mtd[workspace_name].getNames(), True
else:
return [workspace_name], False
示例13: Fblock
def Fblock(a,first): #read Ascii block of Floats
line1 = a[first]
line2 = a[first+1]
val = ExtractInt(line2)
numb = val[0]
lines=numb/5
last = numb-5*lines
if line1.startswith('F'):
error= ''
else:
error = 'NOT an F block starting at line ' +str(first)
logger.information('ERROR *** ' + error)
sys.exit(error)
fval = []
for m in range(0, lines):
mm = first+2+m
val = ExtractFloat(a[mm])
for n in range(0, 5):
fval.append(val[n])
mm += 1
val = ExtractFloat(a[mm])
for n in range(0, last):
fval.append(val[n])
mm += 1
return mm,fval #values as list
示例14: identify_bad_detectors
def identify_bad_detectors(workspace_name):
"""
Identify detectors which should be masked
@param workspace_name Name of workspace to use to get masking detectors
@return List of masked spectra
"""
from mantid.simpleapi import (IdentifyNoisyDetectors, DeleteWorkspace)
instrument = mtd[workspace_name].getInstrument()
try:
masking_type = instrument.getStringParameter('Workflow.Masking')[0]
except IndexError:
masking_type = 'None'
logger.information('Masking type: %s' % masking_type)
masked_spec = list()
if masking_type == 'IdentifyNoisyDetectors':
ws_mask = '__workspace_mask'
IdentifyNoisyDetectors(InputWorkspace=workspace_name,
OutputWorkspace=ws_mask)
# Convert workspace to a list of spectra
num_spec = mtd[ws_mask].getNumberHistograms()
masked_spec = [spec for spec in range(0, num_spec) if mtd[ws_mask].readY(spec)[0] == 0.0]
# Remove the temporary masking workspace
DeleteWorkspace(ws_mask)
logger.debug('Masked spectra for workspace %s: %s' % (workspace_name, str(masked_spec)))
return masked_spec
示例15: CheckAnalysers
def CheckAnalysers(in1WS, in2WS):
"""
Check workspaces have identical analysers and reflections
Args:
@param in1WS - first 2D workspace
@param in2WS - second 2D workspace
Returns:
@return None
Raises:
@exception Valuerror - workspaces have different analysers
@exception Valuerror - workspaces have different reflections
"""
ws1 = s_api.mtd[in1WS]
try:
analyser_1 = ws1.getInstrument().getStringParameter('analyser')[0]
reflection_1 = ws1.getInstrument().getStringParameter('reflection')[0]
except IndexError:
raise RuntimeError('Could not find analyser or reflection for workspace %s' % in1WS)
ws2 = s_api.mtd[in2WS]
try:
analyser_2 = ws2.getInstrument().getStringParameter('analyser')[0]
reflection_2 = ws2.getInstrument().getStringParameter('reflection')[0]
except:
raise RuntimeError('Could not find analyser or reflection for workspace %s' % in2WS)
if analyser_1 != analyser_2:
raise ValueError('Workspace %s and %s have different analysers' % (ws1, ws2))
elif reflection_1 != reflection_2:
raise ValueError('Workspace %s and %s have different reflections' % (ws1, ws2))
else:
logger.information('Analyser is %s, reflection %s' % (analyser_1, reflection_1))