finesse.solutions.array module

Simulation output

class finesse.solutions.array.ArraySolution(name, parent, shape, xs, params)[source]

Bases: BaseSolution

Holds 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

parentBaseSolution

Parent solutions that have preceded this solution being calculated. Can be None.

xtuple(ndarray)

Array of axes that have been scanned over

shapenumpy.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

axes[source]
axis_info
data[source]
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.

entries[source]

The number of outputs that have been stored in here so far

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

write_legacy_data()

Parameters

modelfinesse.model.Model

The Model used to produce this output file.

Returns

legacy_datanumpy.ndarray

The data array

column_nameslist

List of column names

plot_type‘2D plot’ or ‘3D plot’

String indicating if the data should represent 2D or 3D scan.

masked
outputs[source]

Returns all the outputs that have been stored.

p0[source]

ArraySolution.p0: str

p1[source]

ArraySolution.p1: str

p2[source]

ArraySolution.p2: str

p3[source]

ArraySolution.p3: str

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]

See finesse.plotting.plot.

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

get_legacy_data()

Parameters

modelModel

The model used to produce this output file.

filenamestr, optional

The path of the output file.

legacy_datanumpy.ndarray, optional

The legacy output data to be written.

column_nameslist, 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.

x
x0[source]

ArraySolution.x0: np.ndarray

x1[source]

ArraySolution.x1: np.ndarray

x2[source]

ArraySolution.x2: np.ndarray

x3[source]

ArraySolution.x3: np.ndarray

class finesse.solutions.array.ArraySolutionSet(solutions)[source]

Bases: Set

A set of Arraysolution. Outputs from mutliple similar ArraySolutions can be returned.

property outputs[source]
finesse.solutions.array.deserialize(args, dtype, masked, _data, detectors, _axes, _num, trace_info, axis_info)[source]

Generic deserialiser that maps a bunch of data back into an ArraySolution

finesse.solutions.array.from_array_solution_hdf(data, parent)[source]
finesse.solutions.array.plot_info_to_json(info, indent=None)[source]
finesse.solutions.array.to_array_solution_hdf(sol, grp)[source]