__all__ = [
"DegeneracyWarning",
"ConvergenceFailure",
"MaxiterReached",
"StepProblem",
"CorrelatedErrors",
"MissingTOAs",
"PropertyAttributeError",
"TimingModelError",
"MissingParameter",
"AliasConflict",
"UnknownParameter",
"UnknownBinaryModel",
"MissingBinaryError",
"PINTPrecisionError",
"PrefixError",
"InvalidModelParameters",
"ComponentConflict",
"ClockCorrectionError",
"NoClockCorrections",
"ClockCorrectionOutOfRange",
]
# originally from fitter.py
[docs]class DegeneracyWarning(UserWarning):
pass
[docs]class ConvergenceFailure(ValueError):
pass
[docs]class MaxiterReached(ConvergenceFailure):
pass
[docs]class StepProblem(ConvergenceFailure):
pass
# from timing_model.py
[docs]class MissingTOAs(ValueError):
"""Some parameter does not describe any TOAs."""
def __init__(self, parameter_names):
if isinstance(parameter_names, str):
parameter_names = [parameter_names]
if len(parameter_names) == 1:
msg = f"Parameter {parameter_names[0]} does not correspond to any TOAs: you might need to run `model.find_empty_masks(toas, freeze=True)`"
elif len(parameter_names) > 1:
msg = f"Parameters {' '.join(parameter_names)} do not correspond to any TOAs: you might need to run `model.find_empty_masks(toas, freeze=True)`"
else:
raise ValueError("Incorrect attempt to construct MissingTOAs")
super().__init__(msg)
self.parameter_names = parameter_names
[docs]class PropertyAttributeError(ValueError):
pass
[docs]class TimingModelError(ValueError):
"""Generic base class for timing model errors."""
pass
[docs]class MissingParameter(TimingModelError):
"""A required model parameter was not included.
Parameters
----------
module
name of the model class that raised the error
param
name of the missing parameter
msg
additional message
"""
def __init__(self, module, param, msg=None):
super().__init__(msg)
self.module = module
self.param = param
self.msg = msg
def __str__(self):
result = f"{self.module}.{self.param}"
if self.msg is not None:
result += "\n " + self.msg
return result
[docs]class AliasConflict(TimingModelError):
"""If the same alias is used for different parameters."""
pass
[docs]class UnknownParameter(TimingModelError):
"""Signal that a parameter name does not match any PINT parameters and their aliases."""
pass
[docs]class UnknownBinaryModel(TimingModelError):
"""Signal that the par file requested a binary model not in PINT."""
def __init__(self, message, suggestion=None):
super().__init__(message)
self.suggestion = suggestion
def __str__(self):
base_message = super().__str__()
if self.suggestion:
return f"{base_message} Perhaps use {self.suggestion}?"
return base_message
[docs]class MissingBinaryError(TimingModelError):
"""Error for missing BINARY parameter."""
pass
# from utils.py
[docs]class PINTPrecisionError(RuntimeError):
pass
[docs]class PrefixError(ValueError):
pass
# from models.parameter.py
[docs]class InvalidModelParameters(ValueError):
pass
# models.model_builder.py
[docs]class ComponentConflict(ValueError):
"""Error for multiple components can be select but no other indications."""
# observatories.__init__.py
[docs]class ClockCorrectionError(RuntimeError):
"""Unspecified error doing clock correction."""
pass
[docs]class NoClockCorrections(ClockCorrectionError):
"""Clock corrections are expected but none are available."""
pass
[docs]class ClockCorrectionOutOfRange(ClockCorrectionError):
"""Clock corrections are available but the requested time is not covered."""
pass