fitting

sans.perspectives.fitting.fitting

class sans.perspectives.fitting.fitting.Plugin(standalone=False)

Bases: sans.guiframe.plugin_base.PluginBase

Fitting plugin is used to perform fit

add_color(color, id)

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

add_fit_page(data)

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

can_load_data()

if return True, then call handler to laod data

clear_panel()
delete_data(data)

delete the given data from panel

draw_model(model, page_id, data=None, smearer=None, enable1D=True, enable2D=False, state=None, toggle_mode_on=False, qmin=0.001, qmax=0.13, qstep=50, update_chisqr=True)

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_context_menu(plotpanel=None)

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_page_finder()

return self.page_finder used also by simfitpage.py

get_panels(parent)

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(evt)

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(data_id)
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(event)

Load data

load_folder(event)

Load entire folder

onFit(uid=None)

perform fit

on_add_new_page(event=None)

ask fit panel to create a new empty page

on_add_sim_page(event)

Create a page to access simultaneous fit option

on_batch_selection(flag)

switch the the notebook of batch mode or not

on_perspective(event=None)

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

Parameters:event – menu event
on_set_state_helper(event=None)

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(owner)

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(calc_fit)

Ready for another fit

remove_plot(uid, theory=False)

remove model plot when a fit page is closed

save_fit_state(filepath, fitstate)

save fit page state into file

schedule_for_fit(value=0, uid=None, fitproblem=None)

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.

Parameters:
  • value – integer 0 or 1
  • fitproblem – fitproblem to schedule or not to fit
set_batch_selection(flag)

the plugin to its batch state if flag is True

set_data(data_list=None)

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(uid, qmin, qmax)

Set the fitting range of a given page

set_ftol(ftol=None)

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

set_is_active(active=False)
set_page_finder(modelname, names, values)

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_smearer(uid, smearer, qmin=None, qmax=None, draw=True, enable2D=False)

Get a smear object and store it to a fit problem

Parameters:smearer – smear object to allow smearing data
set_state(state=None, datainfo=None, format=None)

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(theory_list=None)
set_top_panel()

Close default (welcome) panel

show_ftol_dialog(event=None)

Dialog to select ftol for Scipy

split_string(item)

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(uid)

Stop the fit engine

store_data(uid, data=None, data_list=None, caption=None)

Helper to save page reference into the plug-in

Parameters:page – page to store
update_fit(result=None, msg='')
use_data()

return True if these plugin use data

Table Of Contents

Previous topic

fitproblem

Next topic

help_panel

This Page