Fitting.parsing

Parsing utilities for REFL1D output files.

fitting.parsing.refl1d.update_with_results(fit_problem, par_name, value, error)

Update a mode with a parameter value.

Parameters
  • fit_problem (FitProblem) – fit problem object to update

  • par_name (str) – parameter name

  • value (float) – parameter value

  • error (float) – parameter error

fitting.parsing.refl1d.find_error(layer_name, par_name, value, error_output, tolerance=0.001, pretty_print=False)

Find the error of a parameter in the list of output parameters. @param layer_name: name of the layer @param par_name: name of the parameter @param value: output value, so we can recognize the entry @param error_output: list of fit output parameters from the DREAM output

The output parameter list should be in the format: [ [parameter name, value, error], … ] The DREAM outputs are not grouped by sample/experiment, so we have to use the parameter values to determine which is which.

Because of constraints, parameters can have any name, so key on the parameter value to assign the errors, but don’t change the reported value in case we incorrectly assign errors.

fitting.parsing.refl1d.update_model_from_dict(fit_problem, experiment, error_output=None, pretty_print=False)

Parse a json representation of the experiment :param FitProblem fit_problem: FitProblem-like ojbect :param dict experiment: dictionary representation of the fit problem read from the json output :param list error_output: list of DREAM output parameters, with errors. :param bool pretty_print: if True, the value will be turned into a value +- error string

fitting.parsing.refl1d.update_model_from_json(content, fit_problem)

Update a model described by a FitProblem object according to the contents of a REFL1D log.

Parameters
  • content (str) – log contents

  • fit_problem (FitProblem) – fit problem object to update

fitting.parsing.refl1d.update_model(content, fit_problem)

Update a model described by a FitProblem object according to the contents of a REFL1D log.

Parameters
  • content (str) – log contents

  • fit_problem (FitProblem) – fit problem object to update

fitting.parsing.refl1d.extract_multi_data_from_log(log_content)

Extract data block from a log. For simultaneous fits, an EXPT_START tag precedes every block:

EXPT_START 0 REFL_START

Parameters

log_content (str) – string buffer of the job log

fitting.parsing.refl1d.extract_multi_sld_from_log(log_content)

Extract multiple SLD profiles from a simultaneous REFL1D fit.

Parameters

log_content (str) – string buffer of the job log

fitting.parsing.refl1d.extract_multi_json_from_log(log_content)

Extract multiple JSON blocks from a REFL1D fit log.

fitting.parsing.refl1d.parse_single_param(line)

Parse a line of the refl1d DREAM output log 1 intensity 1.084(31) 1.0991 1.1000 [ 1.062 1.100] [ 1.000 1.100] 2 air rho 0.91(91)e-3 0.00062 0.00006 [ 0.0001 0.0017] [ 0.0000 0.0031]