Last modified: 18 December 2023

What is the function of a Sherpa model's "cache" attribute?


Model caching is available in Sherpa for each instance of a model component via the "cache" attribute ("model.cache"), for reducing the time taken to evaluate the model when fitting is expected to be slow. This function is useful in those instances when a model is evaluated multiple times without a change in parameters; during simultaneous fitting of multiple data sets - e.g., fitting the four grating arms of a single Chandra grating data set or joint Chandra-Suzaku data - and when it is necessary to allow for different cross-normalization constants in the model. Examples of computationally intensive models include a subset of Comptonization models, jet models, ionized absorption models, and relativistic line models.

The Sherpa model caching feature offers fitting speed improvements approaching a factor equal to the number of data sets that are being fit - and on occasion, can noticeably reduce the time taken to fit a single data set.

Model caching is disabled by setting the "cache" attribute of an instance of a model component to "0", and turned on by setting it to any non-zero integer number.

sherpa> set_source(2, xswabs.a1*xsbbody.b1)
sherpa> a1.cache=0
sherpa> b1.cache=0

See the set_source ahelp file for more examples of usage of the model "cache" attribute.