@@ -62,12 +62,40 @@ def __str__(self):
6262
6363@dataclass
6464class CalculationResults (RATResult ):
65+ """The goodness of fit from the Abeles calculation.
66+
67+ Attributes
68+ ----------
69+ chiValues : np.ndarray
70+ The chi-squared value for each contrast.
71+ sumChi : float
72+ The sum of the chiValues array.
73+
74+ """
75+
6576 chiValues : np .ndarray
6677 sumChi : float
6778
6879
6980@dataclass
7081class ContrastParams (RATResult ):
82+ """The experimental parameters for each contrast.
83+
84+ Attributes
85+ ----------
86+ scalefactors : np.ndarray
87+ An array containing the scalefactor values for each contrast.
88+ bulkIn : np.ndarray
89+ An array containing the bulk in values for each contrast.
90+ bulkOut : np.ndarray
91+ An array containing the bulk out values for each contrast.
92+ subRoughs : np.ndarray
93+ An array containing the substrate roughness values for each contrast.
94+ resample : np.ndarray
95+ An array containing whether each contrast was resampled.
96+
97+ """
98+
7199 scalefactors : np .ndarray
72100 bulkIn : np .ndarray
73101 bulkOut : np .ndarray
@@ -77,6 +105,43 @@ class ContrastParams(RATResult):
77105
78106@dataclass
79107class Results :
108+ """The results of a RAT calculation.
109+
110+ Attributes
111+ ----------
112+ reflectivity : list
113+ The reflectivity curves for each contrast,
114+ with the same range as the data
115+ (``data_range`` in the contrast's ``Data`` object)
116+ simulation : list
117+ The reflectivity curves for each contrast,
118+ which can be a different range to allow extrapolation
119+ (``simulation_range`` in the contrast's ``Data`` object).
120+ shiftedData : list
121+ The data from each contrast extrapolated over the simulation range
122+ with scalefactors and background corrections applied.
123+ backgrounds : list
124+ The background for each contrast, constructed from the contrast's background data.
125+ resolutions : list
126+ The resolution for each contrast, constructed from the contrast's resolution data.
127+ layerSlds : list
128+ The array of layer parameter values for each contrast.
129+ sldProfiles : list
130+ The SLD profiles for each contrast.
131+ resampledLayers : list
132+ If resampling is used, the SLD for each contrast after resampling has been performed.
133+ calculationResults : CalculationResults
134+ The chi-squared fit results from the final calculation and fit.
135+ contrastParams : ContrastParams
136+ The experimental parameters for the contrasts.
137+ fitParams : np.ndarray
138+ The best fit value of the parameter with name ``fitNames[i]``.
139+ fitNames : list[str]
140+ The names of the fit parameters, where ``fitNames[i]`` is the name
141+ of the parameter with value given in ``fitParams[i]``.
142+
143+ """
144+
80145 reflectivity : list
81146 simulation : list
82147 shiftedData : list
@@ -99,20 +164,100 @@ def __str__(self):
99164
100165@dataclass
101166class PredictionIntervals (RATResult ):
167+ """The Bayesian prediction intervals for 95% and 65% confidence.
168+
169+ For ``reflectivity`` and ``sld``, each list item is an array
170+ with five rows. The 0th and 4th index are the minimum and maximum
171+ range with 95% confidence, the 1st and 3rd are the minimum and maximum
172+ with 65% confidence, and the 2nd is the mean value of the interval.
173+ Column ``i`` is this data for the i'th point of the reflectivity or
174+ SLD result.
175+
176+ Attributes
177+ ----------
178+ reflectivity : list
179+ The prediction interval data for reflectivity of each contrast.
180+ SLD : list
181+ The prediction interval data for SLD of each contrast.
182+ sampleChi : np.ndarray
183+
184+ """
185+
102186 reflectivity : list
103187 sld : list
104188 sampleChi : np .ndarray
105189
106190
107191@dataclass
108192class ConfidenceIntervals (RATResult ):
193+ """
194+ The 65% and 95% confidence intervals for the best fit results.
195+
196+ Attributes
197+ ----------
198+ percentile95 : np.ndarray
199+ The 95% confidence intervals.
200+ percentile65 : np.ndarray
201+ The 65% confidence intervals
202+ mean : np.ndarray
203+
204+ """
205+
109206 percentile95 : np .ndarray
110207 percentile65 : np .ndarray
111208 mean : np .ndarray
112209
113210
114211@dataclass
115212class DreamParams (RATResult ):
213+ """The parameters used by the inner DREAM algorithm.
214+
215+ Attributes
216+ ----------
217+ nParams : float
218+ The number of parameters used by the algorithm.
219+ nChains : float
220+ The number of MCMC chains used by the algorithm.
221+ nGenerations : float
222+ The number of DE generations calculated per iteration.
223+ parallel : bool
224+ Whether the algorithm should run chains in parallel.
225+ CPU : float
226+ The number of processor cores used for parallel chains.
227+ jumpProbability : float
228+ A probability range for the size of jumps when performing subspace sampling.
229+ pUnitGamma : float
230+ The probability that the scaling-down factor of jumps will be ignored
231+ and a larger jump will be taken for one iteration.
232+ nCR : float
233+ The number of crossovers performed each iteration.
234+ delta : float
235+ The number of chain mutation pairs proposed each iteration.
236+ steps : float
237+ The number of MCMC steps to perform between conversion checks.
238+ zeta : float
239+ The ergodicity of the algorithm.
240+ outlier : str
241+ What test should be used to detect outliers.
242+ adaptPCR : bool
243+ Whether the crossover probability for differential evolution should be
244+ adapted by the algorithm as it runs.
245+ thinning : float
246+ The thinning rate of each Markov chain (to reduce memory intensity)
247+ epsilon : float
248+ The cutoff threshold for Approximate Bayesian Computation (if used)
249+ ABC : bool
250+ Whether Approximate Bayesian Computation is used.
251+ IO : bool
252+ Whether the algorithm should perform IO writes of the model in parallel.
253+ storeOutput : bool
254+ Whether output model simulations are performed.
255+ R : np.ndarray
256+ An array where row ``i`` is the list of chains
257+ with which chain ``i`` can mutate.
258+
259+ """
260+
116261 nParams : float
117262 nChains : float
118263 nGenerations : float
@@ -136,6 +281,45 @@ class DreamParams(RATResult):
136281
137282@dataclass
138283class DreamOutput (RATResult ):
284+ """The diagnostic output information from DREAM.
285+
286+ Attributes
287+ ----------
288+ allChains : np.ndarray
289+ An ``nGenerations`` x ``nParams + 2`` x ``nChains`` size array,
290+ where ``chain_k = DreamOutput.allChains[:, :, k]``
291+ is the data of chain ``k`` in the final iteration;
292+ for generation i of the final iteration, ``chain_k[i, j]`` represents:
293+
294+ - the sampled value of parameter ``j`` for ``j in 0:nParams``;
295+ - the associated log-prior for those sampled values for ``j = nParams + 1``;
296+ - the associated log-likelihood for those sampled values for ``j = nParams + 2``.
297+
298+ outlierChains : np.ndarray
299+ A two-column array where ``DreamOutput.AR[i, 1]`` is the index of a chain
300+ and ``DreamOutput.AR[i, 0]`` is the length of that chain when it was removed
301+ for being an outlier.
302+ runtime : float
303+ The runtime of the DREAM algorithm in seconds.
304+ iteration : float
305+ The number of iterations performed.
306+ modelOutput : float
307+ Unused. Will always be 0.
308+ AR : np.ndarray
309+ A two-column array where ``DreamOutput.AR[i, 0]`` is an iteration number
310+ and ``DreamOutput.AR[i, 1]`` is the average acceptance rate of chain step
311+ proposals for that iteration.
312+ R_stat : np.ndarray
313+ An array where ``DreamOutput.R_stat[i, 0]`` is an iteration number and
314+ ``DreamOutput.R_stat[i, j]`` is the convergence statistic for parameter ``j``
315+ at that iteration (where chains are indexed 1 to ``nParams`` inclusive).
316+ CR : np.ndarray
317+ A four-column array where ``DreamOutput.CR[i, 0]`` is an iteration number,
318+ ``and DreamOutput.CR[i, j]`` is the selection probability of the ``j``'th crossover
319+ value for that iteration.
320+
321+ """
322+
139323 allChains : np .ndarray
140324 outlierChains : np .ndarray
141325 runtime : float
@@ -148,6 +332,26 @@ class DreamOutput(RATResult):
148332
149333@dataclass
150334class NestedSamplerOutput (RATResult ):
335+ """The output information from the Nested Sampler (ns).
336+
337+ Attributes
338+ ----------
339+ logZ : float
340+ The natural logarithm of the evidence Z for the parameter values.
341+ logZErr : float
342+ The estimated uncertainty in the final value of logZ.
343+ nestSamples : np.ndarray
344+ ``NestedSamplerOutput.nestSamples[i, j]`` represents the values
345+ sampled at iteration ``i``, where this value is:
346+
347+ - the value sampled for parameter ``j``, for ``j`` in ``0:nParams``,
348+ - the minimum log-likelihood for ``j = nParams + 1``.
349+
350+ postSamples : np.ndarray
351+ The posterior values at the points sampled in ``NestedSamplerOutput.nestSamples``.
352+
353+ """
354+
151355 logZ : float
152356 logZErr : float
153357 nestSamples : np .ndarray
@@ -156,6 +360,26 @@ class NestedSamplerOutput(RATResult):
156360
157361@dataclass
158362class BayesResults (Results ):
363+ """The results of a Bayesian RAT calculation.
364+
365+ Attributes
366+ ----------
367+ predictionIntervals : PredictionIntervals
368+ The prediction intervals.
369+ confidenceIntervals : ConfidenceIntervals
370+ The 65% and 95% confidence intervals for the best fit results.
371+ dreamParams : DreamParams
372+ The parameters used by DREAM, if relevant.
373+ dreamOutput : DreamOutput
374+ The output from DREAM if DREAM was used.
375+ nestedSamplerOutput : NestedSamplerOutput
376+ The output from nested sampling if ns was used.
377+ chain : np.ndarray
378+ The MCMC chains for each parameter.
379+ The ``i``'th column of the array contains the chain for parameter ``fitNames[i]``.
380+
381+ """
382+
159383 predictionIntervals : PredictionIntervals
160384 confidenceIntervals : ConfidenceIntervals
161385 dreamParams : DreamParams
@@ -169,7 +393,24 @@ def make_results(
169393 output_results : RATapi .rat_core .OutputResult ,
170394 bayes_results : Optional [RATapi .rat_core .BayesResults ] = None ,
171395) -> Union [Results , BayesResults ]:
172- """Initialise a python Results or BayesResults object using the outputs from a RAT calculation."""
396+ """Initialise a python Results or BayesResults object using the outputs from a RAT calculation.
397+
398+ Parameters
399+ ----------
400+ procedure : Procedures
401+ The procedure used by the calculation.
402+ output_results : RATapi.rat_core.OutputResult
403+ The C++ output results from the calculation.
404+ bayes_results : Optional[RATapi.rat_core.BayesResults]
405+ The optional extra C++ Bayesian output results from a Bayesian calculation.
406+
407+ Returns
408+ -------
409+ Results or BayesResults
410+ A result object containing the results of the calculation, of type
411+ Results for non-Bayesian procedures and BayesResults for Bayesian procedures.
412+
413+ """
173414 calculation_results = CalculationResults (
174415 chiValues = output_results .calculationResults .chiValues ,
175416 sumChi = output_results .calculationResults .sumChi ,
0 commit comments