sas.sasgui.perspectives.fitting package
Submodules
sas.sasgui.perspectives.fitting.basepage module
Base Page for fitting
-
class
sas.sasgui.perspectives.fitting.basepage.
BasicPage
(parent, color='blue', **kwargs)[source] Bases:
wx.lib.scrolledpanel.ScrolledPanel
,sas.sasgui.guiframe.panel_base.PanelBase
This class provide general structure of the fitpanel page
-
ID_BOOKMARK
= 177
-
ID_DISPERSER_HELP
= 178
-
check_invalid_panel
()[source] check if the user can already perform some action with this panel
-
createMemento
()[source] return the current state of the page
-
create_default_data
()[source] Given the user selection, creates a 1D or 2D data Only when the page is on theory mode.
-
define_page_structure
()[source] Create empty sizer for a panel
-
formfactor_combo_init
()[source] First time calls _show_combox_helper
-
get_all_checked_params
()[source] Found all parameters current check and add them to list of parameters to fit if implemented
-
get_cat_combo_box_pos
(state)[source] Iterate through the categories to find the structurefactor :return: combo_box_position
-
get_clipboard
()[source] Get strings in the clipboard
-
get_copy
()[source] Get copy params to clipboard
-
get_copy_excel
()[source] Get copy params to clipboard
-
get_copy_latex
()[source] Get copy params to clipboard
-
get_copy_params
()[source] Get the string copies of the param names and values in the tap
-
get_copy_params_excel
()[source] Get the string copies of the param names and values in the tap
-
get_copy_params_latex
()[source] Get the string copies of the param names and values in the tap
-
get_data
()[source] return the current data
-
get_data_list
()[source] return the current data
-
get_images
()[source] Get the images of the plots corresponding this panel for report
: return graphs: list of figures : Need Move to guiframe
-
get_paste
()[source] Paste params from the clipboard
-
get_paste_params
(text='')[source] Get the string copies of the param names and values in the tap
-
get_state
()[source] return the current page state
-
get_weight_flag
()[source] Get flag corresponding to a given weighting dI data if implemented
-
initialize_combox
()[source] put default value in the combo box
-
onContextMenu
(event)[source] Retrieve the state selected state
-
onPinholeSmear
(event)[source] Create a custom pinhole smear object if implemented
-
onRedo
(event)[source] Restore the previous action cancelled
-
onResetModel
(event)[source] Reset model state
-
onSetFocus
(evt)[source] highlight the current textcrtl and hide the error text control shown after fitting
-
onSlitSmear
(event)[source] Create a custom slit smear object if implemented
-
onSmear
(event)[source] Create a smear object if implemented
-
onUndo
(event)[source] Cancel the previous action
-
on_bookmark
(event)[source] save history of the data and model
-
on_copy
(event)[source] Copy Parameter values to the clipboad
-
on_function_help_clicked
(event)[source] Function called when ‘Help’ button is pressed next to model of interest. This calls DocumentationWindow from documentation_window.py. It will load the top level of the html model help documenation sphinx generated if either a plugin model (which normally does not have an html help help file) is selected or if no model is selected. Otherwise, if a regula model is selected, the documention for that model will be sent to a browser window.
:todo the quick fix for no documentation in plugins is the if statment. However, the right way to do this would be to check whether the hmtl file exists and load the model docs if it does and the general docs if it doesn’t - this will become important if we ever figure out how to build docs for plugins on the fly. Sep 9, 2018 -PDB
Parameters: event – on Help Button pressed event
-
on_left_down
(event)[source] Get key stroke event
-
on_model_help_clicked
(event)[source] Function called when ‘Description’ button is pressed next to model of interest. This calls the Description embedded in the model. This should work with either Wx2.8 and lower or higher. If no model is selected it will give the message that a model must be chosen first in the box that would normally contain the description. If a badly behaved model is encountered which has no description then it will give the message that none is available.
Parameters: event – on Description Button pressed event
-
on_paste
(event)[source] Paste Parameter values to the panel if possible
-
on_pd_help_clicked
(event)[source] Bring up Polydispersity Documentation whenever the ? button is clicked. Calls DocumentationWindow with the path of the location within the documentation tree (after /doc/ ....”. Note that when using old versions of Wx (before 2.9) and thus not the release version of istallers, the help comes up at the top level of the file as webbrowser does not pass anything past the # to the browser when it is running “file:///....”
Parameters: event – Triggers on clicking ? in polydispersity box
-
on_preview
(event)[source] Report the current fit results
-
on_reset_clicked
(event)[source] On ‘Reset’ button for Q range clicked
-
on_save
(event)[source] Save the current state into file
-
on_set_focus
(event)[source] On Set Focus, update guimanger and menu
-
on_smear_helper
(update=False)[source] Help for onSmear if implemented
Parameters: update – force or not to update
-
on_tap_focus
()[source] Update menu1 on cliking the page tap
-
populate_box
(model_list_box)[source] Store list of model
Parameters: model_list_box – dictionary containing categorized models
-
read_file
(path)[source] Read two columns file
Parameters: path – the path to the file to read
-
reset_page
(state, first=False)[source] reset the state if implemented
-
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 changes as well as the state of the graphic interface
-
save_current_state
()[source] Store current state
-
save_current_state_fit
()[source] Store current state for fit_page
-
select_log
(event)[source] Log checked to generate log spaced points for theory model
-
select_param
(event)[source] Select TextCtrl checked if implemented
-
set_clipboard
(content=None)[source] Put the string to the clipboard
-
set_data
(data=None)[source] Sets data if implemented
-
set_dispers_sizer
()[source] fill sizer containing dispersity info
-
set_index_model
(index)[source] Index related to this page
-
set_layout
()[source] layout
-
set_manager
(manager)[source] set panel manager
Parameters: manager – instance of plugin fitting
-
set_model_dictionary
(model_dictionary)[source] Store a dictionary linking model name -> model object
Parameters: model_dictionary – dictionary containing all models
-
set_model_state
(state)[source] reset page given a model state
-
set_owner
(owner)[source] set owner of fitpage
Parameters: owner – the class responsible of plotting
-
show_npts2fit
()[source] setValue Npts for fitting if implemented
-
update_pinhole_smear
()[source] Method to be called by sub-classes Moveit; This method doesn’t belong here
-
update_slit_smear
()[source] called by kill_focus on pinhole TextCntrl to update the changes if implemented
-
window_name
= 'Fit Page'
-
-
class
sas.sasgui.perspectives.fitting.basepage.
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 0x133a7340> >, 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
sas.sasgui.perspectives.fitting.batchfitpage module
Batch panel
-
class
sas.sasgui.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.sasgui.perspectives.fitting.batchfitpage.
BatchFitPage
(parent, color=None)[source] Bases:
sas.sasgui.perspectives.fitting.fitpage.FitPage
Batch Page
-
window_name
= 'BatchFit'
-
sas.sasgui.perspectives.fitting.console module
-
class
sas.sasgui.perspectives.fitting.console.
ConsoleUpdate
(parent, manager=None, quiet=False, progress_delta=60, improvement_delta=5)[source] Bases:
sas.sascalc.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.sasgui.perspectives.fitting.fit_thread module
-
class
sas.sasgui.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, reset_flag=False)[source] Bases:
sas.sascalc.data_util.calcthread.CalcThread
Thread performing the fit
-
compute
()[source] Perform a fit
-
isquit
()[source] Raises: KeyboardInterrupt – when the thread is interrupted
-
-
sas.sasgui.perspectives.fitting.fit_thread.
map_apply
(arguments)[source]
-
sas.sasgui.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.sasgui.perspectives.fitting.fitpage module
FitPanel class contains fields allowing to display results when fitting a model and one data
-
class
sas.sasgui.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.sasgui.perspectives.fitting.fitpage.
FitPage
(parent, color=None)[source] Bases:
sas.sasgui.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 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 to normalize chisq 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 computed 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_set_focus
(event)[source] Override the basepage focus method to ensure the save flag is set properly when focusing on the fit page.
-
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_param
(event=None)[source] Select TextCtrl checked for fitting purpose and stores them in self.param_toFit=[] list
-
set_data
(data)[source] reset the current data
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.sasgui.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.sasgui.perspectives.fitting.fitpanel.
FitPanel
(parent, manager=None, *args, **kwargs)[source] Bases:
wx.aui.AuiNotebook
,sas.sasgui.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
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_list – 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_manager
(manager)[source] set panel manager
Parameters: manager – instance of plugin fitting
-
set_model_dictionary
(model_dictionary)[source] copy a dictionary of model name -> model object
Parameters: model_dictionary – dictionary linking model name -> model object
-
set_model_list
(dict)[source] copy a dictionary of model into its own dictionary
Parameters: 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_name
= 'Fit panel'
-
sas.sasgui.perspectives.fitting.fitproblem module
Inferface containing information to store data, model, range of data, etc... and retrieve this information. This is an inferface for a fitProblem i.e relationship between data and model.
-
class
sas.sasgui.perspectives.fitting.fitproblem.
FitProblem
[source] Bases:
object
Define the relationship between data and model, including range, weights, etc.
-
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 ignore smear value.
-
get_fit_data
()[source] Returns: data associate with this class
-
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_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.sasgui.perspectives.fitting.fitproblem.
FitProblemDictionary
[source] Bases:
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 ignore smear value.
-
get_batch_result
()[source] get result
-
get_fit_data
(fid)[source] return data for the given fitproblem id :param fid: key representing a fitproblem, usually extract from data id
-
get_fit_problem
()[source] return fitproblem contained in this dictionary
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
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.sasgui.perspectives.fitting.fitting module
Fitting perspective
-
class
sas.sasgui.perspectives.fitting.fitting.
Plugin
[source] Bases:
sas.sasgui.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
-
create_theory_1D
(x, y, page_id, model, data, state, data_description, data_id, dy=None)[source] Create a theory object associate with an existing Data1D and add it to the data manager. @param x: x-values of the data @param y: y_values of the data @param page_id: fit page ID @param model: model used for fitting @param data: Data1D object to create the theory for @param state: model state @param data_description: title to use in the data manager @param data_id: unique data ID
-
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 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
-
load_plugin_models
(event)[source] Update of models in plugin_models folder
-
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 fitters. 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] Open the bumps options panel.
-
on_fit_results
(event=None)[source] Make the Fit Results panel visible.
-
on_fitter_changed
(event)[source]
-
on_gpu_options
(event=None)[source] Make the Fit Results panel visible.
-
on_help
(algorithm_id)[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
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 containing fitting information
-
select_data
(panel)[source]
-
set_data
(data_list=None)[source] receive a list of data to fit
Set list of the edit model menu labels
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_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 of the model for with the parameter has to reset
- value – can be a string in this case.
- names – the parameter name
-
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]
-
split_string
(item)[source] receive a word containing dot and split it. used to split parameterset name into model name and parameter name example:
parameterset (item) = M1.A Will return model_name = M1 , parameter name = A
-
stop_fit
(uid)[source] Stop the fit
-
store_data
(uid, data_list=None, caption=None)[source] Receive 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.sasgui.perspectives.fitting.fitting_widgets module
-
class
sas.sasgui.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.sasgui.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.sasgui.perspectives.fitting.fitting_widgets.
DialogPanel
(*args, **kwds)[source] Bases:
wx.lib.scrolledpanel.ScrolledPanel
sas.sasgui.perspectives.fitting.gpu_options module
Module provides dialog for setting SAS_OPENCL variable, which defines device choice for OpenCL calculation
Created on Nov 29, 2016
@author: wpotrzebowski
-
class
sas.sasgui.perspectives.fitting.gpu_options.
CustomMessageBox
(parent, msg, title)[source] Bases:
wx._windows.Dialog
Custom message box for OpenCL results
-
class
sas.sasgui.perspectives.fitting.gpu_options.
GpuOptions
(*args, **kwds)[source] Bases:
wx._windows.Dialog
“OpenCL options” Dialog Box
Provides dialog for setting SAS_OPENCL variable, which defines device choice for OpenCL calculation
-
on_OK
(event)[source] Close window on accpetance
-
on_check
(event)[source] Action triggered when box is selected :param event: :return:
-
on_help
(event)[source] Provide help on opencl options.
-
on_reset
(event)[source] Resets selected values
-
on_test
(event)[source] Run sasmodels check from here and report results from
-
sas.sasgui.perspectives.fitting.hint_fitpage module
This class provide general structure of fitpanel page
-
class
sas.sasgui.perspectives.fitting.hint_fitpage.
HelpWindow
(parent, id, title)[source] Bases:
wx._windows.Frame
-
class
sas.sasgui.perspectives.fitting.hint_fitpage.
HintFitPage
(parent)[source] Bases:
wx._windows.ScrolledWindow
,sas.sasgui.guiframe.panel_base.PanelBase
This class provide general structure of fitpanel page
-
createMemento
()[source]
-
do_layout
()[source] Draw the page
-
window_name
= 'Hint Page'
-
sas.sasgui.perspectives.fitting.model_thread module
Calculation thread for modeling
-
class
sas.sasgui.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, exception_handler=None)[source] Bases:
sas.sascalc.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.sasgui.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, exception_handler=None)[source] Bases:
sas.sascalc.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.sasgui.perspectives.fitting.report_dialog module
Dialog report panel to show and summarize the results of the fitting calculation.
-
class
sas.sasgui.perspectives.fitting.report_dialog.
ReportDialog
(report_list, *args, **kwds)[source] Bases:
sas.sasgui.guiframe.report_dialog.BaseReportDialog
The report dialog box.
-
onSave
(event=None)[source] Save
-
sas.sasgui.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.sasgui.perspectives.fitting.resultpanel.
ResultPanel
(parent, manager=None, *args, **kwargs)[source] Bases:
wx.aui.AuiNotebook
,sas.sasgui.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
-
get_frame
()[source]
-
on_close
(event)[source]
-
on_plot_results
(event)[source]
-
window_name
= 'Result panel'
-
sas.sasgui.perspectives.fitting.simfitpage module
Simultaneous or Batch fit page
-
class
sas.sasgui.perspectives.fitting.simfitpage.
ConstraintLine
(model_cbox, param_cbox, egal_txt, constraint, btRemove, sizer) Bases:
tuple
-
btRemove
Alias for field number 4
-
constraint
Alias for field number 3
-
egal_txt
Alias for field number 2
-
model_cbox
Alias for field number 0
-
param_cbox
Alias for field number 1
-
sizer
Alias for field number 5
-
-
class
sas.sasgui.perspectives.fitting.simfitpage.
SimultaneousFitPage
(parent, page_finder={}, id=-1, batch_on=False, *args, **kwargs)[source] Bases:
wx.lib.scrolledpanel.ScrolledPanel
,sas.sasgui.guiframe.panel_base.PanelBase
Simultaneous fitting panel All that needs to be defined are the two data members window_name and window_caption
-
ID_ADD
= 182
-
ID_DOC
= 179
-
ID_FIT
= 181
-
ID_SET_ALL
= 180
-
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 sizers, their hierarchy and set the sizer for the panel
-
draw_page
()[source] Construct the Simultaneous/Constrained fit page. fills the first region (sizer1) with the list of available fit page pairs of data and models. Then fills sizer2 with the checkbox for adding constraints, and finally fills sizer3 with the fit button and instructions.
-
get_state
()[source] Return the state of the current page :return: self.state
-
load_from_save_state
(sim_state)[source] Load in a simultaneous/constrained fit from a save state :param fit: Fitpanel object :return: None
-
on_fit
(event)[source] signal for fitting
-
on_remove
(event)[source] Remove constraint fields
-
on_set_focus
(event=None)[source] The derivative class is on focus if implemented
Set fit button label depending on the fit_started
-
set_manager
(manager)[source] set panel manager
Parameters: manager – instance of plugin fitting
-
set_state
()[source] Define a set of state parameters for saving simultaneous fits.
-
window_name
= 'Simultaneous Fit Page'
-
-
sas.sasgui.perspectives.fitting.simfitpage.
get_fittableParam
(model)[source] return list of fittable parameters from a model
Parameters: model – the model used
-
sas.sasgui.perspectives.fitting.simfitpage.
setComboBoxItems
(cbox, items)[source]
sas.sasgui.perspectives.fitting.utils module
Module contains functions frequently used in this package
-
sas.sasgui.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