Errors and Warnings
GalSim uses some custom Exception and Warning classes when it finds some exceptional occurrence:
GalSimErrorThis is the base class for all other GalSim exceptions. So you can catch this exception if you want to catch just the exceptions raised by GalSim. It is roughly analogous to a
RuntimeError.GalSimValueErrorThis indicates that you provided an invalid value for an argument to a function. It includes attributes that tell you about what value you provided and sometimes about the allowed values.
GalSimKeyErrorThis indicates that you tried to access some dict-like object (e.g.
FitsHeaderorCatalog) with an invalid key.GalSimIndexErrorThis indicates that you tried to access some list-like object (e.g.
RealGalaxyCatalog) with an invalid index.GalSimRangeErrorThis indicates that you provided a value that is outside of the allowed range. It includes attributes indicating what value you provided and what the allowed range is.
GalSimBoundsErrorThis indicates that you used a
Positionoutside of the allowedBounds. It is basically aGalSimRangeError, but in two dimensions. It includes attributes that tell you thePositionand the allowedBounds.GalSimUndefinedBoundsErrorThis indicates that you are trying to use an undefined
Boundsinstance in a context where it must be defined.GalSimImmutableErrorThis indicates that you tried to change an immutable
Imagein some way.GalSimIncompatibleValuesErrorThis indicates that two or more values that you provided to some function are not compatible with each other. It includes attributes telling you the two values that are incompatible.
GalSimSEDErrorThis indicates that you tried to use an SED in a context where it is required to be either spectral or dimensionless, and you provided the other kind.
GalSimHSMErrorThis indicates that the HSM algorithm raised some kind of exception.
GalSimFFTSizeErrorThis indicates that something you did requires a very large FFT, in particular one that is larger than the relevant
gsparams.maximum_fft_sizeparameter. It includes attributes that tell you both the size that was required and how much memory it would have used, so you can decide whether you want to adjust some parameters of your simulation or to adjust the object’sGSParamsoptions.GalSimConfigErrorThis indicates that there was some kind of failure processing a configuration file.
GalSimConfigValueErrorThis indicates that some parameter in your configuration file is an invalid value.
GalSimNotImplementedErrorThis indicates that you tried to do something that is not implemented currently.
GalSimWarningThis indicates that you did something that is not necessarily an error, but we think it is likely that you didn’t do something right.
GalSimDeprecationWarningThis indicates that you are using functionality that is currently deprecated. Your code will generally continue to work until the next major upgrade, but you are encouraged to update your code to the new syntax.
- class galsim.GalSimValueError(message, value, allowed_values=None)[source]
Bases:
GalSimError,ValueErrorA GalSim-specific exception class indicating that some user-input value is invalid.
- Attributes:
value – The invalid value
allowed_values – A list of allowed values if appropriate (may be None)
- class galsim.GalSimKeyError(message, key)[source]
Bases:
GalSimError,KeyErrorA GalSim-specific exception class indicating an attempt to access a dict-like object with an invalid key.
- Attributes:
key – The invalid key
- class galsim.GalSimIndexError(message, index)[source]
Bases:
GalSimError,IndexErrorA GalSim-specific exception class indicating an attempt to access a list-like object with an invalid index.
- Attributes:
index – The invalid index
- class galsim.GalSimRangeError(message, value, min, max=None)[source]
Bases:
GalSimError,ValueErrorA GalSim-specific exception class indicating that some user-input value is outside of the allowed range of values.
- Attributes:
value – The invalid value
min – The minimum allowed value (may be None)
max – The maximum allowed value (may be None)
- class galsim.GalSimBoundsError(message, pos, bounds)[source]
Bases:
GalSimError,ValueErrorA GalSim-specific exception class indicating that some user-input position is outside of the allowed bounds.
- Attributes:
pos – The invalid position
bounds – The bounds in which it was expected to fall
- class galsim.GalSimUndefinedBoundsError[source]
Bases:
GalSimErrorA GalSim-specific exception class indicating an attempt to access the extent of a
Boundsinstance that has not yet been defined.
- class galsim.GalSimImmutableError(message, image)[source]
Bases:
GalSimErrorA GalSim-specific exception class indicating an attempt to modify an immutable image.
- Attributes:
image – The image that the user attempted to modify
- class galsim.GalSimIncompatibleValuesError(message, values={}, **kwargs)[source]
Bases:
GalSimError,ValueError,TypeErrorA GalSim-specific exception class indicating that 2 or more user-input values are incompatible as given.
- Attributes:
values – A dict of {name : value} giving the values that in combination are invalid.
- class galsim.GalSimSEDError(message, sed)[source]
Bases:
GalSimError,TypeErrorA GalSim-specific exception class indicating an attempt to do something invalid for the kind of
SEDthat is present. Typically involving a dimensionlessSEDwhere a spectralSEDis required (or vice versa).- Attributes:
sed – The invalid
SED
- class galsim.GalSimHSMError[source]
Bases:
GalSimErrorA GalSim-specific exception class indicating some kind of failure of the HSM algorithms
- class galsim.GalSimFFTSizeError(message, size)[source]
Bases:
GalSimErrorA GalSim-specific exception class indicating that a requested FFT exceeds the relevant maximum_fft_size.
- Attributes:
size – The size that was deemed too large
mem – The estimated memory that would be required (in GB) for the FFT.
- class galsim.GalSimConfigError[source]
Bases:
GalSimError,ValueErrorA GalSim-specific exception class indicating some kind of failure processing a configuration file.
- class galsim.GalSimConfigValueError(message, value, allowed_values=None)[source]
Bases:
GalSimValueError,GalSimConfigErrorA GalSim-specific exception class indicating that a config entry has an invalid value.
- Attributes:
value – The invalid value
allowed_values – A list of allowed values if appropriate (may be None)
- class galsim.GalSimNotImplementedError[source]
Bases:
GalSimError,NotImplementedErrorA GalSim-specific exception class indicating that the feature being attempted is not currently implemented.
If this is a feature you feel you need, please open an issue about it at
Even better, feel free to offer to contribute code to implement the feature.
- class galsim.GalSimDeprecationWarning[source]
Bases:
GalSimWarningA GalSim-specific warning class used for deprecation warnings.