run_tolerances

marxs.design.tolerancing.run_tolerances(photons_in, instrum, wigglefunc, wiggleparts, parameters, analyzefunc)[source] [edit on github]

Run tolerancing calculations for a range of parameters

This function takes an instrument configuration and a function to change one aspect of it. For every change it runs a simulations and calculates a figure of merit. As the name indicates, this function is designed to derive alignment tolerances for certain instrument parts but it might be general enough for other parameter studies in instrument design.

Parameters:
photons_inastropy.table.Table

Input photons list. To speed up the computation, it is useful if photon list has been run through all elements of the instrument that are located before the first element that is toleranced here.

instrummarxs.simulator.Sequence object

An instance of the instrument which contains all elements that photons_in still have to pass. This can include elements that are toleranced in this run and those that are located behind them.

wigglefunccallable

Function that modifies the instrum with the following calling signature: wigglefunc(wiggleparts, pars) where pars is one dict from parameters. Note that this function is called with wiggleparts which can be the same as instrum or just a subset.

wigglepartsmarxs.base.SimulationSequenceElement instance

Element which is modified by wigglefunc. Typically this is a subset of instrum. For example, to tolerance the mirror alignments wiggleparts would just be the mirror objects, while instrum would contain all the parts of the instrument that the photons need to run though up to the detector.

parameterslist of dicts

List of parameter values for calls to wigglefunc.

analyzefunccallable function or object

This is called with a photon table and should return a dictionary of results. This could be, e.g. a marxs.analysis.gratings.CaptureResAeff instance.

Returns:
resultlist of dicts

Each dict contains parameters and results for one run.

Notes

The format of input and output as lists of dicts is chosen because this would work well for a parallel version of this function which could have the same interface when it is implemented.