def validate(self): is_invalid = {} if one_is_none([self.wavelength_interval, self.wavelength_step_type]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_low": self.wavelength_interval, "wavelength_step_type": self.wavelength_step_type}) is_invalid.update(entry) if self.wavelength_step_type is RangeStepType.NOT_SET: entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_step_type": self.wavelength_step_type}) is_invalid.update(entry) try: self.adjustment_files[DetectorType.LAB.value].validate() self.adjustment_files[DetectorType.HAB.value].validate() except ValueError as e: is_invalid.update({"adjustment_files": str(e)}) if is_invalid: raise ValueError("StateWavelengthAndPixelAdjustment: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def validate(self): is_invalid = dict() if one_is_none( [self.wavelength_low, self.wavelength_high, self.wavelength_step]): entry = validation_message( "A wavelength entry has not been set.", "Make sure that all entries for the wavelength are set.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step }) is_invalid.update(entry) if is_not_none_and_first_larger_than_second( [self.wavelength_low, self.wavelength_high]): entry = validation_message( "Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high }) is_invalid.update(entry) if is_invalid: raise ValueError( "StateWavelength: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid, indent=4)))
def validate(self): is_invalid = {} if one_is_none([self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_low, self.wavelength_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high}) is_invalid.update(entry) try: self.adjustment_files[DetectorType.to_string(DetectorType.LAB)].validate() self.adjustment_files[DetectorType.to_string(DetectorType.HAB)].validate() except ValueError as e: is_invalid.update({"adjustment_files": str(e)}) if is_invalid: raise ValueError("StateWavelengthAndPixelAdjustment: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def validate(self): is_invalid = dict() if one_is_none([self.wavelength_interval]): entry = validation_message( "A wavelength entry has not been set.", "Make sure that all entries for the wavelength are set.", {"wavelength_binning": self.wavelength_interval}) is_invalid.update(entry) if is_invalid: raise ValueError( "StateWavelength: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid, indent=4)))
def validate(self): is_invalid = {} if one_is_none([ self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type ]): entry = validation_message( "A wavelength entry has not been set.", "Make sure that all entries are set.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type }) is_invalid.update(entry) if self.wavelength_step_type is RangeStepType.NOT_SET: entry = validation_message( "A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_step_type": self.wavelength_step_type}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second( [self.wavelength_low, self.wavelength_high]): entry = validation_message( "Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high }) is_invalid.update(entry) try: self.adjustment_files[DetectorType.LAB.value].validate() self.adjustment_files[DetectorType.HAB.value].validate() except ValueError as e: is_invalid.update({"adjustment_files": str(e)}) if is_invalid: raise ValueError( "StateWavelengthAndPixelAdjustment: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def validate(self): is_invalid = dict() if one_is_none([self.wavelength_low, self.wavelength_high, self.wavelength_step]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries for the wavelength are set.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_low, self.wavelength_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high}) is_invalid.update(entry) if is_invalid: raise ValueError("StateWavelength: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid, indent=4)))
def validate(self): is_invalid = {} # ----------------- # incident Monitor # ----------------- if self.incident_monitor is None: is_invalid.update( {"incident_monitor": "An incident monitor must be specified."}) # ----------------- # Prompt peak # ----------------- if not is_pure_none_or_not_none( [self.prompt_peak_correction_min, self.prompt_peak_correction_max ]): entry = validation_message( "A prompt peak correction entry has not been set.", "Make sure that either all prompt peak entries have been set or none.", { "prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max }) is_invalid.update(entry) if is_not_none_and_first_larger_than_second( [self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message( "Incorrect prompt peak correction bounds.", "Make sure that lower prompt peak time bound is smaller then upper bound.", { "prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max }) is_invalid.update(entry) # ----------------- # Wavelength rebin # ----------------- if one_is_none([ self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type ]): entry = validation_message( "A wavelength entry has not been set.", "Make sure that all entries are set.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type }) is_invalid.update(entry) if is_not_none_and_first_larger_than_second( [self.wavelength_low, self.wavelength_high]): entry = validation_message( "Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", { "wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high }) is_invalid.update(entry) # ---------------------- # Background correction # ---------------------- if not is_pure_none_or_not_none([ self.background_TOF_general_start, self.background_TOF_general_stop ]): entry = validation_message( "A general background TOF entry has not been set.", "Make sure that either all general background TOF entries are set or none.", { "background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop }) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([ self.background_TOF_general_start, self.background_TOF_general_stop ]): entry = validation_message( "Incorrect general background TOF bounds.", "Make sure that lower general background TOF bound is smaller then upper bound.", { "background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop }) is_invalid.update(entry) if not is_pure_none_or_not_none([ self.background_TOF_monitor_start, self.background_TOF_monitor_stop ]): entry = validation_message( "A monitor background TOF entry has not been set.", "Make sure that either all monitor background TOF entries are set or none.", { "background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop }) is_invalid.update(entry) if self.background_TOF_monitor_start is not None and self.background_TOF_monitor_stop is not None: if len(self.background_TOF_monitor_start) != len( self.background_TOF_monitor_stop): entry = validation_message( "The monitor background TOF entries have a length mismatch.", "Make sure that all monitor background TOF entries have the same length.", { "background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop }) is_invalid.update(entry) for key_start, value_start in list( self.background_TOF_monitor_start.items()): if key_start not in self.background_TOF_monitor_stop: entry = validation_message( "The monitor background TOF had spectrum number mismatch.", "Make sure that all monitors have entries for start and stop.", { "background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop }) is_invalid.update(entry) else: value_stop = self.background_TOF_monitor_stop[key_start] if value_start > value_stop: entry = validation_message( "Incorrect monitor background TOF bounds.", "Make sure that lower monitor background TOF bound is" " smaller then upper bound.", { "background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop }) is_invalid.update(entry) if is_invalid: raise ValueError( "StateMoveDetector: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def test_that_detects_if_one_is_none(self): self.assertTrue(one_is_none(["test", None, "test"])) self.assertFalse(one_is_none([])) self.assertFalse(one_is_none(["test", "test", "test"]))
def validate(self): is_invalid = {} # ----------------- # incident Monitor # ----------------- if self.incident_monitor is None: is_invalid.update({"incident_monitor": "An incident monitor must be specified."}) # ----------------- # Prompt peak # ----------------- if not is_pure_none_or_not_none([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("A prompt peak correction entry has not been set.", "Make sure that either all prompt peak entries have been set or none.", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("Incorrect prompt peak correction bounds.", "Make sure that lower prompt peak time bound is smaller then upper bound.", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) # ----------------- # Wavelength rebin # ----------------- if one_is_none([self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_low, self.wavelength_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high}) is_invalid.update(entry) # ---------------------- # Background correction # ---------------------- if not is_pure_none_or_not_none([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("A general background TOF entry has not been set.", "Make sure that either all general background TOF entries are set or none.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("Incorrect general background TOF bounds.", "Make sure that lower general background TOF bound is smaller then upper bound.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if not is_pure_none_or_not_none([self.background_TOF_monitor_start, self.background_TOF_monitor_stop]): entry = validation_message("A monitor background TOF entry has not been set.", "Make sure that either all monitor background TOF entries are set or none.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) if self.background_TOF_monitor_start is not None and self.background_TOF_monitor_stop is not None: if len(self.background_TOF_monitor_start) != len(self.background_TOF_monitor_stop): entry = validation_message("The monitor background TOF entries have a length mismatch.", "Make sure that all monitor background TOF entries have the same length.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) for key_start, value_start in list(self.background_TOF_monitor_start.items()): if key_start not in self.background_TOF_monitor_stop: entry = validation_message("The monitor background TOF had spectrum number mismatch.", "Make sure that all monitors have entries for start and stop.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) else: value_stop = self.background_TOF_monitor_stop[key_start] if value_start > value_stop: entry = validation_message("Incorrect monitor background TOF bounds.", "Make sure that lower monitor background TOF bound is" " smaller then upper bound.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) if is_invalid: raise ValueError("StateMoveDetector: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def validate(self): # noqa is_invalid = {} # ----------------- # Incident monitor # ----------------- if self.incident_monitor is None and self.default_incident_monitor is None: entry = validation_message("No incident monitor was specified.", "Make sure that incident monitor has been specified.", {"incident_monitor": self.incident_monitor, "default_incident_monitor": self.default_incident_monitor}) is_invalid.update(entry) # -------------- # Transmission, either we need some ROI (ie radius, roi files /mask files) or a transmission monitor # -------------- has_no_transmission_monitor_setting = self.transmission_monitor is None and\ self.default_transmission_monitor is None # noqa has_no_transmission_roi_setting = self.transmission_radius_on_detector is None and\ self.transmission_roi_files is None # noqa if has_no_transmission_monitor_setting and has_no_transmission_roi_setting: entry = validation_message("No transmission settings were specified.", "Make sure that transmission settings are specified.", {"transmission_monitor": self.transmission_monitor, "default_transmission_monitor": self.default_transmission_monitor, "transmission_radius_on_detector": self.transmission_radius_on_detector, "transmission_roi_files": self.transmission_roi_files}) is_invalid.update(entry) # ----------------- # Prompt peak # ----------------- if not is_pure_none_or_not_none([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("Inconsistent prompt peak setting.", "Make sure that you have specified both prompt peak bounds (or none).", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("Incorrect prompt peak bounds.", "Make sure that lower prompt peak bound is smaller then upper bound.", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) # ----------------- # Wavelength rebin # ----------------- if one_is_none([self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type, self.rebin_type]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type, "rebin_type": self.rebin_type}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_low, self.wavelength_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high}) is_invalid.update(entry) if self.use_full_wavelength_range: if self.wavelength_full_range_low is None or self.wavelength_full_range_high is None: entry = validation_message("Incorrect full wavelength settings.", "Make sure that both full wavelength entries have been set.", {"wavelength_full_range_low": self.wavelength_full_range_low, "wavelength_full_range_high": self.wavelength_full_range_high}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_full_range_low, self.wavelength_full_range_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower full wavelength bound is smaller then upper bound.", {"wavelength_full_range_low": self.wavelength_full_range_low, "wavelength_full_range_high": self.wavelength_full_range_high}) is_invalid.update(entry) # ---------------------- # Background correction # ---------------------- if not is_pure_none_or_not_none([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("A general background TOF entry has not been set.", "Make sure that either all general background TOF entries are set or none.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("Incorrect general background TOF bounds.", "Make sure that lower general background TOF bound is smaller then upper bound.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if not is_pure_none_or_not_none([self.background_TOF_roi_start, self.background_TOF_roi_stop]): entry = validation_message("A ROI background TOF entry has not been set.", "Make sure that either all ROI background TOF entries are set or none.", {"background_TOF_roi_start": self.background_TOF_roi_start, "background_TOF_roi_stop": self.background_TOF_roi_stop}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.background_TOF_roi_start, self.background_TOF_roi_stop]): entry = validation_message("Incorrect ROI background TOF bounds.", "Make sure that lower ROI background TOF bound is smaller then upper bound.", {"background_TOF_roi_start": self.background_TOF_roi_start, "background_TOF_roi_stop": self.background_TOF_roi_stop}) is_invalid.update(entry) if not is_pure_none_or_not_none([self.background_TOF_monitor_start, self.background_TOF_monitor_stop]): entry = validation_message("A monitor background TOF entry has not been set.", "Make sure that either all monitor background TOF entries are set or none.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) if self.background_TOF_monitor_start is not None and self.background_TOF_monitor_stop is not None: if len(self.background_TOF_monitor_start) != len(self.background_TOF_monitor_stop): entry = validation_message("The monitor background TOF entries have a length mismatch.", "Make sure that all monitor background TOF entries have the same length.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) for key_start, value_start in self.background_TOF_monitor_start.items(): if key_start not in self.background_TOF_monitor_stop: entry = validation_message("The monitor background TOF had spectrum number mismatch.", "Make sure that all monitors have entries for start and stop.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) else: value_stop = self.background_TOF_monitor_stop[key_start] if value_start > value_stop: entry = validation_message("Incorrect monitor background TOF bounds.", "Make sure that lower monitor background TOF bound is" " smaller then upper bound.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) # ----- # Fit # ----- self.fit[DataType.to_string(DataType.Sample)].validate() self.fit[DataType.to_string(DataType.Can)].validate() if is_invalid: raise ValueError("StateCalculateTransmission: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))
def validate(self): # noqa is_invalid = {} # ----------------- # Incident monitor # ----------------- if self.incident_monitor is None and self.default_incident_monitor is None: entry = validation_message("No incident monitor was specified.", "Make sure that incident monitor has been specified.", {"incident_monitor": self.incident_monitor, "default_incident_monitor": self.default_incident_monitor}) is_invalid.update(entry) # -------------- # Transmission, either we need some ROI (ie radius, roi files /mask files) or a transmission monitor # -------------- has_no_transmission_monitor_setting = self.transmission_monitor is None and\ self.default_transmission_monitor is None # noqa has_no_transmission_roi_setting = self.transmission_radius_on_detector is None and\ self.transmission_roi_files is None # noqa if has_no_transmission_monitor_setting and has_no_transmission_roi_setting: entry = validation_message("No transmission settings were specified.", "Make sure that transmission settings are specified.", {"transmission_monitor": self.transmission_monitor, "default_transmission_monitor": self.default_transmission_monitor, "transmission_radius_on_detector": self.transmission_radius_on_detector, "transmission_roi_files": self.transmission_roi_files}) is_invalid.update(entry) # ----------------- # Prompt peak # ----------------- if not is_pure_none_or_not_none([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("Inconsistent prompt peak setting.", "Make sure that you have specified both prompt peak bounds (or none).", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.prompt_peak_correction_min, self.prompt_peak_correction_max]): entry = validation_message("Incorrect prompt peak bounds.", "Make sure that lower prompt peak bound is smaller then upper bound.", {"prompt_peak_correction_min": self.prompt_peak_correction_min, "prompt_peak_correction_max": self.prompt_peak_correction_max}) is_invalid.update(entry) # ----------------- # Wavelength rebin # ----------------- if one_is_none([self.wavelength_low, self.wavelength_high, self.wavelength_step, self.wavelength_step_type, self.wavelength_step_type, self.rebin_type]): entry = validation_message("A wavelength entry has not been set.", "Make sure that all entries are set.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high, "wavelength_step": self.wavelength_step, "wavelength_step_type": self.wavelength_step_type, "rebin_type": self.rebin_type}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_low, self.wavelength_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower wavelength bound is smaller then upper bound.", {"wavelength_low": self.wavelength_low, "wavelength_high": self.wavelength_high}) is_invalid.update(entry) if self.use_full_wavelength_range: if self.wavelength_full_range_low is None or self.wavelength_full_range_high is None: entry = validation_message("Incorrect full wavelength settings.", "Make sure that both full wavelength entries have been set.", {"wavelength_full_range_low": self.wavelength_full_range_low, "wavelength_full_range_high": self.wavelength_full_range_high}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.wavelength_full_range_low, self.wavelength_full_range_high]): entry = validation_message("Incorrect wavelength bounds.", "Make sure that lower full wavelength bound is smaller then upper bound.", {"wavelength_full_range_low": self.wavelength_full_range_low, "wavelength_full_range_high": self.wavelength_full_range_high}) is_invalid.update(entry) # ---------------------- # Background correction # ---------------------- if not is_pure_none_or_not_none([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("A general background TOF entry has not been set.", "Make sure that either all general background TOF entries are set or none.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.background_TOF_general_start, self.background_TOF_general_stop]): entry = validation_message("Incorrect general background TOF bounds.", "Make sure that lower general background TOF bound is smaller then upper bound.", {"background_TOF_general_start": self.background_TOF_general_start, "background_TOF_general_stop": self.background_TOF_general_stop}) is_invalid.update(entry) if not is_pure_none_or_not_none([self.background_TOF_roi_start, self.background_TOF_roi_stop]): entry = validation_message("A ROI background TOF entry has not been set.", "Make sure that either all ROI background TOF entries are set or none.", {"background_TOF_roi_start": self.background_TOF_roi_start, "background_TOF_roi_stop": self.background_TOF_roi_stop}) is_invalid.update(entry) if is_not_none_and_first_larger_than_second([self.background_TOF_roi_start, self.background_TOF_roi_stop]): entry = validation_message("Incorrect ROI background TOF bounds.", "Make sure that lower ROI background TOF bound is smaller then upper bound.", {"background_TOF_roi_start": self.background_TOF_roi_start, "background_TOF_roi_stop": self.background_TOF_roi_stop}) is_invalid.update(entry) if not is_pure_none_or_not_none([self.background_TOF_monitor_start, self.background_TOF_monitor_stop]): entry = validation_message("A monitor background TOF entry has not been set.", "Make sure that either all monitor background TOF entries are set or none.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) if self.background_TOF_monitor_start is not None and self.background_TOF_monitor_stop is not None: if len(self.background_TOF_monitor_start) != len(self.background_TOF_monitor_stop): entry = validation_message("The monitor background TOF entries have a length mismatch.", "Make sure that all monitor background TOF entries have the same length.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) for key_start, value_start in list(self.background_TOF_monitor_start.items()): if key_start not in self.background_TOF_monitor_stop: entry = validation_message("The monitor background TOF had spectrum number mismatch.", "Make sure that all monitors have entries for start and stop.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) else: value_stop = self.background_TOF_monitor_stop[key_start] if value_start > value_stop: entry = validation_message("Incorrect monitor background TOF bounds.", "Make sure that lower monitor background TOF bound is" " smaller then upper bound.", {"background_TOF_monitor_start": self.background_TOF_monitor_start, "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) # ----- # Fit # ----- self.fit[DataType.to_string(DataType.Sample)].validate() self.fit[DataType.to_string(DataType.Can)].validate() if is_invalid: raise ValueError("StateCalculateTransmission: The provided inputs are illegal. " "Please see: {0}".format(json.dumps(is_invalid)))