fitting

sans.perspectives.fitting.fitting

class sans.perspectives.fitting.fitting.Plugin

Bases: sans.guiframe.plugin_base.PluginBase

Fitting plugin is used to perform fit

__init__()
__module__ = 'sans.perspectives.fitting.fitting'
_batch_fit_complete()

Display fit result in batch :param result: list of objects received fromt fit engines :param pars: list of fitted parameters names :param page_id: list of page ids which called fit function :param elapsed: time spent at the fitting level

_cal_chisqr()

Get handy Chisqr using the output from draw1D and 2D, instead of calling expansive CalcChisqr in guithread

_closed_fitpage()

request fitpanel to close a given page when its unique data is removed from the plot. close fitpage only when the a loaded data is removed

_complete1D()

Complete plotting 1D data

_complete2D()

Complete get the result of modelthread and create model 2D that can be plot.

_draw_model1D()

Draw model 1D from loaded data1D

Parameters:
  • data – loaded data
  • model – the model to plot
_draw_model2D()

draw model in 2D

Parameters:
  • model – instance of the model to draw
  • description – the description of the model
  • enable2D – when True allows to draw model 2D
  • qmin – the minimum value to draw model 2D
  • qmax – the maximum value to draw model 2D
  • qstep – the number of division of Qx and Qy of the model to draw
_fit_completed()

Display result of the fit on related panel(s). :param result: list of object generated when fit ends :param pars: list of names of parameters fitted :param page_id: list of page ids which called fit function :param elapsed: time spent at the fitting level

_fit_helper()

Create and set fit engine with series of data and model :param pars: list of fittable parameters :param fitter_list: list of fit engine :param value: structure storing data mapped to their model, range etc..

_mac_sleep()

Give sleep to MAC

_onEVT_SLICER_PANEL()

receive and event telling to update a panel with a name starting with event.panel_name. this method update slicer panel for a given interactor.

Parameters:event – contains type of slicer , paramaters for updating the panel and panel_name to find the slicer ‘s panel concerned.
_onSelect()

when Select data to fit a new page is created .Its reference is added to self.page_finder

_on_change_engine()

Allow to select the type of engine to perform fit

Parameters:engine – the key work of the engine
_on_model_panel()

react to model selection on any combo box or model menu.plot the model

Parameters:evt – wx.combobox event
_on_show_panel()
_on_slicer_event()

Receive a panel as event and send it to guiframe

Parameters:event – event containing a panel
_onclearslicer()

Clear the boxslicer when close the panel associate with this slicer

_onset_engine_park()

set engine to park

_onset_engine_scipy()

set engine to scipy

_plot_residuals()

Plot the residuals

Parameters:
  • data – data
  • index – index array (bool)

: Note: this is different from the residuals in cal_chisqr()

_reset_schedule_problem()

unschedule or schedule all fitproblem to be fit

_return_engine_type()

return the current type of engine

_update1D()

Update the output of plotting model 1D

_update2D()

Update the output of plotting model

_update_fit_button()

Update Fit button when fit stopped

: parameter page_id: fitpage where the button is

add_color()

adds a color as a key with a plot id as its value to a dictionary

add_fit_page()

given a data, ask to the fitting panel to create a new fitting page, get this page and store it into the page_finder of this plug-in :param data: is a list of data

can_load_data()

if return True, then call handler to laod data

clear_panel()
create_fit_problem()

Given an ID create a fitproblem container

delete_data()

delete the given data from panel

delete_fit_problem()

Given an ID create a fitproblem container

draw_model()

Draw model.

Parameters:
  • model – the model to draw
  • name – the name of the model to draw
  • data – the data on which the model is based to be drawn
  • description – model’s description
  • enable1D – if true enable drawing model 1D
  • enable2D – if true enable drawing model 2D
  • qmin – Range’s minimum value to draw model
  • qmax – Range’s maximum value to draw model
  • qstep – number of step to divide the x and y-axis
  • update_chisqr – update chisqr [bool]
get_batch_capable()

Check if the plugin has a batch capability

get_context_menu()

Get the context menu items available for P(r).them allow fitting option for Data2D and Data1D only.

Parameters:graph – the Graph object to which we attach the context menu
Returns:a list of menu items with call-back function
Note :if Data1D was generated from Theory1D the fitting option is not allowed
get_extensions()

return state reader and its extensions

get_graph_id()

Set graph_id for fitprobelm

get_page_finder()

return self.page_finder used also by simfitpage.py

get_panels()

Create and return a list of panel objects

get_perspective()

Get the list of panel names for this perspective

get_tools()

Returns a set of menu entries for tools

help()

Show a general help dialog.

is_always_active()

return True is this plugin is always active and it is local to guiframe even if the user is switching between perspectives

is_in_use()
get a data id a list of data name if data data is
currently used by the plugin and the name of the plugin

data_name = ‘None’ in_use = False example [(data_name, self.sub_menu)]

load_data()

Load data

load_folder()

Load entire folder

onFit()

Get series of data, model, associates parameters and range and send then to series of fit engines. Fit data and model, display result to corresponding panels. :param uid: id related to the panel currently calling this fit function.

on_add_new_page()

ask fit panel to create a new empty page

on_add_sim_page()

Create a page to access simultaneous fit option

on_batch_selection()

switch the the notebook of batch mode or not

on_perspective()

Call back function for the perspective menu item. We notify the parent window that the perspective has changed.

Parameters:event – menu event
on_reset_batch_flag()

Set batch_reset_flag

on_set_batch_result()
on_set_state_helper()

Set_state_helper. This actually sets state after plotting data from state file.

: event: FitStateUpdateEvent called
by dataloader.plot_data from guiframe
populate_file_menu()

Append menu item under file menu item of the frame

populate_menu()

Create a menu for the Fitting plug-in

Parameters:
  • id – id to create a menu
  • owner – owner of menu
Returns:

list of information to populate the main menu

post_init()

Post initialization call back to close the loose ends

ready_fit()

Ready for another fit

remove_plot()

remove model plot when a fit page is closed :param uid: the id related to the fitpage to close :param fid: the id of the fitproblem(data, model, range,etc)

save_fit_state()

save fit page state into file

schedule_for_fit()

Set the fit problem field to 0 or 1 to schedule that problem to fit. Schedule the specified fitproblem or get the fit problem related to the current page and set value. :param value: integer 0 or 1 :param uid: the id related to a page contaning fitting information

select_data()
set_batch_selection()

the plugin to its batch state if flag is True

set_data()

receive a list of data to fit

set_default_perspective()

Call back method that True to notify the parent that the current plug-in can be set as default perspective. when returning False, the plug-in is not candidate for an automatic default perspective setting

set_fit_range()

Set the fitting range of a given page for all its data by default. If fid is provide then set the range only for the data with fid as id :param uid: id corresponding to a fit page :param fid: id corresponding to a fit problem (data, model) :param qmin: minimum value of the fit range :param qmax: maximum value of the fit range

set_fit_weight()

Set the fit weights of a given page for all its data by default. If fid is provide then set the range only for the data with fid as id :param uid: id corresponding to a fit page :param fid: id corresponding to a fit problem (data, model) :param weight: current dy data

set_ftol()

Set ftol: Relative error desired in the sum of chi squares.

set_graph_id()

Set graph_id for fitprobelm

set_is_active()
set_page_finder()

Used by simfitpage.py to reset a parameter given the string constrainst.

Parameters:
  • modelname – the name ot the model for with the parameter has to reset
  • value – can be a string in this case.
  • names – the paramter name
Note :

expecting park used for fit.

set_param2fit()

Set the list of param names to fit for fitprobelm

set_smearer()

Get a smear object and store it to a fit problem of fid as id. If proper flag is enable , will plot the theory with smearing information.

Parameters:
  • smearer – smear object to allow smearing data of id fid
  • enable_smearer – Define whether or not all (data, model) contained in the structure of id uid will be smeared before fitting.
  • qmin – the maximum value of the theory plotting range
  • qmax – the maximum value of the theory plotting range
  • draw – Determine if the theory needs to be plot
set_state()

Call-back method for the fit page state reader. This method is called when a .fitv/.svs file is loaded.

: param state: PageState object : param datainfo: data

set_theory()
set_top_panel()

Close default (welcome) panel

show_ftol_dialog()

Dialog to select ftol for Scipy

split_string()

receive a word containing dot and split it. used to split parameterset name into model name and parameter name example:

paramaterset (item) = M1.A
Will return model_name = M1 , parameter name = A
stop_fit()

Stop the fit engine

store_data()

Recieve a list of data and store them ans well as a caption of the fit page where they come from. :param uid: if related to a fit page :param data_list: list of data to fit :param caption: caption of the window related to these data

update_fit()
use_data()

return True if these plugin use data

Table Of Contents

Previous topic

fitproblem

Next topic

fitting_widgets

This Page