Errors and Warnings

GalSim uses some custom Exception and Warning classes when it finds some exceptional occurrence:

GalSimError

This 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.

GalSimValueError

This 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.

GalSimKeyError

This indicates that you tried to access some dict-like object (e.g. FitsHeader or Catalog) with an invalid key.

GalSimIndexError

This indicates that you tried to access some list-like object (e.g. RealGalaxyCatalog) with an invalid index.

GalSimRangeError

This 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.

GalSimBoundsError

This indicates that you used a Position outside of the allowed Bounds. It is basically a GalSimRangeError, but in two dimensions. It includes attributes that tell you the Position and the allowed Bounds.

GalSimUndefinedBoundsError

This indicates that you are trying to use an undefined Bounds instance in a context where it must be defined.

GalSimImmutableError

This indicates that you tried to change an immutable Image in some way.

GalSimIncompatibleValuesError

This 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.

GalSimSEDError

This 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.

GalSimHSMError

This indicates that the HSM algorithm raised some kind of exception.

GalSimFFTSizeError

This indicates that something you did requires a very large FFT, in particular one that is larger than the relevant gsparams.maximum_fft_size parameter. 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’s GSParams options.

GalSimConfigError

This indicates that there was some kind of failure processing a configuration file.

GalSimConfigValueError

This indicates that some parameter in your configuration file is an invalid value.

GalSimNotImplementedError

This indicates that you tried to do something that is not implemented currently.

GalSimWarning

This indicates that you did something that is not necessarily an error, but we think it is likely that you didn’t do something right.

GalSimDeprecationWarning

This 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.GalSimError[source]

The base class for GalSim-specific run-time errors.

class galsim.GalSimValueError(message, value, allowed_values=None)[source]

Bases: GalSimError, ValueError

A 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, KeyError

A 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, IndexError

A 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, ValueError

A 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, ValueError

A 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: GalSimError

A GalSim-specific exception class indicating an attempt to access the extent of a Bounds instance that has not yet been defined.

class galsim.GalSimImmutableError(message, image)[source]

Bases: GalSimError

A 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, TypeError

A 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, TypeError

A GalSim-specific exception class indicating an attempt to do something invalid for the kind of SED that is present. Typically involving a dimensionless SED where a spectral SED is required (or vice versa).

Attributes:

sed – The invalid SED

class galsim.GalSimHSMError[source]

Bases: GalSimError

A GalSim-specific exception class indicating some kind of failure of the HSM algorithms

class galsim.GalSimFFTSizeError(message, size)[source]

Bases: GalSimError

A 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, ValueError

A GalSim-specific exception class indicating some kind of failure processing a configuration file.

class galsim.GalSimConfigValueError(message, value, allowed_values=None)[source]

Bases: GalSimValueError, GalSimConfigError

A 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, NotImplementedError

A 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.GalSimWarning[source]

Bases: UserWarning

The base class for GalSim-emitted warnings.

class galsim.GalSimDeprecationWarning[source]

Bases: GalSimWarning

A GalSim-specific warning class used for deprecation warnings.