sas.perspectives.fitting package

Submodules

sas.perspectives.fitting.basepage module

Base Page for fitting

class sas.perspectives.fitting.basepage.BasicPage(parent, color='blue', **kwargs)[source]

Bases: wx.lib.scrolledpanel.ScrolledPanel, sas.guiframe.panel_base.PanelBase

This class provide general structure of fitpanel page

class ModelTextCtrl(parent, id=-1, value=u'', pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidator *' at 0x1070e8ca0> >, name=u'text', kill_focus_callback=None, set_focus_callback=None, mouse_up_callback=None, text_enter_callback=None)[source]

Bases: wx._controls.TextCtrl

Text control for model and fit parameters. Binds the appropriate events for user interactions. Default callback methods can be overwritten on initialization

Parameters:
  • kill_focus_callback – callback method for EVT_KILL_FOCUS event
  • set_focus_callback – callback method for EVT_SET_FOCUS event
  • mouse_up_callback – callback method for EVT_LEFT_UP event
  • text_enter_callback – callback method for EVT_TEXT_ENTER event
full_selection = False
BasicPage.check_invalid_panel()[source]

check if the user can already perform some action with this panel

BasicPage.createMemento()[source]

return the current state of the page

BasicPage.create_default_data()[source]

Given the user selection, creates a 1D or 2D data Only when the page is on theory mode.

BasicPage.define_page_structure()[source]

Create empty sizer for a panel

BasicPage.formfactor_combo_init()[source]

First time calls _show_combox_helper

BasicPage.get_all_checked_params()[source]

Found all parameters current check and add them to list of parameters to fit if implemented

BasicPage.get_clipboard()[source]

Get strings in the clipboard

BasicPage.get_copy()[source]

Get copy params to clipboard

BasicPage.get_copy_excel()[source]

Get copy params to clipboard

BasicPage.get_copy_latex()[source]

Get copy params to clipboard

BasicPage.get_copy_params()[source]

Get the string copies of the param names and values in the tap

BasicPage.get_copy_params_excel()[source]

Get the string copies of the param names and values in the tap

BasicPage.get_copy_params_latex()[source]

Get the string copies of the param names and values in the tap

BasicPage.get_data()[source]

return the current data

BasicPage.get_data_list()[source]

return the current data

BasicPage.get_images()[source]

Get the images of the plots corresponding this panel for report

: return graphs: list of figures : Need Move to guiframe

BasicPage.get_paste()[source]

Paste params from the clipboard

BasicPage.get_paste_params(text='')[source]

Get the string copies of the param names and values in the tap

BasicPage.get_state()[source]
BasicPage.get_weight_flag()[source]

Get flag corresponding to a given weighting dI data if implemented

BasicPage.initialize_combox()[source]

put default value in the combobox

BasicPage.onContextMenu(event)[source]

Retrieve the state selected state

BasicPage.onPinholeSmear(event)[source]

Create a custom pinhole smear object if implemented

BasicPage.onRedo(event)[source]

Restore the previous action cancelled

BasicPage.onResetModel(event)[source]

Reset model state

BasicPage.onSetFocus(evt)[source]

highlight the current textcrtl and hide the error text control shown after fitting

BasicPage.onSlitSmear(event)[source]

Create a custom slit smear object if implemented

BasicPage.onSmear(event)[source]

Create a smear object if implemented

BasicPage.onUndo(event)[source]

Cancel the previous action

BasicPage.on_bookmark(event)[source]

save history of the data and model

BasicPage.on_copy(event)[source]

Copy Parameter values to the clipboad

BasicPage.on_left_down(event)[source]

Get key stroke event

BasicPage.on_model_help_clicked(event)[source]

on ‘More details’ button

BasicPage.on_paste(event)[source]

Paste Parameter values to the panel if possible

BasicPage.on_pd_help_clicked(event)[source]

Button event for PD help

BasicPage.on_preview(event)[source]

Report the current fit results

BasicPage.on_reset_clicked(event)[source]

On ‘Reset’ button for Q range clicked

BasicPage.on_save(event)[source]

Save the current state into file

BasicPage.on_set_focus(event)[source]

On Set Focus, update guimanger and menu

BasicPage.on_smear_helper(update=False)[source]

Help for onSmear if implemented

Parameters:update – force or not to update
BasicPage.on_tap_focus()[source]

Update menu1 on cliking the page tap

BasicPage.populate_box(model_dict)[source]

Store list of model

Parameters:model_dict – dictionary containing list of models
BasicPage.read_file(path)[source]

Read two columns file

Parameters:path – the path to the file to read
BasicPage.reset_page(state, first=False)[source]

reset the state if implemented

BasicPage.reset_page_helper(state)[source]

Use page_state and change the state of existing page

Precondition:the page is already drawn or created
Postcondition:the state of the underlying data change as well as the state of the graphic interface
BasicPage.save_current_state()[source]

Store current state

BasicPage.save_current_state_fit()[source]

Store current state for fit_page

BasicPage.select_all_param(event)[source]

set to true or false all checkBox if implemented

BasicPage.select_log(event)[source]

Log checked to generate log spaced points for theory model

BasicPage.select_param(event)[source]

Select TextCtrl checked if implemented

BasicPage.set_clipboard(content=None)[source]

Put the string to the clipboard

BasicPage.set_data(data=None)[source]

Sets data if implemented

BasicPage.set_dispers_sizer()[source]

fill sizer containing dispersity info

BasicPage.set_index_model(index)[source]

Index related to this page

BasicPage.set_layout()[source]

layout

BasicPage.set_manager(manager)[source]

set panel manager

Parameters:manager – instance of plugin fitting
BasicPage.set_model_dictionary(model_dict)[source]

Store a dictionary linking model name -> model object

Parameters:model_dict – dictionary containing list of models
BasicPage.set_model_state(state)[source]

reset page given a model state

BasicPage.set_owner(owner)[source]

set owner of fitpage

Parameters:owner – the class responsible of plotting
BasicPage.set_page_info(page_info)[source]

set some page important information at once

BasicPage.show_npts2fit()[source]

setValue Npts for fitting if implemented

BasicPage.update_pinhole_smear()[source]

Method to be called by sub-classes Moveit; This method doesn’t belong here

BasicPage.update_slit_smear()[source]

called by kill_focus on pinhole TextCntrl to update the changes if implemented

BasicPage.window_caption = 'Fit Page '
BasicPage.window_name = 'Fit Page'

sas.perspectives.fitting.batchfitpage module

Batch panel

class sas.perspectives.fitting.batchfitpage.BGTextCtrl(*args, **kwds)[source]

Bases: wx._controls.TextCtrl

Text control used to display outputs. No editing allowed. The background is grayed out. User can’t select text.

class sas.perspectives.fitting.batchfitpage.BatchFitPage(parent, color=None)[source]

Bases: sas.perspectives.fitting.fitpage.FitPage

Batch Page

save_current_state()[source]

Currently no save option implemented for batch page

save_current_state_fit()[source]

Currently no save option implemented for batch page

set_data(data)[source]

reset the current data

window_caption = 'BatchFit'
window_name = 'BatchFit'

sas.perspectives.fitting.console module

class sas.perspectives.fitting.console.ConsoleUpdate(parent, manager=None, quiet=False, progress_delta=60, improvement_delta=5)[source]

Bases: sas.fit.AbstractFitEngine.FitHandler

Print progress to the console.

abort()[source]
error(msg)[source]

Model had an error; print traceback

finalize()[source]
get_result()[source]
improvement()[source]

Called when a result is observed which is better than previous results from the fit.

improvement_delta = 5

Number of seconds between improvement updates

isbetter = False

Record whether results improved since last update

print_result()[source]

Print result object

progress(k, n)[source]

Report on progress.

progress_delta = 60

Number of seconds between progress updates

set_result(result)[source]
starting_fit()[source]
stop(msg)[source]

Post event msg and stop

update_fit(last=False)[source]

sas.perspectives.fitting.fit_thread module

class sas.perspectives.fitting.fit_thread.FitThread(fn, page_id, handler, batch_outputs, batch_inputs=None, pars=None, completefn=None, updatefn=None, yieldtime=0.03, worktime=0.03, ftol=None, reset_flag=False)[source]

Bases: sas.data_util.calcthread.CalcThread

Thread performing the fit

compute()[source]

Perform a fit

isquit()[source]
Raises KeyboardInterrupt:
 when the thread is interrupted
sas.perspectives.fitting.fit_thread.map_apply(arguments)[source]
sas.perspectives.fitting.fit_thread.map_getattr(classInstance, classFunc, *args)[source]

Take an instance of a class and a function name as a string. Execute class.function and return result

sas.perspectives.fitting.fitpage module

FitPanel class contains fields allowing to display results when fitting a model and one data

class sas.perspectives.fitting.fitpage.BGTextCtrl(*args, **kwds)[source]

Bases: wx._controls.TextCtrl

Text control used to display outputs. No editing allowed. The background is grayed out. User can’t select text.

class sas.perspectives.fitting.fitpage.FitPage(parent, color=None)[source]

Bases: sas.perspectives.fitting.basepage.BasicPage

FitPanel class contains fields allowing to display results when fitting a model and one data

Note:For Fit to be performed the user should check at least one parameter on fit Panel window.
compute_data_range(data)[source]

compute the minimum and the maximum range of the data return the npts contains in data :param data:

compute_data_set_range(data_list)[source]

find the range that include all data in the set return the minimum and the maximum values

enable_datasource()[source]

Enable or disable data source control depending on existing data

enable_fit_button()[source]

Enable fit button if data is valid and model is valid

fill_data_combobox(data_list)[source]

Get a list of data and fill the corresponding combobox

get_all_checked_params()[source]

Found all parameters current check and add them to list of parameters to fit

get_chi2()[source]

return the current chi2

get_npts2fit()[source]

return numbers of data points within qrange

Note:This is for Park where chi2 is not normalized by Npts of fit
get_range()[source]

return the fitting range

get_view_mode()[source]

return True if the panel allow 2D or False if 1D

get_weight_flag()[source]

Get flag corresponding to a given weighting dI data.

onPinholeSmear(event)[source]

Create a custom pinhole smear object that will change the way residuals are compute when fitting

Note:accuracy is given by strings’High’,’Med’, ‘Low’ FOR 2d, None for 1D
onSlitSmear(event)[source]

Create a custom slit smear object that will change the way residuals are compute when fitting

onSmear(event)[source]

Create a smear object that will change the way residuals are compute when fitting

onWeighting(event)[source]

On Weighting radio button event, sets the weightbt_string

on_complete_chisqr(event)[source]

Display result chisqr on the panel :event: activated by fitting/ complete after draw

on_key(event)[source]

On Key down

on_qrange_text(event)[source]

#On q range value updated. DO not combine with qrange_click().

on_right_down(event)[source]

Get key stroke event

on_select_data(event=None)[source]

On_select_data

on_smear_helper(update=False)[source]

Help for onSmear

Parameters:update – force or not to update
onsetValues(chisqr, p_name, out, cov)[source]

Build the panel from the fit result

Parameters:
  • chisqr – Value of the goodness of fit metric
  • p_name – the name of parameters
  • out – list of parameter with the best value found during fitting
  • cov – Covariance matrix
qrang_set_focus(event=None)[source]

ON Qrange focus

qrange_click(event)[source]

On Qrange textctrl click, make the qrange lines in the plot

rename_model()[source]

find a short name for model

reset_page(state, first=False)[source]

reset the state

select_all_param(event)[source]

set to true or false all checkBox given the main checkbox value cb1

select_param(event)[source]

Select TextCtrl checked for fitting purpose and stores them in self.param_toFit=[] list

set_data(data)[source]

reset the current data

set_fitbutton()[source]

Set fit button label depending on the fit_started[bool]

set_model_param_sizer(model)[source]

Build the panel from the model content

Parameters:model – the model selected in combo box for fitting purpose
show_npts2fit()[source]

setValue Npts for fitting

update_pinhole_smear()[source]

called by kill_focus on pinhole TextCntrl to update the changes

Returns:False when wrong value was entered
update_slit_smear()[source]

called by kill_focus on pinhole TextCntrl to update the changes

Returns:False when wrong value was entered

sas.perspectives.fitting.fitpanel module

FitPanel class contains fields allowing to fit models and data

note:For Fit to be performed the user should check at least one parameter on fit Panel window.
class sas.perspectives.fitting.fitpanel.FitPanel(parent, manager=None, *args, **kwargs)[source]

Bases: wx.aui.AuiNotebook, sas.guiframe.panel_base.PanelBase

FitPanel class contains fields allowing to fit models and data

Note:For Fit to be performed the user should check at least one parameter on fit Panel window.
CENTER_PANE = True
add_empty_page()[source]

add an empty page

add_sim_page(caption='Const & Simul Fit')[source]

Add the simultaneous fit page

clear_panel()[source]

Clear and close all panels, used by guimanager

close_all()[source]

remove all pages, used when a svs file is opened

close_page_with_data(deleted_data)[source]

close a fit page when its data is completely remove from the graph

delete_data(data)[source]

Delete the given data

enable_close_button()[source]

display the close button on tab for more than 1 tabs else remove the close button

get_current_page()[source]
Returns:the current page selected
get_data()[source]

get the data in the current page

get_page_by_id(uid)[source]
get_state()[source]

return the state of the current selected page

helper_on_page_change()[source]
on_close_page(event=None)[source]

close page and remove all references to the closed page

on_closed(event)[source]
on_page_changing(event)[source]

calls the function when the current event handler has exited. avoiding to call panel on focus on a panel that is currently deleted

on_set_focus(event)[source]
reset_pmodel_list()[source]
save_project(doc=None)[source]
return an xml node containing state of the panel
that guiframe can write to file
set_data(data_list)[source]

Add a fitting page on the notebook contained by fitpanel

Parameters:data – data to fit

:return panel : page just added for further used. is used by fitting module

set_data_on_batch_mode(data_list)[source]

Add all data to a single tab when the application is on Batch mode. However all data in the set of data must be either 1D or 2D type. This method presents option to select the data type before creating a tab.

set_engine_helper(panel, name='scipy')[source]
set_manager(manager)[source]

set panel manager

Parameters:manager – instance of plugin fitting
set_model_dict(m_dict)[source]

copy a dictionary of model name -> model object

Parameters:m_dict – dictionary linking model name -> model object
set_model_list(dict)[source]

copy a dictionary of model into its own dictionary

Parameters:m_dict – dictionnary made of model name as key and model class

as value

set_model_state(state)[source]

receive a state to reset the model in the current page

set_state(state)[source]

Restore state of the panel

update_model_list()[source]
window_caption = 'Fit Panel '
window_name = 'Fit panel'

sas.perspectives.fitting.fitproblem module

Inferface containing information to store data, model, range of data, etc... and retreive this information. This is an inferface for a fitProblem i.e relationship between data and model.

class sas.perspectives.fitting.fitproblem.FitProblem[source]

Bases: sas.perspectives.fitting.fitproblem.FitProblemComponent

FitProblem class allows to link a model with the new name created in _on_model, a name theory created with that model and the data fitted with the model. FitProblem is mostly used as value of the dictionary by fitting module.

clear_model_param()[source]

clear constraint info

enable_smearing(flag=False)[source]
Parameters:flag – bool.When flag is 1 get the computer smear value. When

flag is 0 ingore smear value.

get_fit_data()[source]
Returns:data associate with this class
get_fit_tab_caption()[source]
get_graph_id()[source]

Get graph_id

get_model()[source]
Returns:saved model
get_model_param()[source]

return list of couple of parameter name and value

get_name()[source]
get_origin_data()[source]
get_param2fit()[source]

return the list param names to fit

get_range()[source]
Returns:fitting range
get_residuals()[source]
Returns:residuals
get_result()[source]

get result

get_scheduled()[source]

return true or false if a problem as being schedule for fitting

get_smearer()[source]

return smear object

get_theory_data()[source]
Returns:theory generated with the current model and data of this class
get_weight()[source]

returns weight array

save_model_name(name)[source]
schedule_tofit(schedule=0)[source]

set schedule to true to decide if this fit must be performed

set_fit_data(data)[source]

Store data associated with this class :param data: list of data selected

set_fit_tab_caption(caption)[source]
set_graph_id(id)[source]

Set graph id (from data_group_id at the time the graph produced)

set_model(model)[source]

associates each model with its new created name :param model: model selected :param name: name created for model

set_model_param(name, value=None)[source]

Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter

set_param2fit(list)[source]

Store param names to fit (checked) :param list: list of the param names

set_range(qmin=None, qmax=None)[source]

set fitting range :param qmin: minimum value to consider for the fit range :param qmax: maximum value to consider for the fit range

set_residuals(residuals)[source]

save a copy of residual :param data: data selected

set_result(result)[source]
set_smearer(smearer)[source]

save reference of smear object on fitdata

Parameters:smear – smear object from DataLoader
set_theory_data(data)[source]

save a copy of the data select to fit

Parameters:data – data selected
set_weight(is2d, flag=None)[source]

Received flag and compute error on data. :param flag: flag to transform error of data. :param is2d: flag to distinguish 1D to 2D Data

class sas.perspectives.fitting.fitproblem.FitProblemComponent[source]

Bases: object

Inferface containing information to store data, model, range of data, etc... and retreive this information. This is an inferface for a fitProblem i.e relationship between data and model.

clear_model_param()[source]

clear constraint info

enable_smearing(flag=False)[source]
Parameters:flag – bool.When flag is 1 get the computer smear value. When

flag is 0 ingore smear value.

get_fit_data()[source]
get_fit_tab_caption()[source]

Return the caption of the page associated with object

get_graph_id()[source]

Get graph_id

get_model()[source]
Returns:saved model
get_model_param()[source]

return list of couple of parameter name and value

get_name()[source]
get_param2fit()[source]

return the list param names to fit

get_range()[source]
Returns:fitting range
get_residuals()[source]
Returns:residuals
get_result()[source]

get result

get_scheduled()[source]

return true or false if a problem as being schedule for fitting

get_smearer()[source]

return smear object

get_theory_data()[source]
Returns:list of data dList
get_weight()[source]

get fitting weight

save_model_name(name)[source]
schedule_tofit(schedule=0)[source]

set schedule to true to decide if this fit must be performed

set_fit_data(data)[source]
Store of list of data and create by create new fitproblem of each data id , if there was existing information about model, this information get copy to the new fitproblem
Parameters:data – list of data selected
set_fit_tab_caption(caption)[source]

store the caption of the page associated with object

set_graph_id(id)[source]

Set graph id (from data_group_id at the time the graph produced)

set_model(model)[source]

associates each model with its new created name :param model: model selected :param name: name created for model

set_model_param(name, value=None)[source]

Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter

set_param2fit(list)[source]

Store param names to fit (checked) :param list: list of the param names

set_range(qmin=None, qmax=None)[source]

set fitting range

set_residuals(residuals)[source]

save a copy of residual :param data: data selected

set_result(result)[source]
set_theory_data(data)[source]

save a copy of the data select to fit :param data: data selected

set_weight(flag=None)[source]

set fitting range

class sas.perspectives.fitting.fitproblem.FitProblemDictionary[source]

Bases: sas.perspectives.fitting.fitproblem.FitProblemComponent, dict

This module implements a dictionary of fitproblem objects

add_data(data)[source]

Add data to the current dictionary of fitproblem. if data id does not exist create a new fit problem. :note: only data changes in the fit problem

clear_model_param(fid=None)[source]

clear constraint info

enable_smearing(flag=False, fid=None)[source]
Parameters:flag – bool.When flag is 1 get the computer smear value. When

flag is 0 ingore smear value.

get_batch_result()[source]

get result

get_fit_data(fid)[source]

return data for the given fitproblem id :param fid: is key representing a fitproblem. usually extract from data

id
get_fit_problem()[source]

return fitproblem contained in this dictionary

get_fit_tab_caption()[source]

Return the caption of the page associated with object

get_graph_id()[source]

Get graph_id

get_model(fid)[source]
Returns:saved model
get_model_param(fid)[source]

return list of couple of parameter name and value

get_name(fid=None)[source]
get_param2fit()[source]

return the list param names to fit

get_range(fid)[source]
Returns:fitting range
get_residuals(fid)[source]
Returns:residuals
get_result(fid)[source]

get result

get_scheduled()[source]

return true or false if a problem as being schedule for fitting

get_smearer(fid=None)[source]

return smear object

get_theory_data(fid)[source]
Returns:list of data dList
get_weight(fid=None)[source]

return fit weight

save_model_name(name, fid=None)[source]
schedule_tofit(schedule=0)[source]

set schedule to true to decide if this fit must be performed

set_batch_result(batch_inputs, batch_outputs)[source]

set a list of result

set_fit_data(data)[source]

save a copy of the data select to fit :param data: data selected

set_fit_tab_caption(caption)[source]

store the caption of the page associated with object

set_graph_id(id)[source]

Set graph id (from data_group_id at the time the graph produced)

set_model(model, fid=None)[source]

associates each model with its new created name :param model: model selected :param name: name created for model

set_model_param(name, value=None, fid=None)[source]

Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter

set_param2fit(list)[source]

Store param names to fit (checked) :param list: list of the param names

set_range(qmin=None, qmax=None, fid=None)[source]

set fitting range

set_residuals(residuals, fid)[source]

save a copy of residual :param data: data selected

set_result(result, fid)[source]
set_smearer(smearer, fid=None)[source]

save reference of smear object on fitdata :param smear: smear object from DataLoader

set_theory_data(fid, data=None)[source]

save a copy of the data select to fit :param data: data selected

set_weight(is2d, flag=None, fid=None)[source]

fit weight

sas.perspectives.fitting.fitting module

Fitting perspective

class sas.perspectives.fitting.fitting.Plugin(standalone=False)[source]

Bases: sas.guiframe.plugin_base.PluginBase

Fitting plugin is used to perform fit

add_color(color, id)[source]

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

add_fit_page(data)[source]

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

clear_panel()[source]
create_fit_problem(page_id)[source]

Given an ID create a fitproblem container

delete_custom_model(event)[source]

Delete custom model file

delete_data(data)[source]

delete the given data from panel

delete_fit_problem(page_id)[source]

Given an ID create a fitproblem container

draw_model(model, page_id, data=None, smearer=None, enable1D=True, enable2D=False, state=None, fid=None, toggle_mode_on=False, qmin=None, qmax=None, update_chisqr=True, weight=None, source='model')[source]

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]
edit_custom_model(event)[source]

Get the python editor panel

get_batch_capable()[source]

Check if the plugin has a batch capability

get_context_menu(plotpanel=None)[source]

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_graph_id(uid)[source]

Set graph_id for fitprobelm

get_page_finder()[source]

return self.page_finder used also by simfitpage.py

get_panels(parent)[source]

Create and return a list of panel objects

help(evt)[source]

Show a general help dialog.

make_new_model(event)[source]

Make new model

make_sum_model(event)[source]

Edit summodel template and make one

onFit(uid)[source]

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(event=None)[source]

ask fit panel to create a new empty page

on_add_sim_page(event)[source]

Create a page to access simultaneous fit option

on_batch_selection(flag)[source]

switch the the notebook of batch mode or not

on_bumps_options(event=None)[source]
on_reset_batch_flag(event)[source]

Set batch_reset_flag

on_set_batch_result(page_id, fid, batch_outputs, batch_inputs)[source]
on_set_state_helper(event=None)[source]

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

: event: FitStateUpdateEvent called
by dataloader.plot_data from guiframe
populate_menu(owner)[source]

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

put_icon(frame)[source]

Put icon in the frame title bar

remove_plot(uid, fid=None, theory=False)[source]

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(filepath, fitstate)[source]

save fit page state into file

schedule_for_fit(value=0, uid=None)[source]

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(panel)[source]
set_data(data_list=None)[source]

receive a list of data to fit

set_default_perspective()[source]

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_edit_menu(owner)[source]

Set list of the edit model menu labels

set_edit_menu_helper(owner=None, menu=None)[source]

help for setting list of the edit model menu labels

set_fit_range(uid, qmin, qmax, fid=None)[source]

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(uid, flag, is2d=False, fid=None)[source]

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(ftol=None)[source]

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

set_graph_id(uid, graph_id)[source]

Set graph_id for fitprobelm

set_page_finder(modelname, names, values)[source]

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(uid, param2fit)[source]

Set the list of param names to fit for fitprobelm

set_smearer(uid, smearer, fid, qmin=None, qmax=None, draw=True, enable_smearer=False)[source]

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(state=None, datainfo=None, format=None)[source]

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)[source]
show_ftol_dialog(event=None)[source]

Dialog to select ftol for Scipy

split_string(item)[source]

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)[source]

Stop the fit engine

store_data(uid, data_list=None, caption=None)[source]

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_custom_combo()[source]

Update custom model list in the fitpage combo box

update_fit(result=None, msg='')[source]

sas.perspectives.fitting.fitting_widgets module

class sas.perspectives.fitting.fitting_widgets.BatchDataDialog(parent=None, *args, **kwds)[source]

Bases: wx._windows.Dialog

The current design of Batch fit allows only of type of data in the data set. This allows the user to make a quick selection of the type of data to use in fit tab.

get_data()[source]

return 1 if user requested Data1D , 2 if user requested Data2D

class sas.perspectives.fitting.fitting_widgets.DataDialog(data_list, parent=None, text='', nb_data=4, *args, **kwds)[source]

Bases: wx._windows.Dialog

Allow file selection at loading time

get_data()[source]

return the selected data

class sas.perspectives.fitting.fitting_widgets.DialogPanel(*args, **kwds)[source]

Bases: wx.lib.scrolledpanel.ScrolledPanel

sas.perspectives.fitting.ftol_dialog module

Dialog to set ftol for Scipy

ftol(float): Relative error desired in the sum of squares.
class sas.perspectives.fitting.ftol_dialog.ChangeFtol(parent, base, id=-1, title='FTolerance')[source]

Bases: wx._windows.Dialog

Dialog to select ftol

OnFtolSelection(event=None)[source]

Changes the ftol on selection of the radio button

get_ftol()[source]

Get the ftol value

sas.perspectives.fitting.help_panel module

Help dialog

class sas.perspectives.fitting.help_panel.HelpPanel(parent, **kwargs)[source]

Bases: wx.lib.scrolledpanel.ScrolledPanel

class sas.perspectives.fitting.help_panel.HelpWindow(parent, id, title='Fitting Help', pageToOpen=None, size=(850, 540))[source]

Bases: wx._windows.Frame

OnButtonClicked(event)[source]

Function to diplay Model html page related to the hyperlinktext selected

OnLinkClicked(event)[source]

Function to diplay html page related to the hyperlinktext selected

on_Size(event)[source]

Recover the scroll position On Size

sas.perspectives.fitting.hint_fitpage module

This class provide general structure of fitpanel page

class sas.perspectives.fitting.hint_fitpage.HelpWindow(parent, id, title)[source]

Bases: wx._windows.Frame

class sas.perspectives.fitting.hint_fitpage.HintFitPage(parent)[source]

Bases: wx._windows.ScrolledWindow, sas.guiframe.panel_base.PanelBase

This class provide general structure of fitpanel page

createMemento()[source]
do_layout()[source]

Draw the page

window_caption = 'Hint page '
window_name = 'Hint Page'

sas.perspectives.fitting.model_thread module

Calculation thread for modeling

class sas.perspectives.fitting.model_thread.Calc1D(model, page_id, data, fid=None, qmin=None, qmax=None, weight=None, smearer=None, toggle_mode_on=False, state=None, completefn=None, update_chisqr=True, source='model', updatefn=None, yieldtime=0.01, worktime=0.01)[source]

Bases: sas.data_util.calcthread.CalcThread

Compute 1D data

compute()[source]

Compute model 1d value given qmin , qmax , x value

results()[source]

Send resuts of the computation

class sas.perspectives.fitting.model_thread.Calc2D(data, model, smearer, qmin, qmax, page_id, state=None, weight=None, fid=None, toggle_mode_on=False, completefn=None, updatefn=None, update_chisqr=True, source='model', yieldtime=0.04, worktime=0.04)[source]

Bases: sas.data_util.calcthread.CalcThread

Compute 2D model This calculation assumes a 2-fold symmetry of the model where points are computed for one half of the detector and I(qx, qy) = I(-qx, -qy) is assumed.

compute()[source]

Compute the data given a model function

sas.perspectives.fitting.models module

Utilities to manage models

class sas.perspectives.fitting.models.ModelList[source]

Bases: object

Contains dictionary of model and their type

get_list()[source]

return all the list stored in a dictionary object

reset_list(name, mylist)[source]
Parameters:
  • name – the type of the list
  • mylist – the list to add
set_list(name, mylist)[source]
Parameters:
  • name – the type of the list
  • mylist – the list to add
class sas.perspectives.fitting.models.ModelManager[source]

Bases: object

implement model

cat_model_list = []
findModels()[source]
get_model_dictionary()[source]
get_model_list()[source]
get_model_name_list()[source]
is_changed()[source]
model_name = 'LorentzModel'
populate_menu(modelmenu, event_owner)[source]
pulgins_reset()[source]
update()[source]
class sas.perspectives.fitting.models.ModelManagerBase[source]

Base class for the model manager

event_owner = None
findModels()[source]

find plugin model in directory of plugin .recompile all file in the directory if file were modified

form_factor_dict = {'167': [<class 'sas.models.SphereModel.SphereModel'>]}
get_model_dictionary()[source]

return dictionary linking model names to objects

get_model_list()[source]

return dictionary of models for fitpanel use

get_model_name_list()[source]

return regular model name list

is_changed()[source]
check the last time the plugin dir has changed and return true
is the directory was modified else return false
last_time_dir_modified = 0
model_combobox = <sas.perspectives.fitting.models.ModelList object at 0x115dd1cd0>
multi_func_list = [<class sas.models.CoreMultiShellModel.CoreMultiShellModel at 0x1132dcef0>, <class sas.models.OnionExpShellModel.OnionExpShellModel at 0x1142cc3f8>, <class sas.models.SphericalSLDModel.SphericalSLDModel at 0x11483cce8>, <class sas.models.RPA10Model.RPA10Model at 0x1145f1598>, <class sas.models.UnifiedPowerRgModel.UnifiedPowerRgModel at 0x11530b9a8>, <class sas.models.ReflectivityModel.ReflectivityModel at 0x114d8f120>, <class sas.models.ReflectivityIIModel.ReflectivityIIModel at 0x114921c80>]
multiplication_factor = [<class 'sas.models.SphereModel.SphereModel'>, <class 'sas.models.FuzzySphereModel.FuzzySphereModel'>, <class 'sas.models.CoreShellModel.CoreShellModel'>, <class sas.models.CoreMultiShellModel.CoreMultiShellModel at 0x1132dcef0>, <class 'sas.models.VesicleModel.VesicleModel'>, <class 'sas.models.MultiShellModel.MultiShellModel'>, <class sas.models.OnionExpShellModel.OnionExpShellModel at 0x1142cc3f8>, <class sas.models.SphericalSLDModel.SphericalSLDModel at 0x11483cce8>, <class 'sas.models.CylinderModel.CylinderModel'>, <class 'sas.models.CoreShellCylinderModel.CoreShellCylinderModel'>, <class 'sas.models.CoreShellBicelleModel.CoreShellBicelleModel'>, <class 'sas.models.HollowCylinderModel.HollowCylinderModel'>, <class 'sas.models.StackedDisksModel.StackedDisksModel'>, <class 'sas.models.ParallelepipedModel.ParallelepipedModel'>, <class 'sas.models.CSParallelepipedModel.CSParallelepipedModel'>, <class 'sas.models.EllipticalCylinderModel.EllipticalCylinderModel'>, <class 'sas.models.EllipsoidModel.EllipsoidModel'>, <class 'sas.models.CoreShellEllipsoidModel.CoreShellEllipsoidModel'>, <class 'sas.models.CoreShellEllipsoidXTModel.CoreShellEllipsoidXTModel'>, <class 'sas.models.TriaxialEllipsoidModel.TriaxialEllipsoidModel'>, <class 'sas.models.RectangularPrismModel.RectangularPrismModel'>, <class 'sas.models.RectangularHollowPrismInfThinWallsModel.RectangularHollowPrismInfThinWallsModel'>, <class 'sas.models.RectangularHollowPrismModel.RectangularHollowPrismModel'>, <class 'sas.models.MicelleSphCoreModel.MicelleSphCoreModel'>]
plugins = []
pulgins_reset()[source]

return a dictionary of model

struct_factor_dict = {}
struct_list = [<class 'sas.models.SquareWellStructure.SquareWellStructure'>, <class 'sas.models.HardsphereStructure.HardsphereStructure'>, <class 'sas.models.StickyHSStructure.StickyHSStructure'>, <class 'sas.models.HayterMSAStructure.HayterMSAStructure'>]
update()[source]

return a dictionary of model if new models were added else return empty dictionary

class sas.perspectives.fitting.models.ReportProblem[source]
sas.perspectives.fitting.models.compile_file(dir)[source]

Compile a py file

sas.perspectives.fitting.models.find_plugins_dir()[source]

Find path of the plugins directory. The plugin directory is located in the user’s home directory.

sas.perspectives.fitting.models.get_model_python_path()[source]
sas.perspectives.fitting.models.log(message)[source]

Log a message in a file located in the user’s home directory

sas.perspectives.fitting.pagestate module

Class that holds a fit page state

class sas.perspectives.fitting.pagestate.PageState(parent=None, model=None, data=None)[source]

Bases: object

Contains information to reconstruct a page of the fitpanel.

clone()[source]

Create a new copy of the current object

fromXML(file=None, node=None)[source]

Load fitting state from a file

Parameters:
  • file – .fitv file
  • node – node of a XML document to read from
report(figs=None, canvases=None)[source]

Invoke report dialog panel

: param figs: list of pylab figures [list]

set_plot_state(figs, canvases)[source]

Build image state that wx.html understand by plotting, putting it into wx.FileSystem image object

set_report_string()[source]

Get the values (strings) from __str__ for report

toXML(file='fitting_state.fitv', doc=None, entry_node=None)[source]

Writes the state of the InversionControl panel to file, as XML.

Compatible with standalone writing, or appending to an already existing XML document. In that case, the XML document is required. An optional entry node in the XML document may also be given.

Parameters:
  • file – file to write to
  • doc – XML document object [optional]
  • entry_node – XML node within the XML document at which we will append the data [optional]
class sas.perspectives.fitting.pagestate.Reader(call_back=None, cansas=True)[source]

Bases: sas.dataloader.readers.cansas_reader.Reader

Class to load a .fitv fitting file

ext = ['.fitv', '.FITV', '.svs', 'SVS']
get_state()[source]
read(path)[source]

Load a new P(r) inversion state from file

Parameters:path – file path
type = ['Fitting files (*.fitv)|*.fitvSASView file (*.svs)|*.svs']
type_name = 'Fitting'
write(filename, datainfo=None, fitstate=None)[source]

Write the content of a Data1D as a CanSAS XML file only for standalone

Parameters:
  • filename – name of the file to write
  • datainfo – Data1D object
  • fitstate – PageState object
write_toXML(datainfo=None, state=None)[source]

Write toXML, a helper for write(), could be used by guimanager._on_save()

: return: xml doc

sas.perspectives.fitting.pagestate.parse_entry_helper(node, item)[source]

Create a numpy list from value extrated from the node

Parameters:
  • node – node from each the value is stored
  • item – list name of three strings.the two first are name of data attribute and the third one is the type of the value of that attribute. type can be string, float, bool, etc.

: return: numpy array

sas.perspectives.fitting.report_dialog module

Dialog report panel to show and summarize the results of the invariant calculation.

class sas.perspectives.fitting.report_dialog.ReportDialog(list, *args, **kwds)[source]

Bases: wx._windows.Dialog

The report dialog box.

HTML2PDF(data, filename)[source]

Create a PDF file from html source string.

: data: html string : filename: name of file to be saved

OnClose(event=None)[source]

Close the Dialog

: event: Close button event

onPreview(event=None)[source]

Preview

: event: Preview button event

onPrint(event=None)[source]

Print

: event: Print button event

onSave(event=None)[source]

Save

sas.perspectives.fitting.resultpanel module

FitPanel class contains fields allowing to fit models and data

note:For Fit to be performed the user should check at least one parameter on fit Panel window.
class sas.perspectives.fitting.resultpanel.ResultPanel(parent, manager=None, *args, **kwargs)[source]

Bases: wx.aui.AuiNotebook, sas.guiframe.panel_base.PanelBase

FitPanel class contains fields allowing to fit models and data

Note:For Fit to be performed the user should check at least one parameter on fit Panel window.
CENTER_PANE = True
add_panel(panel)[source]
get_frame()[source]
get_panel(panel_class)[source]
on_close(event)[source]
on_plot_results(event)[source]
window_caption = 'Result Panel'
window_name = 'Result panel'

sas.perspectives.fitting.simfitpage module

Simultaneous fit page

class sas.perspectives.fitting.simfitpage.SimultaneousFitPage(parent, page_finder={}, id=-1, batch_on=False, *args, **kwargs)[source]

Bases: wx.lib.scrolledpanel.ScrolledPanel, sas.guiframe.panel_base.PanelBase

Simultaneous fitting panel All that needs to be defined are the two data members window_name and window_caption

check_all_model_name(event=None)[source]

check all models names

check_model_name(event)[source]

Save information related to checkbox and their states

define_page_structure()[source]

Create empty sizer for a panel

draw_page()[source]

Draw a sizer containing couples of data and model

onFit(event)[source]

signal for fitting

onRemove(event)[source]

Remove constraint fields

on_set_focus(event=None)[source]

The derivative class is on focus if implemented

set_layout()[source]

layout

set_manager(manager)[source]

set panel manager

Parameters:manager – instance of plugin fitting
set_scroll()[source]
window_caption = 'Simultaneous Fit Page'
window_name = 'simultaneous Fit page'
sas.perspectives.fitting.simfitpage.get_fittableParam(model)[source]

return list of fittable parameters name of a model

Parameters:model – the model used

sas.perspectives.fitting.utils module

Module contains functions frequently used in this package

sas.perspectives.fitting.utils.get_weight(data, is2d, flag=None)[source]

Received flag and compute error on data. :param flag: flag to transform error of data. :param is2d: flag to distinguish 1D to 2D Data

Module contents

sas.perspectives.fitting.data_files()[source]

Return the data files associated with media.

The format is a list of (directory, [files...]) pairs which can be used directly in setup(...,data_files=...) for setup.py.

sas.perspectives.fitting.get_data_path(media)[source]