run_tolerances_for_energies

marxs.design.tolerancing.run_tolerances_for_energies(source, energies, instrum_before, instrum_remaining, wigglefunc, wiggleparts, parameters, analyzefunc, reset=None, t_source=<Quantity 1. 1 / s>)[source] [edit on github]

Run tolerancing for a grid of parameters and energies

This function loops over run_tolerances for different energies. This function takes an instrument configuration and a function to change one aspect of it. For every change it runs 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.

There are two nested loops here looping over energy and tolerancing parameters. In this case, the outer loop is over energies and then for every energy, run_tolerances loops over the parameters. This works well where running the wigglefunc is relatively fast, but propagating the photons through instrum_before is slow and minimizes the memory footprint, because only one photon list is in memory at any one time. It also implies that runs for the same wiggle parameters but different energies are run on different realizations of any random draws that are performed by wigglefunc.

Parameters:
sourcemarxs.source.Source

Source used to generate the photons for every energy. This function changes the energy of the source, so the source should be set for monoenergetic emission with a constant flux of 1.

energiesastropy.units.quantity.Quantity

An array of energy values.

instrum_beforemarxs.simulator.Sequence

An instance of the instrument which contains all elements before the first elements in wiggleparts. The first element should be a marxs.source.pointing.PointingModel. In principle, instrum_before can be an empty sequence and the entire instrument can be defined in instrum_remaining, however, instrum_before is run only once per energy and thus it can greatly speed up the simulation to set this.

instrum_remainingmarxs.simulator.Sequence

An instance of the instrument which contains all elements not included in instrum_before. instrum_remaining should include elements that are toleranced in this run and those that are located behind them.

wigglefunc, wiggleparts, parameters, analyzefunc

These parameters are passed to marxs.design.tolerancing.run_tolerances. See that function for a description of these parameters.

resetdict or None

A dictionary of values for the wigglefunc function that resets the positions or properties of the wiggled elements to their default. If reset=None, then the elements affected by wigglefunc will be in the state corresponding to the last entry in parameters when this function exits.

t_sourceastropy.units.quantity.Quantity

parameter for source.generate_photons(). If the source flux is set to one, then t_source determines the number of photons used in the tolerancing simulation.

Returns:
resultastropy.table.Table

Each row in the table contains energy, wave, parameter values, and results from analyzefunc for a single run.