finesse.solutions.array module
Simulation output
- class finesse.solutions.array.ArraySolution(name, parent, shape, xs, params)[source]
Bases:
BaseSolutionHolds outputs from running a simulation.
This is essentially a wrapped up Numpy structured array whose named elements are the names of outputs in a model.
Detectors are stored in the array by their name. So you can use:
output['detector_name']
or, if the key has an attribute called name (as all Finesse.detectors do) it will use that, so using:
output[ifo.detector]
will return the same values.
The underlying storage format is a Numpy structured array. You can select runs by:
output[ifo.detector][a:b:c]
where a:b:c is your slice. Or you can select multiple outputs with:
output[['det1', 'det2']][a:b:c]
Attributes
- namestr
Name to give to this analysis
- parent
BaseSolution Parent solutions that have preceded this solution being calculated. Can be None.
- xtuple(ndarray)
Array of axes that have been scanned over
- shape
numpy.ndarray The shape of the underlying data array. use a single integer for 1D outputs, N-dimensional outputs can be specified by using tuples, i.e. (10,5,100) for a 3D array with the requested sizes.
- params[array_like(objects)|array_like(str)]
Parameters associtated with each dimension of the data
- axis_info
- detectors
- dtype
- enable_update(self, detector_workspaces)[source]
This method will setup this solution to allow for fast C access for updating the solution in simulations. It must be called before any update calls are made. This will allocate memory for the workspaces to write data too.
Parameters
- detector_workspacesiterable[
finesse.detectors.workspace.DetectorWorkspace] A collection of detector workspaces that should be called and the output saved into this solution.
- detector_workspacesiterable[
- expand(self, shape)[source]
Expands the output buffer by shape elements. This will be slow if you call repeatedly to increase by just a few elements as the whole array is copied into a new block of memory.
Parameters
- shape
Shape of new array to make
- flatiters
- get_legacy_data(self, model)[source]
Get legacy style data
This produces a Numpy array and set of headers which is equivelent to parsing a Finesse 2 output file.
See Also
Parameters
- modelfinesse.model.Model
The Model used to produce this output file.
Returns
- legacy_data
numpy.ndarray The data array
- column_names
list List of column names
- plot_type‘2D plot’ or ‘3D plot’
String indicating if the data should represent 2D or 3D scan.
- masked
- params
- plot(self, *detectors, log=False, logx=None, logy=None, degrees=True, cmap=None, figsize_scale=1, tight_layout=True, show=True, separate=True, _test_fig_handles=None)[source]
- print_detector_info(self)[source]
Pretty print the contents of self.trace_info, which contains information about the detectors in the solution and their units and data type.
- shape
- trace_info
- update(self, int index, bool mask) int
Calling this will compute all detector outputs and add an entry to the outputs stored. Calling it multiple times without re-running the simulation will result in duplicate entries.
enable_update must be called to setup which detectors will be written to this solution object.
Parameters
- index(int, …)
Index to calculate the outputs for, use tuples of N-size for N-dimensional outputs
- maskboolean
Sets the index of all outputs to np.nan if true. This should be used when a recoverable invalidity has occurred at some point in the scan of a parameter of a simulation - e.g. invalid beam tracing due to instabilities.
Returns
- numint
Number of entries updated so far.
- write_legacy_data(self, model, filename='data.out', legacy_data=None, column_names=None, plot_type=None)[source]
Write Finesse 2 style ASCII output file
See Also
Parameters
- model
Model The model used to produce this output file.
- filename
str, optional The path of the output file.
- legacy_data
numpy.ndarray, optional The legacy output data to be written.
- column_names
list, optional The colomn names which correspond to the legacy data.
- plot_type“2D plot” or “3D plot”, optional
String indicating if the data should represent 2D or 3D scan.
Notes
If any of legacy_data, column_names or plot_type are None then all three will be automatically computed.
- model
- x
- class finesse.solutions.array.ArraySolutionSet(solutions)[source]
Bases:
SetA set of Arraysolution. Outputs from mutliple similar ArraySolutions can be returned.