本文整理汇总了Python中sans.common.general_functions.create_child_algorithm函数的典型用法代码示例。如果您正苦于以下问题:Python create_child_algorithm函数的具体用法?Python create_child_algorithm怎么用?Python create_child_algorithm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_child_algorithm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _perform_initial_move
def _perform_initial_move(self, workspaces, state):
move_name = "SANSMove"
state_dict = state.property_manager
zero_options = {"SANSState": state_dict,
"MoveType": "SetToZero",
"Component": ""}
zero_alg = create_child_algorithm(self, move_name, **zero_options)
move_options = {"SANSState": state_dict,
"MoveType": "InitialMove"}
move_alg = create_child_algorithm(self, move_name, **move_options)
# The workspaces are stored in a dict: workspace_names (sample_scatter, etc) : ListOfWorkspaces
for key, workspace_list in workspaces.items():
if SANSDataType.to_string(key) in ("SampleTransmission", "CanTransmission", "CanDirect", "SampleDirect"):
is_trans = True
else:
is_trans = False
move_alg.setProperty("IsTransmissionWorkspace", is_trans)
for workspace in workspace_list:
zero_alg.setProperty("Workspace", workspace)
zero_alg.execute()
zeroed_workspace = zero_alg.getProperty("Workspace").value
# If beam centre was specified then use it
beam_coordinates = self.getProperty("BeamCoordinates").value
if beam_coordinates:
move_alg.setProperty("BeamCoordinates", beam_coordinates)
# ZOOM and LARMOR only have LAB, SANS2D and LOQ move both at once.
move_alg.setProperty("Component", "LAB")
move_alg.setProperty("Workspace", zeroed_workspace)
move_alg.execute()
示例2: _adjustment
def _adjustment(self, state_serialized, workspace, monitor_workspace, component_as_string, data_type):
transmission_workspace = self._get_transmission_workspace()
direct_workspace = self._get_direct_workspace()
adjustment_name = "SANSCreateAdjustmentWorkspaces"
adjustment_options = {"SANSState": state_serialized,
"Component": component_as_string,
"DataType": data_type,
"MonitorWorkspace": monitor_workspace,
"SampleData": workspace,
"OutputWorkspaceWavelengthAdjustment": EMPTY_NAME,
"OutputWorkspacePixelAdjustment": EMPTY_NAME,
"OutputWorkspaceWavelengthAndPixelAdjustment": EMPTY_NAME}
if transmission_workspace:
transmission_workspace = self._move(state_serialized, transmission_workspace, component_as_string,
is_transmission=True)
adjustment_options.update({"TransmissionWorkspace": transmission_workspace})
if direct_workspace:
direct_workspace = self._move(state_serialized, direct_workspace, component_as_string, is_transmission=True)
adjustment_options.update({"DirectWorkspace": direct_workspace})
adjustment_alg = create_child_algorithm(self, adjustment_name, **adjustment_options)
adjustment_alg.execute()
wavelength_adjustment = adjustment_alg.getProperty("OutputWorkspaceWavelengthAdjustment").value
pixel_adjustment = adjustment_alg.getProperty("OutputWorkspacePixelAdjustment").value
wavelength_and_pixel_adjustment = adjustment_alg.getProperty(
"OutputWorkspaceWavelengthAndPixelAdjustment").value
calculated_transmission_workspace = adjustment_alg.getProperty("CalculatedTransmissionWorkspace").value
unfitted_transmission_workspace = adjustment_alg.getProperty("UnfittedTransmissionWorkspace").value
return wavelength_adjustment, pixel_adjustment, wavelength_and_pixel_adjustment, \
calculated_transmission_workspace, unfitted_transmission_workspace
示例3: _run_quartile_reduction
def _run_quartile_reduction(self, scatter_workspace, transmission_workspace, direct_workspace, data_type,
scatter_monitor_workspace, component, state, centre1, centre2, r_min, r_max):
algorithm_name = "SANSBeamCentreFinderCore"
alg_options = {"ScatterWorkspace": scatter_workspace,
"ScatterMonitorWorkspace": scatter_monitor_workspace,
"TransmissionWorkspace": transmission_workspace,
"DirectWorkspace": direct_workspace,
"Component": component,
"SANSState": state,
"DataType": data_type,
"Centre1": centre1,
"Centre2": centre2,
"OutputWorkspaceLeft": EMPTY_NAME,
"OutputWorkspaceRight": EMPTY_NAME,
"OutputWorkspaceTop": EMPTY_NAME,
"OutputWorkspaceBottom": EMPTY_NAME,
"RMax": r_max,
"RMin": r_min}
alg = create_child_algorithm(self, algorithm_name, **alg_options)
alg.execute()
out_left = strip_end_nans(alg.getProperty("OutputWorkspaceLeft").value, self)
out_right = strip_end_nans(alg.getProperty("OutputWorkspaceRight").value, self)
out_top = strip_end_nans(alg.getProperty("OutputWorkspaceTop").value, self)
out_bottom = strip_end_nans(alg.getProperty("OutputWorkspaceBottom").value, self)
return {MaskingQuadrant.Left: out_left, MaskingQuadrant.Right: out_right, MaskingQuadrant.Top: out_top,
MaskingQuadrant.Bottom: out_bottom}
示例4: _get_cloned_workspace
def _get_cloned_workspace(self, workspace):
clone_name = "CloneWorkspace"
clone_options = {"InputWorkspace": workspace,
"OutputWorkspace": EMPTY_NAME}
clone_alg = create_child_algorithm(self, clone_name, **clone_options)
clone_alg.execute()
return clone_alg.getProperty("OutputWorkspace").value
示例5: _convert_to_q
def _convert_to_q(self, state_serialized, workspace, wavelength_adjustment_workspace, pixel_adjustment_workspace,
wavelength_and_pixel_adjustment_workspace):
"""
A conversion to momentum transfer is performed in this step.
The conversion can be either to the modulus of Q in which case the output is a 1D workspace, or it can
be a 2D reduction where the y axis is Qy, ie it is a numeric axis.
@param state: a SANSState object
@param workspace: the workspace to convert to momentum transfer.
@param wavelength_adjustment_workspace: the wavelength adjustment workspace.
@param pixel_adjustment_workspace: the pixel adjustment workspace.
@param wavelength_and_pixel_adjustment_workspace: the wavelength and pixel adjustment workspace.
@return: a reduced workspace
"""
convert_name = "SANSConvertToQ"
convert_options = {"InputWorkspace": workspace,
"OutputWorkspace": EMPTY_NAME,
"SANSState": state_serialized,
"OutputParts": True}
if wavelength_adjustment_workspace:
convert_options.update({"InputWorkspaceWavelengthAdjustment": wavelength_adjustment_workspace})
if pixel_adjustment_workspace:
convert_options.update({"InputWorkspacePixelAdjustment": pixel_adjustment_workspace})
if wavelength_and_pixel_adjustment_workspace:
convert_options.update({"InputWorkspaceWavelengthAndPixelAdjustment":
wavelength_and_pixel_adjustment_workspace})
convert_alg = create_child_algorithm(self, convert_name, **convert_options)
convert_alg.execute()
data_workspace = convert_alg.getProperty("OutputWorkspace").value
sum_of_counts = convert_alg.getProperty("SumOfCounts").value
sum_of_norms = convert_alg.getProperty("SumOfNormFactors").value
return data_workspace, sum_of_counts, sum_of_norms
示例6: correct
def correct(self, workspaces, parent_alg):
"""
For LOQ we want to apply a different instrument definition for the transmission runs.
:param workspaces: a dictionary of data types, e.g. SampleScatter vs. a workspace
:param parent_alg: a handle to the parent algorithm
"""
# Get the transmission and the direct workspaces and apply the correction to them
workspace_which_require_transmission_correction = []
for data_type, _ in list(workspaces.items()):
if is_transmission_type(data_type):
workspace_which_require_transmission_correction.append(workspaces[data_type])
# We want to apply a different instrument for the transmission runs
for workspace in workspace_which_require_transmission_correction:
assert len(workspace) == 1
workspace = workspace[0]
instrument = workspace.getInstrument()
has_m4 = instrument.getComponentByName("monitor4")
if has_m4 is None:
trans_definition_file = os.path.join(config.getString('instrumentDefinition.directory'),
'LOQ_trans_Definition.xml')
else:
trans_definition_file = os.path.join(config.getString('instrumentDefinition.directory'),
'LOQ_trans_Definition_M4.xml')
# Done
instrument_name = "LoadInstrument"
instrument_options = {"Workspace": workspace,
"Filename": trans_definition_file,
"RewriteSpectraMap": False}
instrument_alg = create_child_algorithm(parent_alg, instrument_name, **instrument_options)
instrument_alg.execute()
示例7: apply_missing_parameters
def apply_missing_parameters(calibration_workspace, workspace, missing_parameters, parent_alg):
"""
Transfers missing properties from the data workspace to the calibration workspace.
:param calibration_workspace: the calibration workspace.
:param workspace: the data workspace.
:param missing_parameters: a list of missing parameters which exist on the data workspace but not on the calibration
workspace.
:param parent_alg: a handle to the parent algorithm
"""
instrument = workspace.getInstrument()
component_name = instrument.getName()
component_name = sanitise_instrument_name(component_name)
set_instrument_name = "SetInstrumentParameter"
set_instrument_parameter_options = {"Workspace": calibration_workspace,
"ComponentName": component_name}
alg = create_child_algorithm(parent_alg, set_instrument_name, **set_instrument_parameter_options)
# For now only string, int and double are handled
type_options = {"string": "String", "int": "Number", "double": "Number"}
value_options = {"string": instrument.getStringParameter,
"int": instrument.getIntParameter,
"double": instrument.getNumberParameter}
try:
for missing_parameter in missing_parameters:
parameter_type = instrument.getParameterType(missing_parameter)
type_to_save = type_options[parameter_type]
value = value_options[parameter_type](missing_parameter)
alg.setProperty("ParameterName", missing_parameter)
alg.setProperty("ParameterType", type_to_save)
alg.setProperty("Value", str(value[0]))
except KeyError:
raise RuntimeError("SANSCalibration: An Instrument Parameter File value of unknown type"
"was going to be copied. Cannot handle this currently.")
示例8: get_calibration_workspace
def get_calibration_workspace(full_file_path, use_loaded, parent_alg):
"""
Load the calibration workspace from the specified file
:param full_file_path: Path to the calibration file.
:param use_loaded: Allows us to check for the calibration file on the ADS.
:param parent_alg: a handle to the parent algorithm
:return: the calibration workspace.
"""
calibration_workspace = None
# Here we can avoid reloading of the calibration workspace
if use_loaded:
calibration_workspace = get_already_loaded_calibration_workspace(full_file_path)
if calibration_workspace is None:
if not isfile(full_file_path):
raise RuntimeError("SANSCalibration: The file for {0} does not seem to exist".format(full_file_path))
loader_name = "LoadNexusProcessed"
loader_options = {"Filename": full_file_path,
"OutputWorkspace": "dummy"}
loader = create_child_algorithm(parent_alg, loader_name, **loader_options)
loader.execute()
calibration_workspace = loader.getProperty("OutputWorkspace").value
return calibration_workspace
示例9: _mask
def _mask(self, state_serialized, workspace, component):
mask_name = "SANSMaskWorkspace"
mask_options = {"SANSState": state_serialized,
"Workspace": workspace,
"Component": component}
mask_alg = create_child_algorithm(self, mask_name, **mask_options)
mask_alg.execute()
return mask_alg.getProperty("Workspace").value
示例10: _scale
def _scale(self, state_serialized, workspace):
scale_name = "SANSScale"
scale_options = {"SANSState": state_serialized,
"InputWorkspace": workspace,
"OutputWorkspace": EMPTY_NAME}
scale_alg = create_child_algorithm(self, scale_name, **scale_options)
scale_alg.execute()
return scale_alg.getProperty("OutputWorkspace").value
示例11: apply_mask
def apply_mask(state, workspace, component):
state_serialized = state.property_manager
mask_name = "SANSMaskWorkspace"
mask_options = {"SANSState": state_serialized,
"Workspace": workspace,
"Component": component}
mask_alg = create_child_algorithm('', mask_name, **mask_options)
mask_alg.execute()
return mask_alg.getProperty("Workspace").value
示例12: _get_cropped_workspace
def _get_cropped_workspace(self, component):
scatter_workspace = self.getProperty("SampleScatterWorkspace").value
crop_name = "SANSCrop"
crop_options = {"InputWorkspace": scatter_workspace,
"OutputWorkspace": EMPTY_NAME,
"Component": component}
crop_alg = create_child_algorithm(self, crop_name, **crop_options)
crop_alg.execute()
return crop_alg.getProperty("OutputWorkspace").value
示例13: _convert_to_wavelength
def _convert_to_wavelength(self, state_serialized, workspace):
wavelength_name = "SANSConvertToWavelength"
wavelength_options = {"SANSState": state_serialized,
"InputWorkspace": workspace}
wavelength_alg = create_child_algorithm(self, wavelength_name, **wavelength_options)
wavelength_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME)
wavelength_alg.setProperty("OutputWorkspace", workspace)
wavelength_alg.execute()
return wavelength_alg.getProperty("OutputWorkspace").value
示例14: _run_center_of_mass_position
def _run_center_of_mass_position(self, scatter_workspace, centre1, centre2, r_min, tolerance):
algorithm_name = "FindCenterOfMassPosition"
alg_options = {"InputWorkspace": scatter_workspace,
"CenterX": centre1,
"CenterY": centre2,
"BeamRadius": r_min,
"Tolerance": tolerance,
"DirectBeam": False}
alg = create_child_algorithm(self, algorithm_name, **alg_options)
alg.execute()
return alg.getProperty("CenterOfMass").value
示例15: calibrate
def calibrate(calibration_workspace, workspace_to_calibrate, parent_alg):
"""
Performs a calibration. The instrument parameters are copied from the calibration workspace to the data workspace.
:param calibration_workspace: the calibration workspace
:param workspace_to_calibrate: the workspace which has the calibration applied to it.
:param parent_alg: a handle to the parent algorithm
"""
copy_instrument_name = "CopyInstrumentParameters"
copy_instrument_options = {"InputWorkspace": calibration_workspace,
"OutputWorkspace": workspace_to_calibrate}
alg = create_child_algorithm(parent_alg, copy_instrument_name, **copy_instrument_options)
alg.execute()