本文整理汇总了Python中mantid.kernel.Logger.warning方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.warning方法的具体用法?Python Logger.warning怎么用?Python Logger.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.kernel.Logger
的用法示例。
在下文中一共展示了Logger.warning方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unicode_logger
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
def test_unicode_logger(self):
logger = Logger("LoggerTest")
self.assertTrue(isinstance(logger, Logger))
for att in ['fatal', 'error', 'warning', 'notice', 'information', 'debug']:
if not hasattr(logger, att):
self.fail("Logger object does not have the required attribute '%s'" % att)
logger.fatal('This is a test')
logger.error('This is a test')
logger.warning('This is a test')
logger.notice('This is a test')
logger.information('This is a test')
logger.debug('This is a test')
示例2: MaskingTablePresenter
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
class MaskingTablePresenter(object):
DISPLAY_WORKSPACE_NAME = "__sans_mask_display_dummy_workspace"
class ConcreteMaskingTableListener(MaskingTable.MaskingTableListener):
def __init__(self, presenter):
super(MaskingTablePresenter.ConcreteMaskingTableListener, self).__init__()
self._presenter = presenter
def on_row_changed(self):
self._presenter.on_row_changed()
def on_update_rows(self):
self._presenter.on_update_rows()
def on_display(self):
self._presenter.on_display()
class DisplayMaskListener(WorkHandler.WorkListener):
def __init__(self, presenter):
super(MaskingTablePresenter.DisplayMaskListener, self).__init__()
self._presenter = presenter
def on_processing_finished(self, result):
self._presenter.on_processing_finished_masking_display(result)
def on_processing_error(self, error):
self._presenter.on_processing_error_masking_display(error)
def __init__(self, parent_presenter):
super(MaskingTablePresenter, self).__init__()
self._view = None
self._parent_presenter = parent_presenter
self._work_handler = WorkHandler()
self._logger = Logger("SANS")
def on_row_changed(self):
row_index = self._view.get_current_row()
state = self.get_state(row_index, file_lookup=False)
if state:
self.display_masking_information(state)
def on_display(self):
# Get the state information for the selected row.
# Disable the button
self._view.set_display_mask_button_to_processing()
try:
row_index = self._view.get_current_row()
state = self.get_state(row_index)
except Exception as e:
self.on_processing_error_masking_display(e)
raise Exception(str(e)) # propagate errors for run_tab_presenter to deal with
else:
if not state:
self._logger.information("You can only show a masked workspace if a user file has been loaded and there"
"valid sample scatter entry has been provided in the selected row.")
return
# Run the task
listener = MaskingTablePresenter.DisplayMaskListener(self)
state_copy = copy.copy(state)
self._work_handler.process(listener, load_and_mask_workspace, 0, state_copy, self.DISPLAY_WORKSPACE_NAME)
def on_processing_finished_masking_display(self, result):
# Enable button
self._view.set_display_mask_button_to_normal()
# Display masked workspace
self._display(result)
def on_processing_error_masking_display(self, error):
self._logger.warning("There has been an error. See more: {}".format(error))
# Enable button
self._view.set_display_mask_button_to_normal()
def on_processing_error(self, error):
pass
def on_update_rows(self):
"""
Update the row selection in the combobox
"""
current_row_index = self._view.get_current_row()
valid_row_indices = self._parent_presenter.get_row_indices()
new_row_index = -1
if current_row_index in valid_row_indices:
new_row_index = current_row_index
elif len(valid_row_indices) > 0:
new_row_index = valid_row_indices[0]
self._view.update_rows(valid_row_indices)
if new_row_index != -1:
self.set_row(new_row_index)
self.on_row_changed()
def set_row(self, index):
self._view.set_row(index)
#.........这里部分代码省略.........
示例3: SettingsDiagnosticPresenter
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
class SettingsDiagnosticPresenter(object):
class ConcreteSettingsDiagnosticTabListener(SettingsDiagnosticTab.SettingsDiagnosticTabListener):
def __init__(self, presenter):
super(SettingsDiagnosticPresenter.ConcreteSettingsDiagnosticTabListener, self).__init__()
self._presenter = presenter
def on_row_changed(self):
self._presenter.on_row_changed()
def on_update_rows(self):
self._presenter.on_update_rows()
def on_collapse(self):
self._presenter.on_collapse()
def on_expand(self):
self._presenter.on_expand()
def on_save_state_to_file(self):
self._presenter.on_save_state()
def __init__(self, parent_presenter):
super(SettingsDiagnosticPresenter, self).__init__()
self._view = None
self._parent_presenter = parent_presenter
# Logger
self.gui_logger = Logger("SANS GUI LOGGER")
def on_collapse(self):
self._view.collapse()
def on_expand(self):
self._view.expand()
def on_row_changed(self):
try:
row_index = self._view.get_current_row()
state = self.get_state(row_index)
if state:
self.display_state_diagnostic_tree(state)
except RuntimeError as e:
self.gui_logger.error(str(e))
self._parent_presenter.display_warning_box('Warning', 'Unable to find files.', str(e))
def on_update_rows(self):
"""
Update the row selection in the combobox
"""
current_row_index = self._view.get_current_row()
valid_row_indices = self._parent_presenter.get_row_indices()
new_row_index = -1
if current_row_index in valid_row_indices:
new_row_index = current_row_index
elif len(valid_row_indices) > 0:
new_row_index = valid_row_indices[0]
self._view.update_rows(valid_row_indices)
if new_row_index != -1:
self.set_row(new_row_index)
self.on_row_changed()
def set_row(self, index):
self._view.set_row(index)
def set_view(self, view):
if view:
self._view = view
# Set up row selection listener
listener = SettingsDiagnosticPresenter.ConcreteSettingsDiagnosticTabListener(self)
self._view.add_listener(listener)
# Set the default gui
self._set_default_gui()
def _set_default_gui(self):
self._view.update_rows([])
self.display_state_diagnostic_tree(state=None)
def get_state(self, index):
return self._parent_presenter.get_state_for_row(index)
def display_state_diagnostic_tree(self, state):
# Convert to dict before passing the state to the view
if state is not None:
state = state.property_manager
self._view.set_tree(state)
def on_save_state(self):
# Get the save location
save_location = self._view.get_save_location()
# Check if it exists
path_dir = os.path.dirname(save_location)
if not path_dir:
self.gui_logger.warning("The provided save location for the SANS state does not seem to exist. "
"Please provide a validate path")
return
#.........这里部分代码省略.........
示例4: BilbySANSDataProcessor
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
#.........这里部分代码省略.........
elif not ws_tranEmp.isHistogramData():
inputs["TransmissionEmptyBeamWorkspace"] = "has to be a histogram"
if ws_tranMsk:
isinstance(ws_tranMsk, IMaskWorkspace)
inputs = self.check_geometry_and_cuts(inputs)
return inputs
def check_geometry_and_cuts(self, inputs):
scale = self.getProperty("ScalingFactor").value
thickness = self.getProperty("SampleThickness").value
radiuscut = self.getProperty("RadiusCut").value
wavecut = self.getProperty("WaveCut").value
if scale <= 0.0:
inputs["ScalingFactor"] = "has to be greater than zero"
if thickness <= 0.0:
inputs["SampleThickness"] = "has to be greater than zero"
if radiuscut < 0.0:
inputs["radiuscut"] = "has to be equal or greater than zero"
if wavecut < 0.0:
inputs["wavecut"] = "has to be equal or greater than zero"
return inputs
def PyExec(self):
self.sanslog.warning(
"SANSDataProcessing is in the beta phase of development. Properties may change without notice.")
self.sanslog.warning("Log on the changes is recorded in the body of SANSDataProcessor.py file")
# -- Get Arguments --
ws_sam = self.getProperty("InputWorkspace").value
ws_samMsk = self.getProperty("InputMaskingWorkspace").value
ws_blk = self.getProperty("BlockedBeamWorkspace").value
ws_emp = self.getProperty("EmptyBeamSpectrumShapeWorkspace").value
ws_sen = self.getProperty("SensitivityCorrectionMatrix").value
ws_tranSam = self.getProperty("TransmissionWorkspace").value
ws_tranEmp = self.getProperty("TransmissionEmptyBeamWorkspace").value
ws_tranMsk = self.getProperty("TransmissionMaskingWorkspace").value
scale = self.getProperty("ScalingFactor").value
thickness = self.getProperty("SampleThickness").value
binning_wavelength = self.getProperty("BinningWavelength").value
binning_q = self.getProperty("BinningQ").value
wavecut = self.getProperty("WaveCut").value
radiuscut = self.getProperty("RadiusCut").value
binning_wavelength_transm = self.getProperty("BinningWavelengthTransm").value
fitmethod = self.getProperty("FitMethod").value
polynomialorder = self.getProperty("PolynomialOrder").value
time_mode = self.getProperty(
"TimeMode").value
# True if External time frame (i.e. choppers), False if Internal time frames (Neutron Velocity Selector)
account_for_gravity = self.getProperty("AccountForGravity").value
示例5: float
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
# Wavelength interval: if reduction on wavelength intervals is needed
wavelength_interval_input = current_reduction_settings[0]["wavelength_intervals"].lower()
wavelength_intervals = BilbyCustomFunctions_Reduction.string_boolean(wavelength_interval_input)
wavelength_intervals_original = wavelength_intervals
wav_delta = 0.0 # set the value, needed for the "wavelengh_slices" function
try:
Lt0 = float(ws_empty.run().getProperty("Lt0").value)
Ltof_curtainl = float(ws_empty.run().getProperty("Ltof_curtainl").value)
Ltof_curtainu = float(ws_empty.run().getProperty("Ltof_curtainu").value)
Ltof_det = float(ws_empty.run().getProperty("Ltof_det").value)
resolution_left_curtain = Lt0 / Ltof_curtainl
resolution_rear = Lt0 / Ltof_det
except:
ansto_logger.warning("Lt0, Ltof_curtainl, Ltof_curtainu, Ltof_det are not defined")
# If needed to reduce 2D - this option is a defining one for the overall reduction
reduce_2D_input = current_reduction_settings[0]["reduce_2D"].lower()
reduce_2D = BilbyCustomFunctions_Reduction.string_boolean(reduce_2D_input)
if reduce_2D:
print "2D reduction is performing. Q interval and number of points are taking into account; Q-binning intervals are ignored."
try:
number_data_points_2D = float(current_reduction_settings[0]["2D_number_data_points"]) # for 2D Q-binning is not intuitive, hence only number of points is needed
except:
raise ValueError("Number of points shall be given")
plot_2D = current_reduction_settings[0]["plot_2D"].lower()
plot_2D = BilbyCustomFunctions_Reduction.string_boolean(plot_2D)
binning_q[1] = (binning_q[0] + binning_q[2]) / number_data_points_2D # To replace deltaQ from the input file
示例6: BeamCentrePresenter
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
class BeamCentrePresenter(object):
class ConcreteBeamCentreListener(BeamCentre.BeamCentreListener):
def __init__(self, presenter):
self._presenter = presenter
def on_run_clicked(self):
self._presenter.on_run_clicked()
class CentreFinderListener(WorkHandler.WorkListener):
def __init__(self, presenter):
super(BeamCentrePresenter.CentreFinderListener, self).__init__()
self._presenter = presenter
def on_processing_finished(self, result):
self._presenter.on_processing_finished_centre_finder(result)
def on_processing_error(self, error):
self._presenter.on_processing_error_centre_finder(error)
def __init__(self, parent_presenter, WorkHandler, BeamCentreModel, SANSCentreFinder):
super(BeamCentrePresenter, self).__init__()
self._view = None
self._parent_presenter = parent_presenter
self._work_handler = WorkHandler()
self._logger = Logger("SANS")
self._beam_centre_model = BeamCentreModel(SANSCentreFinder)
def set_view(self, view):
if view:
self._view = view
# Set up run listener
listener = BeamCentrePresenter.ConcreteBeamCentreListener(self)
self._view.add_listener(listener)
# Set the default gui
self._view.set_options(self._beam_centre_model)
def on_update_instrument(self, instrument):
self._beam_centre_model.set_scaling(instrument)
self._view.on_update_instrument(instrument)
def on_update_rows(self):
file_information = self._parent_presenter._table_model.get_file_information_for_row(0)
if file_information:
self._beam_centre_model.reset_to_defaults_for_instrument(file_information=file_information)
self._view.set_options(self._beam_centre_model)
def on_processing_finished_centre_finder(self, result):
# Enable button
self._view.set_run_button_to_normal()
# Update Centre Positions in model and GUI
if self._beam_centre_model.update_lab:
self._beam_centre_model.lab_pos_1 = result['pos1']
self._beam_centre_model.lab_pos_2 = result['pos2']
self._view.lab_pos_1 = self._beam_centre_model.lab_pos_1 * self._beam_centre_model.scale_1
self._view.lab_pos_2 = self._beam_centre_model.lab_pos_2 * self._beam_centre_model.scale_2
if self._beam_centre_model.update_hab:
self._beam_centre_model.hab_pos_1 = result['pos1']
self._beam_centre_model.hab_pos_2 = result['pos2']
self._view.hab_pos_1 = self._beam_centre_model.hab_pos_1 * self._beam_centre_model.scale_1
self._view.hab_pos_2 = self._beam_centre_model.hab_pos_2 * self._beam_centre_model.scale_2
def on_processing_error_centre_finder(self, error):
self._logger.warning("There has been an error. See more: {}".format(error))
self._view.set_run_button_to_normal()
def on_processing_error(self, error):
self._view.set_run_button_to_normal()
def on_run_clicked(self):
# Get the state information for the first row.
state = self._parent_presenter.get_state_for_row(0)
if not state:
self._logger.information("You can only calculate the beam centre if a user file has been loaded and there"
"valid sample scatter entry has been provided in the selected row.")
return
# Disable the button
self._view.set_run_button_to_processing()
#Update model
self._update_beam_model_from_view()
# Run the task
listener = BeamCentrePresenter.CentreFinderListener(self)
state_copy = copy.copy(state)
self._work_handler.process(listener, self._beam_centre_model.find_beam_centre, 0, state_copy)
def _update_beam_model_from_view(self):
self._beam_centre_model.r_min = self._view.r_min
self._beam_centre_model.r_max = self._view.r_max
self._beam_centre_model.max_iterations = self._view.max_iterations
self._beam_centre_model.tolerance = self._view.tolerance
self._beam_centre_model.left_right = self._view.left_right
self._beam_centre_model.verbose = self._view.verbose
self._beam_centre_model.COM = self._view.COM
self._beam_centre_model.up_down = self._view.up_down
#.........这里部分代码省略.........
示例7: SANSDataProcessor
# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import warning [as 别名]
#.........这里部分代码省略.........
elif ws_sen.getAxis(0).getUnit().symbol():
inputs["SensitivityCorrectionMatrix"] = "has to be unitless"
tran_histograms = ws_transam.getNumberHistograms()
if tran_histograms <= 0:
inputs["TransmissionWorkspace"] = "hast to contain at least one spectrum"
elif not ws_transam.isHistogramData():
inputs["TransmissionWorkspace"] = "has to be a histogram"
if ws_tranemp.getNumberHistograms() != tran_histograms:
inputs["TransmissionEmptyBeamWorkspace"] = "must have same number of spectra as the TransmissionWorkspace"
elif not ws_tranEmp.isHistogramData():
inputs["TransmissionEmptyBeamWorkspace"] = "has to be a histogram"
if type(ws_tranmsk).__name__ != 'MaskWorkspace':
inputs["TransmissionMaskingWorkspace"] = "has to be a MaskWorkspace"
elif ws_tranmsk.getNumberHistograms() != sam_histograms:
inputs["TransmissionMaskingWorkspace"] = "must have same number of spectra as the TransmissionWorkspace"
if scale <= 0.0:
inputs["ScalingFactor"] = "has to be greater than zero"
if thickness <= 0.0:
inputs["SampleThickness"] = "has to be greater than zero"
return inputs # - CHECK -why need it? I would believe it is optional
if radiuscut < 0.0:
inputs["radiuscut"] = "has to be equal or greater than zero"
if wavecut < 0.0:
inputs["wavecut"] = "has to be equal or greater than zero"
def PyExec(self):
self.sanslog.warning(
"SANSDataProcessing is in the beta phase of development. Properties may change without notice.")
self.sanslog.warning("Log on the changes is recorded in the body of SANSDataProcessor.py file")
# -- Get Arguments --
ws_sam = self.getProperty("InputWorkspace").value
ws_sammsk = self.getProperty("InputMaskingWorkspace").value
ws_blk = self.getProperty("BlockedBeamWorkspace").value
ws_emp = self.getProperty("EmptyBeamSpectrumShapeWorkspace").value
ws_sen = self.getProperty("SensitivityCorrectionMatrix").value
ws_transam = self.getProperty("TransmissionWorkspace").value
ws_tranemp = self.getProperty("TransmissionEmptyBeamWorkspace").value
ws_tranmsk = self.getProperty("TransmissionMaskingWorkspace").value
scale = self.getProperty("ScalingFactor").value
thickness = self.getProperty("SampleThickness").value
binning_wavelength = self.getProperty("BinningWavelength").value
binning_q = self.getProperty("BinningQ").value
wavecut = self.getProperty("WaveCut").value
radiuscut = self.getProperty("RadiusCut").value
binning_wavelength_transm = self.getProperty("BinningWavelengthTransm").value
fitmethod = self.getProperty("FitMethod").value
polynomialorder = self.getProperty("PolynomialOrder").value
time_mode = self.getProperty(
"TimeMode").value
# True if External time frame (i.e. choppers), False if Internal time frames (Neutron Velocity Selector)
account_for_gravity = self.getProperty("AccountForGravity").value