Fitting.view_util

Utilities for fitting views.

Utilities for modeling application

fitting.view_util.extract_ascii_from_div(html_data)

Extract data from a plot <div>. Only returns the first one it finds.

Parameters

html_data (str) – <div> string

TODO: This should be refactored. When storing data locally, as opposed to using the external ORNL plot server, we can simply store the data as json. This function then needs to determine which approach to take.

fitting.view_util.check_permissions(request, run_id, instrument)

Verify that the user has the permissions to access the data

Parameters
  • run_id (str) – run identifier (usually a number)

  • instrument (str) – instrument name, or user name

fitting.view_util.get_fit_problem(request, instrument, data_id)

Get the latest FitProblem object for an instrument/data pair

Parameters
  • data_id (str) – run identifier (usually a number)

  • instrument (str) – instrument name, or user name

fitting.view_util.get_model_as_csv(request, instrument, data_id)

Return an ASCII block with model information to be loaded in third party applications.

Parameters
  • data_id (str) – run identifier (usually a number)

  • instrument (str) – instrument name, or user name

fitting.view_util.get_results(request, fit_problem)

Get the model parameters for a given fit problem

Parameters

fit_problem (FitProblem) – FitProblem object

fitting.view_util.get_plot_from_html(html_data, rq4=False, fit_problem=None)

Process html data and return plot data

Parameters
  • html_data (str) – stored json for plotted data

  • rq4 (bool) – if True, the plot will be in R*Q^4

  • fit_problem (FitProblem) – if supplied, a theory curve will be added

fitting.view_util.assemble_plots(request, instrument, data_id, fit_problem, rq4=False)

Find all that needs to be plotted for this fit problem.

Parameters
  • instrument (str) – instrument name, or user name

  • data_id (str) – run identifier (usually a number)

  • fit_problem (FitProblem) – FitProblem object

  • rq4 (bool) – if True, the plot will be in R*Q^4

fitting.view_util.find_overlay_data(fit_problem)

Find extra data to be over-plotted for a given fit problem.

Parameters

fit_problem (FitProblem) – FitProblem object

fitting.view_util.is_fittable(data_form, layers_form)

Return True if a fit problem (comprised of all its forms) is fittable or not. To be fittable, refl1d requires at least one free parameter.

fitting.view_util.evaluate_model(data_form, layers_form, html_data, fit=True, user=None, run_info=None, session=None)

Protected version of the call to refl1d

fitting.view_util.evaluate_simultaneous_fit(request, instrument, data_id, run_info)

Assemble all the information for co-refinement

fitting.view_util.save_fit_problem(data_form, layers_form, job_object, user)

Save the state of the model forms

fitting.view_util.apply_model(fit_problem, saved_model, instrument, data_id)

Apply a saved model to a fit problem

fitting.view_util.model_hash(fit_problem)

Return a secret hash for a given fit problem

fitting.view_util.copy_fit_problem(fit_problem, user)

Make a duplicate copy of a FitProblem object

fitting.view_util.plot1d(data_list, data_names=None, x_title='', y_title='', x_log=True, y_log=True, show_dx=False)

Produce a 1D plot :param data_list: list of traces [ [x1, y1], [x2, y2], …] :param data_names: name for each trace, for the legend

fitting.view_util.parse_ascii_file(request, file_name, raw_content)

Process an uploaded data file :param request: http request object :param str file_name: name of the uploaded file :param str raw_content: content of the file

fitting.view_util.get_user_files(request)

Get list of uploaded files

Parameters

request – http request object

fitting.view_util.parse_data_path(data_path)

Parse a data path of the form <instrument>/<data>

fitting.view_util.reverse_model(fit_problem)

Reverse a layer model