finesse.analysis.actions.random module
Random collection of Actions that do no warrant a separate module.
- class finesse.analysis.actions.random.Change(change_dict=None, *, relative=False, name='change', **kwargs)[source]
Bases:
ActionChanges a model Parameter to some value during an analysis.
Parameters
- change_dictdict, optional
Dictionary of parameter:value pairs to change.
- relativebool, optional
Whether to increment from the parameters current value or not
- namestr, optional
Name of action
- **kwargs
Alternative method to specify parameter:value pairs to change
Examples
A simple change of a parameter between running two noxaxis analyses:
>>> model = finesse.script.parse("l L1 P=1") >>> model.run('series(noxaxis(), change(L1.P=2), noxaxis())')
Or increment from the current value: >>> model.run(‘series(noxaxis(), change(L1.P=1, relative=True), noxaxis())’)
- class finesse.analysis.actions.random.Execute(do_fn, parameters=None, name='execute')[source]
Bases:
ActionAn action that will execute the function passed to it when it is run.
Parameters
- do_fnfunction
A function that takes an AnalysisState, and the name of the Exec action as its only arguments. If this function returns a
finesse.solutions.base.BaseSolutionobject then it will be added to the simulations solution to return to the user.- parameterslist, optional
A list of parameters that will be changed by do_fn, if any.
- namestr
The name to give this action.
Examples
A simple function to execute might use a pattern such as this, which generates a Solution that is returned back to the user.
>>> from finesse.solutions import SimpleSolution >>> def my_action(state, name): ... sol = SimpleSolution(name) ... return sol
The
finesse.solutions.simple.SimpleSolutionobject is just an object you can store anything you want in. You can extract any state information about the simulation or model and store it here. This allows you to probe and store details that might not be available as a detector, for example.
- class finesse.analysis.actions.random.MakeTransparent(surfaces, name='make transparent')[source]
Bases:
ActionAction to make all provided surfaces transparent. Simply sets the reflectivity to zero and transmitivity to one.
Parameters
- surfaceslist
A list of surface component names to be made transparent.
- class finesse.analysis.actions.random.PrintModel(name='print_model')[source]
Bases:
ActionAn action that prints the model object being currently used to run actions.
- class finesse.analysis.actions.random.PrintModelAttr(*args, eval=True, prefix='')[source]
Bases:
ActionPrints an attribute of the model being currently used.
Parameters
- *args(str,)
Strings input for the attribute to print
- evalbool, optional
When True symbolic expressions will be evaluated before printing. Defaults to True.
- prefixstr, optional
Optional string to print before the attributes
Examples
You can print the current value of parameters and such using:
>>> PrintModelAttr("m1.R", "bs.phi")
- class finesse.analysis.actions.random.Printer(*args, name='printer', eval=True)[source]
Bases:
Action
- class finesse.analysis.actions.random.SaveModelAttrSolution[source]
Bases:
BaseSolutionAttributes
- valuesdict
Dictionary of model attribute values
- class finesse.analysis.actions.random.Scale(scales: dict, **kwargs)[source]
Bases:
ActionAction for scaling simulation outputs by some fixed amount. Included for compatibility with legacy Finesse code. New users should apply any desired scalings manually from Python.
Parameters
- detectorsdict
A dictionary of detector name: scaling factor mappings.