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 thewigglefunc
is relatively fast, but propagating the photons throughinstrum_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 bywigglefunc
.- Parameters:
- source
marxs.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.
- energies
astropy.units.quantity.Quantity
An array of energy values.
- instrum_before
marxs.simulator.Sequence
An instance of the instrument which contains all elements before the first elements in
wiggleparts
. The first element should be amarxs.source.pointing.PointingModel
. In principle,instrum_before
can be an empty sequence and the entire instrument can be defined ininstrum_remaining
, however,instrum_before
is run only once per energy and thus it can greatly speed up the simulation to set this.- instrum_remaining
marxs.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. Ifreset=None
, then the elements affected bywigglefunc
will be in the state corresponding to the last entry inparameters
when this function exits.- t_source
astropy.units.quantity.Quantity
parameter for
source.generate_photons()
. If the source flux is set to one, thent_source
determines the number of photons used in the tolerancing simulation.
- source
- Returns:
- result
astropy.table.Table
Each row in the table contains energy, wave, parameter values, and results from
analyzefunc
for a single run.
- result