def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) normalize_to_monitor_state = state.adjustment.normalize_to_monitor # 1. Extract the spectrum of the incident monitor incident_monitor_spectrum_number = normalize_to_monitor_state.incident_monitor workspace = self._extract_monitor(incident_monitor_spectrum_number) # 2. Multiply the workspace by the specified scaling factor. scale_factor = self.getProperty("ScaleFactor").value if scale_factor != 1.0: workspace = self._scale(workspace, scale_factor) # 3. Remove the prompt peak (if it exists) workspace = self._perform_prompt_peak_correction(workspace, normalize_to_monitor_state) # 4. Perform a flat background correction workspace = self._perform_flat_background_correction(workspace, normalize_to_monitor_state) # 5. Convert to wavelength with the specified bin settings. workspace = self._convert_to_wavelength(workspace, normalize_to_monitor_state) self.setProperty("OutputWorkspace", workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) progress = Progress(self, start=0.0, end=1.0, nreports=3) input_workspace = self.getProperty("InputWorkspace").value data_type_as_string = self.getProperty("DataType").value data_type = DataType.from_string(data_type_as_string) slicer = SliceEventFactory.create_slicer(state, input_workspace, data_type) slice_info = state.slice # Perform the slicing progress.report("Starting to slice the workspace.") sliced_workspace, slice_factor = slicer.create_slice(input_workspace, slice_info) # Scale the monitor accordingly progress.report("Scaling the monitors.") self.scale_monitors(slice_factor) # Set the outputs append_to_sans_file_tag(sliced_workspace, "_sliced") self.setProperty("OutputWorkspace", sliced_workspace) self.setProperty("SliceEventFactor", slice_factor) progress.report("Finished slicing.")
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) wavelength_and_pixel_adjustment_state = state.adjustment.wavelength_and_pixel_adjustment # Get the wavelength adjustment workspace transmission_workspace = self.getProperty("TransmissionWorkspace").value monitor_normalization_workspace = self.getProperty("NormalizeToMonitorWorkspace").value component = self.getProperty("Component").value wavelength_adjustment_file = wavelength_and_pixel_adjustment_state.adjustment_files[component].wavelength_adjustment_file rebin_string = self._get_rebin_string(wavelength_and_pixel_adjustment_state) wavelength_adjustment_workspace = self._get_wavelength_adjustment_workspace(wavelength_adjustment_file, transmission_workspace, monitor_normalization_workspace, rebin_string) # Get the pixel adjustment workspace pixel_adjustment_file = wavelength_and_pixel_adjustment_state.adjustment_files[component].pixel_adjustment_file idf_path = wavelength_and_pixel_adjustment_state.idf_path pixel_adjustment_workspace = self._get_pixel_adjustment_workspace(pixel_adjustment_file, component, idf_path) # Set the output if wavelength_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wavelength_adjustment_workspace) if pixel_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_adjustment_workspace)
def PyExec(self): # State state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) wavelength_state = state.wavelength # Input workspace workspace = get_input_workspace_as_copy_if_not_same_as_output_workspace( self) wavelength_name = "SANSConvertToWavelengthAndRebin" wavelength_options = { "InputWorkspace": workspace, "WavelengthLow": wavelength_state.wavelength_low, "WavelengthHigh": wavelength_state.wavelength_high, "WavelengthStep": wavelength_state.wavelength_step, "WavelengthStepType": RangeStepType.to_string(wavelength_state.wavelength_step_type), "RebinMode": RebinType.to_string(wavelength_state.rebin_type) } wavelength_alg = create_unmanaged_algorithm(wavelength_name, **wavelength_options) wavelength_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME) wavelength_alg.setProperty("OutputWorkspace", workspace) wavelength_alg.execute() converted_workspace = wavelength_alg.getProperty( "OutputWorkspace").value append_to_sans_file_tag(converted_workspace, "_wavelength") self.setProperty("OutputWorkspace", converted_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Run the appropriate SANSLoader and get the workspaces and the workspace monitors # Note that cache optimization is only applied to the calibration workspace since it is not available as a # return property and it is also something which is most likely not to change between different reductions. use_cached = self.getProperty("UseCached").value publish_to_ads = self.getProperty("PublishToCache").value data = state.data progress = self._get_progress_for_file_loading(data) # Get the correct SANSLoader from the SANSLoaderFactory load_factory = SANSLoadDataFactory() loader = load_factory.create_loader(state) workspaces, workspace_monitors = loader.execute(data_info=data, use_cached=use_cached, publish_to_ads=publish_to_ads, progress=progress, parent_alg=self) progress.report("Loaded the data.") progress_move = Progress(self, start=0.8, end=1.0, nreports=2) progress_move.report("Starting to move the workspaces.") self._perform_initial_move(workspaces, state) progress_move.report("Finished moving the workspaces.") # Set output workspaces for workspace_type, workspace in workspaces.items(): self.set_output_for_workspaces(workspace_type, workspace) # Set the output monitor workspaces for workspace_type, workspace in workspace_monitors.items(): self.set_output_for_monitor_workspaces(workspace_type, workspace)
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager( state_property_manager) state.validate() except ValueError as err: errors.update({"SANSCreateWavelengthAndPixelAdjustment": str(err)}) # The transmission and the normalize to monitor workspace must have exactly one histogram present transmission_workspace = self.getProperty( "TransmissionWorkspace").value normalize_to_monitor = self.getProperty( "NormalizeToMonitorWorkspace").value if transmission_workspace and transmission_workspace.getNumberHistograms( ) != 1: errors.update({ "TransmissionWorkspace": "The transmission workspace can have only one histogram." }) if normalize_to_monitor.getNumberHistograms() != 1: errors.update({ "NormalizeToMonitorWorkspace": "The monitor normalization workspace can have" " only one histogram." }) return errors
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Run the appropriate SANSLoader and get the workspaces and the workspace monitors # Note that cache optimization is only applied to the calibration workspace since it is not available as a # return property and it is also something which is most likely not to change between different reductions. use_cached = self.getProperty("UseCached").value publish_to_ads = self.getProperty("PublishToCache").value data = state.data progress = self._get_progress_for_file_loading(data) # Get the correct SANSLoader from the SANSLoaderFactory load_factory = SANSLoadDataFactory() loader = load_factory.create_loader(state) workspaces, workspace_monitors = loader.execute(data_info=data, use_cached=use_cached, publish_to_ads=publish_to_ads, progress=progress, parent_alg=self) progress.report("Loaded the data.") progress_move = Progress(self, start=0.8, end=1.0, nreports=2) progress_move.report("Starting to move the workspaces.") self._perform_initial_move(workspaces, state) progress_move.report("Finished moving the workspaces.") # Set output workspaces for workspace_type, workspace in list(workspaces.items()): self.set_output_for_workspaces(workspace_type, workspace) # Set the output monitor workspaces for workspace_type, workspace in list(workspace_monitors.items()): self.set_output_for_monitor_workspaces(workspace_type, workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) component = self._get_component() # Get the correct SANS masking strategy from create_masker workspace = self.getProperty("Workspace").value masker = create_masker(state, component) # Perform the masking number_of_masking_options = 7 progress = Progress(self, start=0.0, end=1.0, nreports=number_of_masking_options) mask_info = state.mask workspace = masker.mask_workspace(mask_info, workspace, component, progress) append_to_sans_file_tag(workspace, "_masked") self.setProperty("Workspace", workspace) progress.report("Completed masking the workspace")
def test_that_sans_state_can_be_serialized_and_deserialized_when_going_through_an_algorithm(self): class FakeAlgorithm(Algorithm): def PyInit(self): self.declareProperty(PropertyManagerProperty("Args")) def PyExec(self): pass # Arrange state = ComplexState() # Act serialized = state.property_manager fake = FakeAlgorithm() fake.initialize() fake.setProperty("Args", serialized) property_manager = fake.getProperty("Args").value # Assert self.assertTrue(type(serialized) == dict) self.assertTrue(type(property_manager) == PropertyManager) state_2 = create_deserialized_sans_state_from_property_manager(property_manager) state_2.property_manager = property_manager # The direct sub state self._assert_simple_state(state_2.sub_state_1) # The two states in the dictionary self._assert_simple_state(state_2.dict_parameter["A"]) self._assert_simple_state(state_2.dict_parameter["B"]) # The regular parameters self.assertTrue(state_2.float_parameter == 23.) self.assertTrue(state_2.positive_float_with_none_parameter == 234.)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) normalize_to_monitor_state = state.adjustment.normalize_to_monitor # 1. Extract the spectrum of the incident monitor incident_monitor_spectrum_number = normalize_to_monitor_state.incident_monitor workspace = self._extract_monitor(incident_monitor_spectrum_number) # 2. Multiply the workspace by the specified scaling factor. scale_factor = self.getProperty("ScaleFactor").value if scale_factor != 1.0: workspace = self._scale(workspace, scale_factor) # 3. Remove the prompt peak (if it exists) workspace = self._perform_prompt_peak_correction( workspace, normalize_to_monitor_state) # 4. Perform a flat background correction workspace = self._perform_flat_background_correction( workspace, normalize_to_monitor_state) # 5. Convert to wavelength with the specified bin settings. workspace = self._convert_to_wavelength(workspace, normalize_to_monitor_state) self.setProperty("OutputWorkspace", workspace)
def _convert_property_manager_to_state(property_managers): states = {} for key, property_manager in property_managers.items(): state = create_deserialized_sans_state_from_property_manager( property_manager) states.update({key: state}) return states
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSNormalizeToMonitor": str(err)}) return errors
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) calculate_transmission_state = state.adjustment.calculate_transmission # The calculation of the transmission has the following steps: # 1. Get all spectrum numbers which take part in the transmission calculation # 2. Clean up the transmission and direct workspaces, ie peak prompt correction, flat background calculation, # wavelength conversion and rebinning of the data. # 3. Run the CalculateTransmission algorithm transmission_workspace = self.getProperty( "TransmissionWorkspace").value direct_workspace = self.getProperty("DirectWorkspace").value incident_monitor_spectrum_number = calculate_transmission_state.incident_monitor if incident_monitor_spectrum_number is None: incident_monitor_spectrum_number = calculate_transmission_state.default_incident_monitor # 1. Get relevant spectra detector_id_incident_monitor = get_detector_id_for_spectrum_number( transmission_workspace, incident_monitor_spectrum_number) detector_ids_roi, detector_id_transmission_monitor, detector_id_default_transmission_monitor = \ self._get_detector_ids_for_transmission_calculation(transmission_workspace, calculate_transmission_state) all_detector_ids = [detector_id_incident_monitor] if len(detector_ids_roi) > 0: all_detector_ids.extend(detector_ids_roi) elif detector_id_transmission_monitor is not None: all_detector_ids.append(detector_id_transmission_monitor) elif detector_id_default_transmission_monitor is not None: all_detector_ids.append(detector_id_default_transmission_monitor) else: raise RuntimeError( "SANSCalculateTransmission: No region of interest or transmission monitor selected." ) # 2. Clean transmission data data_type_string = self.getProperty("DataType").value data_type = DataType.from_string(data_type_string) transmission_workspace = self._get_corrected_wavelength_workspace( transmission_workspace, all_detector_ids, calculate_transmission_state) direct_workspace = self._get_corrected_wavelength_workspace( direct_workspace, all_detector_ids, calculate_transmission_state) # 3. Fit output_workspace, unfitted_transmission_workspace = \ self._perform_fit(transmission_workspace, direct_workspace, detector_ids_roi, detector_id_transmission_monitor, detector_id_default_transmission_monitor, detector_id_incident_monitor, calculate_transmission_state, data_type) self.setProperty("OutputWorkspace", output_workspace) if unfitted_transmission_workspace: self.setProperty("UnfittedData", unfitted_transmission_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) # -------------------------------------- # Get the monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace( state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace( state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if calculated_transmission_workspace and unfitted_transmission_workspace and state.adjustment.show_transmission: data_type = self.getProperty("DataType").value output_workspace_name, output_workspace_base_name = get_standard_output_workspace_name( state, state.reduction.reduction_mode, transmission=True, data_type=data_type) AnalysisDataService.addOrReplace( output_workspace_base_name, calculated_transmission_workspace) AnalysisDataService.addOrReplace( output_workspace_base_name + '_unfitted', unfitted_transmission_workspace)
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSSMask": str(err)}) return errors
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager( state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSCalculateTransmission": str(err)}) state = None if state is not None: transmission_workspace = self.getProperty( "TransmissionWorkspace").value calculate_transmission_state = state.adjustment.calculate_transmission try: incident_monitor = calculate_transmission_state.incident_monitor if incident_monitor is None: incident_monitor = calculate_transmission_state.default_incident_monitor transmission_workspace.getIndexFromSpectrumNumber( incident_monitor) except RuntimeError: errors.update({ "IncidentMonitorSpectrumNumber": "The spectrum number for the incident monitor spectrum " "does not seem to exist for the transmission" " workspace." }) if state is not None: calculate_transmission_state = state.adjustment.calculate_transmission fit = calculate_transmission_state.fit data_type_string = self.getProperty("DataType").value data_type = DataType.from_string(data_type_string) sample = fit[DataType.to_string(DataType.Sample)] can = fit[DataType.to_string(DataType.Can)] if data_type is DataType.Sample and sample.fit_type is None: errors.update({ "DataType": "There does not seem to be a fit type set for the selected data type" }) if data_type is DataType.Can and can.fit_type is None: errors.update({ "DataType": "There does not seem to be a fit type set for the selected data type" }) return errors
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) calculate_transmission_state = state.adjustment.calculate_transmission # The calculation of the transmission has the following steps: # 1. Get all spectrum numbers which take part in the transmission calculation # 2. Clean up the transmission and direct workspaces, ie peak prompt correction, flat background calculation, # wavelength conversion and rebinning of the data. # 3. Run the CalculateTransmission algorithm transmission_workspace = self.getProperty("TransmissionWorkspace").value direct_workspace = self.getProperty("DirectWorkspace").value incident_monitor_spectrum_number = calculate_transmission_state.incident_monitor if incident_monitor_spectrum_number is None: incident_monitor_spectrum_number = calculate_transmission_state.default_incident_monitor # 1. Get relevant spectra detector_id_incident_monitor = get_detector_id_for_spectrum_number(transmission_workspace, incident_monitor_spectrum_number) detector_ids_roi, detector_id_transmission_monitor, detector_id_default_transmission_monitor = \ self._get_detector_ids_for_transmission_calculation(transmission_workspace, calculate_transmission_state) all_detector_ids = [detector_id_incident_monitor] if len(detector_ids_roi) > 0: all_detector_ids.extend(detector_ids_roi) elif detector_id_transmission_monitor is not None: all_detector_ids.append(detector_id_transmission_monitor) elif detector_id_default_transmission_monitor is not None: all_detector_ids.append(detector_id_default_transmission_monitor) else: raise RuntimeError("SANSCalculateTransmission: No region of interest or transmission monitor selected.") # 2. Clean transmission data data_type_string = self.getProperty("DataType").value data_type = DataType.from_string(data_type_string) transmission_workspace = self._get_corrected_wavelength_workspace(transmission_workspace, all_detector_ids, calculate_transmission_state) direct_workspace = self._get_corrected_wavelength_workspace(direct_workspace, all_detector_ids, calculate_transmission_state) # 3. Fit output_workspace, unfitted_transmission_workspace = \ self._perform_fit(transmission_workspace, direct_workspace, detector_ids_roi, detector_id_transmission_monitor, detector_id_default_transmission_monitor, detector_id_incident_monitor, calculate_transmission_state, data_type) self.setProperty("OutputWorkspace", output_workspace) if unfitted_transmission_workspace: self.setProperty("UnfittedData", unfitted_transmission_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) # -------------------------------------- # Get the monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace( state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace( state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if state.adjustment.show_transmission: self.setProperty("CalculatedTransmissionWorkspace", calculated_transmission_workspace) self.setProperty("UnfittedTransmissionWorkspace", unfitted_transmission_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # -------------------------------------- # Get the monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace(state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace(state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if calculated_transmission_workspace and unfitted_transmission_workspace and state.adjustment.show_transmission: data_type = self.getProperty("DataType").value output_workspace_name, output_workspace_base_name = get_standard_output_workspace_name(state, state.reduction.reduction_mode , transmission = True, data_type = data_type) AnalysisDataService.addOrReplace(output_workspace_base_name, calculated_transmission_workspace) AnalysisDataService.addOrReplace(output_workspace_base_name + '_unfitted', unfitted_transmission_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Perform either a 1D reduction or a 2D reduction convert_to_q = state.convert_to_q reduction_dimensionality = convert_to_q.reduction_dimensionality if reduction_dimensionality is ReductionDimensionality.OneDim: output_workspace, sum_of_counts_workspace, sum_of_norms_workspace = self._run_q_1d(state) else: output_workspace, sum_of_counts_workspace, sum_of_norms_workspace = self._run_q_2d(state) # Set the output append_to_sans_file_tag(output_workspace, "_convertq") self.setProperty("OutputWorkspace", output_workspace) if sum_of_counts_workspace and sum_of_norms_workspace: self._set_partial_workspaces(sum_of_counts_workspace, sum_of_norms_workspace)
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSSMove": str(err)}) # Check that if the MoveType is either InitialMove or ElementaryDisplacement, then there are beam coordinates # supplied. In the case of SetToZero these coordinates are ignored if they are supplied coordinates = self.getProperty("BeamCoordinates").value selected_move_type = self._get_move_type() if len(coordinates) == 0 and (selected_move_type is MoveType.ElementaryDisplacement): errors.update({"BeamCoordinates": "Beam coordinates were not specified. An elementary displacement " "requires beam coordinates."}) return errors
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.validate() except ValueError as err: errors.update({"SANSCreateWavelengthAndPixelAdjustment": str(err)}) # The transmission and the normalize to monitor workspace must have exactly one histogram present transmission_workspace = self.getProperty("TransmissionWorkspace").value normalize_to_monitor = self.getProperty("NormalizeToMonitorWorkspace").value if transmission_workspace and transmission_workspace.getNumberHistograms() != 1: errors.update({"TransmissionWorkspace": "The transmission workspace can have only one histogram."}) if normalize_to_monitor.getNumberHistograms() != 1: errors.update({"NormalizeToMonitorWorkspace": "The monitor normalization workspace can have" " only one histogram."}) return errors
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Perform either a 1D reduction or a 2D reduction convert_to_q = state.convert_to_q reduction_dimensionality = convert_to_q.reduction_dimensionality if reduction_dimensionality is ReductionDimensionality.OneDim: output_workspace, sum_of_counts_workspace, sum_of_norms_workspace = self._run_q_1d(state) else: output_workspace, sum_of_counts_workspace, sum_of_norms_workspace = self._run_q_2d(state) # Set the output append_to_sans_file_tag(output_workspace, "_convertq") self.setProperty("OutputWorkspace", output_workspace) output_parts = self.getProperty("OutputParts").value if output_parts: self._set_partial_workspaces(sum_of_counts_workspace, sum_of_norms_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) # Get the correct SANS move strategy from the SANSMoveFactory workspace = self.getProperty("Workspace").value move_factory = SANSMoveFactory() mover = move_factory.create_mover(workspace) # Get the selected component and the beam coordinates move_info = state.move full_component_name = self._get_full_component_name(move_info) coordinates = self._get_coordinates(move_info, full_component_name) # Get which move operation the user wants to perform on the workspace. This can be: # 1. Initial move: Suitable when a workspace has been freshly loaded. # 2. Elementary displacement: Takes the degrees of freedom of the detector into account. This is normally used # for beam center finding # 3. Set to zero: Set the component to its zero position progress = Progress(self, start=0.0, end=1.0, nreports=2) selected_move_type = self._get_move_type() if selected_move_type is MoveType.ElementaryDisplacement: progress.report("Starting elementary displacement") mover.move_with_elementary_displacement(move_info, workspace, coordinates, full_component_name) elif selected_move_type is MoveType.InitialMove: is_transmission_workspace = self.getProperty( "IsTransmissionWorkspace").value progress.report("Starting initial move.") mover.move_initial(move_info, workspace, coordinates, full_component_name, is_transmission_workspace) elif selected_move_type is MoveType.SetToZero: progress.report("Starting set to zero.") mover.set_to_zero(move_info, workspace, full_component_name) else: raise ValueError("SANSMove: The selection {0} for the move type " "is unknown".format(str(selected_move_type))) progress.report("Completed move.")
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) component = self._get_component() # Get the correct SANS masking strategy from create_masker workspace = self.getProperty("Workspace").value masker = create_masker(state, component) # Perform the masking number_of_masking_options = 7 progress = Progress(self, start=0.0, end=1.0, nreports=number_of_masking_options) mask_info = state.mask workspace = masker.mask_workspace(mask_info, workspace, component, progress) append_to_sans_file_tag(workspace, "_masked") self.setProperty("Workspace", workspace) progress.report("Completed masking the workspace")
def PyExec(self): state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Get the correct SANS move strategy from the SANSMaskFactory workspace = self.getProperty("InputWorkspace").value progress = Progress(self, start=0.0, end=1.0, nreports=3) # Multiply by the absolute scale progress.report("Applying absolute scale.") workspace = self._multiply_by_absolute_scale(workspace, state) # Divide by the sample volume progress.report("Dividing by the sample volume.") workspace = self._divide_by_volume(workspace, state) append_to_sans_file_tag(workspace, "_scale") self.setProperty("OutputWorkspace", workspace) progress.report("Finished applying absolute scale")
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # -------------------------------------- # Get the monitor normalization workspace # -------------------------------------- monitor_normalization_workspace = self._get_monitor_normalization_workspace(state) # -------------------------------------- # Get the calculated transmission # -------------------------------------- calculated_transmission_workspace, unfitted_transmission_workspace =\ self._get_calculated_transmission_workspace(state) # -------------------------------------- # Get the wide angle correction workspace # -------------------------------------- wave_length_and_pixel_adjustment_workspace = self._get_wide_angle_correction_workspace(state, calculated_transmission_workspace) # noqa # -------------------------------------------- # Get the full wavelength and pixel adjustment # -------------------------------------------- wave_length_adjustment_workspace, \ pixel_length_adjustment_workspace = self._get_wavelength_and_pixel_adjustment_workspaces(state, monitor_normalization_workspace, # noqa calculated_transmission_workspace) # noqa if wave_length_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wave_length_adjustment_workspace) if pixel_length_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_length_adjustment_workspace) if wave_length_and_pixel_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAndPixelAdjustment", wave_length_and_pixel_adjustment_workspace) if state.adjustment.show_transmission: self.setProperty("CalculatedTransmissionWorkspace", calculated_transmission_workspace) self.setProperty("UnfittedTransmissionWorkspace", unfitted_transmission_workspace)
def PyExec(self): state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) # Get the correct SANS move strategy from the SANSMaskFactory workspace = self.getProperty("InputWorkspace").value progress = Progress(self, start=0.0, end=1.0, nreports=3) # Multiply by the absolute scale progress.report("Applying absolute scale.") workspace = self._multiply_by_absolute_scale(workspace, state) # Divide by the sample volume progress.report("Dividing by the sample volume.") workspace = self._divide_by_volume(workspace, state) append_to_sans_file_tag(workspace, "_scale") self.setProperty("OutputWorkspace", workspace) progress.report("Finished applying absolute scale")
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSCalculateTransmission": str(err)}) state = None if state is not None: transmission_workspace = self.getProperty("TransmissionWorkspace").value calculate_transmission_state = state.adjustment.calculate_transmission try: incident_monitor = calculate_transmission_state.incident_monitor if incident_monitor is None: incident_monitor = calculate_transmission_state.default_incident_monitor transmission_workspace.getIndexFromSpectrumNumber(incident_monitor) except RuntimeError: errors.update({"IncidentMonitorSpectrumNumber": "The spectrum number for the incident monitor spectrum " "does not seem to exist for the transmission" " workspace."}) if state is not None: calculate_transmission_state = state.adjustment.calculate_transmission fit = calculate_transmission_state.fit data_type_string = self.getProperty("DataType").value data_type = DataType.from_string(data_type_string) sample = fit[DataType.to_string(DataType.Sample)] can = fit[DataType.to_string(DataType.Can)] if data_type is DataType.Sample and sample.fit_type is None: errors.update({"DataType": "There does not seem to be a fit type set for the selected data type"}) if data_type is DataType.Can and can.fit_type is None: errors.update({"DataType": "There does not seem to be a fit type set for the selected data type"}) return errors
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) wavelength_and_pixel_adjustment_state = state.adjustment.wavelength_and_pixel_adjustment # Get the wavelength adjustment workspace transmission_workspace = self.getProperty( "TransmissionWorkspace").value monitor_normalization_workspace = self.getProperty( "NormalizeToMonitorWorkspace").value component = self.getProperty("Component").value wavelength_adjustment_file = wavelength_and_pixel_adjustment_state.adjustment_files[ component].wavelength_adjustment_file rebin_string = self._get_rebin_string( wavelength_and_pixel_adjustment_state) wavelength_adjustment_workspace = self._get_wavelength_adjustment_workspace( wavelength_adjustment_file, transmission_workspace, monitor_normalization_workspace, rebin_string) # Get the pixel adjustment workspace pixel_adjustment_file = wavelength_and_pixel_adjustment_state.adjustment_files[ component].pixel_adjustment_file idf_path = wavelength_and_pixel_adjustment_state.idf_path pixel_adjustment_workspace = self._get_pixel_adjustment_workspace( pixel_adjustment_file, component, idf_path) # Set the output if wavelength_adjustment_workspace: self.setProperty("OutputWorkspaceWavelengthAdjustment", wavelength_adjustment_workspace) if pixel_adjustment_workspace: self.setProperty("OutputWorkspacePixelAdjustment", pixel_adjustment_workspace)
def PyExec(self): # Read the state state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) # Get the correct SANS move strategy from the SANSMoveFactory workspace = self.getProperty("Workspace").value move_factory = SANSMoveFactory() mover = move_factory.create_mover(workspace) # Get the selected component and the beam coordinates move_info = state.move full_component_name = self._get_full_component_name(move_info) coordinates = self._get_coordinates(move_info, full_component_name) # Get which move operation the user wants to perform on the workspace. This can be: # 1. Initial move: Suitable when a workspace has been freshly loaded. # 2. Elementary displacement: Takes the degrees of freedom of the detector into account. This is normally used # for beam center finding # 3. Set to zero: Set the component to its zero position progress = Progress(self, start=0.0, end=1.0, nreports=2) selected_move_type = self._get_move_type() if selected_move_type is MoveType.ElementaryDisplacement: progress.report("Starting elementary displacement") mover.move_with_elementary_displacement(move_info, workspace, coordinates, full_component_name) elif selected_move_type is MoveType.InitialMove: is_transmission_workspace = self.getProperty("IsTransmissionWorkspace").value progress.report("Starting initial move.") mover.move_initial(move_info, workspace, coordinates, full_component_name, is_transmission_workspace) elif selected_move_type is MoveType.SetToZero: progress.report("Starting set to zero.") mover.set_to_zero(move_info, workspace, full_component_name) else: raise ValueError("SANSMove: The selection {0} for the move type " "is unknown".format(str(selected_move_type))) progress.report("Completed move.")
def test_that_sans_state_can_be_serialized_and_deserialized_when_going_through_an_algorithm( self): class FakeAlgorithm(Algorithm): def PyInit(self): self.declareProperty(PropertyManagerProperty("Args")) def PyExec(self): pass # Arrange state = ComplexState() # Act serialized = state.property_manager fake = FakeAlgorithm() fake.initialize() fake.setProperty("Args", serialized) property_manager = fake.getProperty("Args").value # Assert self.assertEqual(type(serialized), dict) self.assertEqual(type(property_manager), PropertyManager) state_2 = create_deserialized_sans_state_from_property_manager( property_manager) state_2.property_manager = property_manager # The direct sub state self._assert_simple_state(state_2.sub_state_1) # The two states in the dictionary self._assert_simple_state(state_2.dict_parameter["A"]) self._assert_simple_state(state_2.dict_parameter["B"]) # The regular parameters self.assertEqual(state_2.float_parameter, 23.) self.assertEqual(state_2.positive_float_with_none_parameter, 234.)
def PyExec(self): # State state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) wavelength_state = state.wavelength # Input workspace workspace = get_input_workspace_as_copy_if_not_same_as_output_workspace(self) wavelength_name = "SANSConvertToWavelengthAndRebin" wavelength_options = {"InputWorkspace": workspace, "WavelengthLow": wavelength_state.wavelength_low[0], "WavelengthHigh": wavelength_state.wavelength_high[0], "WavelengthStep": wavelength_state.wavelength_step, "WavelengthStepType": RangeStepType.to_string( wavelength_state.wavelength_step_type), "RebinMode": RebinType.to_string(wavelength_state.rebin_type)} wavelength_alg = create_unmanaged_algorithm(wavelength_name, **wavelength_options) wavelength_alg.setPropertyValue("OutputWorkspace", EMPTY_NAME) wavelength_alg.setProperty("OutputWorkspace", workspace) wavelength_alg.execute() converted_workspace = wavelength_alg.getProperty("OutputWorkspace").value append_to_sans_file_tag(converted_workspace, "_wavelength") self.setProperty("OutputWorkspace", converted_workspace)
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSState": str(err)}) # We need to validate that the for each expected output workspace of the SANSState a output workspace name # was supplied in the PyInit # For sample scatter sample_scatter = self.getProperty("SampleScatterWorkspace").value sample_scatter_as_string = self.getProperty("SampleScatterWorkspace").valueAsStr if sample_scatter is None and not sample_scatter_as_string: errors.update({"SampleScatterWorkspace": "A sample scatter output workspace needs to be specified."}) # For sample scatter monitor sample_scatter_monitor = self.getProperty("SampleScatterMonitorWorkspace").value sample_scatter_monitor_as_string = self.getProperty("SampleScatterMonitorWorkspace").valueAsStr if sample_scatter_monitor is None and not sample_scatter_monitor_as_string: errors.update({"SampleScatterMonitorWorkspace": "A sample scatter output workspace needs to be specified."}) # ------------------------------------ # Check the optional output workspaces # If they are specified in the SANSState, then we require them to be set on the output as well. state = create_deserialized_sans_state_from_property_manager(state_property_manager) data_info = state.data # For sample transmission sample_transmission = self.getProperty("SampleTransmissionWorkspace").value sample_transmission_as_string = self.getProperty("SampleTransmissionWorkspace").valueAsStr sample_transmission_was_set = sample_transmission is not None or len(sample_transmission_as_string) > 0 sample_transmission_from_state = data_info.sample_transmission if not sample_transmission_was_set and sample_transmission_from_state is not None: errors.update({"SampleTransmissionWorkspace": "You need to set the output for the sample transmission" " workspace since it is specified to be loaded in your " "reduction configuration."}) if sample_transmission_was_set and sample_transmission_from_state is None: errors.update({"SampleTransmissionWorkspace": "You set an output workspace for sample transmission, " "although none is specified in the reduction configuration."}) # For sample direct sample_direct = self.getProperty("SampleDirectWorkspace").value sample_direct_as_string = self.getProperty("SampleDirectWorkspace").valueAsStr sample_direct_was_set = sample_direct is not None or len(sample_direct_as_string) > 0 sample_direct_from_state = data_info.sample_direct if not sample_direct_was_set and sample_direct_from_state is not None: errors.update({"SampleDirectWorkspace": "You need to set the output for the sample direct" " workspace since it is specified to be loaded in your " "reduction configuration."}) if sample_direct_was_set and sample_direct_from_state is None: errors.update({"SampleDirectWorkspace": "You set an output workspace for sample direct, " "although none is specified in the reduction configuration."}) # For can scatter + monitor can_scatter = self.getProperty("CanScatterWorkspace").value can_scatter_as_string = self.getProperty("CanScatterWorkspace").valueAsStr can_scatter_was_set = can_scatter is not None or len(can_scatter_as_string) > 0 can_scatter_from_state = data_info.can_scatter if not can_scatter_was_set and can_scatter_from_state is not None: errors.update({"CanScatterWorkspace": "You need to set the output for the can scatter" " workspace since it is specified to be loaded in your " "reduction configuration."}) if can_scatter_was_set and can_scatter_from_state is None: errors.update({"CanScatterWorkspace": "You set an output workspace for can scatter, " "although none is specified in the reduction configuration."}) # For can scatter monitor can_scatter_monitor = self.getProperty("CanScatterMonitorWorkspace").value can_scatter_monitor_as_string = self.getProperty("CanScatterMonitorWorkspace").valueAsStr can_scatter_monitor_was_set = can_scatter_monitor is not None or len(can_scatter_monitor_as_string) > 0 if not can_scatter_monitor_was_set and can_scatter_from_state is not None: errors.update({"CanScatterMonitorWorkspace": "You need to set the output for the can scatter monitor" " workspace since it is specified to be loaded in your " "reduction configuration."}) if can_scatter_monitor_was_set and can_scatter_from_state is None: errors.update({"CanScatterMonitorWorkspace": "You set an output workspace for can scatter monitor, " "although none is specified in the reduction configuration."}) # For sample transmission can_transmission = self.getProperty("CanTransmissionWorkspace").value can_transmission_as_string = self.getProperty("CanTransmissionWorkspace").valueAsStr can_transmission_was_set = can_transmission is not None or len(can_transmission_as_string) > 0 can_transmission_from_state = data_info.can_transmission if not can_transmission_was_set and can_transmission_from_state is not None: errors.update({"CanTransmissionWorkspace": "You need to set the output for the can transmission" " workspace since it is specified to be loaded in your " "reduction configuration."}) if can_transmission_was_set and can_transmission_from_state is None: errors.update({"CanTransmissionWorkspace": "You set an output workspace for can transmission, " "although none is specified in the reduction configuration."}) # For can direct can_direct = self.getProperty("CanDirectWorkspace").value can_direct_as_string = self.getProperty("CanDirectWorkspace").valueAsStr can_direct_was_set = can_direct is not None or len(can_direct_as_string) > 0 can_direct_from_state = data_info.can_direct if not can_direct_was_set and can_direct_from_state is not None: errors.update({"CanDirectWorkspace": "You need to set the output for the can direct" " workspace since it is specified to be loaded in your " "reduction configuration."}) if can_direct_was_set and can_direct_from_state is None: errors.update({"CanDirectWorkspace": "You set an output workspace for can direct, " "although none is specified in the reduction configuration."}) return errors
def validateInputs(self): errors = dict() # Check that the input can be converted into the right state object state_property_manager = self.getProperty("SANSState").value try: state = create_deserialized_sans_state_from_property_manager( state_property_manager) state.property_manager = state_property_manager state.validate() except ValueError as err: errors.update({"SANSState": str(err)}) # We need to validate that the for each expected output workspace of the SANSState a output workspace name # was supplied in the PyInit # For sample scatter sample_scatter = self.getProperty("SampleScatterWorkspace").value sample_scatter_as_string = self.getProperty( "SampleScatterWorkspace").valueAsStr if sample_scatter is None and not sample_scatter_as_string: errors.update({ "SampleScatterWorkspace": "A sample scatter output workspace needs to be specified." }) # For sample scatter monitor sample_scatter_monitor = self.getProperty( "SampleScatterMonitorWorkspace").value sample_scatter_monitor_as_string = self.getProperty( "SampleScatterMonitorWorkspace").valueAsStr if sample_scatter_monitor is None and not sample_scatter_monitor_as_string: errors.update({ "SampleScatterMonitorWorkspace": "A sample scatter output workspace needs to be specified." }) # ------------------------------------ # Check the optional output workspaces # If they are specified in the SANSState, then we require them to be set on the output as well. state = create_deserialized_sans_state_from_property_manager( state_property_manager) data_info = state.data # For sample transmission sample_transmission = self.getProperty( "SampleTransmissionWorkspace").value sample_transmission_as_string = self.getProperty( "SampleTransmissionWorkspace").valueAsStr sample_transmission_was_set = sample_transmission is not None or len( sample_transmission_as_string) > 0 sample_transmission_from_state = data_info.sample_transmission if not sample_transmission_was_set and sample_transmission_from_state is not None: errors.update({ "SampleTransmissionWorkspace": "You need to set the output for the sample transmission" " workspace since it is specified to be loaded in your " "reduction configuration." }) if sample_transmission_was_set and sample_transmission_from_state is None: errors.update({ "SampleTransmissionWorkspace": "You set an output workspace for sample transmission, " "although none is specified in the reduction configuration." }) # For sample direct sample_direct = self.getProperty("SampleDirectWorkspace").value sample_direct_as_string = self.getProperty( "SampleDirectWorkspace").valueAsStr sample_direct_was_set = sample_direct is not None or len( sample_direct_as_string) > 0 sample_direct_from_state = data_info.sample_direct if not sample_direct_was_set and sample_direct_from_state is not None: errors.update({ "SampleDirectWorkspace": "You need to set the output for the sample direct" " workspace since it is specified to be loaded in your " "reduction configuration." }) if sample_direct_was_set and sample_direct_from_state is None: errors.update({ "SampleDirectWorkspace": "You set an output workspace for sample direct, " "although none is specified in the reduction configuration." }) # For can scatter + monitor can_scatter = self.getProperty("CanScatterWorkspace").value can_scatter_as_string = self.getProperty( "CanScatterWorkspace").valueAsStr can_scatter_was_set = can_scatter is not None or len( can_scatter_as_string) > 0 can_scatter_from_state = data_info.can_scatter if not can_scatter_was_set and can_scatter_from_state is not None: errors.update({ "CanScatterWorkspace": "You need to set the output for the can scatter" " workspace since it is specified to be loaded in your " "reduction configuration." }) if can_scatter_was_set and can_scatter_from_state is None: errors.update({ "CanScatterWorkspace": "You set an output workspace for can scatter, " "although none is specified in the reduction configuration." }) # For can scatter monitor can_scatter_monitor = self.getProperty( "CanScatterMonitorWorkspace").value can_scatter_monitor_as_string = self.getProperty( "CanScatterMonitorWorkspace").valueAsStr can_scatter_monitor_was_set = can_scatter_monitor is not None or len( can_scatter_monitor_as_string) > 0 if not can_scatter_monitor_was_set and can_scatter_from_state is not None: errors.update({ "CanScatterMonitorWorkspace": "You need to set the output for the can scatter monitor" " workspace since it is specified to be loaded in your " "reduction configuration." }) if can_scatter_monitor_was_set and can_scatter_from_state is None: errors.update({ "CanScatterMonitorWorkspace": "You set an output workspace for can scatter monitor, " "although none is specified in the reduction configuration." }) # For sample transmission can_transmission = self.getProperty("CanTransmissionWorkspace").value can_transmission_as_string = self.getProperty( "CanTransmissionWorkspace").valueAsStr can_transmission_was_set = can_transmission is not None or len( can_transmission_as_string) > 0 can_transmission_from_state = data_info.can_transmission if not can_transmission_was_set and can_transmission_from_state is not None: errors.update({ "CanTransmissionWorkspace": "You need to set the output for the can transmission" " workspace since it is specified to be loaded in your " "reduction configuration." }) if can_transmission_was_set and can_transmission_from_state is None: errors.update({ "CanTransmissionWorkspace": "You set an output workspace for can transmission, " "although none is specified in the reduction configuration." }) # For can direct can_direct = self.getProperty("CanDirectWorkspace").value can_direct_as_string = self.getProperty( "CanDirectWorkspace").valueAsStr can_direct_was_set = can_direct is not None or len( can_direct_as_string) > 0 can_direct_from_state = data_info.can_direct if not can_direct_was_set and can_direct_from_state is not None: errors.update({ "CanDirectWorkspace": "You need to set the output for the can direct" " workspace since it is specified to be loaded in your " "reduction configuration." }) if can_direct_was_set and can_direct_from_state is None: errors.update({ "CanDirectWorkspace": "You set an output workspace for can direct, " "although none is specified in the reduction configuration." }) return errors
def _convert_property_manager_to_state(property_managers): states = {} for key, property_manager in property_managers.items(): state = create_deserialized_sans_state_from_property_manager(property_manager) states.update({key: state}) return states
def _get_state(self): state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager( state_property_manager) state.property_manager = state_property_manager return state
def _get_state(self): state_property_manager = self.getProperty("SANSState").value state = create_deserialized_sans_state_from_property_manager(state_property_manager) state.property_manager = state_property_manager return state